forked from wolfSSL/wolfssh
-
Notifications
You must be signed in to change notification settings - Fork 1
180 lines (163 loc) · 5.87 KB
/
Copy pathcode-coverage.yml
File metadata and controls
180 lines (163 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Code Coverage
on:
push:
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_wolfssl:
name: Build wolfSSL
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout wolfSSL
uses: actions/checkout@v6
with:
repository: wolfssl/wolfssl
path: wolfssl
# Match the sshd-test workflow so the cert and ML-DSA paths are built
# and measured rather than compiled out.
- name: Build wolfSSL
working-directory: ./wolfssl
run: |
./autogen.sh
./configure --enable-all --enable-mldsa
make -j$(nproc)
sudo make install
sudo ldconfig
- name: tar build-dir
run: tar -zcf wolfssl-install.tgz /usr/local/lib/libwolfssl* /usr/local/include/wolfssl
- name: Upload built lib
uses: actions/upload-artifact@v7
with:
name: wolfssl-coverage
path: wolfssl-install.tgz
retention-days: 5
# Use clang to report line, branch, function and MC/DC coverage in one run.
coverage:
name: Coverage
runs-on: ubuntu-latest
timeout-minutes: 45
needs: build_wolfssl
steps:
- name: Checkout wolfSSH
uses: actions/checkout@v6
# clang 18 is the min: -fcoverage-mcdc does not exist before it.
- name: Install clang and LLVM coverage tools
run: |
sudo apt-get update
sudo apt-get install -y clang-18 llvm-18 libclang-rt-18-dev
- name: Download wolfSSL
uses: actions/download-artifact@v8
with:
name: wolfssl-coverage
- name: Install wolfSSL
run: |
sudo tar -xzf wolfssl-install.tgz -C /
sudo ldconfig
# -O0 keeps line and branch attribution honest; atomic counters are
# required because several tests drive client and server on separate
# threads, and the default non-atomic updates lose increments.
- name: Build wolfSSH
run: |
./autogen.sh
./configure --enable-all --enable-ossh-certs CC=clang-18 \
CPPFLAGS="-DMAX_PATH_SZ=120" \
CFLAGS="-fprofile-instr-generate -fcoverage-mapping -fcoverage-mcdc -fprofile-update=atomic -O0 -g" \
LDFLAGS="-fprofile-instr-generate"
make -j$(nproc)
# %p in the pattern keeps forked servers from overwriting the raw
# profile of the client that spawned them.
- name: Run tests
run: |
mkdir -p prof
LLVM_PROFILE_FILE="$PWD/prof/%p-%m.profraw" \
timeout -k 30 1200 make check
# 'make check' does not execute wolfsshd, so run it separately
- name: Run wolfSSHd tests
working-directory: ./apps/wolfsshd/test
run: |
prof="$GITHUB_WORKSPACE/prof/%p-%m.profraw"
sudo LLVM_PROFILE_FILE="$prof" SSHD_ENV="LLVM_PROFILE_FILE=$prof" \
./run_all_sshd_tests.sh
sudo chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE/prof"
- name: Report coverage
run: |
llvm-profdata-18 merge -sparse prof/*.profraw -o wolfssh.profdata
# llvm-cov takes one binary positionally and the rest via -object.
# Programs linking the shared library are libtool wrapper scripts, so
# take the real binary from .libs when one is there. The apps are
# optional, so skip whatever this configuration did not build.
first=""
args=()
for t in tests/*.test apps/wolfssh/wolfssh apps/wolfsshd/wolfsshd \
apps/wolfsshd/test/test_configuration; do
[ -e "$t" ] || continue
real="$(dirname "$t")/.libs/$(basename "$t")"
[ -x "$real" ] || real="$t"
if [ -z "$first" ]; then
first="$real"
else
args+=(-object "$real")
fi
done
if [ -z "$first" ]; then
echo "no instrumented binaries found"
exit 1
fi
ignore='(tests|examples)/.*|apps/wolfsshd/test/.*'
ignore="$ignore"'|.*/include/wolfssl/.*|.*/wolfssh/.*\.h'
llvm-cov-18 report "$first" "${args[@]}" \
-instr-profile=wolfssh.profdata \
--show-mcdc-summary \
--ignore-filename-regex="$ignore" | tee coverage-report.txt
llvm-cov-18 show "$first" "${args[@]}" \
-instr-profile=wolfssh.profdata \
--show-mcdc --format=html --output-dir=coverage-html \
--ignore-filename-regex="$ignore"
# lcov text for any external dashboard that consumes it.
llvm-cov-18 export "$first" "${args[@]}" \
-instr-profile=wolfssh.profdata \
--format=lcov \
--ignore-filename-regex="$ignore" > coverage.lcov
{
echo '### Coverage'
echo '```'
cat coverage-report.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage report
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: |
coverage-report.txt
coverage.lcov
coverage-html/
retention-days: 30
- name: Show test logs on failure
if: failure()
run: |
echo "=== test-suite.log ==="
cat test-suite.log || true
for f in tests/*.log scripts/*.log; do
[ -f "$f" ] || continue
echo ""
echo "=== $f ==="
cat "$f"
done
- name: Upload failure logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: wolfssh-coverage-logs
path: |
test-suite.log
tests/*.log
scripts/*.log
config.log
retention-days: 5