blob: 1f111b9e6e9af0de3cda56857279da942234c66f [file] [log] [blame]
create_unit_test() {
create_unit_test.pl $1
}
setup() {
./clean
}
golden_module_unit_test() {
sed -e "s/FILE/$1/" $SVUNIT_INSTALL/test/templates/module_unit_test.gold | sed -e "s/MYNAME/$2/g" > ${1}_unit_test.gold
}
golden_if_unit_test() {
sed -e "s/FILE/$1/" $SVUNIT_INSTALL/test/templates/if_unit_test.gold | sed -e "s/MYNAME/$2/g" > ${1}_unit_test.gold
}
golden_class_unit_test() {
sed -e "s/FILE/$1/" $SVUNIT_INSTALL/test/templates/class_unit_test.gold | sed -e "s/MYNAME/$2/g" > ${1}_unit_test.gold
}
golden_testsuite_with_1_unittest() {
sed -e "s/MYNAME/$1/g" $SVUNIT_INSTALL/test/templates/testsuite_with_1_unittest.gold > testsuite.gold
}
golden_testrunner_with_1_testsuite() {
cp $SVUNIT_INSTALL/test/templates/testrunner_with_1_testsuite.gold testrunner.gold
}
golden_testrunner_with_2_testsuites() {
cp $SVUNIT_INSTALL/test/templates/testrunner_with_2_testsuite.gold testrunner.gold
}
golden_testrunner_with_4_testsuites() {
cp $SVUNIT_INSTALL/test/templates/testrunner_with_4_testsuite.gold testrunner.gold
}
verify_file() {
if [ "`diff -bB $1 $2`" != "" ]; then
echo $1 failed;
exit 1;
fi
}
verify_testsuite() {
PWD=`pwd | sed -e "s/[\/-]/_/g"`
sed -e "s/PWD/$PWD/g" $1 > .$1
verify_file .$1 .${PWD}_testsuite.sv
}
verify_testrunner() {
PWD=`pwd | sed -e "s/[\/-]/_/g"`
sed -e "s/PWD/$PWD/g" $1 | \
sed -e "s/CHILD1/$2/g" | \
sed -e "s/CHILD2/$3/g" | \
sed -e "s/CHILD3/$4/g" > .$1
verify_file .testrunner.gold .testrunner.sv
}
expect_file() {
if [ ! -e $1 ]; then
echo $1 not created
exit 1
fi
}
expect_eq() {
if [ "$1" != "$2" ]; then
exit 1
fi
}
expect_return_code() {
if [ "$?" != "$1" ]; then
echo bad return code $?
exit 1
fi
}
expect_file_does_not_contain() {
grep "$1" $2 >/dev/null
if [ "$?" == "0" ]; then
exit 1;
fi
}
expect_testrunner_pass() {
grep "INFO: \[.*\]\[testrunner\]: Testrunner::PASSED" $1 >/dev/null
if [ "$?" != "0" ]; then
echo PASS not detected from Testrunner in $1
exit 1;
fi
}
expect_testrunner_fail() {
grep "INFO: \[.*\]\[testrunner\]: Testrunner::FAILED" $1 >/dev/null
if [ "$?" != "0" ]; then
echo PASS not detected from Testrunner in $1
exit 1;
fi
}
expect_string() {
grep "$1" $2 >/dev/null
if [ "$?" != "0" ]; then
echo "$1" not detected in $2
exit 1;
fi
}
expect_passing_example() {
pushd . >/dev/null
cd $1
create_svunit.pl
# build and run svunit with qverilog
make SIMULATOR=$2
# check the log output for a PASS from the testrunner
expect_file run.log
expect_testrunner_pass run.log
make SIMULATOR=$2 clean
popd >/dev/null
}