|
| 1 | +# Copyright (C) 2019 Intel Corporation. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | + |
| 4 | +function(check_ubuntu_version) |
| 5 | +# ubuntu 2204 is the recommended environment for collecting coverage data for now |
| 6 | +# otherwise, there will be ERRORs, when using 2404, like below and |
| 7 | +# |
| 8 | +# geninfo: ERROR: ('mismatch') mismatched end line for _ZN63compilation_aot_emit_memory_test_aot_check_memory_overflow_Test8TestBodyEv at /workspaces/wasm-micro-runtime/tests/unit/compilation/aot_emit_memory_test.cc:96: 96 -> 106 |
| 9 | +# (use "geninfo --ignore-errors mismatch,mismatch ..." to suppress this warning) |
| 10 | +# geninfo: ERROR: ('negative') Unexpected negative count '-3' for /workspaces/wasm-micro-runtime/core/iwasm/interpreter/wasm_interp_classic.c:5473. |
| 11 | +# Perhaps you need to compile with '-fprofile-update=atomic |
| 12 | +# (use "geninfo --ignore-errors negative,negative ..." to suppress this warning) |
| 13 | +# |
| 14 | +# For sure, `--ignore-errors` can be used to ignore these errors, but better to use the recommended environment. |
| 15 | + file(READ "/etc/os-release" OS_RELEASE_CONTENT) |
| 16 | + string(REGEX MATCH "VERSION_ID=\"([0-9]+)\\.([0-9]+)\"" _ ${OS_RELEASE_CONTENT}) |
| 17 | + if(NOT DEFINED CMAKE_MATCH_1 OR NOT DEFINED CMAKE_MATCH_2) |
| 18 | + message(WARNING "Unable to detect Ubuntu version. Please ensure you are using Ubuntu 22.04.") |
| 19 | + return() |
| 20 | + endif() |
| 21 | + |
| 22 | + set(UBUNTU_MAJOR_VERSION ${CMAKE_MATCH_1}) |
| 23 | + set(UBUNTU_MINOR_VERSION ${CMAKE_MATCH_2}) |
| 24 | + |
| 25 | + if(NOT (UBUNTU_MAJOR_VERSION EQUAL 22 AND UBUNTU_MINOR_VERSION EQUAL 04)) |
| 26 | + message(WARNING "Ubuntu ${UBUNTU_MAJOR_VERSION}.${UBUNTU_MINOR_VERSION} detected. Ubuntu 22.04 is recommended for collecting coverage data.") |
| 27 | + else() |
| 28 | + message(STATUS "Ubuntu 22.04 detected. Proceeding with coverage data collection.") |
| 29 | + endif() |
| 30 | +endfunction() |
| 31 | + |
| 32 | +check_ubuntu_version() |
| 33 | + |
| 34 | +# add compile options for code coverage globally |
| 35 | +add_compile_options(--coverage -O0 -g) |
| 36 | +link_libraries(gcov) |
| 37 | +add_definitions (-DCOLLECT_CODE_COVERAGE) |
0 commit comments