[libc-commits] [libc] 5b24c08 - [libc] Move all tests to a top level `test` directory.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Mon Jan 6 10:25:06 PST 2020
Author: Siva Chandra Reddy
Date: 2020-01-06T10:14:43-08:00
New Revision: 5b24c088171d3bd7a8ff559c82926e5d4b04f032
URL: https://github.com/llvm/llvm-project/commit/5b24c088171d3bd7a8ff559c82926e5d4b04f032
DIFF: https://github.com/llvm/llvm-project/commit/5b24c088171d3bd7a8ff559c82926e5d4b04f032.diff
LOG: [libc] Move all tests to a top level `test` directory.
A toplevel target, `check-libc` has also been added.
Reviewers: abrachet, phosek
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D72177
Added:
libc/test/CMakeLists.txt
libc/test/config/CMakeLists.txt
libc/test/config/linux/CMakeLists.txt
libc/test/config/linux/x86_64/CMakeLists.txt
libc/test/config/linux/x86_64/syscall_test.cpp
libc/test/src/CMakeLists.txt
libc/test/src/errno/CMakeLists.txt
libc/test/src/errno/errno_test.cpp
libc/test/src/string/CMakeLists.txt
libc/test/src/string/strcat_test.cpp
libc/test/src/string/strcpy_test.cpp
libc/test/src/sys/CMakeLists.txt
libc/test/src/sys/mman/CMakeLists.txt
libc/test/src/sys/mman/mmap_test.cpp
Modified:
libc/CMakeLists.txt
libc/config/linux/x86_64/CMakeLists.txt
libc/docs/source_layout.rst
libc/src/errno/CMakeLists.txt
libc/src/string/CMakeLists.txt
libc/src/string/strcat/CMakeLists.txt
libc/src/string/strcpy/CMakeLists.txt
libc/src/sys/mman/CMakeLists.txt
Removed:
libc/config/linux/x86_64/syscall_test.cpp
libc/src/errno/errno_test.cpp
libc/src/string/strcat/strcat_test.cpp
libc/src/string/strcpy/strcpy_test.cpp
libc/src/sys/mman/mmap_test.cpp
################################################################################
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index d07646d7701f..ee57e5d313c4 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -22,5 +22,10 @@ include(LLVMLibCRules)
add_subdirectory(src)
add_subdirectory(config)
add_subdirectory(include)
-add_subdirectory(lib)
add_subdirectory(utils)
+
+# The lib and test directories are added at the very end as tests
+# and libraries potentially draw from the components present in all
+# of the other directories.
+add_subdirectory(lib)
+add_subdirectory(test)
diff --git a/libc/config/linux/x86_64/CMakeLists.txt b/libc/config/linux/x86_64/CMakeLists.txt
index 8ed89823261f..e69de29bb2d1 100644
--- a/libc/config/linux/x86_64/CMakeLists.txt
+++ b/libc/config/linux/x86_64/CMakeLists.txt
@@ -1,10 +0,0 @@
-add_custom_target(libc_linux_x86_64_unittests)
-
-add_libc_unittest(
- libc_linux_x86_64_syscall_unittest
- SUITE libc_linux_x86_64_unittests
- SRCS syscall_test.cpp
- DEPENDS
- syscall_impl_h
- support_common_h
-)
diff --git a/libc/docs/source_layout.rst b/libc/docs/source_layout.rst
index b06ad96e1b85..685798c19575 100644
--- a/libc/docs/source_layout.rst
+++ b/libc/docs/source_layout.rst
@@ -11,6 +11,7 @@ directories::
- lib
- loader
- src
+ - test
+ utils
- build_scripts
- testing
@@ -69,6 +70,15 @@ further organized as follows:
implementation standard document explains more about the *header*
directories.
+The ``test`` directory
+----------------------
+
+This directory contains tests for the various components of llvm-libc. The
+directory structure within this directory mirrors the directory structure of the
+toplevel ``libc`` directory itself. A test for, say the ``mmap`` function, lives
+in the directory ``test/src/sys/mman/`` as implementation of ``mmap`` lives in
+``src/sys/mman``.
+
The ``www`` directory
---------------------
diff --git a/libc/src/errno/CMakeLists.txt b/libc/src/errno/CMakeLists.txt
index 32d7262044b2..9f244908d700 100644
--- a/libc/src/errno/CMakeLists.txt
+++ b/libc/src/errno/CMakeLists.txt
@@ -5,15 +5,3 @@ add_entrypoint_object(
HDRS
llvmlibc_errno.h
)
-
-add_custom_target(libc_errno_unittests)
-
-add_libc_unittest(
- errno_test
- SUITE
- libc_errno_unittests
- SRCS
- errno_test.cpp
- DEPENDS
- __errno_location
-)
diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index a8984f6ee9f3..459d9489e3a9 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -1,4 +1,2 @@
-add_custom_target(libc_string_unittests)
-
add_subdirectory(strcpy)
add_subdirectory(strcat)
diff --git a/libc/src/string/strcat/CMakeLists.txt b/libc/src/string/strcat/CMakeLists.txt
index 790d77bbb1a0..e37e4262b3ef 100644
--- a/libc/src/string/strcat/CMakeLists.txt
+++ b/libc/src/string/strcat/CMakeLists.txt
@@ -8,14 +8,3 @@ add_entrypoint_object(
strcpy
string_h
)
-
-add_libc_unittest(
- strcat_test
- SUITE
- libc_string_unittests
- SRCS
- strcat_test.cpp
- DEPENDS
- strcat
- strcpy
-)
diff --git a/libc/src/string/strcpy/CMakeLists.txt b/libc/src/string/strcpy/CMakeLists.txt
index 9f2791139ee6..411333a73a8e 100644
--- a/libc/src/string/strcpy/CMakeLists.txt
+++ b/libc/src/string/strcpy/CMakeLists.txt
@@ -7,13 +7,3 @@ add_entrypoint_object(
DEPENDS
string_h
)
-
-add_libc_unittest(
- strcpy_test
- SUITE
- libc_string_unittests
- SRCS
- strcpy_test.cpp
- DEPENDS
- strcpy
-)
diff --git a/libc/src/sys/mman/CMakeLists.txt b/libc/src/sys/mman/CMakeLists.txt
index f2d98a455181..9b8cc66299a6 100644
--- a/libc/src/sys/mman/CMakeLists.txt
+++ b/libc/src/sys/mman/CMakeLists.txt
@@ -25,17 +25,3 @@ add_entrypoint_object(
syscall_impl_h
__errno_location
)
-
-add_custom_target(libc_sys_mman_unittests)
-
-add_libc_unittest(
- mmap_test
- SUITE
- libc_sys_mman_unittests
- SRCS
- mmap_test.cpp
- DEPENDS
- mmap
- munmap
- __errno_location
-)
diff --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt
new file mode 100644
index 000000000000..fa7f29e1d2ac
--- /dev/null
+++ b/libc/test/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_custom_target(check_libc)
+
+add_subdirectory(config)
+add_subdirectory(src)
diff --git a/libc/test/config/CMakeLists.txt b/libc/test/config/CMakeLists.txt
new file mode 100644
index 000000000000..a1034f995474
--- /dev/null
+++ b/libc/test/config/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(linux)
diff --git a/libc/test/config/linux/CMakeLists.txt b/libc/test/config/linux/CMakeLists.txt
new file mode 100644
index 000000000000..5a20f90881f0
--- /dev/null
+++ b/libc/test/config/linux/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_custom_target(libc_linux_tests)
+add_dependencies(check_libc libc_linux_tests)
+
+add_subdirectory(x86_64)
diff --git a/libc/test/config/linux/x86_64/CMakeLists.txt b/libc/test/config/linux/x86_64/CMakeLists.txt
new file mode 100644
index 000000000000..370073cd1cf7
--- /dev/null
+++ b/libc/test/config/linux/x86_64/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_custom_target(libc_linux_x86_64_tests)
+add_dependencies(libc_linux_tests libc_linux_x86_64_tests)
+
+add_libc_unittest(
+ libc_linux_x86_64_syscall_unittest
+ SUITE libc_linux_x86_64_tests
+ SRCS syscall_test.cpp
+ DEPENDS
+ syscall_impl_h
+ support_common_h
+)
diff --git a/libc/config/linux/x86_64/syscall_test.cpp b/libc/test/config/linux/x86_64/syscall_test.cpp
similarity index 100%
rename from libc/config/linux/x86_64/syscall_test.cpp
rename to libc/test/config/linux/x86_64/syscall_test.cpp
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
new file mode 100644
index 000000000000..daf0f1ce57ce
--- /dev/null
+++ b/libc/test/src/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_subdirectory(errno)
+add_subdirectory(string)
+add_subdirectory(sys)
diff --git a/libc/test/src/errno/CMakeLists.txt b/libc/test/src/errno/CMakeLists.txt
new file mode 100644
index 000000000000..6c21da5701b4
--- /dev/null
+++ b/libc/test/src/errno/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_custom_target(libc_errno_unittests)
+add_dependencies(check_libc libc_errno_unittests)
+
+add_libc_unittest(
+ errno_test
+ SUITE
+ libc_errno_unittests
+ SRCS
+ errno_test.cpp
+ DEPENDS
+ __errno_location
+)
diff --git a/libc/src/errno/errno_test.cpp b/libc/test/src/errno/errno_test.cpp
similarity index 100%
rename from libc/src/errno/errno_test.cpp
rename to libc/test/src/errno/errno_test.cpp
diff --git a/libc/test/src/string/CMakeLists.txt b/libc/test/src/string/CMakeLists.txt
new file mode 100644
index 000000000000..bc5c088d169f
--- /dev/null
+++ b/libc/test/src/string/CMakeLists.txt
@@ -0,0 +1,23 @@
+add_custom_target(libc_string_unittests)
+add_dependencies(check_libc libc_string_unittests)
+
+add_libc_unittest(
+ strcat_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strcat_test.cpp
+ DEPENDS
+ strcat
+ strcpy
+)
+
+add_libc_unittest(
+ strcpy_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ strcpy_test.cpp
+ DEPENDS
+ strcpy
+)
diff --git a/libc/src/string/strcat/strcat_test.cpp b/libc/test/src/string/strcat_test.cpp
similarity index 100%
rename from libc/src/string/strcat/strcat_test.cpp
rename to libc/test/src/string/strcat_test.cpp
diff --git a/libc/src/string/strcpy/strcpy_test.cpp b/libc/test/src/string/strcpy_test.cpp
similarity index 100%
rename from libc/src/string/strcpy/strcpy_test.cpp
rename to libc/test/src/string/strcpy_test.cpp
diff --git a/libc/test/src/sys/CMakeLists.txt b/libc/test/src/sys/CMakeLists.txt
new file mode 100644
index 000000000000..03c59bfc4a0b
--- /dev/null
+++ b/libc/test/src/sys/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(mman)
diff --git a/libc/test/src/sys/mman/CMakeLists.txt b/libc/test/src/sys/mman/CMakeLists.txt
new file mode 100644
index 000000000000..3e153eb11344
--- /dev/null
+++ b/libc/test/src/sys/mman/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_custom_target(libc_sys_mman_unittests)
+add_dependencies(check_libc libc_sys_mman_unittests)
+
+add_libc_unittest(
+ mmap_test
+ SUITE
+ libc_sys_mman_unittests
+ SRCS
+ mmap_test.cpp
+ DEPENDS
+ mmap
+ munmap
+ __errno_location
+)
diff --git a/libc/src/sys/mman/mmap_test.cpp b/libc/test/src/sys/mman/mmap_test.cpp
similarity index 100%
rename from libc/src/sys/mman/mmap_test.cpp
rename to libc/test/src/sys/mman/mmap_test.cpp
More information about the libc-commits
mailing list