Skip to content

Commit bb04a71

Browse files
committed
Consolidate tests scripts into one
1 parent f5f8780 commit bb04a71

File tree

2 files changed

+87
-120
lines changed

2 files changed

+87
-120
lines changed

tests/functional/single_cells/run-test.sh

+87-29
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,138 @@
11
#!/bin/bash
22

3-
# Initialize an array to store the names of failing RTLIL files and their failure types
4-
declare -A failing_files
5-
# Initialize an array to store the names of successful RTLIL files
6-
declare -A successful_files
3+
declare -A cxx_failing_files
4+
declare -A smt_failing_files
5+
declare -A cxx_successful_files
6+
declare -A smt_successful_files
77

8-
# Function to run the test on a given RTLIL file
9-
run_test() {
10-
# Define the common variable for the relative path
8+
run_cxx_test() {
119
BASE_PATH="../../../"
1210

1311
local rtlil_file=$1
1412

15-
# Extract the base name without extension
1613
local base_name=$(basename "$rtlil_file" .v)
1714

18-
# Run yosys to process each RTLIL file
1915
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; write_functional_cxx my_module_functional_cxx.cc"; then
2016
echo "Yosys processed $rtlil_file successfully."
2117

22-
# Compile the generated C++ files with vcd_harness.cpp
2318
if ${CXX:-g++} -g -fprofile-arcs -ftest-coverage vcd_harness.cc -I ${BASE_PATH}backends/functional/cxx_runtime/ -std=c++17 -o vcd_harness; then
2419
echo "Compilation successful."
25-
# Generate VCD files with base_name
2620
if ./vcd_harness ${base_name}_functional_cxx.vcd; then
2721

28-
# Run yosys to process each RTLIL file
2922
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; sim -r ${base_name}_functional_cxx.vcd -scope gold -vcd ${base_name}_yosys_sim.vcd -timescale 1us -sim-gold"; then
3023
echo "Yosys sim $rtlil_file successfully."
31-
successful_files["$rtlil_file"]="Success"
24+
cxx_successful_files["$rtlil_file"]="Success"
3225
else
3326
${BASE_PATH}yosys -p "read_rtlil $rtlil_file; sim -vcd ${base_name}_yosys_sim.vcd -r ${base_name}_functional_cxx.vcd -scope gold -timescale 1us"
3427
echo "Yosys simulation of $rtlil_file failed. There is a discrepancy with functional cxx"
35-
failing_files["$rtlil_file"]="Yosys sim failure"
28+
cxx_failing_files["$rtlil_file"]="Yosys sim failure"
3629
fi
3730

3831
else
3932
echo "Failed to generate VCD files for $rtlil_file."
40-
failing_files["$rtlil_file"]="VCD generation failure"
33+
cxx_failing_files["$rtlil_file"]="VCD generation failure"
4134
fi
4235
else
4336
echo "Failed to compile harness for $rtlil_file."
44-
failing_files["$rtlil_file"]="Compilation failure"
37+
cxx_failing_files["$rtlil_file"]="Compilation failure"
4538
fi
4639
else
4740
echo "Yosys failed to process $rtlil_file."
48-
failing_files["$rtlil_file"]="Yosys failure"
41+
cxx_failing_files["$rtlil_file"]="Yosys failure"
4942
fi
5043
}
5144

52-
# Main function to run all tests
45+
run_smt_test() {
46+
BASE_PATH="../../../"
47+
48+
local rtlil_file=$1
49+
50+
local base_name=$(basename "$rtlil_file" .il)
51+
52+
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; write_functional_smt2 ${base_name}.smt2"; then
53+
echo "Yosys processed $rtlil_file successfully."
54+
# TODO: which SMT solver should be run?
55+
if z3 "${base_name}.smt2"; then
56+
echo "SMT file ${base_name}.smt2 is valid ."
57+
58+
if python3 using_smtio.py "${base_name}.smt2"; then
59+
echo "Python script generated VCD file for $rtlil_file successfully."
60+
61+
if [ -f "${base_name}.smt2.vcd" ]; then
62+
echo "VCD file ${base_name}.vcd generated successfully by Python."
63+
64+
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; sim -vcd ${base_name}_yosys.vcd -r ${base_name}.smt2.vcd -scope gold -timescale 1us"; then
65+
echo "Yosys simulation for $rtlil_file completed successfully."
66+
smt_successful_files["$rtlil_file"]="Success"
67+
else
68+
echo "Yosys simulation failed for $rtlil_file."
69+
smt_failing_files["$rtlil_file"]="Yosys simulation failure"
70+
fi
71+
else
72+
73+
echo "Failed to generate VCD file (${base_name}.vcd) for $rtlil_file. "
74+
smt_failing_files["$rtlil_file"]="VCD generation failure"
75+
fi
76+
else
77+
echo "Failed to run Python script for $rtlil_file."
78+
smt_failing_files["$rtlil_file"]="Python script failure"
79+
fi
80+
else
81+
echo "SMT file for $rtlil_file is invalid"
82+
smt_failing_files["$rtlil_file"]="Invalid SMT"
83+
fi
84+
else
85+
echo "Yosys failed to process $rtlil_file."
86+
smt_failing_files["$rtlil_file"]="Yosys failure"
87+
fi
88+
}
89+
90+
5391
run_all_tests() {
54-
# Loop through all RTLIL files in the rtlil directory
92+
return_code=0
5593
for rtlil_file in rtlil/*.il; do
56-
run_test "$rtlil_file"
94+
run_cxx_test "$rtlil_file"
95+
run_smt_test "$rtlil_file"
5796
done
58-
59-
# Check if the array of failing files is empty
60-
if [ ${#failing_files[@]} -eq 0 ]; then
97+
98+
echo "C++ tests results:"
99+
if [ ${#cxx_failing_files[@]} -eq 0 ]; then
100+
echo "All files passed."
101+
echo "The following files passed:"
102+
for file in "${!cxx_successful_files[@]}"; do
103+
echo "$file"
104+
done
105+
else
106+
echo "The following files failed:"
107+
for file in "${!cxx_failing_files[@]}"; do
108+
echo "$file: ${cxx_failing_files[$file]}"
109+
done
110+
echo "The following files passed:"
111+
for file in "${!cxx_successful_files[@]}"; do
112+
echo "$file"
113+
done
114+
return_code=1
115+
fi
116+
117+
echo "SMT tests results:"
118+
if [ ${#smt_failing_files[@]} -eq 0 ]; then
61119
echo "All files passed."
62120
echo "The following files passed:"
63-
for file in "${!successful_files[@]}"; do
121+
for file in "${!smt_successful_files[@]}"; do
64122
echo "$file"
65123
done
66-
return 0
67124
else
68125
echo "The following files failed:"
69-
for file in "${!failing_files[@]}"; do
70-
echo "$file: ${failing_files[$file]}"
126+
for file in "${!smt_failing_files[@]}"; do
127+
echo "$file: ${smt_failing_files[$file]}"
71128
done
72129
echo "The following files passed:"
73-
for file in "${!successful_files[@]}"; do
130+
for file in "${!smt_successful_files[@]}"; do
74131
echo "$file"
75132
done
76-
return 1
133+
return_code=1
77134
fi
135+
return $return_code
78136
}
79137

80138
# If the script is being sourced, do not execute the tests

tests/functional/single_cells/run-test_smt.sh

-91
This file was deleted.

0 commit comments

Comments
 (0)