설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

output.bats 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/usr/bin/env bats
  2. @test "task1: Check that we have a debug output" {
  3. run stat "$BATS_TEST_DIRNAME/../target/debug/task1"
  4. [ "$status" -eq 0 ]
  5. }
  6. # Check lines of output
  7. # wc output with white spaces is trimmed by xargs
  8. @test "task1: Output with Zombie must at least 4 Lines long" {
  9. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' | wc -l | xargs"
  10. [ "$output" -gt 4 ]
  11. }
  12. # wc output with white spaces is trimmed by xargs
  13. @test "task1: Output with to many paras must be exact 1 line long" {
  14. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 2 3 4 | wc -l | xargs"
  15. [ "$output" = "1" ]
  16. }
  17. # wc output with white spaces is trimmed by xargs
  18. @test "task1: Output with wrong para must be exact 1 line long" {
  19. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' y | wc -l | xargs"
  20. [ "$output" = "1" ]
  21. }
  22. # wc output with white spaces is trimmed by xargs
  23. @test "task1: Output with wrong para must be exact 1 line long" {
  24. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' -1 | wc -l | xargs"
  25. [ "$output" = "1" ]
  26. }
  27. # wc output with white spaces is trimmed by xargs
  28. @test "task1: Output with para 0 must be exact 0 line long" {
  29. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 0 | wc -l | xargs"
  30. [ "$output" = "0" ]
  31. }
  32. # wc output with white spaces is trimmed by xargs
  33. @test "task1: Output with para 256 must be exact 1 line long" {
  34. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 256 | wc -l | xargs"
  35. [ "$output" = "1" ]
  36. }
  37. # wc output with white spaces is trimmed by xargs
  38. @test "task1: Output with para 1 must be exact 4 line long" {
  39. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 1 | wc -l | xargs"
  40. [ "$output" = "4" ]
  41. }
  42. # wc output with white spaces is trimmed by xargs
  43. @test "task1: Output with para 16 must be exact 34 line long" {
  44. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 16 | wc -l | xargs"
  45. [ "$output" = "34" ]
  46. }
  47. # wc output with white spaces is trimmed by xargs
  48. @test "task1: Output with para 255 must be exact 512 line long" {
  49. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 255 | wc -l | xargs"
  50. [ "$output" = "512" ]
  51. }
  52. # Status checks
  53. @test "task1: Output with wrong CHILD_NUMBERS does not crash" {
  54. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 0 "
  55. [ "$status" = 1 ]
  56. }
  57. @test "task1: Output with wrong CHILD_NUMBERS does not crash" {
  58. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 256 "
  59. [ "$status" = 1 ]
  60. }
  61. @test "task1: Output with wrong PARAM does not crash" {
  62. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' a "
  63. [ "$status" = 1 ]
  64. }
  65. @test "task1: Output with to many para does not crash" {
  66. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 2 3 4 "
  67. [ "$status" = 1 ]
  68. }
  69. @test "task1: Output with standard CHILD_NUMBERS exits with 0" {
  70. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 4 "
  71. [ "$status" = 0 ]
  72. }
  73. @test "task1: Output with MIN CHILD_NUMBERS exits with 0" {
  74. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 1 "
  75. [ "$status" = 0 ]
  76. }
  77. @test "task1: Output with MAX CHILD_NUMBERS exits with 0" {
  78. run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 255 "
  79. [ "$status" = 0 ]
  80. }