Skip to content

Commit 47fa75b

Browse files
tests: Add script tests
Currently provides tests for logging quoted strings.
1 parent 9c5ecfd commit 47fa75b

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ endif
821821
+cd tests/various && bash run-test.sh
822822
+cd tests/select && bash run-test.sh
823823
+cd tests/sat && bash run-test.sh
824+
+cd tests/scripts && bash run-test.sh
824825
+cd tests/sim && bash run-test.sh
825826
+cd tests/svinterfaces && bash run-test.sh $(SEEDOPT)
826827
+cd tests/svtypes && bash run-test.sh $(SEEDOPT)

tests/scripts/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.err
2+
*.log
3+
run-test.mk

tests/scripts/run-test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
source ../gen-tests-makefile.sh
4+
run_tests --bash

tests/scripts/test_logging.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
var=0
4+
rm -f quotes-*.log quotes-*.err
5+
6+
test_log()
7+
{
8+
# Usage: test_log <log_str> <grep_str>
9+
var=$((var + 1))
10+
log_str="$1"
11+
grep_str="$2"
12+
log_file="quotes-$var.log"
13+
../../yosys -QTq -l $log_file -p "log $log_str"
14+
if ! grep -qx "$grep_str" $log_file; then
15+
echo "ERROR: Expected 'yosys> log $log_str' to log '$grep_str'." > "quotes-$var.err"
16+
cat "quotes-$var.err"
17+
fi
18+
}
19+
20+
test_log "test" "test"
21+
test_log "test;" "test"
22+
test_log "test;;" "test"
23+
test_log "\"test" "\"test"
24+
test_log "test\"" "test\""
25+
test_log "\"test\"" "test"
26+
test_log "\"test;\"" "test;"
27+
test_log "\"test;;\"" "test;;"
28+
test_log "\"test\" abc" "\"test\" abc"
29+
30+
if [ -f quotes-*.err ] ; then
31+
exit 1
32+
fi

0 commit comments

Comments
 (0)