1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) International Business Machines Corp., 2001
4 * Copyright (c) Linux Test Project, 2001-2023
5 */
6
7 /*\
8 * [Description]
9 *
10 * Test for gettimeofday error.
11 *
12 * - EFAULT: tv pointed outside the accessible address space
13 * - EFAULT: tz pointed outside the accessible address space
14 * - EFAULT: both tv and tz pointed outside the accessible address space
15 */
16
17 #include "tst_test.h"
18 #include "lapi/syscalls.h"
19
20 static struct timeval tv1;
21
22 static struct tcase {
23 void *tv;
24 void *tz;
25 } tcases[] = {
26 /* timezone structure is obsolete, tz should be treated as null */
27 {(void *)-1, NULL},
28 {&tv1, (void *)-1},
29 {(void *)-1, (void *)-1},
30 };
31
verify_gettimeofday(unsigned int n)32 static void verify_gettimeofday(unsigned int n)
33 {
34 struct tcase *tc = &tcases[n];
35
36 TST_EXP_FAIL(tst_syscall(__NR_gettimeofday, tc->tv, tc->tz), EFAULT);
37 }
38
39 static struct tst_test test = {
40 .tcnt = ARRAY_SIZE(tcases),
41 .test = verify_gettimeofday,
42 };
43