test 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. # shellcheck disable=SC2154
  3. shellfu import jat
  4. shellfu import jat_dump
  5. shellfu import preupg
  6. shellfu import xcase
  7. xcase__enum() {
  8. echo mresult=error,verbose=on
  9. echo mresult=failed,verbose=on
  10. echo mresult=fixed,verbose=on
  11. echo mresult=informational,verbose=on
  12. echo mresult=needs_action,verbose=on
  13. echo mresult=needs_inspection,verbose=on
  14. echo mresult=not_applicable,verbose=on
  15. echo mresult=pass,verbose=on
  16. echo mresult=error,verbose=off
  17. echo mresult=failed,verbose=off
  18. echo mresult=fixed,verbose=off
  19. echo mresult=informational,verbose=off
  20. echo mresult=needs_action,verbose=off
  21. echo mresult=needs_inspection,verbose=off
  22. echo mresult=not_applicable,verbose=off
  23. echo mresult=pass,verbose=off
  24. }
  25. xcase__setup() {
  26. PREUPG__UPATH="@$mresult" \
  27. preupg__run1 --skip-common; echo $?>o_paes
  28. }
  29. xcase__test() {
  30. local t_vrbarg='' # test: verbose argument
  31. local o_es=0 # oracle: exit status
  32. local o_out=false # oracle: any stdout?
  33. local o_err=false # oracle: any stderr?
  34. local r_es=0 # result: exit status
  35. local o_paes # oracle: preupg exit status
  36. o_paes=$(<o_paes)
  37. case $mresult:$verbose in
  38. failed:on) o_out=true; t_vrbarg="--verbose" ;;
  39. esac
  40. case $mresult in
  41. error) o_es=2 ;;
  42. failed) o_es=2 ;;
  43. fixed) o_es=0 ;;
  44. informational) o_es=0 ;;
  45. needs_action) o_es=1 ;;
  46. needs_inspection) o_es=0 ;;
  47. not_applicable) o_es=0 ;;
  48. pass) o_es=0 ;;
  49. esac
  50. jat__cmd -o preupg.out -e preupg.err -S $o_es \
  51. preupg --riskcheck $t_vrbarg; r_es=$?
  52. preupg__LibraryLimited loscap "HTML generation warning removed" \
  53. && jat__eval "sed -i '/Generating simply styled report due to the limitations of the installed OpenSCAP/d' preupg.out"
  54. #FIXME: the message should be in stderr after https://github.com/upgrades-migrations/preupgrade-assistant/issues/315
  55. jat__cmp -h "exit status corresponds to module result" \
  56. "$r_es" eq "$o_es"
  57. jat__cmp -h "exit status is the same as of preupg" \
  58. "$r_es" eq "$o_paes"
  59. $o_out && jat__cmd -S 0 -h "there is some stdout" test -s preupg.out
  60. $o_out || jat__cmd -S 1 -h "there is no stdout" test -s preupg.out
  61. $o_err && jat__cmd -S 0 -h "there is some stderr" test -s preupg.err
  62. $o_err || jat__cmd -S 1 -h "there is no stderr" test -s preupg.err
  63. }
  64. xcase__diag() {
  65. jat_dump__file preupg.out preupg.err
  66. }
  67. xcase__cleanup() {
  68. preupg__rmresult
  69. }
  70. PREUPG__UPATH=@pass \
  71. preupg__Run1
  72. xcase__run -v
  73. preupg__Cleanup