3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 17:15:33 +00:00

tests: Add script tests

Currently provides tests for logging quoted strings.
This commit is contained in:
Krystine Sherwin 2024-08-17 11:33:28 +12:00
parent 3dd32d741a
commit e44d69908b
No known key found for this signature in database
4 changed files with 40 additions and 0 deletions

3
tests/scripts/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.err
*.log
run-test.mk

4
tests/scripts/run-test.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eu
source ../gen-tests-makefile.sh
run_tests --bash

32
tests/scripts/test_logging.sh Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
var=0
rm -f quotes-*.log quotes-*.err
test_log()
{
# Usage: test_log <log_str> <grep_str>
var=$((var + 1))
log_str="$1"
grep_str="$2"
log_file="quotes-$var.log"
../../yosys -QTq -l $log_file -p "log $log_str"
if ! grep -qx "$grep_str" $log_file; then
echo "ERROR: Expected 'yosys> log $log_str' to log '$grep_str'." > "quotes-$var.err"
cat "quotes-$var.err"
fi
}
test_log "test" "test"
test_log "test;" "test"
test_log "test;;" "test"
test_log "\"test" "\"test"
test_log "test\"" "test\""
test_log "\"test\"" "test"
test_log "\"test;\"" "test;"
test_log "\"test;;\"" "test;;"
test_log "\"test\" abc" "\"test\" abc"
if [ -f quotes-*.err ] ; then
exit 1
fi