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