[libc-commits] [libc] 9a20e02 - [libc] Enable the 'string' unit tests to be hermetic
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue May 2 16:51:21 PDT 2023
Author: Joseph Huber
Date: 2023-05-02T18:51:11-05:00
New Revision: 9a20e024a25ce1e20556dc4e567a9d943bff4c7e
URL: https://github.com/llvm/llvm-project/commit/9a20e024a25ce1e20556dc4e567a9d943bff4c7e
DIFF: https://github.com/llvm/llvm-project/commit/9a20e024a25ce1e20556dc4e567a9d943bff4c7e.diff
LOG: [libc] Enable the 'string' unit tests to be hermetic
This changes over the string unit tests to the new `add_libc_test`
framework. The one test that wasn't changes was the memory utils because
it overran the static buffer used for the hermetic test's bump pointer.
Depends on D149656
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149662
Added:
Modified:
libc/test/UnitTest/CMakeLists.txt
libc/test/src/string/CMakeLists.txt
libc/test/src/string/memory_utils/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index 0335a8199fc2..cc8140713106 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -126,5 +126,5 @@ add_dependencies(
foreach(lib LibcFPTestHelpers LibcMemoryHelpers LibcPrintfHelpers LibcScanfHelpers)
target_include_directories(${lib} PUBLIC ${LIBC_SOURCE_DIR})
target_compile_options(${lib} PRIVATE -fno-exceptions -fno-rtti)
-target_link_libraries(${lib} LibcUnitTest)
+ target_link_libraries(${lib} LibcUnitTest)
endforeach()
diff --git a/libc/test/src/string/CMakeLists.txt b/libc/test/src/string/CMakeLists.txt
index 4614cd809a43..b90da43f9a7b 100644
--- a/libc/test/src/string/CMakeLists.txt
+++ b/libc/test/src/string/CMakeLists.txt
@@ -1,11 +1,11 @@
-add_custom_target(libc_string_unittests)
+add_custom_target(libc-string-tests)
add_subdirectory(memory_utils)
-add_libc_unittest(
+add_libc_test(
bcopy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
bcopy_test.cpp
DEPENDS
@@ -20,10 +20,10 @@ add_header_library(
StrchrTest.h
)
-add_libc_unittest(
+add_libc_test(
index_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
index_test.cpp
DEPENDS
@@ -31,60 +31,60 @@ add_libc_unittest(
.strchr_test_support
)
-add_libc_unittest(
+add_libc_test(
memccpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
memccpy_test.cpp
DEPENDS
libc.src.string.memccpy
)
-add_libc_unittest(
+add_libc_test(
mempcpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
mempcpy_test.cpp
DEPENDS
libc.src.string.mempcpy
)
-add_libc_unittest(
+add_libc_test(
memmem_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
memmem_test.cpp
DEPENDS
libc.src.string.memmem
)
-add_libc_unittest(
+add_libc_test(
memchr_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
memchr_test.cpp
DEPENDS
libc.src.string.memchr
)
-add_libc_unittest(
+add_libc_test(
memrchr_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
memrchr_test.cpp
DEPENDS
libc.src.string.memrchr
)
-add_libc_unittest(
+add_libc_test(
rindex_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
rindex_test.cpp
DEPENDS
@@ -92,40 +92,40 @@ add_libc_unittest(
.strchr_test_support
)
-add_libc_unittest(
+add_libc_test(
stpcpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
stpcpy_test.cpp
DEPENDS
libc.src.string.stpcpy
)
-add_libc_unittest(
+add_libc_test(
stpncpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
stpncpy_test.cpp
DEPENDS
libc.src.string.stpncpy
)
-add_libc_unittest(
+add_libc_test(
strcat_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcat_test.cpp
DEPENDS
libc.src.string.strcat
)
-add_libc_unittest(
+add_libc_test(
strchr_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strchr_test.cpp
DEPENDS
@@ -133,80 +133,80 @@ add_libc_unittest(
.strchr_test_support
)
-add_libc_unittest(
+add_libc_test(
strchrnul_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strchrnul_test.cpp
DEPENDS
libc.src.string.strchrnul
)
-add_libc_unittest(
+add_libc_test(
strcmp_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcmp_test.cpp
DEPENDS
libc.src.string.strcmp
)
-add_libc_unittest(
+add_libc_test(
strcasecmp_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcasecmp_test.cpp
DEPENDS
libc.src.string.strcasecmp
)
-add_libc_unittest(
+add_libc_test(
strcasestr_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcasestr_test.cpp
DEPENDS
libc.src.string.strcasestr
)
-add_libc_unittest(
+add_libc_test(
strcoll_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcoll_test.cpp
DEPENDS
libc.src.string.strcoll
)
-add_libc_unittest(
+add_libc_test(
strcpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcpy_test.cpp
DEPENDS
libc.src.string.strcpy
)
-add_libc_unittest(
+add_libc_test(
strcspn_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strcspn_test.cpp
DEPENDS
libc.src.string.strcspn
)
-add_libc_unittest(
+add_libc_test(
strdup_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strdup_test.cpp
DEPENDS
@@ -215,10 +215,10 @@ add_libc_unittest(
libc.src.errno.errno
)
-add_libc_unittest(
+add_libc_test(
strerror_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strerror_test.cpp
DEPENDS
@@ -226,90 +226,90 @@ add_libc_unittest(
)
-add_libc_unittest(
+add_libc_test(
strerror_r_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strerror_r_test.cpp
DEPENDS
libc.src.string.strerror_r
)
-add_libc_unittest(
+add_libc_test(
strlcat_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strlcat_test.cpp
DEPENDS
libc.src.string.strlcat
)
-add_libc_unittest(
+add_libc_test(
strlcpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strlcpy_test.cpp
DEPENDS
libc.src.string.strlcpy
)
-add_libc_unittest(
+add_libc_test(
strlen_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strlen_test.cpp
DEPENDS
libc.src.string.strlen
)
-add_libc_unittest(
+add_libc_test(
strncat_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strncat_test.cpp
DEPENDS
libc.src.string.strncat
)
-add_libc_unittest(
+add_libc_test(
strncmp_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strncmp_test.cpp
DEPENDS
libc.src.string.strncmp
)
-add_libc_unittest(
+add_libc_test(
strncasecmp_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strncasecmp_test.cpp
DEPENDS
libc.src.string.strncasecmp
)
-add_libc_unittest(
+add_libc_test(
strncpy_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strncpy_test.cpp
DEPENDS
libc.src.string.strncpy
)
-add_libc_unittest(
+add_libc_test(
strndup_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strndup_test.cpp
DEPENDS
@@ -317,30 +317,30 @@ add_libc_unittest(
libc.src.string.strndup
)
-add_libc_unittest(
+add_libc_test(
strnlen_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strnlen_test.cpp
DEPENDS
libc.src.string.strnlen
)
-add_libc_unittest(
+add_libc_test(
strpbrk_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strpbrk_test.cpp
DEPENDS
libc.src.string.strpbrk
)
-add_libc_unittest(
+add_libc_test(
strrchr_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strrchr_test.cpp
DEPENDS
@@ -348,70 +348,70 @@ add_libc_unittest(
.strchr_test_support
)
-add_libc_unittest(
+add_libc_test(
strsep_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strsep_test.cpp
DEPENDS
libc.src.string.strsep
)
-add_libc_unittest(
+add_libc_test(
strsignal_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strsignal_test.cpp
DEPENDS
libc.src.string.strsignal
)
-add_libc_unittest(
+add_libc_test(
strspn_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strspn_test.cpp
DEPENDS
libc.src.string.strspn
)
-add_libc_unittest(
+add_libc_test(
strstr_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strstr_test.cpp
DEPENDS
libc.src.string.strstr
)
-add_libc_unittest(
+add_libc_test(
strtok_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strtok_test.cpp
DEPENDS
libc.src.string.strtok
)
-add_libc_unittest(
+add_libc_test(
strtok_r_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strtok_r_test.cpp
DEPENDS
libc.src.string.strtok_r
)
-add_libc_unittest(
+add_libc_test(
strxfrm_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
strxfrm_test.cpp
DEPENDS
@@ -425,10 +425,10 @@ function(add_libc_multi_impl_test name)
get_target_property(required_cpu_features ${fq_config_name} REQUIRE_CPU_FEATURES)
cpu_supports(can_run "${required_cpu_features}")
if(can_run)
- add_libc_unittest(
+ add_libc_test(
${fq_config_name}_test
SUITE
- libc_string_unittests
+ libc-string-tests
COMPILE_OPTIONS
${LIBC_COMPILE_OPTIONS_NATIVE}
LINK_LIBRARIES
diff --git a/libc/test/src/string/memory_utils/CMakeLists.txt b/libc/test/src/string/memory_utils/CMakeLists.txt
index e222a616321b..c67142fc1bbf 100644
--- a/libc/test/src/string/memory_utils/CMakeLists.txt
+++ b/libc/test/src/string/memory_utils/CMakeLists.txt
@@ -1,7 +1,8 @@
+# This test uses too much memory to be made hermetic.
add_libc_unittest(
utils_test
SUITE
- libc_string_unittests
+ libc-string-tests
SRCS
op_tests.cpp
utils_test.cpp
More information about the libc-commits
mailing list