summaryrefslogtreecommitdiff
path: root/Tests/LibC/TestLibCDirEnt.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/TestLibCDirEnt.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/TestLibCDirEnt.cpp')
-rw-r--r--Tests/LibC/TestLibCDirEnt.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/LibC/TestLibCDirEnt.cpp b/Tests/LibC/TestLibCDirEnt.cpp
new file mode 100644
index 0000000000..b7f85d7528
--- /dev/null
+++ b/Tests/LibC/TestLibCDirEnt.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+#include <dirent.h>
+#include <string.h>
+
+TEST_CASE(scandir_basic_scenario)
+{
+ struct dirent** namelist = nullptr;
+ auto entries = scandir("/etc", &namelist, nullptr, nullptr);
+ EXPECT(entries > 0);
+ EXPECT_NE(namelist, nullptr);
+
+ bool found_passwd = false;
+ for (auto i = 0; i < entries; i++) {
+ if (strcmp(namelist[i]->d_name, "passwd") == 0) {
+ found_passwd = true;
+ }
+ free(namelist[i]);
+ }
+ EXPECT(found_passwd);
+ free(namelist);
+}