22# Experimental, for the experiment/snprintf-compare branch only, not for main: what the
33# uninitialized-variable analysis may count as written by snprintf.
44# - libc: which bytes of its destination a failing snprintf writes, with glibc and with musl.
5+ # - compare: the reports of main's analyzer and of the analyzer of
6+ # fix/uninitialized-snprintf-destination (#293), on one runner and on the same inputs. Both
7+ # are built as the CI builds them. The checks of a buffer that snprintf fills run with main's
8+ # analyzer, where they must fail, and with the fix's, where they must pass; the fixtures of
9+ # what must stay reported must pass with both. Then each fixture of the fix's tree is
10+ # analyzed alone by both, and main's sources as the Self-analysis step of ci.yml does. The
11+ # diagnostics that only one of the two reports are listed and kept.
512name : Compare snprintf reports
613
714on :
@@ -15,6 +22,11 @@ concurrency:
1522 group : snprintf-compare
1623 cancel-in-progress : true
1724
25+ env :
26+ MAIN_SHA : 6ae059ba258382c4573c809603cdbb6023958a48
27+ FIX_SHA : 6d3261163f35187db0adc5ec824e6012623c33b6
28+ M : /work/scripts/scripts/bench/snprintf-compare
29+
1830defaults :
1931 run :
2032 shell : bash
@@ -64,3 +76,105 @@ jobs:
6476 name : snprintf-libc
6577 path : out
6678 retention-days : 90
79+
80+ compare :
81+ name : main and the fix on the same inputs
82+ runs-on : ubuntu-24.04
83+ timeout-minutes : 60
84+ steps :
85+ - uses : actions/checkout@v4
86+ with :
87+ # main's commit and the fix's are needed next to the branch's.
88+ fetch-depth : 0
89+
90+ # As ci.yml does on Linux, without ccache: every build here is a cold one.
91+ - name : Install dependencies
92+ run : |
93+ sudo apt-get update
94+ sudo apt-get install -y build-essential cmake python3 \
95+ ninja-build lld libz3-dev pkg-config
96+ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
97+ UBUNTU_CODENAME=$(lsb_release -cs)
98+ sudo apt-add-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-20 main"
99+ sudo apt-get update
100+ sudo apt-get install -y llvm-20 llvm-20-dev clang-20 libclang-20-dev
101+
102+ - name : Lay out the two source trees
103+ run : |
104+ sudo mkdir -p /work
105+ sudo chown "$(id -u):$(id -g)" /work
106+ mkdir -p /work/out
107+ git fetch --no-tags origin "$FIX_SHA"
108+ git worktree add --detach /work/scripts HEAD
109+ git worktree add --detach /work/main "$MAIN_SHA"
110+ git worktree add --detach /work/fix "$FIX_SHA"
111+ # The fix is main and its own commits, nothing else.
112+ test "$(git merge-base "$MAIN_SHA" "$FIX_SHA")" = "$MAIN_SHA"
113+ {
114+ echo "main $MAIN_SHA"
115+ echo "fix $FIX_SHA"
116+ git diff --stat "$MAIN_SHA" "$FIX_SHA"
117+ echo "scripts $(git rev-parse HEAD)"
118+ lscpu | grep -E '^ *(Model name|CPU\(s\)):'
119+ uname -r
120+ c++ --version | head -1
121+ } | tee /work/out/machine.txt
122+
123+ - name : Build main
124+ run : bash "$M/build.sh" main
125+
126+ - name : Build the fix
127+ run : bash "$M/build.sh" fix
128+
129+ - name : The checks with main's analyzer (those of a filled buffer must fail)
130+ timeout-minutes : 10
131+ run : |
132+ python3 -u "$M/red_green.py" /work/main/build/stack_usage_analyzer fail \
133+ 2>&1 | tee /work/out/checks-main.log
134+
135+ - name : The checks with the fix's analyzer (must pass)
136+ if : ${{ !cancelled() }}
137+ timeout-minutes : 10
138+ run : |
139+ python3 -u "$M/red_green.py" /work/fix/build/stack_usage_analyzer pass \
140+ 2>&1 | tee /work/out/checks-fix.log
141+
142+ - name : Compare on every fixture
143+ if : ${{ !cancelled() }}
144+ timeout-minutes : 30
145+ run : |
146+ python3 -u "$M/compare.py" --out /work/out \
147+ --a main=/work/main/build/stack_usage_analyzer \
148+ --b fix=/work/fix/build/stack_usage_analyzer \
149+ fixtures /work/fix | tee /work/out/fixtures.log
150+
151+ - name : Compare on main's sources
152+ if : ${{ !cancelled() }}
153+ timeout-minutes : 15
154+ run : |
155+ python3 -u "$M/compare.py" --out /work/out \
156+ --a main=/work/main/build/stack_usage_analyzer \
157+ --b fix=/work/fix/build/stack_usage_analyzer \
158+ project /work/main | tee /work/out/project.log
159+
160+ - name : Summary
161+ if : always()
162+ run : |
163+ {
164+ echo '### main and the fix on the same inputs'
165+ echo '```'
166+ cat /work/out/machine.txt 2>/dev/null || true
167+ grep -hE '^with |passes$|FAILS$|^as expected' /work/out/checks-main.log /work/out/checks-fix.log 2>/dev/null || true
168+ for mode in fixtures project; do
169+ sed -n "/^${mode}: /,\$p" "/work/out/${mode}.log" 2>/dev/null || true
170+ done
171+ echo '```'
172+ } >> "$GITHUB_STEP_SUMMARY"
173+
174+ - name : Keep the results
175+ if : always()
176+ uses : actions/upload-artifact@v4
177+ with :
178+ name : snprintf-compare
179+ path : /work/out
180+ retention-days : 90
0 commit comments