Skip to content

Commit 4984ddd

Browse files
authored
Use eqy and sby to perform formal verification (#2529)
This PR changes the way Formal Verification is performed. Up to now, some of the tests were failing because we failed to prove equivalence (but it doesn't mean that we proved that they aren't equivalent). FV is now performed using `eqy` and `sby` tools, which lowers false-negative (and positive) tests.
2 parents 7f99048 + 66b3c26 commit 4984ddd

25 files changed

+2761
-2379
lines changed

.ci.yml

Lines changed: 46 additions & 250 deletions
Large diffs are not rendered by default.

.github/scripts/run_group_test.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ test_cases=( $(cd ${REPO_DIR}/tests && echo simple_tests/!(${filter_pat})) )
4141
global_status=0
4242
mkdir -p "$(dirname "$RESULTS_FILE")"
4343

44+
declare -a failed_tests_list
45+
4446
# Test
4547

4648
cd $REPO_DIR
4749
for test_case in "${test_cases[@]}"; do
48-
printf '::group::%s\n' "$test_case"
50+
if [ -n "$GITHUB_ACTIONS" ]; then
51+
printf '::group::%s\n' "$test_case"
52+
else
53+
printf "# %s #\n" "$test_case"
54+
fi
4955
export test_case
5056
test_name="${test_case//tests\//}"
5157
test_name="${test_name//\//_}"
@@ -119,9 +125,25 @@ for test_case in "${test_cases[@]}"; do
119125
fi
120126

121127
printf '%d\t%d\t%s\n' "$test_ok" "$asan_ok" "$test_name" >> "$RESULTS_FILE"
122-
printf '::endgroup::\n'
128+
if [ -n "$GITHUB_ACTIONS" ]; then
129+
printf '::endgroup::\n'
130+
else
131+
if (( $test_ok == 1 )); then
132+
printf "| PASS\n\n"
133+
else
134+
failed_tests_list+=("$test_name")
135+
fi
136+
fi
123137
done
124138

139+
if [ -z "$GITHUB_ACTIONS" ] && [[ $global_status -ne 0 ]]; then
140+
echo "Failed tests list:"
141+
for test_name in ${failed_tests_list[@]}
142+
do
143+
echo $test_name
144+
done
145+
fi
146+
125147
# Leave with non-zero error status if any test failed
126148
if [[ $global_status -ne 0 ]]; then
127149
exit 1

.github/scripts/sort_passlists.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ declare -r SELF_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
77
declare -r REPO_DIR=$SELF_DIR/../..
88
cd $REPO_DIR
99

10-
files_to_sort_check=(
11-
tests/formal/passlist.txt
12-
tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt
13-
)
10+
opentitan_passlist="tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt"
11+
formal_testlist="tests/formal/testlist.json"
1412

15-
for f in "${files_to_sort_check[@]}"; do
16-
LC_ALL=C.UTF-8 sort -f -u -o $f $f
17-
done
13+
LC_ALL=C.UTF-8 sort -f -u -o $opentitan_passlist $opentitan_passlist
14+
15+
cat $formal_testlist | jq -s -c 'sort_by(.d) | .[]' | python3 -m json.tool > ${formal_testlist}.tmp
16+
mv ${formal_testlist}.tmp $formal_testlist

.github/workflows/formal-verification.yml

Lines changed: 10 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@ jobs:
1414
matrix:
1515
include:
1616
- name: simple
17-
test-suite: tests/simple_tests
1817
- name: sv2v
19-
test-suite: third_party/sv2v/test
2018
- name: yosys
21-
test-suite: third_party/yosys/tests
2219
fail-fast: false
2320
name: ${{ matrix.name }}
2421
env:
2522
GIT_HTTP_LOW_SPEED_LIMIT: 1
2623
GIT_HTTP_LOW_SPEED_TIME: 600
2724
DEBIAN_FRONTEND: noninteractive
2825
GHA_MACHINE_TYPE: "n2-highmem-8"
29-
PARSER: yosys-plugin
30-
TEST_SUITE_DIR: ${{ matrix.test-suite }}
3126
TEST_SUITE_NAME: ${{ matrix.name }}
3227

3328
steps:
@@ -42,35 +37,12 @@ jobs:
4237
4338
- name: Install dependencies
4439
run: |
45-
apt-get update -q
46-
apt-get install -y \
47-
ant \
48-
build-essential \
49-
cmake \
50-
default-jre \
51-
flex \
52-
git \
53-
google-perftools \
54-
jq \
55-
libfl-dev \
56-
libgoogle-perftools-dev \
57-
python3 \
58-
python3-dev \
59-
swig \
60-
tcl-dev \
61-
tclsh \
62-
time \
63-
uuid \
64-
uuid-dev \
65-
;
40+
./tests/scripts/run_formal.sh --name $TEST_SUITE_NAME install_dependencies
41+
6642
6743
- name: Checkout submodules
6844
run: |
69-
git submodule sync
70-
git submodule update --depth 1 --init --recursive --checkout \
71-
third_party/yosys \
72-
third_party/sv2v \
73-
;
45+
./tests/scripts/run_formal.sh --name $TEST_SUITE_NAME load_submodules
7446
7547
- name: Download binaries
7648
uses: actions/download-artifact@v2
@@ -87,29 +59,21 @@ jobs:
8759
name: sv2v
8860
path: out/current/bin/
8961

62+
- name: Build eqy and sby
63+
run: |
64+
./tests/scripts/run_formal.sh --name $TEST_SUITE_NAME build_dependencies
65+
9066
- name: Test
9167
run: |
9268
chmod +x out/current/bin/sv2v
9369
source .github/scripts/common.sh
94-
export PATH="$PWD/out/current/bin:$PATH"
95-
./run_fv_tests.mk -j$(nproc) \
96-
TEST_SUITE_DIR:="$(realpath ${TEST_SUITE_DIR})" \
97-
TEST_SUITE_NAME:="${TEST_SUITE_NAME}" \
98-
test
70+
./tests/scripts/run_formal.sh --name $TEST_SUITE_NAME run
9971
100-
- name: Generate list of performed tests
101-
run: |
102-
list_file="build/${TEST_SUITE_NAME}.performed_tests_list.txt"
103-
touch "$list_file"
104-
for result_json in build/tests/*/*/result.json; do
105-
test_name=$(jq -r '.name' "${result_json}")
106-
printf '%s:%s\n' "${TEST_SUITE_NAME}" "${test_name}" >> "$list_file"
107-
done
10872
10973
- name: Pack formal verification logs
11074
run: |
11175
cd build
112-
tar cf ${TEST_SUITE_NAME}.tar tests/*/*/*.out tests/*/*/slpp_all/*.log tests/*/*/*.txt tests/*/*/result.json
76+
tar cf ${TEST_SUITE_NAME}.tar tests/*/*
11377
11478
- name: Upload formal verification logs
11579
uses: actions/upload-artifact@v2
@@ -118,12 +82,6 @@ jobs:
11882
path: |
11983
build/*.tar
12084
121-
- name: Upload list of performed tests
122-
uses: actions/upload-artifact@v2
123-
with:
124-
name: formal-verification-tests-list
125-
path: build/*.performed_tests_list.txt
126-
12785
- name: Upload load graphs
12886
uses: actions/upload-artifact@v2
12987
with:
@@ -135,34 +93,5 @@ jobs:
13593
- name: Check results and print a summary
13694
run: |
13795
set -o pipefail
138-
python3 ./tests/formal/results.py "build/tests/${TEST_SUITE_NAME}" | tee $GITHUB_STEP_SUMMARY
139-
140-
passlist-check:
141-
name: Passlist Check
142-
needs: tests-formal-verification
143-
if: ${{ !cancelled() }}
144-
runs-on: [self-hosted, Linux, X64, gcp-custom-runners]
145-
container: ubuntu:jammy-20221130
96+
./tests/scripts/run_formal.sh --name $TEST_SUITE_NAME gather_results | tee $GITHUB_STEP_SUMMARY
14697
147-
steps:
148-
- uses: actions/checkout@v3
149-
with:
150-
fetch-depth: 1
151-
152-
- name: Download lists of performed tests
153-
uses: actions/download-artifact@v2
154-
with:
155-
name: formal-verification-tests-list
156-
157-
- name: Compare lists
158-
run: |
159-
sort *.performed_tests_list.txt > performed_tests_list.txt
160-
grep -o '^[^ #]\+' tests/formal/passlist.txt | sort > sorted_passlist.txt
161-
readarray not_performed_tests < <(comm -13 performed_tests_list.txt sorted_passlist.txt)
162-
if (( ${#not_performed_tests[@]} > 0 )); then
163-
printf '\x1b[1mTests from passlist.txt that were not performed:\x1b[0m\n'
164-
printf '\x1b[91m%s\x1b[0m\n' "${not_performed_tests[@]}"
165-
exit 1
166-
else
167-
exit 0
168-
fi

0 commit comments

Comments
 (0)