Skip to content

Commit

Permalink
Add tests for special characters in beakerlib phase names
Browse files Browse the repository at this point in the history
  • Loading branch information
seberm committed Nov 6, 2024
1 parent 5cfc6e9 commit e343054
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
24 changes: 19 additions & 5 deletions tests/execute/result/special.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/execute/result/special/beaker-phases-special-names.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/execute/result/special/plan.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
discover:
how: fmf
provision:
how: container
execute:
how: tmt
10 changes: 0 additions & 10 deletions tests/execute/result/special/special-chars.fmf

This file was deleted.

9 changes: 9 additions & 0 deletions tests/execute/result/special/test.fmf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e343054

Please sign in to comment.