1 function(add_fp_unittest name)
4 "NEED_MPFR;HERMETIC_TEST_ONLY" # Optional arguments
5 "" # Single value arguments
6 "LINK_LIBRARIES" # Multi-value arguments
10 if(MATH_UNITTEST_NEED_MPFR)
11 if(NOT LIBC_TESTS_CAN_USE_MPFR)
12 message(VERBOSE "Math test ${name} will be skipped as MPFR library is not available.")
17 if(MATH_UNITTEST_HERMETIC_TEST_ONLY)
18 set(test_type HERMETIC_TEST_ONLY)
20 if(MATH_UNITTEST_NEED_MPFR)
21 if(MATH_UNITTEST_HERMETIC_TEST_ONLY)
22 message(FATAL "Hermetic math test cannot require MPFR.")
24 set(test_type UNIT_TEST_ONLY)
25 list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper libc_math_test_utils -lmpfr -lgmp)
27 list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
32 LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
33 "${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
35 endfunction(add_fp_unittest)
37 add_subdirectory(__support)
38 add_subdirectory(ctype)
39 add_subdirectory(errno)
40 add_subdirectory(fenv)
41 add_subdirectory(math)
42 add_subdirectory(string)
43 add_subdirectory(stdlib)
44 add_subdirectory(inttypes)
45 add_subdirectory(stdio)
46 add_subdirectory(wchar)
48 if(${LIBC_TARGET_OS} STREQUAL "linux")
49 add_subdirectory(fcntl)
50 add_subdirectory(sched)
52 add_subdirectory(termios)
53 add_subdirectory(unistd)
56 if(NOT LLVM_LIBC_FULL_BUILD)
60 add_subdirectory(dirent)
61 add_subdirectory(assert)
62 add_subdirectory(network)
63 add_subdirectory(setjmp)
64 add_subdirectory(signal)
65 add_subdirectory(spawn)
66 add_subdirectory(time)
68 if(${LIBC_TARGET_OS} STREQUAL "linux")
69 add_subdirectory(pthread)
72 if(LLVM_RUNTIMES_BUILD OR LIBC_HDRGEN_EXE)
73 # The public API test below uses tablegen to generate the test
74 # source file. Since tablegen is not available during a runtimes
75 # build, we will skip the test.
76 # If a different libc-hdrgen binary is being used, then also we
77 # skip the api-test as we cannot generate the test source file.
81 set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_api_test.cpp)
83 set(entrypoints_name_list "")
84 foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
85 get_target_property(entry_name ${entry} "ENTRYPOINT_NAME")
86 list(APPEND entrypoints_name_list ${entry_name})
89 # TODO: Remove these when they are added to the TableGen.
90 list(REMOVE_ITEM entrypoints_name_list "__assert_fail" "__errno_location")
91 list(TRANSFORM entrypoints_name_list PREPEND "-e=")
93 file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
95 # Generate api test souce code.
98 COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
99 ${entrypoints_name_list}
100 -I ${LIBC_SOURCE_DIR}
101 ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
103 DEPENDS ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td ${spec_files}
104 libc-prototype-testgen ${TARGET_PUBLIC_HEADERS}
108 add_custom_target(libc-api-test)
109 add_dependencies(check-libc libc-api-test)
112 allocator_entrypoints
113 libc.src.stdlib.malloc
114 libc.src.stdlib.calloc
115 libc.src.stdlib.realloc
116 libc.src.stdlib.aligned_alloc
119 set(api-test-entrypoints ${TARGET_LLVMLIBC_ENTRYPOINTS})
120 list(REMOVE_ITEM api-test-entrypoints ${allocator_entrypoints})
121 add_integration_test(
128 ${api-test-entrypoints}
131 if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
135 COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers
136 --checks=-*,llvmlibc-restrict-system-libc-headers
137 "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
139 --warnings-as-errors=llvmlibc-*
140 "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
142 -p ${PROJECT_BINARY_DIR}
145 clang-tidy ${public_test}
147 add_dependencies(libc-api-test libc-api-test-tidy)