[libc] Move all tests to a top level `test` directory.
authorSiva Chandra Reddy <sivachandra@google.com>
Fri, 3 Jan 2020 20:00:45 +0000 (12:00 -0800)
committerSiva Chandra Reddy <sivachandra@google.com>
Mon, 6 Jan 2020 18:14:43 +0000 (10:14 -0800)
A toplevel target, `check-libc` has also been added.

Reviewers: abrachet, phosek

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72177

22 files changed:
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
libc/test/CMakeLists.txt [new file with mode: 0644]
libc/test/config/CMakeLists.txt [new file with mode: 0644]
libc/test/config/linux/CMakeLists.txt [new file with mode: 0644]
libc/test/config/linux/x86_64/CMakeLists.txt [new file with mode: 0644]
libc/test/config/linux/x86_64/syscall_test.cpp [moved from libc/config/linux/x86_64/syscall_test.cpp with 100% similarity]
libc/test/src/CMakeLists.txt [new file with mode: 0644]
libc/test/src/errno/CMakeLists.txt [new file with mode: 0644]
libc/test/src/errno/errno_test.cpp [moved from libc/src/errno/errno_test.cpp with 100% similarity]
libc/test/src/string/CMakeLists.txt [new file with mode: 0644]
libc/test/src/string/strcat_test.cpp [moved from libc/src/string/strcat/strcat_test.cpp with 100% similarity]
libc/test/src/string/strcpy_test.cpp [moved from libc/src/string/strcpy/strcpy_test.cpp with 100% similarity]
libc/test/src/sys/CMakeLists.txt [new file with mode: 0644]
libc/test/src/sys/mman/CMakeLists.txt [new file with mode: 0644]
libc/test/src/sys/mman/mmap_test.cpp [moved from libc/src/sys/mman/mmap_test.cpp with 100% similarity]

index d07646d..ee57e5d 100644 (file)
@@ -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)
index 8ed8982..e69de29 100644 (file)
@@ -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
-)
index b06ad96..685798c 100644 (file)
@@ -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
 ---------------------
 
index 32d7262..9f24490 100644 (file)
@@ -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
-)
index a8984f6..459d948 100644 (file)
@@ -1,4 +1,2 @@
-add_custom_target(libc_string_unittests)
-
 add_subdirectory(strcpy)
 add_subdirectory(strcat)
index 790d77b..e37e426 100644 (file)
@@ -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
-)
index 9f27911..411333a 100644 (file)
@@ -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
-)
index f2d98a4..9b8cc66 100644 (file)
@@ -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 (file)
index 0000000..fa7f29e
--- /dev/null
@@ -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 (file)
index 0000000..a1034f9
--- /dev/null
@@ -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 (file)
index 0000000..5a20f90
--- /dev/null
@@ -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 (file)
index 0000000..370073c
--- /dev/null
@@ -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/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..daf0f1c
--- /dev/null
@@ -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 (file)
index 0000000..6c21da5
--- /dev/null
@@ -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/test/src/string/CMakeLists.txt b/libc/test/src/string/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bc5c088
--- /dev/null
@@ -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/test/src/sys/CMakeLists.txt b/libc/test/src/sys/CMakeLists.txt
new file mode 100644 (file)
index 0000000..03c59bf
--- /dev/null
@@ -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 (file)
index 0000000..3e153eb
--- /dev/null
@@ -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
+)