forked from OSchip/llvm-project
[libc] Rename libc-integration-test to libc-api-test.
Reviewed By: jeffbailey, michaelrj Differential Revision: https://reviews.llvm.org/D122272
This commit is contained in:
parent
7c72f55ea8
commit
3bfbb68e1e
|
@ -0,0 +1,17 @@
|
||||||
|
API Test
|
||||||
|
=====================
|
||||||
|
The implementation of libc-project is unique because our public C header files
|
||||||
|
are generated using information from ground truth captured in TableGen files.
|
||||||
|
Unit tests only exercise the internal C++ implementations and don't ensure the
|
||||||
|
headers were generated by the build system and that the generated header files
|
||||||
|
contain the extpected declarations and definitions. A simple solution is to have
|
||||||
|
contributors write an integration test for each individual function as a C
|
||||||
|
program; however, this would place a large burden on contributors and duplicates
|
||||||
|
some effort from the unit tests.
|
||||||
|
|
||||||
|
Instead we automate the generation of what we call as an API test. This API test
|
||||||
|
ensures that public facing symbols are visible, that the header files are
|
||||||
|
generated as expected, and that each libc function has the correct function
|
||||||
|
prototype as specified by the standards. The API test cmake rules are located in
|
||||||
|
``test/src/CMakeLists.txt``. The source file for the API test is generated in
|
||||||
|
``<build directory>/projects/libc/test/src/public_api_test.cpp``
|
|
@ -77,7 +77,7 @@ Other Interesting Documentation
|
||||||
ground_truth_specification
|
ground_truth_specification
|
||||||
header_generation
|
header_generation
|
||||||
implementation_standard
|
implementation_standard
|
||||||
integration_test
|
api_test
|
||||||
layering
|
layering
|
||||||
mechanics_of_public_api
|
mechanics_of_public_api
|
||||||
redirectors
|
redirectors
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
Integration Tests
|
|
||||||
=====================
|
|
||||||
The implementation of libc-project is unique because our public C header files
|
|
||||||
are generated using information from TableGen. Unit tests only exercise the
|
|
||||||
internal C++ implementations and don't ensure the headers were generated by the
|
|
||||||
build system. End to end testing ensures that, after building, the produced
|
|
||||||
library and headers are usable in the C runtime. A simple solution is to have
|
|
||||||
contributors write an integration test for each individual function as a C
|
|
||||||
program; however, this would place a large burden on contributors and duplicates
|
|
||||||
some effort from the unit tests.
|
|
||||||
|
|
||||||
Instead we automate the generation of integration tests by modeling it from our
|
|
||||||
generated headers. These integration tests ensure that public facing symbols are
|
|
||||||
visible, that header files are generated as expected, and that each libc
|
|
||||||
function has the correct function prototype.
|
|
||||||
|
|
||||||
The integration test cmake rules are located in ``test/src/CMakeLists.txt`` and
|
|
||||||
the generated integration test lives in
|
|
||||||
``llvm/build/projects/libc/test/src/public_integration_test.cpp``
|
|
|
@ -52,7 +52,7 @@ add_subdirectory(stdio)
|
||||||
add_subdirectory(threads)
|
add_subdirectory(threads)
|
||||||
add_subdirectory(time)
|
add_subdirectory(time)
|
||||||
|
|
||||||
set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_integration_test.cpp)
|
set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_api_test.cpp)
|
||||||
|
|
||||||
set(entrypoints_name_list "")
|
set(entrypoints_name_list "")
|
||||||
foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
|
foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS)
|
||||||
|
@ -66,7 +66,7 @@ list(TRANSFORM entrypoints_name_list PREPEND "-e=")
|
||||||
|
|
||||||
file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
|
file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
|
||||||
|
|
||||||
# Generate integration test souce code.
|
# Generate api test souce code.
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${public_test}
|
OUTPUT ${public_test}
|
||||||
COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
|
COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
|
||||||
|
@ -80,32 +80,32 @@ add_custom_command(
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
libc-integration-test
|
libc-api-test
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
${public_test}
|
${public_test}
|
||||||
)
|
)
|
||||||
# Blank out default include directories to prevent accidentally including
|
# Blank out default include directories to prevent accidentally including
|
||||||
# system headers or our own internal headers.
|
# system headers or our own internal headers.
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
libc-integration-test
|
libc-api-test
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
INCLUDE_DIRECTORIES ""
|
INCLUDE_DIRECTORIES ""
|
||||||
)
|
)
|
||||||
# Only include we need is the include for cpp::IsSame and our generated
|
# Only include we need is the include for cpp::IsSame and our generated
|
||||||
# public headers.
|
# public headers.
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
libc-integration-test BEFORE
|
libc-api-test BEFORE
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${LIBC_SOURCE_DIR}/src/__support/CPP"
|
"${LIBC_SOURCE_DIR}/src/__support/CPP"
|
||||||
"${LIBC_BUILD_DIR}/include"
|
"${LIBC_BUILD_DIR}/include"
|
||||||
)
|
)
|
||||||
target_compile_options(
|
target_compile_options(
|
||||||
libc-integration-test
|
libc-api-test
|
||||||
PRIVATE
|
PRIVATE
|
||||||
-ffreestanding
|
-ffreestanding
|
||||||
)
|
)
|
||||||
target_link_options(
|
target_link_options(
|
||||||
libc-integration-test
|
libc-api-test
|
||||||
PRIVATE "-nostdlib"
|
PRIVATE "-nostdlib"
|
||||||
)
|
)
|
||||||
set(library_files)
|
set(library_files)
|
||||||
|
@ -116,7 +116,7 @@ endforeach()
|
||||||
|
|
||||||
if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
|
if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
libc-integration-test-tidy
|
libc-api-test-tidy
|
||||||
VERBATIM
|
VERBATIM
|
||||||
COMMAND $<TARGET_FILE:clang-tidy> --system-headers
|
COMMAND $<TARGET_FILE:clang-tidy> --system-headers
|
||||||
--checks=-*,llvmlibc-restrict-system-libc-headers
|
--checks=-*,llvmlibc-restrict-system-libc-headers
|
||||||
|
@ -130,10 +130,10 @@ if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
|
||||||
DEPENDS
|
DEPENDS
|
||||||
clang-tidy ${public_test}
|
clang-tidy ${public_test}
|
||||||
)
|
)
|
||||||
add_dependencies(libc-integration-test libc-integration-test-tidy)
|
add_dependencies(libc-api-test libc-api-test-tidy)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(libc-integration-test
|
target_link_libraries(libc-api-test
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${library_files}
|
${library_files}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue