1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. . "$TF_DIR/include/subtest.sh"
  3. . "$TF_DIR/include/tools.sh"
  4. PRETTY=plain
  5. . "$(shellfu-get path)" || tf_exit_error "failed to init shellfu"
  6. shellfu import saturnin || tf_exit_error "failed to import saturnin"
  7. tf_enum_subtests() {
  8. echo unknown
  9. echo unknown_dash1
  10. echo unknown_dash2
  11. echo unknown_none
  12. echo unknown_same
  13. echo saturnin_conf_path
  14. echo app_version
  15. echo cache_home
  16. echo libexec
  17. echo libexec_prefix
  18. # warn "unknown devel key: $key"
  19. }
  20. rndtoken() {
  21. head -c 100 /dev/urandom | md5sum | head -c 7
  22. }
  23. ckfuzzy() {
  24. local es
  25. local out="result/$name.stdout"
  26. mkdir -p result
  27. cat > "$out"
  28. case "$name" in
  29. saturnin_conf_path) grep -qx "$SATURNIN_CONF_PATH" ;;
  30. app_version) grep -q '[0-9]' ;;
  31. cache_home) grep -qx "$SATURNIN_CACHE_HOME" ;;
  32. libexec) grep -qx "$SATURNIN_LIBEXEC" ;;
  33. libexec_prefix) grep -qx "$SATURNIN_LIBEXEC_PREFIX" ;;
  34. esac <"$out"; es=$?
  35. if test $es -gt 0;
  36. then
  37. tf_warn "bad output format"
  38. cat "$out"
  39. return "$TF_ES_FAIL"
  40. fi
  41. }
  42. tf_do_subtest() {
  43. local name=$1
  44. local o_err="oracle/$name.stderr"
  45. SATURNIN_APP_VERSION=1.2.3
  46. SATURNIN_CACHE_HOME=chm_$(rndtoken)
  47. SATURNIN_CONF_PATH=cp_$(rndtoken)
  48. SATURNIN_LIBEXEC=lex_$(rndtoken)
  49. SATURNIN_LIBEXEC_PREFIX=lexpfx_$(rndtoken)
  50. case $name in
  51. unknown) tf_testflt -n "$name" -E "$o_err" -S 2 saturnin__main --saturnin-get-foo ;;
  52. unknown_dash1) tf_testflt -n "$name" -E "$o_err" -S 2 saturnin__main --saturnin-get-- ;;
  53. unknown_dash2) tf_testflt -n "$name" -E "$o_err" -S 2 saturnin__main --saturnin-get--- ;;
  54. unknown_none) tf_testflt -n "$name" -E "$o_err" -S 2 saturnin__main --saturnin-get- ;;
  55. unknown_same) tf_testflt -n "$name" -E "$o_err" -S 2 saturnin__main --saturnin-get---saturnin-get ;;
  56. saturnin_conf_path) saturnin__main --saturnin-get-saturnin-conf-path | ckfuzzy ;;
  57. app_version) saturnin__main --saturnin-get-app-version | ckfuzzy ;;
  58. cache_home) saturnin__main --saturnin-get-cache-home | ckfuzzy ;;
  59. libexec) saturnin__main --saturnin-get-libexec | ckfuzzy ;;
  60. libexec_prefix) saturnin__main --saturnin-get-libexec-prefix | ckfuzzy ;;
  61. esac
  62. }
  63. tf_do_subtests