run-test.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. cd "$(dirname $0)"
  3. "$DINIT_EXEC" -d sd -u -p socket -q main &
  4. DINITPID=$!
  5. # give time for socket to open
  6. while [ ! -e socket ]; do
  7. sleep 0.1
  8. done
  9. STATUS=FAIL
  10. DINITCTL=""$DINITCTL_EXEC" -p socket"
  11. while
  12. stage=1
  13. out=$($DINITCTL list)
  14. if [ $? != 0 ]; then break; fi
  15. if [ "$out" != "$(cat expected1)" ]; then break; fi
  16. # both "main" and "secondary" should be running
  17. stage=2
  18. out=$($DINITCTL rm-dep waits-for main secondary)
  19. if [ $? != 0 ]; then break; fi
  20. if [ "$out" != "$(cat expected2)" ]; then break; fi
  21. # "secondary" should stop
  22. stage=3
  23. out=$($DINITCTL list)
  24. if [ $? != 0 ]; then break; fi
  25. if [ "$out" != "$(cat expected3)" ]; then break; fi
  26. stage=4
  27. out=$($DINITCTL add-dep waits-for main secondary)
  28. if [ $? != 0 ]; then break; fi
  29. if [ "$out" != "$(cat expected4)" ]; then break; fi
  30. # "secondary" will not automatically start, this is a waits-for dep
  31. stage=5
  32. out=$($DINITCTL list)
  33. if [ $? != 0 ]; then break; fi
  34. if [ "$out" != "$(cat expected3)" ]; then break; fi
  35. stage=6
  36. out=$($DINITCTL wake secondary)
  37. if [ $? != 0 ]; then break; fi
  38. if [ "$out" != "$(cat expected5)" ]; then break; fi
  39. # if we wake "secondary" it should start and remain started
  40. stage=7
  41. out=$($DINITCTL list)
  42. if [ $? != 0 ]; then break; fi
  43. if [ "$out" != "$(cat expected1)" ]; then break; fi
  44. STATUS=PASS
  45. false
  46. do :; done
  47. kill $DINITPID
  48. wait $DINITPID
  49. if [ $STATUS = PASS ]; then exit 0; fi
  50. echo "failed at stage $stage, with output:" > actual
  51. echo "$out" >> actual
  52. exit 1