test_cocktail_03 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. echo "Test 03: 2 compilations dans le même dossier, même projet."
  3. echo "Un des deux doit tomber en erreur"
  4. RC1=99
  5. RC2=99
  6. handle_child() {
  7. local tmp=()
  8. for((i=0;i<${#pids[@]};++i));
  9. do
  10. if test ! -d /proc/${pids[i]};
  11. then
  12. wait ${pids[i]}
  13. RC0=$?
  14. echo "Stopped ${pids[i]}; exit code: $RC0"
  15. if test "$RC1" -eq 99;
  16. then
  17. RC1="$RC0"
  18. else
  19. if test "$RC2" -eq 99;
  20. then
  21. RC2="$RC0"
  22. fi
  23. fi
  24. else
  25. tmp+=(${pids[i]})
  26. fi
  27. done
  28. pids=(${tmp[@]})
  29. }
  30. set -o monitor
  31. trap "handle_child" CHLD
  32. # Start background processes
  33. ./cocktail -v -d MonDossier -p Abro2 -b 'https://pad.exegetes.eu.org/p/g.DSXI1kGFT1gjor66$Abro-REP-Tele2-Principal/export/txt' -g 'https://pad.exegetes.eu.org/p/g.DSXI1kGFT1gjor66$Abro-REP-Tele2-Garde/export/txt' &
  34. pids+=($!)
  35. ./cocktail -v -d MonDossier -p Abro2 -b 'https://pad.exegetes.eu.org/p/g.DSXI1kGFT1gjor66$Abro-REP-Tele2-Principal/export/txt' -g 'https://pad.exegetes.eu.org/p/g.DSXI1kGFT1gjor66$Abro-REP-Tele2-Garde/export/txt' &
  36. pids+=($!)
  37. # Wait until all background processes are stopped
  38. while [ ${#pids[@]} -gt 0 ];
  39. do
  40. echo "WAITING FOR: ${pids[@]}";
  41. sleep 2;
  42. done
  43. echo STOPPED
  44. echo "RC1=$RC1 RC2=$RC2"
  45. # cocktail exits with rc 2 if error lock
  46. if test "$RC1" -eq 0 -a "$RC2" -eq 2;
  47. then
  48. echo "Test réussi"
  49. exit 0
  50. fi
  51. # cocktail exits with rc 2 if error lock
  52. if test "$RC2" -eq 0 -a "$RC1" -eq 2;
  53. then
  54. echo "Test réussi"
  55. exit 0
  56. fi
  57. echo "Test échoué"
  58. exit 1