Skip to content

Commit 85bcdee

Browse files
committed
rtlil: fix roundtrip test on macOS due to sed non-POSIX non-sense
1 parent 7e6126f commit 85bcdee

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/rtlil/roundtrip-text.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@ YS=../../yosys
33

44
mkdir -p temp
55

6+
# non-POSIX sed -i inconsistency workaround
7+
remove_empty_lines() {
8+
local file="$1"
9+
sed '/^$/d' "$file" > temp/tmp
10+
mv temp/tmp "$file"
11+
}
12+
613
# write_rtlil and dump are equivalent
714
$YS -p "read_verilog -sv everything.v; copy alu zzz; proc zzz; dump -o temp/roundtrip-text.dump.il; write_rtlil temp/roundtrip-text.write.il"
8-
sed '/^$/d' -i.bak temp/roundtrip-text.dump.il
9-
sed '/^$/d' -i.bak temp/roundtrip-text.write.il
15+
remove_empty_lines temp/roundtrip-text.dump.il
16+
remove_empty_lines temp/roundtrip-text.write.il
1017
# Trim first line ("Generated by Yosys ...")
1118
tail -n +2 temp/roundtrip-text.write.il > temp/roundtrip-text.write-nogen.il
1219
diff temp/roundtrip-text.dump.il temp/roundtrip-text.write-nogen.il
1320
diff temp/roundtrip-text.dump.il roundtrip-text.ref.il
1421

1522
# Loading and writing it out again doesn't change the RTLIL
1623
$YS -p "read_rtlil temp/roundtrip-text.dump.il; write_rtlil temp/roundtrip-text.reload.il"
17-
sed '/^$/d' -i.bak temp/roundtrip-text.reload.il
24+
remove_empty_lines temp/roundtrip-text.reload.il
1825
tail -n +2 temp/roundtrip-text.reload.il > temp/roundtrip-text.reload-nogen.il
1926
diff temp/roundtrip-text.dump.il temp/roundtrip-text.reload-nogen.il
2027

2128
# Hashing differences don't change the RTLIL
2229
$YS --hash-seed=2345678 -p "read_rtlil temp/roundtrip-text.dump.il; write_rtlil temp/roundtrip-text.reload-hash.il"
23-
sed '/^$/d' -i.bak temp/roundtrip-text.reload-hash.il
30+
remove_empty_lines temp/roundtrip-text.reload-hash.il
2431
tail -n +2 temp/roundtrip-text.reload-hash.il > temp/roundtrip-text.reload-hash-nogen.il
2532
diff temp/roundtrip-text.dump.il temp/roundtrip-text.reload-hash-nogen.il
2633

2734
echo "Without ABC, we don't get any irreproducibility and can pin that"
2835
echo "Has this test case started failing for you? Consider updating the reference"
2936
$YS -p "read_verilog -sv everything.v; synth -relativeshare -noabc; write_rtlil temp/roundtrip-text.synth.il"
30-
sed '/^$/d' -i.bak temp/roundtrip-text.synth.il
37+
remove_empty_lines temp/roundtrip-text.synth.il
3138
tail -n +2 temp/roundtrip-text.synth.il > temp/roundtrip-text.synth-nogen.il
3239
diff temp/roundtrip-text.synth-nogen.il roundtrip-text.synth.ref.il

0 commit comments

Comments
 (0)