Skip to content

Commit

Permalink
test job (#153)
Browse files Browse the repository at this point in the history
* create linux runner

* better order

* Update and rename libmem-linux.yml to libmem-linux-x86.yml

* Create test.sh

* Update libmem-linux-x86.yml

* Update libmem-linux-x86.yml

* archive artifacts after test coverage report

* build tests

* Update test.sh

* Update test.sh

* Update test.sh

* Update test.sh

* Update libmem-linux-x86.yml

* Update and rename libmem-linux-x86.yml to libmem-linux-x86-tester.yml

* Rename test.sh to unit_test.sh

* Update unit_test.sh

* Update libmem-linux-x86-tester.yml

* Update libmem-linux-x86-tester.yml

* Update unit_test.sh

* Update unit_test.sh

* arrange for tests

* Update CMakeLists.txt

* removed option that breaks MSVC builds

* Update CMakeLists.txt

* Update libmem-linux-x86-tester.yml

* Update libmem-linux-x86-tester.yml

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update unit_test.sh

* Update unit_test.sh

* Update unit_test.sh

* Update and rename libmem-linux-x86-tester.yml to test-linux.yml

* Update unit_test.sh

* Update unit_test.sh

* Update unit_test.sh

* Update unit_test.sh

* run target executable

---------

Co-authored-by: Rdbo <[email protected]>
  • Loading branch information
illegal-instruction-co and rdbo authored Dec 8, 2023
1 parent 2415894 commit 902197a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Libmem Linux x86
name: Test / Linux / x86

on: [push, pull_request]

Expand All @@ -7,28 +7,29 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
- name: Checkout Repository Job
uses: actions/checkout@v2

- name: Install Dependencies
- name: Install Dependencies Job
run: |
sudo apt-get update
sudo apt-get install -y gcovr
sudo chmod +x tools/unit_test.sh
git submodule update --init --recursive
- name: Configure and Build
- name: Configure and Build Job
run: |
cmake -S . -B build
cmake -S . -B build -DLIBMEM_BUILD_TESTS=ON
cmake --build build
- name: Archive Artifacts
- name: Run Unit Tests Job
run: |
sudo tools/unit_test.sh
- name: Archive Artifacts Job
uses: actions/upload-artifact@v2
with:
name: libmem-artifacts
path: |
build/
- name: Run Tests
run: |
cd build
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
-Wpedantic
-g
-ggdb
-O0
-fprofile-arcs
-ftest-coverage
)
endif()
endif()
Expand All @@ -122,6 +125,11 @@ include_directories(${PROJECT_SOURCE_DIR}
${INJECTOR_INC}
)

if (LIBMEM_BUILD_TESTS)
set(TESTS_DIR "${PROJECT_SOURCE_DIR}/tests")
add_subdirectory(${TESTS_DIR})
endif()

set_target_properties(libmem PROPERTIES POSITION_INDEPENDENT_CODE True INCLUDES ${LIBMEM_INC})
target_compile_definitions(libmem PUBLIC LM_EXPORT)
add_dependencies(libmem
Expand All @@ -130,11 +138,6 @@ add_dependencies(libmem
lief-project
)

if (LIBMEM_BUILD_TESTS)
set(TESTS_DIR "${PROJECT_SOURCE_DIR}/tests")
add_subdirectory(${TESTS_DIR})
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL Windows OR ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN)
set(LIBMEM_DEPS
${LIBMEM_DEPS}
Expand Down
31 changes: 31 additions & 0 deletions tools/unit_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

error=0
tests=$(find build/tests -type f -executable -name "unit*")

for test in $tests; do
target=$(find build/tests -type f -executable -name "target*")
echo "Running $target"
./$target &

echo "Running $test"
$test
if [ $? -ne 0 ]; then
error=$((error + $?))
fi

pkill -f "$target"
done

mkdir -p build/coverage

gcda_files=$(find src -name "*.gcda")

for gcda_file in $gcda_files; do
echo "Processing gcov for $gcda_file"
gcov "$gcda_file"
done

gcovr -r . --html --html-details -o build/coverage/index.html

exit $error

0 comments on commit 902197a

Please sign in to comment.