1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. 4 * Author: Madhu T L <madhu.tarikere@wipro.com> 5 */ 6 7/* 8 * [Description] 9 * 10 * Verify that, syslog(2) is successful for type ranging from 1 to 8 11 */ 12 13#include <errno.h> 14 15#include "tst_test.h" 16#include "lapi/syscalls.h" 17#include "tst_safe_macros.h" 18 19struct tcase { 20 int type; 21 char *buf; 22 int len; 23 char *desc; 24}; 25 26static char buf; 27 28#define syslog(arg1, arg2, arg3) tst_syscall(__NR_syslog, arg1, arg2, arg3) 29 30static struct tcase tcases[] = { 31 /* Type 0 and 1 are currently not implemented, always returns success */ 32 {0, &buf, 0, "type 0/Close the log"}, 33 {1, &buf, 0, "type 1/Open the log"}, 34 {2, &buf, 0, "type 2/Read from the log"}, 35 {3, &buf, 0, "type 3/Read ring buffer"}, 36 /* 37 * Next two lines will clear dmesg. 38 * Uncomment if that is okay. -Robbie Williamson 39 */ 40 /* 41 * { 4, &buf, 0, "type 4/Read and clear ring buffer" }, 42 * { 5, &buf, 0, "type 5/Clear ring buffer" }, 43 */ 44 {8, NULL, 1, "type 8/Set log level to 1"}, 45 {8, NULL, 7, "type 8/Set log level to 7(default)"}, 46 {6, NULL, 0, "type 6/Disable printk's to console"}, 47 {7, NULL, 0, "type 7/Enable printk's to console"}, 48}; 49 50static void run(unsigned int n) 51{ 52 struct tcase *tc = &tcases[n]; 53 54 TST_EXP_PASS(syslog(tc->type, tc->buf, tc->len), 55 "syslog() with %s", tc->desc); 56} 57 58static struct tst_test test = { 59 .test = run, 60 .save_restore = (const struct tst_path_val[]) { 61 {"/proc/sys/kernel/printk", NULL, TST_SR_TBROK}, 62 {} 63 }, 64 .needs_root = 1, 65 .tcnt = ARRAY_SIZE(tcases), 66}; 67