• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "lapi/syscalls.h"
13 
14 #define TEST_VARIANTS 3
15 
do_stime(time_t * ntime)16 static int do_stime(time_t *ntime)
17 {
18 	switch (tst_variant) {
19 	case 0:
20 #ifndef HAVE_STIME
21 		tst_brk(TCONF, "libc stime() is not implemented");
22 #else
23 		return stime(ntime);
24 #endif
25 	break;
26 	case 1:
27 		return tst_syscall(__NR_stime, ntime);
28 	case 2: {
29 		struct timeval tv;
30 
31 		tv.tv_sec = *ntime;
32 		tv.tv_usec = 0;
33 
34 		return tst_syscall(__NR_settimeofday, &tv, (struct timezone *) 0);
35 	}
36 	}
37 
38 	return -1;
39 }
40 
stime_info(void)41 static void stime_info(void)
42 {
43 	switch (tst_variant) {
44 	case 0:
45 		tst_res(TINFO, "Testing libc stime()");
46 	break;
47 	case 1:
48 		tst_res(TINFO, "Testing SYS_stime syscall");
49 	break;
50 	case 2:
51 		tst_res(TINFO, "Testing SYS_settimeofday syscall");
52 	break;
53 	}
54 }
55 
56 #endif /* STIME_VAR__ */
57