Skip to content

Commit

Permalink
i#5365: Build AArch64 unit tests with SVE enabled
Browse files Browse the repository at this point in the history
Add BUILD_TESTS_SVE build option to compile with SVE flags and high
optimisation (-O3).

Add some error checking to allow the -O3 build and consequently
update a template (expected output) file.

Issue: #5365
  • Loading branch information
philramsey-arm committed Oct 16, 2023
1 parent 0c6476f commit 4b822fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,10 @@ if (BUILD_TESTS)
include(CTest)
endif (BUILD_TESTS)

if (AARCH64)
option(BUILD_TESTS_SVE "Build tests with SVE enabled and high optimization (-O3)" OFF)
endif (AARCH64)

if (BUILD_CORE)
add_subdirectory(core)
endif (BUILD_CORE)
Expand Down
18 changes: 18 additions & 0 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,24 @@ function(add_exe test source)
"${CMAKE_GENERATOR}" MATCHES "Visual Studio")
add_dependencies(${test} ${gen_asm_tgt})
endif ()
if (BUILD_TESTS_SVE)
target_compile_options(${test} PRIVATE
"-march=armv8.4-a+crypto+rcpc+sha3+sm4+sve+rng+ssbs+nodotprod")

# Some tests give very obscure build errors when built with "-O3"
# FIXME i#5365: fix build issues due to optimisation, unless no
# optimisation is a requirement for a test case.
if (
NOT ${test} STREQUAL "api.rseq" AND
NOT ${test} STREQUAL "linux.rseq" AND
NOT ${test} STREQUAL "linux.rseq_table" AND
NOT ${test} STREQUAL "linux.rseq_noarray" AND
NOT ${test} STREQUAL "linux.clone" AND
NOT ${test} STREQUAL "linux.clone-pie"
)
target_compile_options(${test} PRIVATE "-O3")
endif()
endif(BUILD_TESTS_SVE)
endfunction(add_exe)

# normal app
Expand Down
4 changes: 3 additions & 1 deletion suite/tests/client-interface/drx-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ main(int argc, char **argv)
/* child */
int iter = 0;
close(pipefd[0]); /* close unused read end */
write(pipefd[1], &buf, sizeof(buf));
if (write(pipefd[1], &buf, sizeof(buf)) == -1) {
perror("write to pipe failed\n");
}
close(pipefd[1]);
/* spin until parent kills us or we time out */
while (iter++ < 12) {
Expand Down
3 changes: 2 additions & 1 deletion suite/tests/linux/eintr.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ main(int argc, char **argv)
child_ready = false;
pthread_mutex_unlock(&lock);

write(pipefd[1], "ab", 2);
if (write(pipefd[1], "ab", 2) == -1)
perror("Failed to write to pipe\n");

if (pthread_join(thread, &retval) != 0)
perror("failed to join thread");
Expand Down
11 changes: 6 additions & 5 deletions suite/tests/linux/tool.drcov.eintr.template
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ DA:126,1
DA:127,1
DA:128,1
DA:130,1
DA:132,1
DA:133,0
DA:135,1
DA:131,0
DA:133,1
DA:134,0
DA:136,1
DA:138,1
DA:137,1
DA:139,1
DA:141,1
DA:140,1
DA:142,1
DA:143,1
end_of_record

0 comments on commit 4b822fb

Please sign in to comment.