adds script to run UCB riscv tests

This commit is contained in:
Eyck-Alexander Jentzsch 2023-09-20 09:36:32 +02:00
parent 5883ef1e8d
commit e17e463cf3
4 changed files with 98 additions and 3 deletions

View File

@ -10,6 +10,7 @@ if(CMAKE_PROJECT_NAME STREQUAL "TGFS-ISS")
########################################################################### ###########################################################################
set(CORE_NAME TGC5C CACHE STRING "The core to build the ISS for" ) set(CORE_NAME TGC5C CACHE STRING "The core to build the ISS for" )
option(FW_BUILD "Enable the automatic download and build of some firmware to run on the ISS" OFF) option(FW_BUILD "Enable the automatic download and build of some firmware to run on the ISS" OFF)
option(ENABLE_SANITIZER "Enable address sanitizer" OFF)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -34,7 +35,12 @@ if(CMAKE_PROJECT_NAME STREQUAL "TGFS-ISS")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /WX /EHsc") set(warnings "/W4 /WX /EHsc")
endif() endif()
if(ENABLE_SANITIZER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
endif()
include(GNUInstallDirs) include(GNUInstallDirs)
include(ConanInline) include(ConanInline)
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)

@ -1 +1 @@
Subproject commit 22a0503f2ebe36fa44a5ef1c86950e2dc621848c Subproject commit d18b6a6fd4f7ef0304378cbefb2ab1dd11689e6a

@ -1 +1 @@
Subproject commit 8ee3ac90f72176d0bbdfe10e43ab251f629c7d37 Subproject commit de45d068782e0bd7960dedced11c7ea041a13639

89
run_riscv_tests.sh Executable file
View File

@ -0,0 +1,89 @@
#!/bin/bash
##
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f "$0"`
# Absolute path this script is in, thus /home/user/bin
SCRIPTDIR=`dirname "$SCRIPT"`
SCRIPTNAME=`basename "$SCRIPT"`
function print_help {
echo "Usage: $SCRIPTNAME [-b <backend>] [-s <sim args>]}"
echo "Run UCB risc-v compliance test suite on backends"
echo "Optional cli arguments:"
echo " -b backend type, default all"
echo " -s <args> simulator arguments"
echo " -h print help"
echo " -v increase verbosity"
}
SIM_ARGS="-v1"
BACKENDS=("interp" "tcc" "llvm")
DEBUG=0
BUILD_TYPE=Debug
while getopts 'b:s:hv' c
do
case $c in
b) BACKENDS=($OPTARG);;
s) SIM_ARGS=$OPTARG ;;
h) print_help; exit 0 ;;
v) DEBUG=1 ;;
?)
print_help >&2
exit 1
;;
esac
done
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIR=$DIR
RISCV_TEST=$ROOT_DIR/build/riscv-tests
# prepare riscv-test binaries
if [ ! -d $RISCV_TEST ]; then
mkdir -p $ROOT_DIR/build; cd $ROOT_DIR/build
git clone --recursive https://github.com/riscv/riscv-tests.git
cd $RISCV_TEST
autoconf
./configure --with-xlen=32
cd $ROOT_DIR
make -C $RISCV_TEST -j -k
fi
# check that we have an executable
RISCV_EXE=$ROOT_DIR/build/${BUILD_TYPE}/dbt-rise-tgc/tgc-sim
if [ ! -x $RISCV_EXE ]; then
mkdir -p build/${BUILD_TYPE}
echo "running cmake -B build/${BUILD_TYPE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWITH_TCC=ON -DWITH_LLVM=ON "
cmake -S . -B build/${BUILD_TYPE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWITH_TCC=ON -DWITH_LLVM=ON ../.. || exit 1
cmake --build build/${BUILD_TYPE} -j 20 || exit 1
fi
test_ui_list=`find ${RISCV_TEST}/isa -type f -name rv32ui-p-\* -executable | grep -v fence | grep -v ma_data |sort`
test_uc_list=`find ${RISCV_TEST}/isa -type f -name rv32uc-p-\* -executable | grep -v fence | sort`
test_um_list=`find ${RISCV_TEST}/isa -type f -name rv32um-p-\* -executable | grep -v fence | sort`
test_list="$test_ui_list $test_uc_list $test_um_list $test_mmode_list"
for backend in "${BACKENDS[@]}"; do
failed_list=()
for elf in $test_list; do
[ $DEBUG -eq 0 ] || echo Running "${RISCV_EXE} $SIM_ARGS -f $elf --backend $backend"
${RISCV_EXE} $SIM_ARGS -f $elf --backend $backend
if [ $? != 0 ]; then
failed_list+="$backend:$elf "
fi
done
tcount=`echo $test_list | wc -w`
if [ ! -z "$failed_list" ]; then
fcount=`echo $failed_list | wc -w`
echo "($backend) $fcount of $tcount test(s) failed:"
echo $failed_list | tr ' ' '\n'
else
echo
echo "($backend) $tcount tests passed."
if [ $DEBUG -eq 1 ];then
echo "List of executed tests:"
for t in $test_list; do
name=`basename $t`
echo " $name"
done
fi
fi
done