test.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Cursory tests that things are set up
  3. docker run --name "tp-analysis-test" --rm -d -i tp-analysis:latest || exit 1
  4. # Check that dependencies are installed
  5. docker exec tp-analysis-test sh -c "cd /home/analysis/belarus-2020-2021 && command -v curl && command -v python3 && ./scripts/check-python-deps.py" || exit 1
  6. # Check that we can compile LaTeX
  7. cp parsing-results/table-header.tex test-table.tex && \
  8. cat parsing-results/troll-patrol-table-header.tex >> test-table.tex && \
  9. echo '1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\' >> test-table.tex && \
  10. cat parsing-results/table-footer.tex >> test-table.tex && \
  11. docker cp test-table.tex tp-analysis-test:/home/analysis/parsing-results/test-table.tex && \
  12. docker exec tp-analysis-test sh -c "cd /home/analysis/parsing-results && while pdflatex test-table.tex && grep -q 'Rerun to get' test-table.log; do true; done" && \
  13. docker cp tp-analysis-test:/home/analysis/parsing-results/test-table.pdf test-table.pdf || exit 1
  14. docker stop tp-analysis-test
  15. # Unit tests for the three versions of Lox
  16. allpassed=true
  17. docker run --name "lox-old-test" --rm -d -i lox-old:latest || exit 1
  18. for i in open_invite trust_promotion level0_migration level_up issue_invite redeem_invite mark_unreachable blockage_migration; do
  19. result=$(docker exec lox-old-test cargo test --release --features fast test_$i 2> /dev/null | grep "$i")
  20. echo "$result"
  21. if [[ "$result" != *" ... ok" ]]; then
  22. allpassed=false
  23. fi
  24. done
  25. docker stop lox-old-test
  26. docker run --name "lox-new-test" --rm -d -i lox-new:latest || exit 1
  27. for i in check_blockage issue_invite redeem_invite trust_migration update_cred level_up blockage_migration open_invitation update_invite trust_promotion; do
  28. result=$(docker exec lox-new-test cargo test --release --features bridgeauth,test,fast test_$i 2> /dev/null | grep "$i")
  29. echo "$result"
  30. if [[ "$result" != *" ... ok" ]]; then
  31. allpassed=false
  32. fi
  33. done
  34. docker stop lox-new-test
  35. docker run --name "troll-patrol-test" --rm -d -i troll-patrol:latest || exit 1
  36. for i in check_blockage issue_invite redeem_invite trust_migration update_cred level_up blockage_migration open_invitation update_invite trust_promotion report_protocols; do
  37. result=$(docker exec troll-patrol-test cargo test --release --features bridgeauth,test,fast test_$i 2> /dev/null | grep "$i")
  38. echo "$result"
  39. if [[ "$result" != *" ... ok" ]]; then
  40. allpassed=false
  41. fi
  42. done
  43. docker stop troll-patrol-test
  44. if [ "$allpassed" == "true" ]; then
  45. echo "Everything seems to be set up correctly!"
  46. else
  47. echo "Some tests failed."
  48. fi