Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, the SerenityOS developers.
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <LibTest/TestCase.h>
8#include <errno.h>
9#include <fcntl.h>
10#include <stdio.h>
11#include <unistd.h>
12
13TEST_CASE(exec_should_not_search_current_directory)
14{
15 int fd = open("hax", O_CREAT | O_RDWR, 0755);
16 ftruncate(fd, 0);
17 close(fd);
18
19 int rc = execlp("hax", "hax", nullptr);
20 int saved_errno = errno;
21 perror("execlp");
22 unlink("hax");
23
24 EXPECT_EQ(rc, -1);
25 EXPECT_NE(saved_errno, ENOEXEC);
26}