Merge pull request #497 from hzeller/20230426-canonicalize-paths

Canonicalize paths used in tests.
diff --git a/clockgating-plugin/tests/regfile/regfile.tcl b/clockgating-plugin/tests/regfile/regfile.tcl
index 22bd9d6..b96ce2e 100644
--- a/clockgating-plugin/tests/regfile/regfile.tcl
+++ b/clockgating-plugin/tests/regfile/regfile.tcl
@@ -1,18 +1,20 @@
 yosys -import
-if { [info procs getparam] == {} } { plugin -i params }
+if { [info procs reg_clock_gating] == {} } { plugin -i clockgating }
 yosys -import  ;# ingest plugin commands
 
+set LIBDIR [file dirname $::env(DESIGN_TOP)]/lib
+
 read_verilog $::env(DESIGN_TOP).v
-read_liberty -lib -ignore_miss_dir -setattr blackbox ./lib/sky130_fd_sc_hd.lib 
-read_verilog ./lib/sky130_hd_clkg_blackbox.v
+read_liberty -lib -ignore_miss_dir -setattr blackbox $LIBDIR/sky130_fd_sc_hd.lib
+read_verilog $LIBDIR/sky130_hd_clkg_blackbox.v
 hierarchy -check -auto-top
 
 
-reg_clock_gating ./lib/sky130_hd_ff_map.v
+reg_clock_gating $LIBDIR/sky130_hd_ff_map.v
 opt_clean -purge
 synth -top top
-dfflibmap -liberty ./lib/sky130_fd_sc_hd.lib 
-abc -D 1250 -liberty ./lib/sky130_fd_sc_hd.lib 
+dfflibmap -liberty $LIBDIR/sky130_fd_sc_hd.lib
+abc -D 1250 -liberty $LIBDIR/sky130_fd_sc_hd.lib
 splitnets
 opt_clean -purge
 hilomap -hicell sky130_fd_sc_hd__conb_1 HI -locell sky130_fd_sc_hd__conb_1 LO
@@ -21,7 +23,6 @@
 insbuf -buf sky130_fd_sc_hd__buf_2 A X
 dffinit
 flatten
-opt;; 
+opt;;
 #check
-write_verilog -noattr -noexpr -nohex -nodec -defparam clockgated_regfile.v
-            
\ No newline at end of file
+write_verilog -noattr -noexpr -nohex -nodec -defparam [test_output_path "clockgated_regfile.v"]
diff --git a/systemverilog-plugin/tests/break_continue/break_continue.tcl b/systemverilog-plugin/tests/break_continue/break_continue.tcl
index 166c38e..911db18 100644
--- a/systemverilog-plugin/tests/break_continue/break_continue.tcl
+++ b/systemverilog-plugin/tests/break_continue/break_continue.tcl
@@ -10,4 +10,4 @@
 # Testing simple round-trip
 read_systemverilog -o $TMP_DIR/break-continue-test $::env(DESIGN_TOP).v
 prep
-write_table $::env(DESIGN_TOP).out
+write_table [test_output_path $::env(DESIGN_TOP).out]
diff --git a/systemverilog-plugin/tests/defaults/defaults.tcl b/systemverilog-plugin/tests/defaults/defaults.tcl
index a363895..6639834 100644
--- a/systemverilog-plugin/tests/defaults/defaults.tcl
+++ b/systemverilog-plugin/tests/defaults/defaults.tcl
@@ -12,12 +12,12 @@
 # Stash it
 systemverilog_defaults -push
 systemverilog_defaults -clear
-read_systemverilog $::env(DESIGN_TOP).v
+read_systemverilog -o $TMP_DIR/defaults-test $::env(DESIGN_TOP).v
 # Allow parsing the module again
 delete top
 systemverilog_defaults -pop
 # Skip check for forbidden value
 systemverilog_defaults -add -Pbypass=1
-read_systemverilog $::env(DESIGN_TOP).v
+read_systemverilog -o $TMP_DIR/defaults-test $::env(DESIGN_TOP).v
 hierarchy
 write_verilog
diff --git a/systemverilog-plugin/tests/defines/defines.tcl b/systemverilog-plugin/tests/defines/defines.tcl
index 030c1ad..81a93d4 100644
--- a/systemverilog-plugin/tests/defines/defines.tcl
+++ b/systemverilog-plugin/tests/defines/defines.tcl
@@ -10,6 +10,6 @@
 systemverilog_defines -DPONA
 systemverilog_defines -DPAKALA
 systemverilog_defines -UPAKALA
-read_systemverilog $::env(DESIGN_TOP).v
+read_systemverilog -o $TMP_DIR/defines-test $::env(DESIGN_TOP).v
 hierarchy
 write_verilog
diff --git a/systemverilog-plugin/tests/formal/formal.tcl b/systemverilog-plugin/tests/formal/formal.tcl
index 2474219..e383c08 100644
--- a/systemverilog-plugin/tests/formal/formal.tcl
+++ b/systemverilog-plugin/tests/formal/formal.tcl
@@ -7,6 +7,6 @@
   set TMP_DIR $::env(TMPDIR)
 }
 
-read_systemverilog -formal $::env(DESIGN_TOP).v
+read_systemverilog -o $TMP_DIR/formal-test -formal $::env(DESIGN_TOP).v
 hierarchy
 write_verilog
diff --git a/test-utils/test-utils.tcl b/test-utils/test-utils.tcl
index cc215ae..1b1188a 100644
--- a/test-utils/test-utils.tcl
+++ b/test-utils/test-utils.tcl
@@ -3,5 +3,6 @@
 # Return path where the test output file "filename"
 # is to be written.
 proc test_output_path { filename } {
+    file mkdir [file dirname "$::env(TEST_OUTPUT_PREFIX)${filename}"]
     return "$::env(TEST_OUTPUT_PREFIX)${filename}"
 }