From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/skiboot/external/gard/test/add_test.sh | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 roms/skiboot/external/gard/test/add_test.sh (limited to 'roms/skiboot/external/gard/test/add_test.sh') diff --git a/roms/skiboot/external/gard/test/add_test.sh b/roms/skiboot/external/gard/test/add_test.sh new file mode 100755 index 000000000..6523dffc6 --- /dev/null +++ b/roms/skiboot/external/gard/test/add_test.sh @@ -0,0 +1,67 @@ +#!/bin/bash -uex +# +# this is a really dumb script for auto-generating test cases from known good-data +# +# usage: ./add_test [opal-gard subcommand] +# +# e.g. +# ./add_test.sh fail blank.bin create-bad-instance create /sys256 +# ./add_test.sh pass blank.bin create-normal create /sys0/node0/proc0 +# +# this will generate a test script file and writes the stdout/stderr of the command +# to the respective files. +# + +cd $(dirname $(realpath $0))/../ +echo $PWD + +if [ "$1" = "pass" ]; then + check='if [ "$?" -ne 0 ]; then' + test_type="pass" +else + check='if [ "$?" -eq 0 ]; then' + test_type="fails" +fi +shift + +file="test/files/$1" +if [ ! -f "$file" ]; then + echo "test file not found!" + exit 1; +fi +shift + +name="$1" +shift + +max="$(ls test/tests/ -1|sort -n | sed 's@\(..\).*@\1@' | tail -1 | sed s@^0*@@)" +num="$(printf %02d $((max + 1)))" + +echo "Adding: $num-$name" + +# where we will write the script file +script_file="test/tests/$num-$name" + +echo "making $num-$name: f=$script_file, normally $test_type, cmd='$*'" + +cat > $script_file <$stderr_file >$stdout_file +rm -f $test_input -- cgit 1.2.3-korg