summaryrefslogtreecommitdiff
path: root/Tests/LibC/TestLibCExec.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-05-06 01:14:50 -0700
committerAndreas Kling <kling@serenityos.org>2021-05-06 17:54:28 +0200
commitfd0dbd1ebfbcbc29d46393061daa49dc7390caa7 (patch)
tree278ea94a46900e47ff7dae46b1017cd31095971a /Tests/LibC/TestLibCExec.cpp
parent6e641fadfa61d4b890db52fb60cc3709352336b6 (diff)
downloadserenity-fd0dbd1ebfbcbc29d46393061daa49dc7390caa7.zip
Tests: Establish root Tests directory, move Userland/Tests there
With the goal of centralizing all tests in the system, this is a first step to establish a Tests sub-tree. It will contain all of the unit tests and test harnesses for the various components in the system.
Diffstat (limited to 'Tests/LibC/TestLibCExec.cpp')
-rw-r--r--Tests/LibC/TestLibCExec.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Tests/LibC/TestLibCExec.cpp b/Tests/LibC/TestLibCExec.cpp
new file mode 100644
index 0000000000..25eefa5f46
--- /dev/null
+++ b/Tests/LibC/TestLibCExec.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018-2020, the SerenityOS developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+TEST_CASE(exec_should_not_search_current_directory)
+{
+ int fd = open("hax", O_CREAT | O_RDWR, 0755);
+ ftruncate(fd, 0);
+ close(fd);
+
+ int rc = execlp("hax", "hax", nullptr);
+ int saved_errno = errno;
+ perror("execlp");
+ unlink("hax");
+
+ EXPECT_EQ(rc, -1);
+ EXPECT_NE(saved_errno, ENOEXEC);
+}