@@ -37,13 +37,23 @@ jobs:
3737 WORKER_TOTAL : 4
3838
3939 steps :
40+ - name : Remove unnecessary software to free up disk space
41+ if : matrix.os == 'ubuntu-latest'
42+ run : |
43+ # inspired by https://github.com/easimon/maximize-build-space/blob/master/action.yml
44+ df -h
45+ sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/local/.ghcup
46+ df -h
47+
4048 # Step 1: Check out the repository
4149 - name : Checkout Repository
4250 uses : actions/checkout@v4
4351 with :
4452 path : head
4553 submodules : true
46-
54+ - name : Apply stdarch patch
55+ run : cd head/library/stdarch && patch -p1 < ../../stdarch.patch
56+
4757 # Step 2: Install jq
4858 - name : Install jq
4959 if : matrix.os == 'ubuntu-latest'
@@ -53,6 +63,221 @@ jobs:
5363 - name : Run Kani Verification
5464 run : head/scripts/run-kani.sh --path ${{github.workspace}}/head
5565
66+ kani_autoharness :
67+ name : Verify std library using autoharness
68+ runs-on : ${{ matrix.os }}
69+ strategy :
70+ matrix :
71+ os : [ubuntu-latest, macos-latest]
72+ include :
73+ - os : ubuntu-latest
74+ base : ubuntu
75+ - os : macos-latest
76+ base : macos
77+ fail-fast : false
78+
79+ steps :
80+ - name : Remove unnecessary software to free up disk space
81+ if : matrix.os == 'ubuntu-latest'
82+ run : |
83+ # inspired by https://github.com/easimon/maximize-build-space/blob/master/action.yml
84+ df -h
85+ sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/local/.ghcup
86+ df -h
87+
88+ # Step 1: Check out the repository
89+ - name : Checkout Repository
90+ uses : actions/checkout@v4
91+ with :
92+ submodules : true
93+ - name : Apply stdarch patch
94+ run : cd library/stdarch && patch -p1 < ../../stdarch.patch
95+
96+ # Step 2: Run Kani autoharness on the std library for selected functions.
97+ # Uses "--include-pattern" to make sure we do not try to run across all
98+ # possible functions as that may take a lot longer than expected. Instead,
99+ # explicitly list all functions (or prefixes thereof) the proofs of which
100+ # are known to pass.
101+ # Notes:
102+ # - We use >::disjoint_bitor (and >::unchecked_disjoint_bitor) as pattern
103+ # as whitespace is not supported, cf.
104+ # https://github.com/model-checking/kani/issues/4046
105+ # - core_arch::x86::__m128d::as_f64x2 is just one example of hundreds of
106+ # core_arch::x86:: functions that are known to verify successfully.
107+ - name : Run Kani Verification
108+ run : |
109+ scripts/run-kani.sh --run autoharness --kani-args \
110+ --include-pattern ">::disjoint_bitor" \
111+ --include-pattern ">::unchecked_disjoint_bitor" \
112+ --include-pattern alloc::__default_lib_allocator:: \
113+ --include-pattern alloc::layout::Layout::from_size_align \
114+ --include-pattern ascii::ascii_char::AsciiChar::from_u8 \
115+ --include-pattern char::convert::from_u32_unchecked \
116+ --include-pattern core_arch::x86::__m128d::as_f64x2 \
117+ --include-pattern "num::nonzero::NonZero::<i8>::count_ones" \
118+ --include-pattern "num::nonzero::NonZero::<i16>::count_ones" \
119+ --include-pattern "num::nonzero::NonZero::<i32>::count_ones" \
120+ --include-pattern "num::nonzero::NonZero::<i64>::count_ones" \
121+ --include-pattern "num::nonzero::NonZero::<i128>::count_ones" \
122+ --include-pattern "num::nonzero::NonZero::<isize>::count_ones" \
123+ --include-pattern "num::nonzero::NonZero::<u8>::count_ones" \
124+ --include-pattern "num::nonzero::NonZero::<u16>::count_ones" \
125+ --include-pattern "num::nonzero::NonZero::<u32>::count_ones" \
126+ --include-pattern "num::nonzero::NonZero::<u64>::count_ones" \
127+ --include-pattern "num::nonzero::NonZero::<u128>::count_ones" \
128+ --include-pattern "num::nonzero::NonZero::<usize>::count_ones" \
129+ --include-pattern "num::nonzero::NonZero::<i8>::rotate_" \
130+ --include-pattern "num::nonzero::NonZero::<i16>::rotate_" \
131+ --include-pattern "num::nonzero::NonZero::<i32>::rotate_" \
132+ --include-pattern "num::nonzero::NonZero::<i64>::rotate_" \
133+ --include-pattern "num::nonzero::NonZero::<i128>::rotate_" \
134+ --include-pattern "num::nonzero::NonZero::<isize>::rotate_" \
135+ --include-pattern "num::nonzero::NonZero::<u8>::rotate_" \
136+ --include-pattern "num::nonzero::NonZero::<u16>::rotate_" \
137+ --include-pattern "num::nonzero::NonZero::<u32>::rotate_" \
138+ --include-pattern "num::nonzero::NonZero::<u64>::rotate_" \
139+ --include-pattern "num::nonzero::NonZero::<u128>::rotate_" \
140+ --include-pattern "num::nonzero::NonZero::<usize>::rotate_" \
141+ --include-pattern ptr::align_offset::mod_inv \
142+ --include-pattern ptr::alignment::Alignment::as_nonzero \
143+ --include-pattern ptr::alignment::Alignment::as_usize \
144+ --include-pattern ptr::alignment::Alignment::log2 \
145+ --include-pattern ptr::alignment::Alignment::mask \
146+ --include-pattern ptr::alignment::Alignment::new \
147+ --include-pattern ptr::alignment::Alignment::new_unchecked \
148+ --include-pattern time::Duration::from_micros \
149+ --include-pattern time::Duration::from_millis \
150+ --include-pattern time::Duration::from_nanos \
151+ --include-pattern time::Duration::from_secs \
152+ --exclude-pattern time::Duration::from_secs_f \
153+ --include-pattern unicode::unicode_data::conversions::to_ \
154+ --exclude-pattern ::precondition_check \
155+ --harness-timeout 10m \
156+ --default-unwind 1000 \
157+ --jobs=3 --output-format=terse | tee autoharness-verification.log
158+ gzip autoharness-verification.log
159+
160+ - name : Upload Autoharness Verification Log
161+ uses : actions/upload-artifact@v4
162+ with :
163+ name : ${{ matrix.os }}-autoharness-verification.log.gz
164+ path : autoharness-verification.log.gz
165+ if-no-files-found : error
166+ # Aggressively short retention: we don't really need these
167+ retention-days : 3
168+
169+ run_kani_metrics :
170+ name : Kani Metrics
171+ runs-on : ${{ matrix.os }}
172+ strategy :
173+ matrix :
174+ os : [ubuntu-latest, macos-latest]
175+ include :
176+ - os : ubuntu-latest
177+ base : ubuntu
178+ - os : macos-latest
179+ base : macos
180+ fail-fast : true
181+
182+ steps :
183+ - name : Remove unnecessary software to free up disk space
184+ if : matrix.os == 'ubuntu-latest'
185+ run : |
186+ # inspired by https://github.com/easimon/maximize-build-space/blob/master/action.yml
187+ df -h
188+ sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/local/.ghcup
189+ df -h
190+
191+ # Step 1: Check out the repository
192+ - name : Checkout Repository
193+ uses : actions/checkout@v4
194+ with :
195+ submodules : true
196+
197+ # The Kani metrics collection uses a Python script (kani_std_analysis.py), so make sure Python is installed
198+ - name : Set up Python
199+ uses : actions/setup-python@v4
200+ with :
201+ python-version : ' 3.x'
202+
203+ # Step 2: Run list on the std library
204+ - name : Run Kani Metrics
205+ run : |
206+ scripts/run-kani.sh --run metrics --with-autoharness
207+ pushd /tmp/std_lib_analysis
208+ tar czf results.tar.gz results
209+ popd
210+
211+ - name : Upload kani-list.json
212+ uses : actions/upload-artifact@v4
213+ with :
214+ name : ${{ matrix.os }}-kani-list.json
215+ path : kani-list.json
216+ if-no-files-found : error
217+ # Aggressively short retention: we don't really need these
218+ retention-days : 3
219+
220+ - name : Upload scanner results
221+ uses : actions/upload-artifact@v4
222+ with :
223+ name : ${{ matrix.os }}-results.tar.gz
224+ path : /tmp/std_lib_analysis/results.tar.gz
225+ if-no-files-found : error
226+ # Aggressively short retention: we don't really need these
227+ retention-days : 3
228+
229+ run-log-analysis :
230+ name : Build JSON from logs
231+ needs : [run_kani_metrics, kani_autoharness]
232+ runs-on : ${{ matrix.os }}
233+ strategy :
234+ matrix :
235+ os : [ubuntu-latest, macos-latest]
236+ include :
237+ - os : ubuntu-latest
238+ base : ubuntu
239+ - os : macos-latest
240+ base : macos
241+ fail-fast : false
242+
243+ steps :
244+ - name : Checkout Repository
245+ uses : actions/checkout@v4
246+ with :
247+ submodules : false
248+
249+ - name : Download log
250+ uses : actions/download-artifact@v4
251+ with :
252+ name : ${{ matrix.os }}-autoharness-verification.log.gz
253+
254+ - name : Download kani-list.json
255+ uses : actions/download-artifact@v4
256+ with :
257+ name : ${{ matrix.os }}-kani-list.json
258+
259+ - name : Download scanner results
260+ uses : actions/download-artifact@v4
261+ with :
262+ name : ${{ matrix.os }}-results.tar.gz
263+
264+ - name : Run log parser
265+ run : |
266+ gunzip autoharness-verification.log.gz
267+ tar xzf results.tar.gz
268+ python3 scripts/kani-std-analysis/log_parser.py \
269+ --kani-list-file kani-list.json \
270+ --analysis-results-dir results/ \
271+ autoharness-verification.log \
272+ -o results.json
273+
274+ - name : Upload JSON
275+ uses : actions/upload-artifact@v4
276+ with :
277+ name : ${{ matrix.os }}-results.json
278+ path : results.json
279+ if-no-files-found : error
280+
56281 run-kani-list :
57282 name : Kani List
58283 runs-on : ubuntu-latest
@@ -63,11 +288,19 @@ jobs:
63288 with :
64289 path : head
65290 submodules : true
291+ - name : Apply stdarch patch
292+ run : cd head/library/stdarch && patch -p1 < ../../stdarch.patch
66293
67294 # Step 2: Run list on the std library
68295 - name : Run Kani List
69- run : head/scripts/run-kani.sh --run list --path ${{github.workspace}}/head
70-
296+ run : |
297+ head/scripts/run-kani.sh --run list --with-autoharness --path ${{github.workspace}}/head
298+ # remove duplicate white space to reduce file size (GitHub permits at
299+ # most one 1MB)
300+ ls -l ${{github.workspace}}/head/kani-list.md
301+ perl -p -i -e 's/ +/ /g' ${{github.workspace}}/head/kani-list.md
302+ ls -l ${{github.workspace}}/head/kani-list.md
303+
71304 # Step 3: Add output to job summary
72305 - name : Add Kani List output to job summary
73306 uses : actions/github-script@v6
@@ -79,3 +312,34 @@ jobs:
79312 .addHeading('Kani List Output', 2)
80313 .addRaw(kaniOutput, false)
81314 .write();
315+
316+ run-autoharness-analyzer :
317+ name : Kani Autoharness Analyzer
318+ runs-on : ubuntu-latest
319+ steps :
320+ # Step 1: Check out the repository
321+ - name : Checkout Repository
322+ uses : actions/checkout@v4
323+ with :
324+ submodules : true
325+ - name : Apply stdarch patch
326+ run : cd library/stdarch && patch -p1 < ../../stdarch.patch
327+
328+ # Step 2: Run autoharness analyzer on the std library
329+ - name : Run Autoharness Analyzer
330+ run : scripts/run-kani.sh --run autoharness-analyzer
331+
332+ # Step 3: Add output to job summary
333+ - name : Add Autoharness Analyzer output to job summary
334+ run : |
335+ pushd scripts/autoharness_analyzer
336+ echo "# Autoharness Failure Summary" >> "$GITHUB_STEP_SUMMARY"
337+ echo "## Crate core, all functions" >> "$GITHUB_STEP_SUMMARY"
338+ cat core_autoharness_data.md >> "$GITHUB_STEP_SUMMARY"
339+ echo "## Crate core, unsafe functions" >> "$GITHUB_STEP_SUMMARY"
340+ cat core_autoharness_data.md >> "$GITHUB_STEP_SUMMARY"
341+ echo "## Crate std, all functions" >> "$GITHUB_STEP_SUMMARY"
342+ cat std_autoharness_data.md >> "$GITHUB_STEP_SUMMARY"
343+ echo "## Crate std, unsafe functions" >> "$GITHUB_STEP_SUMMARY"
344+ cat std_unsafe_autoharness_data.md >> "$GITHUB_STEP_SUMMARY"
345+ popd
0 commit comments