Skip to content

Commit e6c2d9c

Browse files
committed
Merge tag 'linux-kselftest-4.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kselftest fix from Shuah Khan: "selftests/exec: Check if the syscall exists and bail if not" * tag 'linux-kselftest-4.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests/exec: Check if the syscall exists and bail if not
2 parents 5fb0f7f + 9a0b574 commit e6c2d9c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/testing/selftests/exec/execveat.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int execveat_(int fd, const char *path, char **argv, char **envp,
3030
#ifdef __NR_execveat
3131
return syscall(__NR_execveat, fd, path, argv, envp, flags);
3232
#else
33-
errno = -ENOSYS;
33+
errno = ENOSYS;
3434
return -1;
3535
#endif
3636
}
@@ -234,6 +234,14 @@ static int run_tests(void)
234234
int fd_cloexec = open_or_die("execveat", O_RDONLY|O_CLOEXEC);
235235
int fd_script_cloexec = open_or_die("script", O_RDONLY|O_CLOEXEC);
236236

237+
/* Check if we have execveat at all, and bail early if not */
238+
errno = 0;
239+
execveat_(-1, NULL, NULL, NULL, 0);
240+
if (errno == ENOSYS) {
241+
printf("[FAIL] ENOSYS calling execveat - no kernel support?\n");
242+
return 1;
243+
}
244+
237245
/* Change file position to confirm it doesn't affect anything */
238246
lseek(fd, 10, SEEK_SET);
239247

0 commit comments

Comments
 (0)