Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 96f7415

Browse files
castuloJosue David Hernandez Gutierrez
authored and
Josue David Hernandez Gutierrez
committedJan 3, 2023
Initial commit with Library code, testing, examples and documentation
Signed-off-by: Josue David Hernandez Gutierrez <[email protected]> Signed-off-by: Castulo J. Martinez <[email protected]>
0 parents  commit 96f7415

File tree

160 files changed

+35073
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+35073
-0
lines changed
 

‎.github/builder/action.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: 'USB I3C* Library for Linux* OS Builder'
2+
description: 'Builds and test the USB I3C* Library for Linux* OS'
3+
inputs:
4+
path:
5+
description: 'Directory in the GitHub workspace where the source files can be found'
6+
required: true
7+
coverage_threshold:
8+
description: 'The minimum unit test coverage percentage that is acceptable for the project'
9+
required: true
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- run: ${{ github.action_path }}/run_unit_test.sh ${{ inputs.path }} ${{ inputs.coverage_threshold }}
14+
shell: bash

‎.github/builder/run_unit_test.sh

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
SRC_PATH=$1
6+
COVERAGE_THRESHOLD=$2
7+
8+
if [ -z "$SRC_PATH" ]; then
9+
echo "SRC_PATH not defined!"
10+
exit 1
11+
fi
12+
13+
if [ -z "$COVERAGE_THRESHOLD" ]; then
14+
echo "COVERAGE_THRESHOLD not defined!"
15+
exit 1
16+
fi
17+
18+
pushd "$SRC_PATH"
19+
20+
rm -fR build
21+
mkdir build
22+
23+
# Run the tests in Release mode and check code coverage
24+
# and code style (the coverage target runs all unit tests)
25+
cmake -DBUILD_TESTS=ON -DCOVERAGE=ON -DDOCUMENTATION=ON -DBUILD_SAMPLES=ON -DCMAKE_BUILD_TYPE=Debug -B build/
26+
cmake --build build/ -- -j6
27+
cmake --build build/ --target coverage
28+
cmake --build build/ --target check_style
29+
30+
# Make sure unit test coverage doesn't fall below the predefined threshold
31+
function_coverage=$(lcov --summary build/coverage/coverage.info | grep functions | cut -c 16-17)
32+
line_coverage=$(lcov --summary build/coverage/coverage.info | grep lines | cut -c 16-17)
33+
echo "The current function coverage is $(lcov --summary build/coverage/coverage.info | grep functions | cut -c 16-19)%"
34+
if [ "$function_coverage" -lt "$COVERAGE_THRESHOLD" ]; then
35+
echo "The current function coverage falls below the $COVERAGE_THRESHOLD% threshold."
36+
exit 1
37+
fi
38+
echo "The current line coverage is $(lcov --summary build/coverage/coverage.info | grep lines | cut -c 16-19)%"
39+
if [ "$line_coverage" -lt "$COVERAGE_THRESHOLD" ]; then
40+
echo "The current line coverage falls below the $COVERAGE_THRESHOLD% threshold."
41+
exit 1
42+
fi
43+
44+
# Copy the coverage directory so we don't loose it
45+
rm -rf ./coverage
46+
cp -r build/coverage .
47+
48+
# Running the various code sanitizers
49+
# -----------------------------------
50+
clean_and_build() {
51+
rm -fR build
52+
mkdir build
53+
cmake -DBUILD_TESTS=ON -DDOCUMENTATION=OFF -DBUILD_SAMPLES=OFF -DCMAKE_BUILD_TYPE="$1" -B build/
54+
cmake --build build/ -- -j6
55+
}
56+
57+
run_tests() {
58+
cmake --build build/ --target unit_test
59+
}
60+
61+
echo -e "\nRunning the UndefinedBehaviorSanitizer...\n"
62+
clean_and_build ubsan
63+
run_tests
64+
65+
echo -e "\nRunning the LeakSanitizer...\n"
66+
clean_and_build lsan
67+
run_tests
68+
69+
echo -e "\nRunning the AddressSanitizer...\n"
70+
clean_and_build asan
71+
run_tests
72+
73+
echo -e "\nRunning the ThreadSanitizer...\n"
74+
clean_and_build tsan
75+
run_tests
76+
77+
popd

0 commit comments

Comments
 (0)
This repository has been archived.