1 function(add_fp_unittest name)
4 "NEED_MPFR;UNIT_TEST_ONLY;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)
19 elseif(MATH_UNITTEST_UNIT_TEST_ONLY)
20 set(test_type UNIT_TEST_ONLY)
22 if(MATH_UNITTEST_NEED_MPFR)
23 if(MATH_UNITTEST_HERMETIC_TEST_ONLY)
24 message(FATAL "Hermetic math test cannot require MPFR.")
26 set(test_type UNIT_TEST_ONLY)
27 list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper libc_math_test_utils -lmpfr -lgmp)
29 list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
34 LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
35 "${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
37 endfunction(add_fp_unittest)
39 add_subdirectory(__support)
40 add_subdirectory(ctype)
41 add_subdirectory(errno)
42 add_subdirectory(fenv)
43 add_subdirectory(math)
44 add_subdirectory(string)
45 add_subdirectory(stdlib)
46 add_subdirectory(inttypes)
47 add_subdirectory(stdio)
48 add_subdirectory(wchar)
50 if(${LIBC_TARGET_OS} STREQUAL "linux")
51 add_subdirectory(fcntl)
52 add_subdirectory(sched)
54 add_subdirectory(termios)
55 add_subdirectory(unistd)
58 if(NOT LLVM_LIBC_FULL_BUILD)
62 add_subdirectory(dirent)
63 add_subdirectory(assert)
64 add_subdirectory(network)
65 add_subdirectory(setjmp)
66 add_subdirectory(signal)
67 add_subdirectory(spawn)
68 add_subdirectory(time)
70 if(${LIBC_TARGET_OS} STREQUAL "linux")
71 add_subdirectory(pthread)
74 if(LLVM_RUNTIMES_BUILD OR LIBC_HDRGEN_EXE)
75 # The public API test below uses tablegen to generate the test
76 # source file. Since tablegen is not available during a runtimes
77 # build, we will skip the test.
78 # If a different libc-hdrgen binary is being used, then also we
79 # skip the api-test as we cannot generate the test source file.
83 set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_api_test.cpp)
85 set(entrypoints_name_list "")
86 foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
87 get_target_property(entry_name ${entry} "ENTRYPOINT_NAME")
88 list(APPEND entrypoints_name_list ${entry_name})
91 # TODO: Remove these when they are added to the TableGen.
92 list(REMOVE_ITEM entrypoints_name_list "__assert_fail" "__errno_location")
93 list(TRANSFORM entrypoints_name_list PREPEND "-e=")
95 file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
97 # Generate api test souce code.
100 COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
101 ${entrypoints_name_list}
102 -I ${LIBC_SOURCE_DIR}
103 ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
105 DEPENDS ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td ${spec_files}
106 libc-prototype-testgen ${TARGET_PUBLIC_HEADERS}
110 add_custom_target(libc-api-test)
111 add_dependencies(check-libc libc-api-test)
114 allocator_entrypoints
115 libc.src.stdlib.malloc
116 libc.src.stdlib.calloc
117 libc.src.stdlib.realloc
118 libc.src.stdlib.aligned_alloc
121 set(api-test-entrypoints ${TARGET_LLVMLIBC_ENTRYPOINTS})
122 list(REMOVE_ITEM api-test-entrypoints ${allocator_entrypoints})
123 add_integration_test(
130 ${api-test-entrypoints}
133 if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
137 COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers
138 --checks=-*,llvmlibc-restrict-system-libc-headers
139 "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
141 --warnings-as-errors=llvmlibc-*
142 "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
144 -p ${PROJECT_BINARY_DIR}
147 clang-tidy ${public_test}
149 add_dependencies(libc-api-test libc-api-test-tidy)