1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
4 * AUTHOR: Aniruddha Marathe <aniruddha.marathe@wipro.com>
5 */
6
7 /*\
8 * [Description]
9 * This is a Phase I test for the reboot(2) system call.
10 * It is intended to provide a limited exposure of the system call.
11 *
12 * [Algorithm]
13 * 1) Two test cases for two flag values
14 * 2) Execute system call
15 * 3) Check return code, if system call failed (return=-1)
16 * 4) Log the errno and Issue a FAIL message
17 * 5) Otherwise, Issue a PASS message
18 *
19 * [Restrictions]
20 * For lib4 and lib5 reboot(2) system call is implemented as
21 * int reboot(int magic, int magic2, int flag, void *arg); This test case
22 * is written for int reboot(int flag); which is implemented under glibc
23 * Therefore this testcase may not work under libc4 and libc5 libraries.
24 */
25
26 #include <unistd.h>
27 #include <sys/reboot.h>
28 #include <linux/reboot.h>
29 #include "tst_test.h"
30
31 static struct tcase {
32 const char *option_message;
33 int flag;
34 } tcases[] = {
35 {"LINUX_REBOOT_CMD_CAD_ON", LINUX_REBOOT_CMD_CAD_ON,},
36 {"LINUX_REBOOT_CMD_CAD_OFF", LINUX_REBOOT_CMD_CAD_OFF,},
37 };
38
run(unsigned int n)39 static void run(unsigned int n)
40 {
41 TST_EXP_PASS(reboot(tcases[n].flag),
42 "reboot(%s)", tcases[n].option_message);
43 }
44
45 static struct tst_test test = {
46 .needs_root = 1,
47 .test = run,
48 .tcnt = ARRAY_SIZE(tcases),
49 };
50