|
| 1 | +# @copyright Copyright (c) contributors to Project Ocre, |
| 2 | +# which has been established as Project Ocre a Series of LF Projects, LLC |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | + |
| 6 | +cmake_minimum_required(VERSION 3.20.0) |
| 7 | + |
| 8 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 9 | + |
| 10 | +# set(CMAKE_C_COMPILER /usr/bin/clang) |
| 11 | + |
| 12 | +list(APPEND OCRE_SDK_PRELOADED_IMAGES |
| 13 | + "return0.wasm" |
| 14 | + "return1.wasm" |
| 15 | + "sleep_5_return_0.wasm" |
| 16 | +) |
| 17 | + |
| 18 | +if (SANITIZER) |
| 19 | + string(APPEND CMAKE_C_FLAGS |
| 20 | + "-fsanitize=address" |
| 21 | +) |
| 22 | +endif() |
| 23 | + |
| 24 | +project(OcreSystemTestPosixIPC) |
| 25 | + |
| 26 | +add_subdirectory(../../.. ocre) |
| 27 | + |
| 28 | +add_library(Unity STATIC |
| 29 | + ../../Unity/src/unity.c |
| 30 | +) |
| 31 | + |
| 32 | +target_include_directories(Unity PUBLIC |
| 33 | + ../../Unity/src |
| 34 | +) |
| 35 | + |
| 36 | +list(APPEND OCRE_TESTS |
| 37 | + context |
| 38 | + container |
| 39 | +) |
| 40 | + |
| 41 | +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/ocre/var/lib/ocre/images) |
| 42 | +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/ocre/var/lib/ocre/containers) |
| 43 | + |
| 44 | +foreach(test ${OCRE_TESTS}) |
| 45 | + add_executable(test_${test} |
| 46 | + ../${test}.c |
| 47 | + setup.c |
| 48 | + ) |
| 49 | + |
| 50 | + set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/../${test}.c PROPERTIES COMPILE_FLAGS |
| 51 | + "-DOCRE_TEST_OTHER_CONTEXT_PATH=\\\"./othercontext\\\" -DtearDown=test_tearDown -DsetUp=test_setUp" |
| 52 | + ) |
| 53 | + |
| 54 | + target_link_libraries(test_${test} |
| 55 | + OcreCommon |
| 56 | + OcreClient |
| 57 | + Unity |
| 58 | + ) |
| 59 | + |
| 60 | + add_custom_command( |
| 61 | + OUTPUT test_${test}.log |
| 62 | + COMMAND cd ocre && LLVM_PROFILE_FILE=../test_${test}.profraw ../test_${test} > ../test_${test}.log |
| 63 | + COMMAND rm -f test_${test}.testpass test_${test}.testfail |
| 64 | + COMMAND sh -c "[ \"$(tail -1 test_${test}.log)\" = \"OK\" ] && cp test_${test}.log test_${test}.testpass || cp test_${test}.log test_${test}.testfail" |
| 65 | + DEPENDS |
| 66 | + test_${test} |
| 67 | + VERBATIM |
| 68 | + ) |
| 69 | +endforeach() |
| 70 | + |
| 71 | +add_custom_target(run-systests |
| 72 | + COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/../../Unity/auto/unity_test_summary.py ${CMAKE_CURRENT_BINARY_DIR} |
| 73 | + DEPENDS |
| 74 | + test_context.log |
| 75 | + test_container.log |
| 76 | +) |
0 commit comments