diff --git a/testsuite/README.md b/testsuite/README.md index 8f55d5ace..f4f3e2ca9 100644 --- a/testsuite/README.md +++ b/testsuite/README.md @@ -95,7 +95,7 @@ These tests are disabled if `showrules` is not found in the The test suite is currently able to use the following developer tools, if they exist in the `TEST_RELEASE` `bin` directory: -`dumpbo`, `vcdcheck`, and `bsc2bsv`. There is also a `dumpba` +`dumpbo`, `vcdcheck`, `bsc2bsv`, and `bsv2bsc`. There is also a `dumpba` tool, which is not being used by the test suite, but could be usefully added. diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp index 1fbb2d931..193974186 100644 --- a/testsuite/config/unix.exp +++ b/testsuite/config/unix.exp @@ -262,6 +262,23 @@ proc which_bsc2bsv {} { return $bsc2bsv } +proc which_bsv2bsc {} { + global env + + if { [info exists BSV2BSC] && [file exists $BSV2BSC] } { + set bsv2bsc [absolute_filename $BSV2BSC] + } elseif { [info exists env(BSV2BSC)] && [file exists $env(BSV2BSC)] } then { + set bsv2bsc [absolute_filename $env(BSV2BSC)] + } else { + set bsv2bsc [which bsv2bsc] + } + if {$bsv2bsc == 0} then { + perror "can't find bsv2bsc -- set BSV2BSC to /path/filename" + exit 1 + } + return $bsv2bsc +} + proc which_dumpbo {} { global env @@ -906,6 +923,11 @@ proc make_bsc2bsv_output_name { file } { return $filename } +proc make_bsv2bsc_output_name { file } { + set filename "$file.bsv2bsc-out" + return $filename +} + proc make_cxx_comp_output_name { source } { set filename "$source.cxx-comp-out" return $filename @@ -1083,6 +1105,25 @@ proc bsc2bsv {source} { return [expr $status == 0] } +proc bsv2bsc {source} { + #do not call this procedure directly, instead use run_bsv2bsc + + global bsv2bsc + global srcdir + global subdir + + set here [absolute $srcdir] + cd [file join $here $subdir] + + set output [make_bsv2bsc_output_name $source] + set cmd "$bsv2bsc $source >& $output" + verbose "Executing: $cmd" 4 + set status [exec_with_log "bsv2bsc" $cmd 2] + + cd $here + return [expr $status == 0] +} + # -u -sim compile @@ -2401,6 +2442,27 @@ proc run_bsc2bsv { source } { } } +## Top level function to run bsv2bsc. +## this is disabled for outside tests, since bsv2bsc is not exported +## in the release. +proc run_bsv2bsc { source } { + global xfail_flag + + bsc_initialize + + if { [do_internal_checks] } { + set current_xfail $xfail_flag + + incr_stat "run_bsv2bsc" + + if [bsv2bsc $source] then { + pass "`$source' passes bsv2bsc" + } else { + fail "`$source' should pass bsv2bsc" + } + } +} + proc absolute_filename { fn } { set path [file dirname $fn] set file [file tail $fn] @@ -3222,6 +3284,7 @@ proc bsc_initialize {} { global dumpbo global vcdcheck global bsc2bsv + global bsv2bsc if {!$bsc_initialized} { @@ -3239,6 +3302,7 @@ proc bsc_initialize {} { set dumpbo [which_dumpbo] set vcdcheck [which_vcdcheck] set bsc2bsv [which_bsc2bsv] + set bsv2bsc [which_bsv2bsc] } # Find the showrules tool @@ -3259,6 +3323,7 @@ proc bsc_initialize {} { verbose -log "Path to dumpbo: $dumpbo" 1 verbose -log "Path to vcdcheck: $vcdcheck" 1 verbose -log "Path to bsc2bsv: $bsc2bsv" 1 + verbose -log "Path to bsv2bsc: $bsv2bsc" 1 } verbose -log "Showrules: $showrules" 1 } diff --git a/testsuite/suitemake.mk b/testsuite/suitemake.mk index 72fba665c..564bf4278 100644 --- a/testsuite/suitemake.mk +++ b/testsuite/suitemake.mk @@ -40,6 +40,7 @@ TEST_SHOWRULES ?= $(TEST_RELEASE)/bin/showrules # These only need to exist when DO_INTERNAL_CHECKS=1 TEST_BSC2BSV ?= $(TEST_RELEASE)/bin/bsc2bsv +TEST_BSV2BSC ?= $(TEST_RELEASE)/bin/bsv2bsc TEST_DUMPBO ?= $(TEST_RELEASE)/bin/dumpbo TEST_VCDCHECK ?= $(TEST_RELEASE)/bin/vcdcheck @@ -57,7 +58,7 @@ TEST_BSC_OPTIONS ?= RUNTESTENV = MAKEFLAGS= BSCTEST=1 \ BSC=$(TEST_BSC) BSC_OPTIONS="${TEST_BSC_OPTIONS}" BSDIR=$(TEST_BSDIR) \ - DUMPBO=$(TEST_DUMPBO) BSC2BSV=$(TEST_BSC2BSV) \ + DUMPBO=$(TEST_DUMPBO) BSC2BSV=$(TEST_BSC2BSV) BSV2BSC=$(TEST_BSV2BSC) \ VCDCHECK=$(TEST_VCDCHECK) SHOWRULES=$(TEST_SHOWRULES) \ BLUESPECDIR=$(BLUESPECDIR) \ BSC_VERILOG_SIM=$(TEST_BSC_VERILOG_SIM) \