Skip to content

Commit

Permalink
Testsuite: Add "which_mach" and use in div-by-zero tests
Browse files Browse the repository at this point in the history
The divmod tests fail on arm64, because the tests are expecting SIGFPE
error to be raised, but ARM does not.  This may need to be addressed in
the code generation for Bluesim, but in the meantime, update the test
to expect no error when the MACHTYPE is arm64.

A new "which_mach" procedure in the testsuite allows querying MACHTYPE.

Found an old test that was calling "uname -m" to get the machtype, and
test for x86_64.  This could be replaced with a call to "which_mach",
but the use was to workaround a bug in iverilog 0.8.3, which is older
than we need to support, so instead the code is just removed.
  • Loading branch information
quark17 committed Apr 7, 2024
1 parent 1ee376a commit 388a61e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
8 changes: 6 additions & 2 deletions testsuite/bsc.misc/divmod/divmod.exp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ test_c_veri_bsv_modules_options DivMod {} "-no-use-negate"

test_c_veri_bsv_modules_options DivModWide {} "-no-use-negate" sysDivModWide.out.expected

# expected status for darwin rh3 and rh4
set fpe [list SIGFPE 8 136]

# Test that divide-by-zero produces some failure in Bluesim
compile_object_pass DivideByZero.bsv sysDivideByZero
link_objects_pass sysDivideByZero sysDivideByZero
sim_output_status sysDivideByZero $fpe
if [string equal [which_mach] "arm64"] {
# This is an expected bug (GitHub #688)
sim_output_status sysDivideByZero 0
} else {
sim_output_status sysDivideByZero $fpe
}

# In Verilog it silently produces x's
test_veri_only_bsv DivideByZero sysDivideByZero.v.out.expected
Expand Down
19 changes: 1 addition & 18 deletions testsuite/bsc.names/portRenaming/misc/misc.exp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,9 @@

if { $vtest == 1 } {

proc test_iverilog_version_and_machine_type {} {
global verilog_compiler
set code [catch "exec $verilog_compiler -V 2>/dev/null | head -1" x2]
set mach [exec uname -m]
set x86_64 [string first "x86_64" $mach]
set icarus [string first "Icarus Verilog" $x2]
set version [string first "0.8.3" $x2]
return [expr {$x86_64 == -1 || $icarus == -1 || $version == -1}]
}

compile_object_pass Small1.bsv
compile_verilog_pass Small1.bsv
if [ test_iverilog_version_and_machine_type ] {
# this test is known to fail for x86_64 for iverilog 0.8.3
# due to a bug (assertion failure) in iverilog
link_verilog_no_main_pass {Tb1.v mkSmallTest1.v} Tb1
} else {
verbose -log "Skipping Tb1 verilog link test"
}

link_verilog_no_main_pass {Tb1.v mkSmallTest1.v} Tb1

compile_object_pass Small2.bsv
compile_verilog_pass Small2.bsv
Expand Down
10 changes: 10 additions & 0 deletions testsuite/config/unix.exp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ proc which_os {} {
return $env(OSTYPE)
}

proc which_mach {} {
global env
if {! [info exists env(MACHTYPE)]} {
perror "can't find architecture -- set MACHTYPE to the name"
exit 1
}
return $env(MACHTYPE)
}

# return true if the given Bluetcl packahe is available
proc bluetcl_package_available { pkg } {
global bluetcl
Expand Down Expand Up @@ -3209,6 +3218,7 @@ verbose -log "Do internal checks is [do_internal_checks]" 1
# System settings

verbose -log "Operating system is [which_os]" 1
verbose -log "Architecture is [which_mach]" 1

# Assume 64-bit
set ::is64 "64"
Expand Down
7 changes: 6 additions & 1 deletion testsuite/suitemake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ ifneq ($(TEST_OSTYPE), $(findstring $(TEST_OSTYPE), Linux Darwin))
$(error TEST_OSTYPE environment not recognized: $(TEST_OSTYPE))
endif

TEST_MACHTYPE ?= $(shell $(CONFDIR)/../platform.sh machtype)
# TODO: Test for expected architectures?

MAKEFLAGS += --no-print-directory

# Make sure that the environments are consistent
Expand Down Expand Up @@ -64,7 +67,9 @@ RUNTESTENV = MAKEFLAGS= BSCTEST=1 \
BSC_VERILOG_SIM=$(TEST_BSC_VERILOG_SIM) \
TEST_CONFIG_DIR=${TEST_CONFIG} \
BLUETCL=$(TEST_BLUETCL) \
OSTYPE=$(TEST_OSTYPE) LC_ALL=$(LC_ALL) \
OSTYPE=$(TEST_OSTYPE) \
MACHTYPE=$(TEST_MACHTYPE) \
LC_ALL=$(LC_ALL) \
SYSTEMC_INC=$(TEST_SYSTEMC_INC) \
SYSTEMC_LIB=$(TEST_SYSTEMC_LIB) \
SYSTEMC_CXXFLAGS=$(TEST_SYSTEMC_CXXFLAGS) \
Expand Down

0 comments on commit 388a61e

Please sign in to comment.