mirror of https://github.com/YosysHQ/yosys.git
Consolidate tests scripts into one
This commit is contained in:
parent
547c5466ec
commit
71aaa1c80d
|
@ -1,80 +1,138 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Initialize an array to store the names of failing RTLIL files and their failure types
|
declare -A cxx_failing_files
|
||||||
declare -A failing_files
|
declare -A smt_failing_files
|
||||||
# Initialize an array to store the names of successful RTLIL files
|
declare -A cxx_successful_files
|
||||||
declare -A successful_files
|
declare -A smt_successful_files
|
||||||
|
|
||||||
# Function to run the test on a given RTLIL file
|
run_cxx_test() {
|
||||||
run_test() {
|
|
||||||
# Define the common variable for the relative path
|
|
||||||
BASE_PATH="../../../"
|
BASE_PATH="../../../"
|
||||||
|
|
||||||
local rtlil_file=$1
|
local rtlil_file=$1
|
||||||
|
|
||||||
# Extract the base name without extension
|
|
||||||
local base_name=$(basename "$rtlil_file" .v)
|
local base_name=$(basename "$rtlil_file" .v)
|
||||||
|
|
||||||
# Run yosys to process each RTLIL file
|
|
||||||
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; write_functional_cxx my_module_functional_cxx.cc"; then
|
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; write_functional_cxx my_module_functional_cxx.cc"; then
|
||||||
echo "Yosys processed $rtlil_file successfully."
|
echo "Yosys processed $rtlil_file successfully."
|
||||||
|
|
||||||
# Compile the generated C++ files with vcd_harness.cpp
|
|
||||||
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
|
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
|
||||||
echo "Compilation successful."
|
echo "Compilation successful."
|
||||||
# Generate VCD files with base_name
|
|
||||||
if ./vcd_harness ${base_name}_functional_cxx.vcd; then
|
if ./vcd_harness ${base_name}_functional_cxx.vcd; then
|
||||||
|
|
||||||
# Run yosys to process each RTLIL file
|
|
||||||
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
|
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
|
||||||
echo "Yosys sim $rtlil_file successfully."
|
echo "Yosys sim $rtlil_file successfully."
|
||||||
successful_files["$rtlil_file"]="Success"
|
cxx_successful_files["$rtlil_file"]="Success"
|
||||||
else
|
else
|
||||||
${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"
|
${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"
|
||||||
echo "Yosys simulation of $rtlil_file failed. There is a discrepancy with functional cxx"
|
echo "Yosys simulation of $rtlil_file failed. There is a discrepancy with functional cxx"
|
||||||
failing_files["$rtlil_file"]="Yosys sim failure"
|
cxx_failing_files["$rtlil_file"]="Yosys sim failure"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Failed to generate VCD files for $rtlil_file."
|
echo "Failed to generate VCD files for $rtlil_file."
|
||||||
failing_files["$rtlil_file"]="VCD generation failure"
|
cxx_failing_files["$rtlil_file"]="VCD generation failure"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Failed to compile harness for $rtlil_file."
|
echo "Failed to compile harness for $rtlil_file."
|
||||||
failing_files["$rtlil_file"]="Compilation failure"
|
cxx_failing_files["$rtlil_file"]="Compilation failure"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Yosys failed to process $rtlil_file."
|
echo "Yosys failed to process $rtlil_file."
|
||||||
failing_files["$rtlil_file"]="Yosys failure"
|
cxx_failing_files["$rtlil_file"]="Yosys failure"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main function to run all tests
|
run_smt_test() {
|
||||||
run_all_tests() {
|
BASE_PATH="../../../"
|
||||||
# Loop through all RTLIL files in the rtlil directory
|
|
||||||
for rtlil_file in rtlil/*.il; do
|
|
||||||
run_test "$rtlil_file"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check if the array of failing files is empty
|
local rtlil_file=$1
|
||||||
if [ ${#failing_files[@]} -eq 0 ]; then
|
|
||||||
|
local base_name=$(basename "$rtlil_file" .il)
|
||||||
|
|
||||||
|
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; write_functional_smt2 ${base_name}.smt2"; then
|
||||||
|
echo "Yosys processed $rtlil_file successfully."
|
||||||
|
# TODO: which SMT solver should be run?
|
||||||
|
if z3 "${base_name}.smt2"; then
|
||||||
|
echo "SMT file ${base_name}.smt2 is valid ."
|
||||||
|
|
||||||
|
if python3 using_smtio.py "${base_name}.smt2"; then
|
||||||
|
echo "Python script generated VCD file for $rtlil_file successfully."
|
||||||
|
|
||||||
|
if [ -f "${base_name}.smt2.vcd" ]; then
|
||||||
|
echo "VCD file ${base_name}.vcd generated successfully by Python."
|
||||||
|
|
||||||
|
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
|
||||||
|
echo "Yosys simulation for $rtlil_file completed successfully."
|
||||||
|
smt_successful_files["$rtlil_file"]="Success"
|
||||||
|
else
|
||||||
|
echo "Yosys simulation failed for $rtlil_file."
|
||||||
|
smt_failing_files["$rtlil_file"]="Yosys simulation failure"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
|
||||||
|
echo "Failed to generate VCD file (${base_name}.vcd) for $rtlil_file. "
|
||||||
|
smt_failing_files["$rtlil_file"]="VCD generation failure"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Failed to run Python script for $rtlil_file."
|
||||||
|
smt_failing_files["$rtlil_file"]="Python script failure"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "SMT file for $rtlil_file is invalid"
|
||||||
|
smt_failing_files["$rtlil_file"]="Invalid SMT"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Yosys failed to process $rtlil_file."
|
||||||
|
smt_failing_files["$rtlil_file"]="Yosys failure"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
run_all_tests() {
|
||||||
|
return_code=0
|
||||||
|
for rtlil_file in rtlil/*.il; do
|
||||||
|
run_cxx_test "$rtlil_file"
|
||||||
|
run_smt_test "$rtlil_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "C++ tests results:"
|
||||||
|
if [ ${#cxx_failing_files[@]} -eq 0 ]; then
|
||||||
echo "All files passed."
|
echo "All files passed."
|
||||||
echo "The following files passed:"
|
echo "The following files passed:"
|
||||||
for file in "${!successful_files[@]}"; do
|
for file in "${!cxx_successful_files[@]}"; do
|
||||||
echo "$file"
|
echo "$file"
|
||||||
done
|
done
|
||||||
return 0
|
|
||||||
else
|
else
|
||||||
echo "The following files failed:"
|
echo "The following files failed:"
|
||||||
for file in "${!failing_files[@]}"; do
|
for file in "${!cxx_failing_files[@]}"; do
|
||||||
echo "$file: ${failing_files[$file]}"
|
echo "$file: ${cxx_failing_files[$file]}"
|
||||||
done
|
done
|
||||||
echo "The following files passed:"
|
echo "The following files passed:"
|
||||||
for file in "${!successful_files[@]}"; do
|
for file in "${!cxx_successful_files[@]}"; do
|
||||||
echo "$file"
|
echo "$file"
|
||||||
done
|
done
|
||||||
return 1
|
return_code=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "SMT tests results:"
|
||||||
|
if [ ${#smt_failing_files[@]} -eq 0 ]; then
|
||||||
|
echo "All files passed."
|
||||||
|
echo "The following files passed:"
|
||||||
|
for file in "${!smt_successful_files[@]}"; do
|
||||||
|
echo "$file"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "The following files failed:"
|
||||||
|
for file in "${!smt_failing_files[@]}"; do
|
||||||
|
echo "$file: ${smt_failing_files[$file]}"
|
||||||
|
done
|
||||||
|
echo "The following files passed:"
|
||||||
|
for file in "${!smt_successful_files[@]}"; do
|
||||||
|
echo "$file"
|
||||||
|
done
|
||||||
|
return_code=1
|
||||||
|
fi
|
||||||
|
return $return_code
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the script is being sourced, do not execute the tests
|
# If the script is being sourced, do not execute the tests
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Initialize an array to store the names of failing RTLIL files and their failure types
|
|
||||||
declare -A failing_files
|
|
||||||
# Initialize an array to store the names of successful RTLIL files
|
|
||||||
declare -A successful_files
|
|
||||||
|
|
||||||
# Function to run the test on a given RTLIL file
|
|
||||||
run_test() {
|
|
||||||
# Define the common variable for the relative path
|
|
||||||
BASE_PATH="../../../"
|
|
||||||
|
|
||||||
local rtlil_file=$1
|
|
||||||
|
|
||||||
# Extract the base name without extension
|
|
||||||
local base_name=$(basename "$rtlil_file" .il)
|
|
||||||
|
|
||||||
# Run yosys to process each RTLIL file
|
|
||||||
if ${BASE_PATH}yosys -p "read_rtlil $rtlil_file; write_functional_smt2 ${base_name}.smt2"; then
|
|
||||||
echo "Yosys processed $rtlil_file successfully."
|
|
||||||
# Check that the smt file generated is valid
|
|
||||||
# Execute the Python script to create a VCD file from the SMT2 file
|
|
||||||
if z3 "${base_name}.smt2"; then
|
|
||||||
echo "SMT file ${base_name}.smt2 is valid ."
|
|
||||||
|
|
||||||
if python3 using_smtio.py "${base_name}.smt2"; then
|
|
||||||
echo "Python script generated VCD file for $rtlil_file successfully."
|
|
||||||
|
|
||||||
# Check if VCD file was generated successfully
|
|
||||||
if [ -f "${base_name}.smt2.vcd" ]; then
|
|
||||||
echo "VCD file ${base_name}.vcd generated successfully by Python."
|
|
||||||
|
|
||||||
# Run yosys simulation to generate a reference VCD file
|
|
||||||
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
|
|
||||||
echo "Yosys simulation for $rtlil_file completed successfully."
|
|
||||||
successful_files["$rtlil_file"]="Success"
|
|
||||||
else
|
|
||||||
echo "Yosys simulation failed for $rtlil_file."
|
|
||||||
failing_files["$rtlil_file"]="Yosys simulation failure"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
|
|
||||||
echo "Failed to generate VCD file (${base_name}.vcd) for $rtlil_file. "
|
|
||||||
failing_files["$rtlil_file"]="VCD generation failure"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Failed to run Python script for $rtlil_file."
|
|
||||||
failing_files["$rtlil_file"]="Python script failure"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "SMT file for $rtlil_file is invalid"
|
|
||||||
failing_files["$rtlil_file"]="Invalid SMT"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Yosys failed to process $rtlil_file."
|
|
||||||
failing_files["$rtlil_file"]="Yosys failure"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main function to run all tests
|
|
||||||
run_all_tests() {
|
|
||||||
# Loop through all RTLIL files in the rtlil directory
|
|
||||||
for rtlil_file in rtlil/*.il; do
|
|
||||||
run_test "$rtlil_file"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check if the array of failing files is empty
|
|
||||||
if [ ${#failing_files[@]} -eq 0 ]; then
|
|
||||||
echo "All files passed."
|
|
||||||
echo "The following files passed:"
|
|
||||||
for file in "${!successful_files[@]}"; do
|
|
||||||
echo "$file"
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "The following files failed:"
|
|
||||||
for file in "${!failing_files[@]}"]; do
|
|
||||||
echo "$file: ${failing_files[$file]}"
|
|
||||||
done
|
|
||||||
echo "The following files passed:"
|
|
||||||
for file in "${!successful_files[@]}"]; do
|
|
||||||
echo "$file"
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# If the script is being sourced, do not execute the tests
|
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
||||||
run_all_tests
|
|
||||||
fi
|
|
Loading…
Reference in New Issue