From e34305482a3ccdba4d363399bce0ade5518d4e0e Mon Sep 17 00:00:00 2001 From: Otto Sabart Date: Wed, 6 Nov 2024 14:10:00 +0100 Subject: [PATCH] Add tests for special characters in beakerlib phase names --- tests/execute/result/special.sh | 24 +++++++++++++++---- .../special/beaker-phases-special-names.sh | 19 +++++++++++++++ tests/execute/result/special/plan.fmf | 6 +++++ .../execute/result/special/special-chars.fmf | 10 -------- tests/execute/result/special/test.fmf | 9 +++++++ 5 files changed, 53 insertions(+), 15 deletions(-) create mode 100755 tests/execute/result/special/beaker-phases-special-names.sh create mode 100644 tests/execute/result/special/plan.fmf delete mode 100644 tests/execute/result/special/special-chars.fmf create mode 100644 tests/execute/result/special/test.fmf diff --git a/tests/execute/result/special.sh b/tests/execute/result/special.sh index 2566710da4..3757245fc5 100755 --- a/tests/execute/result/special.sh +++ b/tests/execute/result/special.sh @@ -10,12 +10,26 @@ rlJournalStart rlPhaseStartTest "Check characters are correctly escaped in tmt-report-result output" rlRun -s "tmt run -v -i $run" 0 - RESULT_FILE="$run/special-chars/execute/data/guest/default-0/0-7-special-characters-in-the-name-1/data/tmt-report-results.yaml" - rlRun "yq -e '.' $RESULT_FILE" 0 "Check the YAML is valid" + # Basic test for special chars + RESULT_FILE_BASIC="$run/plan/execute/data/guest/default-0/test/0-7-special-characters-in-the-name-1/data/tmt-report-results.yaml" + rlRun "yq -e '.' $RESULT_FILE_BASIC" 0 "Check the YAML is valid" - rlAssertGrep 'name: "/0\.\.7 \\"special\\": \\" characters: \*\$@|&>< in: the: name"' "$RESULT_FILE" - rlAssertGrep "result: \"pass\"" "$RESULT_FILE" - rlAssertGrep "end-time: \".*\"" "$RESULT_FILE" + rlAssertGrep 'name: "/0\.\.7 \\"special\\": \\" characters: \*\$@|&>< in: the: name"' "$RESULT_FILE_BASIC" + rlAssertGrep "result: \"pass\"" "$RESULT_FILE_BASIC" + rlAssertGrep "end-time: \".*\"" "$RESULT_FILE_BASIC" + + # Beakerlib phase names with special chars + RESULT_FILE_BKRLIB="$run/plan/execute/data/guest/default-0/test/beakerlib-special-names-2/data/tmt-report-results.yaml" + for phase_name in \ + '/sbin-ldconfig' \ + '/usr-sbin-ldconfig' \ + '/01-some-phase-na-me' \ + '/02-so-me-phase-na-me' + do + rlAssertGrep "name: \"${phase_name}\"" "$RESULT_FILE_BKRLIB" + rlAssertGrep "result: \"pass\"" "$RESULT_FILE_BKRLIB" + rlAssertGrep "end-time: \".*\"" "$RESULT_FILE_BKRLIB" + done rlPhaseEnd rlPhaseStartCleanup diff --git a/tests/execute/result/special/beaker-phases-special-names.sh b/tests/execute/result/special/beaker-phases-special-names.sh new file mode 100755 index 0000000000..3a56d99066 --- /dev/null +++ b/tests/execute/result/special/beaker-phases-special-names.sh @@ -0,0 +1,19 @@ +#!/bin/bash +. /usr/share/beakerlib/beakerlib.sh || exit 1 + + +rlJournalStart + for i in \ + # Ensure the regression from #teemtee/tmt/3333 is covered + /sbin/ldconfig \ + /usr/sbin/ldconfig \ + + # Cover other special characters in the phase name + '//01_some/-phase//na--me-' \ + '\$02_so\$me<->phase?!*na--me/-' + do + rlPhaseStartTest "$i" + rlRun "phase-name: ${i}" + rlPhaseEnd + done +rlJournalEnd diff --git a/tests/execute/result/special/plan.fmf b/tests/execute/result/special/plan.fmf new file mode 100644 index 0000000000..b95e5cdaa1 --- /dev/null +++ b/tests/execute/result/special/plan.fmf @@ -0,0 +1,6 @@ +discover: + how: fmf +provision: + how: container +execute: + how: tmt diff --git a/tests/execute/result/special/special-chars.fmf b/tests/execute/result/special/special-chars.fmf deleted file mode 100644 index db11257e61..0000000000 --- a/tests/execute/result/special/special-chars.fmf +++ /dev/null @@ -1,10 +0,0 @@ -execute: - how: tmt -discover: - how: shell - tests: - - name: '0..7 special: characters: *$@|&>< in: the: name' - result: restraint - test: "tmt-report-result '0..7 \"special\": \" characters: *$@|&>< in: the: name' PASS" -provision: - how: container diff --git a/tests/execute/result/special/test.fmf b/tests/execute/result/special/test.fmf new file mode 100644 index 0000000000..7f6b242f67 --- /dev/null +++ b/tests/execute/result/special/test.fmf @@ -0,0 +1,9 @@ +"/0..7 special: characters: *$@|&>< in: the: name": + summary: Basic test with special characters in the test/subtest name + result: restraint + test: "tmt-report-result '0..7 \"special\": \" characters: *$@|&>< in: the: name' PASS" + +/beakerlib-special-names: + summary: Beakerlib phases with special characters + framework: beakerlib + test: ./beaker-phases-special-names.sh