1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #!/bin/bash
- # shellcheck disable=SC2154
-
- shellfu import jat
- shellfu import jat_dump
- shellfu import preupg
- shellfu import xcase
-
- xcase__enum() {
-
- echo mresult=error,verbose=on
- echo mresult=failed,verbose=on
- echo mresult=fixed,verbose=on
- echo mresult=informational,verbose=on
- echo mresult=needs_action,verbose=on
- echo mresult=needs_inspection,verbose=on
- echo mresult=not_applicable,verbose=on
- echo mresult=pass,verbose=on
-
- echo mresult=error,verbose=off
- echo mresult=failed,verbose=off
- echo mresult=fixed,verbose=off
- echo mresult=informational,verbose=off
- echo mresult=needs_action,verbose=off
- echo mresult=needs_inspection,verbose=off
- echo mresult=not_applicable,verbose=off
- echo mresult=pass,verbose=off
- }
-
-
- xcase__setup() {
- PREUPG__UPATH="@$mresult" \
- preupg__run1 --skip-common; echo $?>o_paes
- }
-
-
- xcase__test() {
- local t_vrbarg='' # test: verbose argument
- local o_es=0 # oracle: exit status
- local o_out=false # oracle: any stdout?
- local o_err=false # oracle: any stderr?
- local r_es=0 # result: exit status
- local o_paes # oracle: preupg exit status
- o_paes=$(<o_paes)
-
- case $mresult:$verbose in
- failed:on) o_out=true; t_vrbarg="--verbose" ;;
- esac
- case $mresult in
- error) o_es=2 ;;
- failed) o_es=2 ;;
- fixed) o_es=0 ;;
- informational) o_es=0 ;;
- needs_action) o_es=1 ;;
- needs_inspection) o_es=0 ;;
- not_applicable) o_es=0 ;;
- pass) o_es=0 ;;
- esac
-
- jat__cmd -o preupg.out -e preupg.err -S $o_es \
- preupg --riskcheck $t_vrbarg; r_es=$?
- preupg__LibraryLimited loscap "HTML generation warning removed" \
- && jat__eval "sed -i '/Generating simply styled report due to the limitations of the installed OpenSCAP/d' preupg.out"
- #FIXME: the message should be in stderr after https://github.com/upgrades-migrations/preupgrade-assistant/issues/315
- jat__cmp -h "exit status corresponds to module result" \
- "$r_es" eq "$o_es"
- jat__cmp -h "exit status is the same as of preupg" \
- "$r_es" eq "$o_paes"
- $o_out && jat__cmd -S 0 -h "there is some stdout" test -s preupg.out
- $o_out || jat__cmd -S 1 -h "there is no stdout" test -s preupg.out
- $o_err && jat__cmd -S 0 -h "there is some stderr" test -s preupg.err
- $o_err || jat__cmd -S 1 -h "there is no stderr" test -s preupg.err
- }
-
- xcase__diag() {
- jat_dump__file preupg.out preupg.err
- }
-
- xcase__cleanup() {
- preupg__rmresult
- }
-
- PREUPG__UPATH=@pass \
- preupg__Run1
- xcase__run -v
- preupg__Cleanup
|