1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2021, BELLSOFT. All rights reserved.
4f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines  Corp., 2001
5f08c3bdfSopenharmony_ci */
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ci/*\
8f08c3bdfSopenharmony_ci * [Description]
9f08c3bdfSopenharmony_ci *
10f08c3bdfSopenharmony_ci * Pass an unused pid to sched_getscheduler() and test for ESRCH.
11f08c3bdfSopenharmony_ci */
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_ci#include <stdio.h>
14f08c3bdfSopenharmony_ci#include <errno.h>
15f08c3bdfSopenharmony_ci
16f08c3bdfSopenharmony_ci#include "tst_test.h"
17f08c3bdfSopenharmony_ci#include "tst_sched.h"
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_cistatic pid_t unused_pid;
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_cistatic void setup(void)
22f08c3bdfSopenharmony_ci{
23f08c3bdfSopenharmony_ci	tst_res(TINFO, "Testing %s variant", sched_variants[tst_variant].desc);
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci	unused_pid = tst_get_unused_pid();
26f08c3bdfSopenharmony_ci}
27f08c3bdfSopenharmony_ci
28f08c3bdfSopenharmony_cistatic void run(void)
29f08c3bdfSopenharmony_ci{
30f08c3bdfSopenharmony_ci	struct sched_variant *tv = &sched_variants[tst_variant];
31f08c3bdfSopenharmony_ci
32f08c3bdfSopenharmony_ci	TST_EXP_FAIL(tv->sched_getscheduler(unused_pid), ESRCH,
33f08c3bdfSopenharmony_ci		     "sched_getscheduler(%d)", unused_pid);
34f08c3bdfSopenharmony_ci}
35f08c3bdfSopenharmony_ci
36f08c3bdfSopenharmony_cistatic struct tst_test test = {
37f08c3bdfSopenharmony_ci	.setup = setup,
38f08c3bdfSopenharmony_ci	.test_variants = ARRAY_SIZE(sched_variants),
39f08c3bdfSopenharmony_ci	.test_all = run,
40f08c3bdfSopenharmony_ci};
41