From dcc721a95bef6f0d8e6d8775b8efe33e5aecd562 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 18:28:20 +0200 Subject: Adding upstream version 8.2402.0. Signed-off-by: Daniel Baumann --- tests/testsuites/omprog-transactions-bin.sh | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 tests/testsuites/omprog-transactions-bin.sh (limited to 'tests/testsuites/omprog-transactions-bin.sh') diff --git a/tests/testsuites/omprog-transactions-bin.sh b/tests/testsuites/omprog-transactions-bin.sh new file mode 100755 index 0000000..a8be3e4 --- /dev/null +++ b/tests/testsuites/omprog-transactions-bin.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +outfile=$RSYSLOG_OUT_LOG + +status="OK" +echo "<= $status" >> $outfile +echo $status + +in_transaction=false +fail_on_commit=false +retry_count=0 + +read line +while [[ -n "$line" ]]; do + message=${line//$'\n'} + echo "=> $message" >> $outfile + + if [[ "$message" == "BEGIN TRANSACTION" ]]; then + in_transaction=true + status="OK" + elif [[ "$message" == "COMMIT TRANSACTION" ]]; then + in_transaction=false + if [[ $fail_on_commit == true ]]; then + status="Error: could not commit transaction" + fail_on_commit=false + else + status="OK" + fi + else + if [[ $in_transaction == true ]]; then + status="DEFER_COMMIT" + else + # Should not occur + status="Error: received a message out of a transaction" + fi + fi + + # First command line argument ($1) indicates whether to test for negative + # cases. If --failed_messages is specified, an error is returned for certain + # messages, forcing them to be retried twice. If --failed_commits is + # specified, the error is returned when committing the transaction. + if [[ "$1" != "" && ($message == *04* || $message == *07*) ]]; then + if [[ $retry_count < 2 ]]; then + if [[ "$1" == "--failed_commits" ]]; then + fail_on_commit=true + else + status="Error: could not process log message" + fi + let "retry_count++" + else + retry_count=0 + fi + fi + + echo "<= $status" >> $outfile + echo $status + read line +done + +exit 0 -- cgit v1.2.3