This moves all DOM (benchmark + test) files to a subdir (#1549)

* This moves all DOM (benchmark + test) files to a subdir

* Missing file.

* CMake + DLL is not pretty.

* Capitalizing AND

* Fixing mismatch endif

* Flipping the order.

* onedemand => ondemand
This commit is contained in:
Daniel Lemire 2021-04-30 18:33:45 -04:00 committed by GitHub
parent 911b06186b
commit c1dffac28c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 186 additions and 186 deletions

View File

@ -1,20 +1,12 @@
add_subdirectory(dom)
include_directories( . linux )
link_libraries(simdjson-windows-headers test-data)
link_libraries(simdjson)
add_executable(benchfeatures benchfeatures.cpp)
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
add_executable(perfdiff perfdiff.cpp)
add_executable(parse parse.cpp)
add_executable(parse_stream parse_stream.cpp)
add_executable(statisticalmodel statisticalmodel.cpp)
add_executable(parse_noutf8validation parse.cpp)
target_compile_definitions(parse_noutf8validation PRIVATE SIMDJSON_SKIPUTF8VALIDATION)
add_executable(parse_nonumberparsing parse.cpp)
target_compile_definitions(parse_nonumberparsing PRIVATE SIMDJSON_SKIPNUMBERPARSING)
add_executable(parse_nostringparsing parse.cpp)
target_compile_definitions(parse_nostringparsing PRIVATE SIMDJSON_SKIPSTRINGPARSING)
if (TARGET benchmark::benchmark)
link_libraries(benchmark::benchmark)
@ -37,4 +29,3 @@ if (TARGET benchmark::benchmark)
endif()
endif()
include(checkperf.cmake)

View File

@ -0,0 +1,16 @@
include_directories( .. ../linux )
link_libraries(simdjson-windows-headers test-data)
link_libraries(simdjson)
add_executable(perfdiff perfdiff.cpp)
add_executable(parse parse.cpp)
add_executable(parse_stream parse_stream.cpp)
add_executable(statisticalmodel statisticalmodel.cpp)
add_executable(parse_noutf8validation parse.cpp)
target_compile_definitions(parse_noutf8validation PRIVATE SIMDJSON_SKIPUTF8VALIDATION)
add_executable(parse_nonumberparsing parse.cpp)
target_compile_definitions(parse_nonumberparsing PRIVATE SIMDJSON_SKIPNUMBERPARSING)
add_executable(parse_nostringparsing parse.cpp)
target_compile_definitions(parse_nostringparsing PRIVATE SIMDJSON_SKIPSTRINGPARSING)
include(checkperf.cmake)

View File

@ -1,189 +1,27 @@
# Most tests need test data, and many need windows headers.
link_libraries(simdjson-internal-flags test-data simdjson-windows-headers)
include(${PROJECT_SOURCE_DIR}/cmake/add_cpp_test.cmake)
add_subdirectory(dom)
add_subdirectory(ondemand)
#
# These tests explicitly do #include "simdjson.cpp" so they can override stuff
#
if(NOT SIMDJSON_LEGACY_VISUAL_STUDIO AND NOT SIMDJSON_WINDOWS_DLL)
add_cpp_test(numberparsingcheck LABELS acceptance per_implementation)
simdjson_apply_props(numberparsingcheck)
target_link_libraries(numberparsingcheck PRIVATE simdjson-windows-headers)
target_compile_definitions(numberparsingcheck PRIVATE NOMINMAX)
target_include_directories(
numberparsingcheck
PRIVATE "${PROJECT_SOURCE_DIR}/src"
)
add_cpp_test(stringparsingcheck LABELS acceptance per_implementation)
simdjson_apply_props(numberparsingcheck)
target_link_libraries(stringparsingcheck PRIVATE simdjson-windows-headers)
target_compile_definitions(stringparsingcheck PRIVATE NOMINMAX)
target_include_directories(
stringparsingcheck
PRIVATE "${PROJECT_SOURCE_DIR}/src"
)
endif()
# All remaining tests link with simdjson proper
link_libraries(simdjson)
if(NOT SIMDJSON_LEGACY_VISUAL_STUDIO AND NOT SIMDJSON_WINDOWS_DLL)
add_cpp_test(random_string_number_tests LABELS dom acceptance per_implementation)
endif()
add_cpp_test(basictests LABELS dom acceptance per_implementation)
add_cpp_test(document_stream_tests LABELS dom acceptance per_implementation)
add_cpp_test(document_tests LABELS dom acceptance per_implementation)
add_cpp_test(errortests LABELS dom acceptance per_implementation)
add_cpp_test(extracting_values_example LABELS dom acceptance per_implementation)
add_cpp_test(integer_tests LABELS dom acceptance per_implementation)
add_cpp_test(jsoncheck LABELS dom acceptance per_implementation)
add_cpp_test(minefieldcheck LABELS dom acceptance per_implementation)
add_cpp_test(parse_many_test LABELS dom acceptance per_implementation)
add_cpp_test(pointercheck LABELS dom acceptance per_implementation) # https://tools.ietf.org/html/rfc6901
add_cpp_test(unicode_tests LABELS dom acceptance per_implementation)
add_cpp_test(trivially_copyable_test LABELS dom acceptance per_implementation)
add_cpp_test(unicode_tests LABELS dom acceptance per_implementation)
add_cpp_test(minify_tests LABELS other acceptance per_implementation)
add_cpp_test(padded_string_tests LABELS other acceptance )
find_program(BASH bash)
# Below we skip anything on Windows, not just visual studio, because running bash under Windows requires you to
# map app paths to their "mounted" equivalent (e.g., /mnt/c/...). So even if you have bash under Windows, extra work would be
# required to make things work robustly. Simply put: bash is not quite portable.
# Script tests
if (BASH AND (NOT WIN32) AND SIMDJSON_BASH AND (TARGET json2json)) # The scripts are not robust enough to run under Windows even if bash is available
#
# json2json test
#
add_test(
NAME testjson2json
COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/testjson2json.sh
WORKING_DIRECTORY $<TARGET_FILE_DIR:minify>
)
set_property(TEST testjson2json APPEND PROPERTY DEPENDS minify json2json)
set_property(TEST testjson2json APPEND PROPERTY LABELS per_implementation)
add_dependencies(per_implementation_tests minify)
#
# Competition parse test
#
if ((SIMDJSON_COMPETITION) AND (!SIMDJSON_SANITIZE))
# It looks like RapidJSON does not pass the sanitizer under some conditions (Clang 10)
add_executable(allparserscheckfile allparserscheckfile.cpp)
add_dependencies(competition_tests allparserscheckfile)
add_dependencies(per_implementation_tests allparserscheckfile)
target_link_libraries(allparserscheckfile PRIVATE competition-all)
add_test(issue150 ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/issue150.sh)
set_property(TEST issue150 APPEND PROPERTY LABELS per_implementation competition)
add_dependencies(all_tests allparserscheckfile)
endif()
#
# json2json tool test: check that json2json can parse twitter.json
#
# This tests validates that the implementation is what we think it is if we get passed
# SIMDJSON_FORCE_IMPLEMENTATION, so we know we're testing what we think we're testing
add_cpp_test(checkimplementation LABELS other per_implementation)
add_test(NAME json2json COMMAND $<TARGET_FILE:json2json> ${EXAMPLE_JSON})
set_property(TEST json2json APPEND PROPERTY LABELS acceptance per_implementation)
add_dependencies(acceptance_tests json2json)
add_dependencies(per_implementation_tests json2json)
#
# SIMDJSON_FORCE_IMPLEMENTATION tests: run json2json with SIMDJSON
#
if (SIMDJSON_IMPLEMENTATION MATCHES "fallback")
add_test(
NAME simdjson_force_implementation
COMMAND
${CMAKE_COMMAND} -E env
SIMDJSON_FORCE_IMPLEMENTATION=fallback
$<TARGET_FILE:checkimplementation>
)
endif()
add_test(
NAME simdjson_force_implementation_error
COMMAND
${CMAKE_COMMAND} -E env
SIMDJSON_FORCE_IMPLEMENTATION=doesnotexist
$<TARGET_FILE:json2json> ${EXAMPLE_JSON}
)
set_tests_properties(simdjson_force_implementation_error PROPERTIES WILL_FAIL TRUE)
endif()
#
# Compile-only tests with simdjson flags on
#
# Don't add the tests if we're on VS2017 or older; they don't succeed.
if(NOT (MSVC AND MSVC_VERSION LESS 1920))
if(SIMDJSON_EXCEPTIONS)
add_cpp_test(readme_examples COMPILE_ONLY LABELS acceptance)
add_cpp_test(readme_examples11 COMPILE_ONLY LABELS acceptance SOURCES readme_examples.cpp)
set_target_properties(readme_examples11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
endif()
add_cpp_test(readme_examples_noexceptions COMPILE_ONLY LABELS acceptance)
add_cpp_test(readme_examples_noexceptions11 COMPILE_ONLY LABELS acceptance SOURCES readme_examples_noexceptions.cpp)
set_target_properties(readme_examples_noexceptions11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
# Compile tests that *should fail*
add_cpp_test(readme_examples_will_fail_with_exceptions_off WILL_FAIL COMPILE_ONLY LABELS acceptance SOURCES readme_examples.cpp)
target_compile_definitions(readme_examples_will_fail_with_exceptions_off PRIVATE SIMDJSON_EXCEPTIONS=0)
endif()
if(MSVC)
add_custom_command(TARGET basictests POST_BUILD # Adds a post-build event
COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:simdjson>"
COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE_DIR:basictests>"
if(MSVC AND BUILD_SHARED_LIBS)
# Copy the simdjson dll into the tests directory
add_custom_command(TARGET unicode_tests POST_BUILD # Adds a post-build event
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake -E copy_if_different..."
"$<TARGET_FILE:simdjson>" # <--this is in-file
"$<TARGET_FILE_DIR:basictests>") # <--this is out-file path
"$<TARGET_FILE_DIR:unicode_tests>") # <--this is out-file path
endif()
# Copy the simdjson dll into the tests directory
if(MSVC)
add_custom_command(TARGET basictests POST_BUILD # Adds a post-build event
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake -E copy_if_different..."
"$<TARGET_FILE:simdjson>" # <--this is in-file
"$<TARGET_FILE_DIR:basictests>") # <--this is out-file path
endif()
## Next bit should not be needed!
#if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
# next line is a workaround for an odr-violation in basictests regarding the globals 0x432a40 and 0x52045c under clang
#set_tests_properties(basictests PROPERTIES
# ENVIRONMENT ASAN_OPTIONS="detect_odr_violation=0")
#endif()
## This causes problems
# add_executable(singleheader ./singleheadertest.cpp ${PROJECT_SOURCE_DIR}/singleheader/simdjson.cpp)
# target_link_libraries(singleheader simdjson simdjson-flags)
# add_test(singleheader singleheader)
if(NOT MSVC)
######
# This tests is to guard us against ever again removing the soversion
# number from the library. See Bug
# https://github.com/simdjson/simdjson/issues/1014
#####
get_target_property(REPORTED_SIMDJSON_SOVERSION simdjson SOVERSION)
if(NOT ${REPORTED_SIMDJSON_SOVERSION} STREQUAL ${SIMDJSON_LIB_SOVERSION})
message(FATAL_ERROR "The library target does not have the proper soversion information." )
endif()
get_target_property(REPORTED_SIMDJSON_VERSION simdjson VERSION)
if(NOT ${REPORTED_SIMDJSON_VERSION} STREQUAL ${SIMDJSON_LIB_VERSION})
message(FATAL_ERROR "The library target does not have the proper version information." )
endif()
endif()
# This tests validates that the implementation is what we think it is if we get passed
# SIMDJSON_FORCE_IMPLEMENTATION, so we know we're testing what we think we're testing
add_cpp_test(checkimplementation LABELS other per_implementation)
add_subdirectory(compilation_failure_tests)

155
tests/dom/CMakeLists.txt Normal file
View File

@ -0,0 +1,155 @@
#
# These tests explicitly do #include "simdjson.cpp" so they can override stuff
#
if(NOT SIMDJSON_LEGACY_VISUAL_STUDIO AND NOT SIMDJSON_WINDOWS_DLL)
add_cpp_test(numberparsingcheck LABELS acceptance per_implementation)
simdjson_apply_props(numberparsingcheck)
target_link_libraries(numberparsingcheck PRIVATE simdjson-windows-headers)
target_compile_definitions(numberparsingcheck PRIVATE NOMINMAX)
target_include_directories(
numberparsingcheck
PRIVATE "${PROJECT_SOURCE_DIR}/src"
)
add_cpp_test(stringparsingcheck LABELS acceptance per_implementation)
simdjson_apply_props(numberparsingcheck)
target_link_libraries(stringparsingcheck PRIVATE simdjson-windows-headers)
target_compile_definitions(stringparsingcheck PRIVATE NOMINMAX)
target_include_directories(
stringparsingcheck
PRIVATE "${PROJECT_SOURCE_DIR}/src"
)
endif()
link_libraries(simdjson)
include_directories(..)
if(NOT SIMDJSON_LEGACY_VISUAL_STUDIO AND NOT SIMDJSON_WINDOWS_DLL)
add_cpp_test(random_string_number_tests LABELS dom acceptance per_implementation)
endif()
add_cpp_test(basictests LABELS dom acceptance per_implementation)
add_cpp_test(document_stream_tests LABELS dom acceptance per_implementation)
add_cpp_test(document_tests LABELS dom acceptance per_implementation)
add_cpp_test(errortests LABELS dom acceptance per_implementation)
add_cpp_test(extracting_values_example LABELS dom acceptance per_implementation)
add_cpp_test(integer_tests LABELS dom acceptance per_implementation)
add_cpp_test(jsoncheck LABELS dom acceptance per_implementation)
add_cpp_test(minefieldcheck LABELS dom acceptance per_implementation)
add_cpp_test(parse_many_test LABELS dom acceptance per_implementation)
add_cpp_test(pointercheck LABELS dom acceptance per_implementation) # https://tools.ietf.org/html/rfc6901
add_cpp_test(trivially_copyable_test LABELS dom acceptance per_implementation)
find_program(BASH bash)
# Below we skip anything on Windows, not just visual studio, because running bash under Windows requires you to
# map app paths to their "mounted" equivalent (e.g., /mnt/c/...). So even if you have bash under Windows, extra work would be
# required to make things work robustly. Simply put: bash is not quite portable.
# Script tests
if (BASH AND (NOT WIN32) AND SIMDJSON_BASH AND (TARGET json2json)) # The scripts are not robust enough to run under Windows even if bash is available
#
# json2json test
#
add_test(
NAME testjson2json
COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/testjson2json.sh
WORKING_DIRECTORY $<TARGET_FILE_DIR:minify>
)
set_property(TEST testjson2json APPEND PROPERTY DEPENDS minify json2json)
set_property(TEST testjson2json APPEND PROPERTY LABELS per_implementation)
add_dependencies(per_implementation_tests minify)
#
# Competition parse test
#
if ((SIMDJSON_COMPETITION) AND (!SIMDJSON_SANITIZE))
# It looks like RapidJSON does not pass the sanitizer under some conditions (Clang 10)
add_executable(allparserscheckfile allparserscheckfile.cpp)
add_dependencies(competition_tests allparserscheckfile)
add_dependencies(per_implementation_tests allparserscheckfile)
target_link_libraries(allparserscheckfile PRIVATE competition-all)
add_test(issue150 ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/issue150.sh)
set_property(TEST issue150 APPEND PROPERTY LABELS per_implementation competition)
add_dependencies(all_tests allparserscheckfile)
endif()
#
# json2json tool test: check that json2json can parse twitter.json
#
add_test(NAME json2json COMMAND $<TARGET_FILE:json2json> ${EXAMPLE_JSON})
set_property(TEST json2json APPEND PROPERTY LABELS acceptance per_implementation)
add_dependencies(acceptance_tests json2json)
add_dependencies(per_implementation_tests json2json)
#
# SIMDJSON_FORCE_IMPLEMENTATION tests: run json2json with SIMDJSON
#
if (SIMDJSON_IMPLEMENTATION MATCHES "fallback")
add_test(
NAME simdjson_force_implementation
COMMAND
${CMAKE_COMMAND} -E env
SIMDJSON_FORCE_IMPLEMENTATION=fallback
$<TARGET_FILE:checkimplementation>
)
endif()
add_test(
NAME simdjson_force_implementation_error
COMMAND
${CMAKE_COMMAND} -E env
SIMDJSON_FORCE_IMPLEMENTATION=doesnotexist
$<TARGET_FILE:json2json> ${EXAMPLE_JSON}
)
set_tests_properties(simdjson_force_implementation_error PROPERTIES WILL_FAIL TRUE)
endif()
#
# Compile-only tests with simdjson flags on
#
# Don't add the tests if we're on VS2017 or older; they don't succeed.
if(NOT (MSVC AND MSVC_VERSION LESS 1920))
if(SIMDJSON_EXCEPTIONS)
add_cpp_test(readme_examples COMPILE_ONLY LABELS acceptance)
add_cpp_test(readme_examples11 COMPILE_ONLY LABELS acceptance SOURCES readme_examples.cpp)
set_target_properties(readme_examples11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
endif()
add_cpp_test(readme_examples_noexceptions COMPILE_ONLY LABELS acceptance)
add_cpp_test(readme_examples_noexceptions11 COMPILE_ONLY LABELS acceptance SOURCES readme_examples_noexceptions.cpp)
set_target_properties(readme_examples_noexceptions11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
# Compile tests that *should fail*
add_cpp_test(readme_examples_will_fail_with_exceptions_off WILL_FAIL COMPILE_ONLY LABELS acceptance SOURCES readme_examples.cpp)
target_compile_definitions(readme_examples_will_fail_with_exceptions_off PRIVATE SIMDJSON_EXCEPTIONS=0)
endif()
if(MSVC AND BUILD_SHARED_LIBS)
add_custom_command(TARGET basictests POST_BUILD # Adds a post-build event
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake -E copy_if_different..."
"$<TARGET_FILE:simdjson>" # <--this is in-file
"$<TARGET_FILE_DIR:basictests>") # <--this is out-file path
endif()
if(NOT MSVC)
######
# This tests is to guard us against ever again removing the soversion
# number from the library. See Bug
# https://github.com/simdjson/simdjson/issues/1014
#####
get_target_property(REPORTED_SIMDJSON_SOVERSION simdjson SOVERSION)
if(NOT ${REPORTED_SIMDJSON_SOVERSION} STREQUAL ${SIMDJSON_LIB_SOVERSION})
message(FATAL_ERROR "The library target does not have the proper soversion information." )
endif()
get_target_property(REPORTED_SIMDJSON_VERSION simdjson VERSION)
if(NOT ${REPORTED_SIMDJSON_VERSION} STREQUAL ${SIMDJSON_LIB_VERSION})
message(FATAL_ERROR "The library target does not have the proper version information." )
endif()
endif()

View File

@ -25,9 +25,9 @@ if(HAVE_POSIX_FORK AND HAVE_POSIX_WAIT) # assert tests use fork and wait, which
endif()
# Copy the simdjson dll into the tests directory
if(MSVC)
if(MSVC AND BUILD_SHARED_LIBS)
add_custom_command(TARGET ondemand_parse_api_tests POST_BUILD # Adds a post-build event
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake -E copy_if_different..."
"$<TARGET_FILE:simdjson>" # <--this is in-file
"$<TARGET_FILE_DIR:ondemand_parse_api_tests>") # <--this is out-file path
endif(MSVC)
endif(MSVC AND BUILD_SHARED_LIBS)

View File

@ -8,7 +8,7 @@
# adds a compilation test. Two targets are created, one expected to
# succeed compilation and one that is expected to fail.
function(add_dual_compile_test TEST_NAME)
add_cpp_test(${TEST_NAME}_should_compile SOURCES ${TEST_NAME}.cpp COMPILE_ONLY LABELS onedemand no_mingw)
add_cpp_test(${TEST_NAME}_should_compile SOURCES ${TEST_NAME}.cpp COMPILE_ONLY LABELS ondemand no_mingw)
add_cpp_test(${TEST_NAME}_should_not_compile SOURCES ${TEST_NAME}.cpp COMPILE_ONLY WILL_FAIL LABELS ondemand acceptance no_mingw)
target_compile_definitions(${TEST_NAME}_should_not_compile PRIVATE COMPILATION_TEST_USE_FAILING_CODE=1)
endfunction(add_dual_compile_test)