1 /* Tests variant of SYS_execve where the first argument is a file descriptor. */
8 #include <sys/syscall.h>
11 static void test_EFAULT(void) {
12 int ret
= syscall(SYS_execve
, -1, 0, 0, 0);
14 if ((ret
!= -1) || (error
!= EFAULT
))
15 fprintf(stderr
, "Expecting EFAULT\n");
18 static void test_EBADF(void) {
19 int ret
= syscall(SYS_execve
, -1, 0, 0, EXEC_DESCRIPTOR
);
21 if ((ret
!= -1) || (error
!= EBADF
))
22 fprintf(stderr
, "Expecting EBADF\n");
25 static int test_fexecve(char * const *envp
) {
26 int fd
= open("/usr/bin/printf", O_EXEC
);
39 char *argv
[] = {"printf", "PASSED\n", NULL
};
41 if (fexecve(fd
, argv
, envp
) < 0) {
52 int main(int argc
, const char *argv
[], char * const *envp
) {
53 /* First exercise the syscall with some invalid input. */
57 return test_fexecve(envp
);