Poor man's XPath library https://pagure.io/shellfu-bash-pxpath

TF_RUN 606B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. #shellcheck disable=SC1090
  3. . "$TF_DIR/include/subtest.sh"
  4. . "$TF_DIR/include/tools.sh"
  5. tf_enum_subtests() {
  6. echo one
  7. echo two
  8. echo three
  9. }
  10. my_sut() {
  11. local word=$1
  12. declare -A map
  13. map[one]=1
  14. map[two]=2
  15. map[three]=33
  16. echo "${map[$word]}"
  17. }
  18. mkoracle() {
  19. mkdir -p oracle
  20. case $subtest in
  21. one) echo 1 ;;
  22. two) echo 2 ;;
  23. three) echo 3 ;;
  24. esac > "oracle/$subtest.stdout"
  25. }
  26. tf_do_subtest() {
  27. local subtest=$1
  28. mkoracle
  29. tf_testflt -n "$subtest" -O "oracle/$subtest.stdout" "my_sut $subtest"
  30. }
  31. tf_do_subtests