1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. 4 * Author: Xiao Yang <yangx.jy@cn.fujitsu.com> 5 */ 6 7 #ifndef STIME_VAR__ 8 #define STIME_VAR__ 9 10 #include <sys/time.h> 11 #include "config.h" 12 #include "tst_timer.h" 13 #include "lapi/syscalls.h" 14 15 #define TEST_VARIANTS 3 16 do_stime(time_t * ntime)17static int do_stime(time_t *ntime) 18 { 19 switch (tst_variant) { 20 case 0: 21 #ifndef HAVE_STIME 22 tst_brk(TCONF, "libc stime() is not implemented"); 23 #else 24 return stime(ntime); 25 #endif 26 break; 27 case 1: 28 return tst_syscall(__NR_stime, ntime); 29 case 2: { 30 struct __kernel_old_timeval tv; 31 32 tv.tv_sec = *ntime; 33 tv.tv_usec = 0; 34 35 return tst_syscall(__NR_settimeofday, &tv, (struct timezone *) 0); 36 } 37 } 38 39 return -1; 40 } 41 stime_info(void)42static void stime_info(void) 43 { 44 switch (tst_variant) { 45 case 0: 46 tst_res(TINFO, "Testing libc stime()"); 47 break; 48 case 1: 49 tst_res(TINFO, "Testing SYS_stime syscall"); 50 break; 51 case 2: 52 tst_res(TINFO, "Testing SYS_settimeofday syscall"); 53 break; 54 } 55 } 56 57 #endif /* STIME_VAR__ */ 58