[libc-commits] [libc] 78d7d62 - [libc] Enable the '__support' unit tests to be hermetic
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Wed May 3 09:38:02 PDT 2023
Author: Joseph Huber
Date: 2023-05-03T11:37:50-05:00
New Revision: 78d7d62c36f54b4264faec8ce38d11f7dd6abfd6
URL: https://github.com/llvm/llvm-project/commit/78d7d62c36f54b4264faec8ce38d11f7dd6abfd6
DIFF: https://github.com/llvm/llvm-project/commit/78d7d62c36f54b4264faec8ce38d11f7dd6abfd6.diff
LOG: [libc] Enable the '__support' unit tests to be hermetic
This patch updates the `__support` unit tests to be built as hermetic
tests. The only tests we needed to disable were because of the use of
`realloc` which is not implemented correctly as it doesn't copy the
memory.
Depends on D149745
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149750
Added:
Modified:
libc/test/src/__support/CMakeLists.txt
libc/test/src/__support/CPP/CMakeLists.txt
libc/test/src/__support/FPUtil/CMakeLists.txt
libc/test/src/__support/File/CMakeLists.txt
libc/test/src/__support/OSUtil/CMakeLists.txt
libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
libc/test/src/__support/char_vector_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index dddb0a8ed2ba9..fec62820718da 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -1,29 +1,29 @@
-add_custom_target(libc_support_unittests)
+add_custom_target(libc-support-tests)
-add_libc_unittest(
+add_libc_test(
blockstore_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
blockstore_test.cpp
DEPENDS
libc.src.__support.blockstore
)
-add_libc_unittest(
+add_libc_test(
endian_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
endian_test.cpp
DEPENDS
libc.src.__support.common
)
-add_libc_unittest(
+add_libc_test(
high_precision_decimal_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
high_precision_decimal_test.cpp
DEPENDS
@@ -31,10 +31,10 @@ add_libc_unittest(
libc.src.__support.uint128
)
-add_libc_unittest(
+add_libc_test(
str_to_float_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
str_to_float_test.cpp
DEPENDS
@@ -43,10 +43,10 @@ add_libc_unittest(
libc.src.errno.errno
)
-add_libc_unittest(
+add_libc_test(
integer_to_string_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
integer_to_string_test.cpp
DEPENDS
@@ -54,20 +54,20 @@ add_libc_unittest(
libc.src.__support.CPP.string_view
)
-add_libc_unittest(
+add_libc_test(
arg_list_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
arg_list_test.cpp
DEPENDS
libc.src.__support.arg_list
)
-add_libc_unittest(
+add_libc_test(
uint_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
uint_test.cpp
DEPENDS
@@ -75,20 +75,22 @@ add_libc_unittest(
libc.src.__support.CPP.optional
)
-add_libc_unittest(
+add_libc_test(
fixedvector_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
fixedvector_test.cpp
DEPENDS
libc.src.__support.fixedvector
)
-add_libc_unittest(
+add_libc_test(
char_vector_test
+ # This test relies on 'realloc' which is not implemented for hermetic tests.
+ UNIT_TEST_ONLY
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
char_vector_test.cpp
DEPENDS
diff --git a/libc/test/src/__support/CPP/CMakeLists.txt b/libc/test/src/__support/CPP/CMakeLists.txt
index a6b80fcce8729..792a28e8cbba3 100644
--- a/libc/test/src/__support/CPP/CMakeLists.txt
+++ b/libc/test/src/__support/CPP/CMakeLists.txt
@@ -1,39 +1,39 @@
-add_custom_target(libc_cpp_utils_unittests)
+add_custom_target(libc-cpp-utils-tests)
-add_libc_unittest(
+add_libc_test(
bitset_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
bitset_test.cpp
DEPENDS
libc.src.__support.CPP.bitset
)
-add_libc_unittest(
+add_libc_test(
cstddef_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
cstddef_test.cpp
DEPENDS
libc.src.__support.CPP.cstddef
)
-add_libc_unittest(
+add_libc_test(
stringview_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
stringview_test.cpp
DEPENDS
libc.src.__support.CPP.string_view
)
-add_libc_unittest(
+add_libc_test(
limits_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
limits_test.cpp
DEPENDS
@@ -41,30 +41,30 @@ add_libc_unittest(
libc.src.__support.uint
)
-add_libc_unittest(
+add_libc_test(
int_seq_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
integer_sequence_test.cpp
DEPENDS
libc.src.__support.CPP.utility
)
-add_libc_unittest(
+add_libc_test(
atomic_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
atomic_test.cpp
DEPENDS
libc.src.__support.CPP.atomic
)
-add_libc_unittest(
+add_libc_test(
stringstream_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
stringstream_test.cpp
DEPENDS
@@ -72,30 +72,32 @@ add_libc_unittest(
libc.src.__support.CPP.stringstream
)
-add_libc_unittest(
+add_libc_test(
optional_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
optional_test.cpp
DEPENDS
libc.src.__support.CPP.optional
)
-add_libc_unittest(
+add_libc_test(
span_test
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
span_test.cpp
DEPENDS
libc.src.__support.CPP.span
)
-add_libc_unittest(
+add_libc_test(
string_test
+ # This test relies on 'realloc' which is not implemented for hermetic tests.
+ UNIT_TEST_ONLY
SUITE
- libc_cpp_utils_unittests
+ libc-cpp-utils-tests
SRCS
string_test.cpp
DEPENDS
diff --git a/libc/test/src/__support/FPUtil/CMakeLists.txt b/libc/test/src/__support/FPUtil/CMakeLists.txt
index 0f57c44b43f15..2e4f7f897773f 100644
--- a/libc/test/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/test/src/__support/FPUtil/CMakeLists.txt
@@ -1,10 +1,10 @@
-add_custom_target(libc_fputil_unittests)
+add_custom_target(libc-fputil-tests)
add_fp_unittest(
dyadic_float_test
NEED_MPFR
SUITE
- libc_fputil_unittests
+ libc-fputil-tests
SRCS
dyadic_float_test.cpp
DEPENDS
diff --git a/libc/test/src/__support/File/CMakeLists.txt b/libc/test/src/__support/File/CMakeLists.txt
index 4ee7a3255aee5..ad4a5f4f38703 100644
--- a/libc/test/src/__support/File/CMakeLists.txt
+++ b/libc/test/src/__support/File/CMakeLists.txt
@@ -4,10 +4,10 @@ if(NOT (TARGET libc.src.__support.threads.mutex))
return()
endif()
-add_libc_unittest(
+add_libc_test(
file_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
file_test.cpp
LINK_LIBRARIES
@@ -21,10 +21,10 @@ add_libc_unittest(
)
if (TARGET libc.src.__support.File.platform_file)
- add_libc_unittest(
+ add_libc_test(
platform_file_test
SUITE
- libc_support_unittests
+ libc-support-tests
SRCS
platform_file_test.cpp
DEPENDS
diff --git a/libc/test/src/__support/OSUtil/CMakeLists.txt b/libc/test/src/__support/OSUtil/CMakeLists.txt
index 9adac7e73b8ff..c8818d4715d0f 100644
--- a/libc/test/src/__support/OSUtil/CMakeLists.txt
+++ b/libc/test/src/__support/OSUtil/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_custom_target(libc_osutil_tests)
+add_custom_target(libc-osutil-tests)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${LIBC_TARGET_OS})
diff --git a/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt b/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
index e0f2549bd8de2..577fd3169cc1f 100644
--- a/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
+++ b/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
@@ -1,6 +1,6 @@
-add_libc_unittest(
- syscall_unittest
- SUITE libc_osutil_tests
+add_libc_test(
+ syscall_test
+ SUITE libc-osutil-tests
SRCS syscall_test.cpp
COMPILE_OPTIONS
-Wno-unused-variable # Only signature tests, declared variables are unused.
diff --git a/libc/test/src/__support/char_vector_test.cpp b/libc/test/src/__support/char_vector_test.cpp
index 70f73729cc517..cbca178283941 100644
--- a/libc/test/src/__support/char_vector_test.cpp
+++ b/libc/test/src/__support/char_vector_test.cpp
@@ -71,8 +71,8 @@ TEST(LlvmLibcCharVectorTest, AppendLong) {
"ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy";
for (size_t i = 0; test_str[i] != '\0'; ++i) {
ASSERT_EQ(v.length(), i);
- v.append(test_str[i]);
+ ASSERT_TRUE(v.append(test_str[i]));
}
- ASSERT_STREQ(v.c_str(), test_str);
ASSERT_EQ(v.length(), size_t(1000));
+ ASSERT_STREQ(v.c_str(), test_str);
}
More information about the libc-commits
mailing list