Skip to content

Commit

Permalink
Testsuite: Add run_bsv2bsc command
Browse files Browse the repository at this point in the history
This is cargo-culted from the existing `run_bsc2bsv` command. This will be used
in a subsequent commit which adds a test case requiring `bsv2bsc` (see B-Lang-org#529).
  • Loading branch information
RyanGlScott committed Jan 6, 2023
1 parent b287fcb commit f897d70
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion testsuite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
65 changes: 65 additions & 0 deletions testsuite/config/unix.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -3222,6 +3284,7 @@ proc bsc_initialize {} {
global dumpbo
global vcdcheck
global bsc2bsv
global bsv2bsc


if {!$bsc_initialized} {
Expand All @@ -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
Expand All @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion testsuite/suitemake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) \
Expand Down

0 comments on commit f897d70

Please sign in to comment.