summaryrefslogtreecommitdiff
path: root/tests/oldselect-efault.c
blob: 5c55538202d145727f2417a773b57aaedf525b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
 * Copyright (c) 2018-2019 The strace developers.
 * All rights reserved.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "tests.h"
#include "scno.h"

#if defined __NR_select && defined __NR__newselect \
 && __NR_select != __NR__newselect \
 && !defined __sparc__

# include <stdint.h>
# include <stdio.h>
# include <string.h>
# include <unistd.h>
# include <sys/select.h>

static const char *errstr;

static long
xselect(const kernel_ulong_t args)
{
	static const kernel_ulong_t dummy = F8ILL_KULONG_MASK | 0xfacefeed;
	long rc = syscall(__NR_select, args, dummy, dummy, dummy, dummy, dummy);
	errstr = sprintrc(rc);
	return rc;
}

int
main(void)
{
	unsigned long *const args = tail_alloc(sizeof(*args) * 4);
	memset(args, 0, sizeof(*args) * 4);

	xselect(0);
# ifndef PATH_TRACING_FD
	printf("select(NULL) = %s\n", errstr);
# endif

	xselect((uintptr_t) args);
# ifndef PATH_TRACING_FD
	printf("select(%p) = %s\n", args, errstr);
# endif

	puts("+++ exited with 0 +++");
	return 0;
}

#else

SKIP_MAIN_UNDEFINED("__NR_select && __NR__newselect"
		    " && __NR_select != __NR__newselect"
		    " && !defined __sparc__")

#endif