1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-only
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) Linux Test Project, 2006-2021
4*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
5*49cdfc7eSAndroid Build Coastguard Worker * Author: Aniruddha Marathe <[email protected]>
6*49cdfc7eSAndroid Build Coastguard Worker */
7*49cdfc7eSAndroid Build Coastguard Worker
8*49cdfc7eSAndroid Build Coastguard Worker /*\
9*49cdfc7eSAndroid Build Coastguard Worker * [Description]
10*49cdfc7eSAndroid Build Coastguard Worker *
11*49cdfc7eSAndroid Build Coastguard Worker * Basic test of libc wrapper of reboot(2) system call.
12*49cdfc7eSAndroid Build Coastguard Worker *
13*49cdfc7eSAndroid Build Coastguard Worker * Test LINUX_REBOOT_CMD_CAD_ON, LINUX_REBOOT_CMD_CAD_OFF commands,
14*49cdfc7eSAndroid Build Coastguard Worker * which do not perform reboot.
15*49cdfc7eSAndroid Build Coastguard Worker */
16*49cdfc7eSAndroid Build Coastguard Worker
17*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
18*49cdfc7eSAndroid Build Coastguard Worker #include <sys/reboot.h>
19*49cdfc7eSAndroid Build Coastguard Worker #include <linux/reboot.h>
20*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
21*49cdfc7eSAndroid Build Coastguard Worker
22*49cdfc7eSAndroid Build Coastguard Worker #define CMD_DESC(x) .cmd = x, .desc = #x
23*49cdfc7eSAndroid Build Coastguard Worker
24*49cdfc7eSAndroid Build Coastguard Worker static struct tcase {
25*49cdfc7eSAndroid Build Coastguard Worker const char *desc;
26*49cdfc7eSAndroid Build Coastguard Worker int cmd;
27*49cdfc7eSAndroid Build Coastguard Worker } tcases[] = {
28*49cdfc7eSAndroid Build Coastguard Worker {CMD_DESC(LINUX_REBOOT_CMD_CAD_ON)},
29*49cdfc7eSAndroid Build Coastguard Worker {CMD_DESC(LINUX_REBOOT_CMD_CAD_OFF)},
30*49cdfc7eSAndroid Build Coastguard Worker };
31*49cdfc7eSAndroid Build Coastguard Worker
run(unsigned int n)32*49cdfc7eSAndroid Build Coastguard Worker static void run(unsigned int n)
33*49cdfc7eSAndroid Build Coastguard Worker {
34*49cdfc7eSAndroid Build Coastguard Worker TST_EXP_PASS(reboot(tcases[n].cmd), "reboot(%s)", tcases[n].desc);
35*49cdfc7eSAndroid Build Coastguard Worker }
36*49cdfc7eSAndroid Build Coastguard Worker
37*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
38*49cdfc7eSAndroid Build Coastguard Worker .needs_root = 1,
39*49cdfc7eSAndroid Build Coastguard Worker .test = run,
40*49cdfc7eSAndroid Build Coastguard Worker .tcnt = ARRAY_SIZE(tcases),
41*49cdfc7eSAndroid Build Coastguard Worker };
42