From 29a8fd0a4a61c72d04f299578ca6f4ae068be38c Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Mon, 25 Jan 2021 14:31:04 +0200 Subject: [PATCH] Tests: Add gcc-target-tests for 32 and 64 bit --- .github/workflows/ccpp.yml | 13 ++++++++ .gitmodules | 4 +++ External/fex-gcc-target-tests-bins | 1 + Scripts/guest_test_runner.py | 8 +++-- unittests/CMakeLists.txt | 2 ++ unittests/gcc-target-tests-32/CMakeLists.txt | 33 +++++++++++++++++++ unittests/gcc-target-tests-32/Disabled_Tests | 0 unittests/gcc-target-tests-32/Expected_Output | 1 + unittests/gcc-target-tests-32/Known_Failures | 9 +++++ unittests/gcc-target-tests-64/CMakeLists.txt | 33 +++++++++++++++++++ unittests/gcc-target-tests-64/Disabled_Tests | 0 unittests/gcc-target-tests-64/Expected_Output | 1 + unittests/gcc-target-tests-64/Known_Failures | 9 +++++ 13 files changed, 112 insertions(+), 2 deletions(-) create mode 160000 External/fex-gcc-target-tests-bins create mode 100644 unittests/gcc-target-tests-32/CMakeLists.txt create mode 100644 unittests/gcc-target-tests-32/Disabled_Tests create mode 100644 unittests/gcc-target-tests-32/Expected_Output create mode 100644 unittests/gcc-target-tests-32/Known_Failures create mode 100644 unittests/gcc-target-tests-64/CMakeLists.txt create mode 100644 unittests/gcc-target-tests-64/Disabled_Tests create mode 100644 unittests/gcc-target-tests-64/Expected_Output create mode 100644 unittests/gcc-target-tests-64/Known_Failures diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 3ce42b11c..9b054b45c 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -76,3 +76,16 @@ jobs: shell: bash # Execute the gvisor tests run: cmake --build . --config $BUILD_TYPE --target gvisor_tests + + - name: gcc target tests 32 + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the gvisor tests + run: cmake --build . --config $BUILD_TYPE --target gcc_target_tests_32 + + - name: gcc target tests 64 + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the gvisor tests + run: cmake --build . --config $BUILD_TYPE --target gcc_target_tests_64 + diff --git a/.gitmodules b/.gitmodules index dee929ca1..10335b78c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,7 @@ shallow = true path = External/fex-gvisor-tests-bins url = https://github.com/FEX-Emu/fex-gvisor-tests-bins.git +[submodule "External/fex-gcc-target-tests-bins"] + shallow = true + path = External/fex-gcc-target-tests-bins + url = https://github.com/FEX-Emu/fex-gcc-target-tests-bins.git diff --git a/External/fex-gcc-target-tests-bins b/External/fex-gcc-target-tests-bins new file mode 160000 index 000000000..9f83d474b --- /dev/null +++ b/External/fex-gcc-target-tests-bins @@ -0,0 +1 @@ +Subproject commit 9f83d474bb992a917ceeb5f5e727eeb7e28a42c6 diff --git a/Scripts/guest_test_runner.py b/Scripts/guest_test_runner.py index f5e60e9fb..bcf366bab 100644 --- a/Scripts/guest_test_runner.py +++ b/Scripts/guest_test_runner.py @@ -58,8 +58,12 @@ else: Process.wait() ResultCode = Process.returncode -if (not test_name in expected_output or expected_output[test_name] != ResultCode): - if expected_output.get(test_name): +# expect zero by default +if (not test_name in expected_output): + expected_output[test_name] = 0 + +if (expected_output[test_name] != ResultCode): + if (test_name in expected_output): print("test failed, expected is", expected_output[test_name], "but got", ResultCode) else: print("Test doesn't have expected output,", test_name) diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index b557c9bfe..969ba2d2b 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -3,3 +3,5 @@ add_subdirectory(32Bit_ASM/) add_subdirectory(IR/) add_subdirectory(POSIX/) add_subdirectory(gvisor-tests/) +add_subdirectory(gcc-target-tests-32/) +add_subdirectory(gcc-target-tests-64/) diff --git a/unittests/gcc-target-tests-32/CMakeLists.txt b/unittests/gcc-target-tests-32/CMakeLists.txt new file mode 100644 index 000000000..0839f070e --- /dev/null +++ b/unittests/gcc-target-tests-32/CMakeLists.txt @@ -0,0 +1,33 @@ + +# Careful. Globbing can't see changes to the contents of files +# Need to do a fresh clean to see changes +file(GLOB_RECURSE TESTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/External/fex-gcc-target-tests-bins/32/*) + +foreach(TEST ${TESTS}) + + string(REPLACE "/fex-gcc-target-tests-bins/32/" ";" TEST_NAME_LIST ${TEST}) + list(GET TEST_NAME_LIST 1 TEST_NAME) + string(REPLACE "/" "-" TEST_NAME ${TEST_NAME}) + + # Interpreter is too slow to run these tests, only generate for jit + + add_test(NAME "${TEST_NAME}.jit.gcc-target-32" + COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/guest_test_runner.py" + "${CMAKE_SOURCE_DIR}/unittests/gcc-target-tests-32/Known_Failures" + "${CMAKE_SOURCE_DIR}/unittests/gcc-target-tests-32/Expected_Output" + "${CMAKE_SOURCE_DIR}/unittests/gcc-target-tests-32/Disabled_Tests" + "${TEST_NAME}" + "${CMAKE_BINARY_DIR}/Bin/FEXLoader" + "-c" "irjit" "-n" "500" "-R" $ENV{ROOTFS} "--" + "${TEST}") + +endforeach() + +execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) +string(STRIP ${CORES} CORES) + +add_custom_target( + gcc_target_tests_32 + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + USES_TERMINAL + COMMAND "ctest" "--timeout" "20" "-j${CORES}" "-R" "\.*.gcc-target-32$$") diff --git a/unittests/gcc-target-tests-32/Disabled_Tests b/unittests/gcc-target-tests-32/Disabled_Tests new file mode 100644 index 000000000..e69de29bb diff --git a/unittests/gcc-target-tests-32/Expected_Output b/unittests/gcc-target-tests-32/Expected_Output new file mode 100644 index 000000000..ce6e06faa --- /dev/null +++ b/unittests/gcc-target-tests-32/Expected_Output @@ -0,0 +1 @@ +# default to zero \ No newline at end of file diff --git a/unittests/gcc-target-tests-32/Known_Failures b/unittests/gcc-target-tests-32/Known_Failures new file mode 100644 index 000000000..8668627e4 --- /dev/null +++ b/unittests/gcc-target-tests-32/Known_Failures @@ -0,0 +1,9 @@ +pr72867.c.gcc-target-test-32 +pr88240.c.gcc-target-test-32 +sse2-mmx-cvtps2pi.c.gcc-target-test-32 +sse2-mmx-cvttps2pi.c.gcc-target-test-32 +sse2-mmx-pextrw.c.gcc-target-test-32 +sse2-mmx-psraw.c.gcc-target-test-32 +sse2-mmx-psrawi.c.gcc-target-test-32 +sse2-psraw-1.c.gcc-target-test-32 +sse2-shiftqihi-constant-2.c.gcc-target-test-32 \ No newline at end of file diff --git a/unittests/gcc-target-tests-64/CMakeLists.txt b/unittests/gcc-target-tests-64/CMakeLists.txt new file mode 100644 index 000000000..a6a521a06 --- /dev/null +++ b/unittests/gcc-target-tests-64/CMakeLists.txt @@ -0,0 +1,33 @@ + +# Careful. Globbing can't see changes to the contents of files +# Need to do a fresh clean to see changes +file(GLOB_RECURSE TESTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/External/fex-gcc-target-tests-bins/64/*) + +foreach(TEST ${TESTS}) + + string(REPLACE "/fex-gcc-target-tests-bins/64/" ";" TEST_NAME_LIST ${TEST}) + list(GET TEST_NAME_LIST 1 TEST_NAME) + string(REPLACE "/" "-" TEST_NAME ${TEST_NAME}) + + # Interpreter is too slow to run these tests, only generate for jit + + add_test(NAME "${TEST_NAME}.jit.gcc-target-64" + COMMAND "python3" "${CMAKE_SOURCE_DIR}/Scripts/guest_test_runner.py" + "${CMAKE_SOURCE_DIR}/unittests/gcc-target-tests-64/Known_Failures" + "${CMAKE_SOURCE_DIR}/unittests/gcc-target-tests-64/Expected_Output" + "${CMAKE_SOURCE_DIR}/unittests/gcc-target-tests-64/Disabled_Tests" + "${TEST_NAME}" + "${CMAKE_BINARY_DIR}/Bin/FEXLoader" + "-c" "irjit" "-n" "500" "-R" $ENV{ROOTFS} "--" + "${TEST}") + +endforeach() + +execute_process(COMMAND "nproc" OUTPUT_VARIABLE CORES) +string(STRIP ${CORES} CORES) + +add_custom_target( + gcc_target_tests_64 + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + USES_TERMINAL + COMMAND "ctest" "--timeout" "20" "-j${CORES}" "-R" "\.*.gcc-target-64$$") diff --git a/unittests/gcc-target-tests-64/Disabled_Tests b/unittests/gcc-target-tests-64/Disabled_Tests new file mode 100644 index 000000000..e69de29bb diff --git a/unittests/gcc-target-tests-64/Expected_Output b/unittests/gcc-target-tests-64/Expected_Output new file mode 100644 index 000000000..ce6e06faa --- /dev/null +++ b/unittests/gcc-target-tests-64/Expected_Output @@ -0,0 +1 @@ +# default to zero \ No newline at end of file diff --git a/unittests/gcc-target-tests-64/Known_Failures b/unittests/gcc-target-tests-64/Known_Failures new file mode 100644 index 000000000..a3368bdee --- /dev/null +++ b/unittests/gcc-target-tests-64/Known_Failures @@ -0,0 +1,9 @@ +asm-5.c.gcc-target-test-64 +pr88240.c.gcc-target-test-64 +sse2-mmx-cvtps2pi.c.gcc-target-test-64 +sse2-mmx-cvttps2pi.c.gcc-target-test-64 +sse2-mmx-pextrw.c.gcc-target-test-64 +sse2-mmx-psraw.c.gcc-target-test-64 +sse2-mmx-psrawi.c.gcc-target-test-64 +sse2-psraw-1.c.gcc-target-test-64 +sse2-shiftqihi-constant-2.c.gcc-target-test-64 \ No newline at end of file