@@ -8,8 +8,18 @@ rlJournalStart
88 rlRun " run=\$ (mktemp -d)" 0 " Creating run directory/id"
99 rlPhaseEnd
1010
11+ function assert_result () {
12+ name=" $1 "
13+ serial=" $2 "
14+ result=" $3 "
15+ guest=" $4 "
16+ note=" $5 "
17+ file=" ${run} /plans/execute/results.yaml"
18+ actual=$( yq -er " .[] | \"\\ (.name) \\ (.\" serial-number\" ) \\ (.result) \\ (.guest.name) \\ (if .note == [] then \"\" else ((.note[] | select(. == \" $note \" )) // .note[0]) end)\" " " $file " )
19+ rlAssertEquals " Check result for $name " " $actual " " $name $serial $result $guest $note "
20+ }
21+
1122 tmt_command=" tmt run --scratch -a --id ${run} provision --how local execute -vv report -vvv test --name"
12- extract_results_command=" yq -er '.[] | \"\\ (.name) \\ (.\" serial-number\" ) \\ (.result) \\ (.guest.name) \\ (.note[0])\" '"
1323
1424 testName=" /tests/pass"
1525 rlPhaseStartTest " ${testName} "
@@ -21,8 +31,7 @@ rlJournalStart
2131 # tmt prints the correct result into log
2232 rlAssertGrep " pass /tests/pass" $rlRun_LOG
2333 # tmt saves the correct results, including note, into results yaml
24- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
25- rlAssertGrep " /tests/pass 1 pass default-0 null" $rlRun_LOG
34+ assert_result " /tests/pass" " 1" " pass" " default-0" " "
2635 rlPhaseEnd
2736
2837 testName=" /tests/fail"
@@ -35,8 +44,7 @@ rlJournalStart
3544 # tmt prints the correct result into log
3645 rlAssertGrep " fail /tests/fail" $rlRun_LOG
3746 # tmt saves the correct results, including note, into results yaml
38- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
39- rlAssertGrep " /tests/fail 1 fail default-0 null" $rlRun_LOG
47+ assert_result " /tests/fail" " 1" " fail" " default-0" " "
4048 rlPhaseEnd
4149
4250 testName=" /tests/warn"
@@ -49,8 +57,7 @@ rlJournalStart
4957 # tmt prints the correct result into log
5058 rlAssertGrep " warn /tests/warn" $rlRun_LOG
5159 # tmt saves the correct results, including note, into results yaml
52- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
53- rlAssertGrep " /tests/warn 1 warn default-0 null" $rlRun_LOG
60+ assert_result " /tests/warn" " 1" " warn" " default-0" " "
5461 rlPhaseEnd
5562
5663 testName=" /tests/worst"
@@ -67,8 +74,7 @@ rlJournalStart
6774 # tmt prints the correct result into log
6875 rlAssertGrep " fail /tests/worst" $rlRun_LOG
6976 # tmt saves the correct results, including note, into results yaml
70- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
71- rlAssertGrep " /tests/worst 1 fail default-0 null" $rlRun_LOG
77+ assert_result " /tests/worst" " 1" " fail" " default-0" " "
7278 rlPhaseEnd
7379
7480 testName=" /tests/timeout"
@@ -85,8 +91,7 @@ rlJournalStart
8591 rlAssertGrep " Maximum test time '5m' exceeded." $rlRun_LOG
8692 rlAssertGrep " Adjust the test 'duration' attribute if necessary." $rlRun_LOG
8793 # tmt saves the correct results, including note, into results yaml
88- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
89- rlAssertGrep " /tests/timeout 1 error default-0 timeout" $rlRun_LOG
94+ assert_result " /tests/timeout" " 1" " error" " default-0" " check 'internal/timeout' failed"
9095 rlPhaseEnd
9196
9297 testName=" /tests/pidlock"
@@ -102,8 +107,7 @@ rlJournalStart
102107 rlAssertGrep " pidfile locking" $rlRun_LOG
103108 rlAssertGrep " warn: Test failed to manage its pidfile." $rlRun_LOG
104109 # tmt saves the correct results, including note, into results yaml
105- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
106- rlAssertGrep " /tests/pidlock 1 error default-0 pidfile locking" $rlRun_LOG
110+ assert_result " /tests/pidlock" " 1" " error" " default-0" " check 'internal/invocation' failed"
107111 rlPhaseEnd
108112
109113 testName=" /tests/incomplete-fail"
@@ -119,8 +123,7 @@ rlJournalStart
119123 rlAssertGrep " errr /tests/incomplete-fail" $rlRun_LOG
120124 rlAssertGrep " beakerlib: State 'incomplete'" $rlRun_LOG
121125 # tmt saves the correct results, including note, into results yaml
122- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
123- rlAssertGrep " /tests/incomplete-fail 1 error default-0 beakerlib: State 'incomplete'" $rlRun_LOG
126+ assert_result " /tests/incomplete-fail" " 1" " error" " default-0" " beakerlib: State 'incomplete'"
124127 rlPhaseEnd
125128
126129 testName=" /tests/incomplete-pass"
@@ -136,8 +139,7 @@ rlJournalStart
136139 rlAssertGrep " errr /tests/incomplete-pass" $rlRun_LOG
137140 rlAssertGrep " beakerlib: State 'incomplete'" $rlRun_LOG
138141 # tmt saves the correct results, including note, into results yaml
139- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
140- rlAssertGrep " /tests/incomplete-pass 1 error default-0 beakerlib: State 'incomplete'" $rlRun_LOG
142+ assert_result " /tests/incomplete-pass" " 1" " error" " default-0" " beakerlib: State 'incomplete'"
141143 rlPhaseEnd
142144
143145 testName=" /tests/notfound"
@@ -152,8 +154,7 @@ rlJournalStart
152154 rlAssertGrep " beakerlib: TestResults FileError" $rlRun_LOG
153155 rlAssertGrep " No such file or directory" $rlRun_LOG
154156 # tmt saves the correct results, including note, into results yaml
155- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
156- rlAssertGrep " /tests/notfound 1 error default-0 beakerlib: TestResults FileError" $rlRun_LOG
157+ assert_result " /tests/notfound" " 1" " error" " default-0" " beakerlib: TestResults FileError"
157158 rlPhaseEnd
158159
159160 testName=" /tests/notexec"
@@ -168,8 +169,7 @@ rlJournalStart
168169 rlAssertGrep " beakerlib: TestResults FileError" $rlRun_LOG
169170 rlAssertGrep " Permission denied" $rlRun_LOG
170171 # tmt saves the correct results, including note, into results yaml
171- rlRun -s " ${extract_results_command} ${run} /plans/execute/results.yaml"
172- rlAssertGrep " /tests/notexec 1 error default-0 beakerlib: TestResults FileError" $rlRun_LOG
172+ assert_result " /tests/notexec" " 1" " error" " default-0" " beakerlib: TestResults FileError"
173173 rlPhaseEnd
174174
175175 rlPhaseStartCleanup
0 commit comments