#349 fix issue with interactive shell
Merged 4 years ago by astepano. Opened 4 years ago by bgoncalv.
bgoncalv/standard-test-roles fix-role  into  master

@@ -161,6 +161,6 @@ 

  if [ -f "$STR_CMD" ]; then

      chmod 0775 "$STR_CMD"

  fi

- timeout "$STR_TIMEOUT" bash -c "$STR_CMD"

+ timeout --foreground "$STR_TIMEOUT" bash -c "$STR_CMD"

  # Explicit return code

  exit $?

@@ -26,7 +26,7 @@ 

  

  ## Test case parameters

  

-  * **timeout**: abort test case after this time. More details on [timeout][1]. default: 0

+  * **timeout**: abort test case after this time. More details on [timeout][2]. default: 0

  

  Example usage:

  
@@ -83,3 +83,4 @@ 

  metadata.

  

  [1]: https://fedoraproject.org/wiki/CI/Metadata

+ [2]: http://man7.org/linux/man-pages/man1/timeout.1.html

@@ -167,7 +167,7 @@ 

  if [ -f "$STR_BKR_TEST" ]; then

      debug "Running test from file: $STR_BKR_TEST"

      cd $(dirname "$STR_BKR_TEST")

-     timeout "$STR_TIMEOUT" /bin/sh -e ./$(basename "$STR_BKR_TEST")

+     timeout --foreground "$STR_TIMEOUT" /bin/sh -e ./$(basename "$STR_BKR_TEST")

      exit

  fi

  
@@ -178,10 +178,10 @@ 

      get-test-deps -i .

      if [ -f "Makefile" ] && command -p -v "make" >"/dev/null" 2>&1; then

          debug "Running test from Makefile"

-         timeout "$STR_TIMEOUT" make run

+         timeout --foreground "$STR_TIMEOUT" make run

      elif [ -f "runtest.sh" ]; then

          debug "Running test from runtest.sh"

-         timeout "$STR_TIMEOUT" /bin/sh -e ./runtest.sh

+         timeout --foreground "$STR_TIMEOUT" /bin/sh -e ./runtest.sh

      else

          echo "FAIL test $STR_BKR_TEST do not know how to run test"

      fi

file modified
+1 -2
@@ -68,7 +68,6 @@ 

    - role: standard-test-basic

      tests:

      - test-basic-timeout:

-         run: ls; sleep 1

          timeout: 5

    tasks:

    - import_tasks: shared-tasks/artifacts_test_env.yml
@@ -84,7 +83,7 @@ 

    - role: standard-test-basic

      tests:

      - test-basic-timeout-fail:

-         run: ls; sleep 5

+         dir: test-basic-timeout

          timeout: 1

      ignore_errors: yes

    tasks:

@@ -0,0 +1,15 @@ 

+ #!/bin/bash

+ PACKAGE="bash"

+ 

+ set -e

+ 

+ # Interactive shell

+ bash -lic "echo OK" | grep OK

+ set +e

+ timeout 1 sleep 3

+ if [ $? -ne 124 ]; then

+     echo "FAIL: Should have exited wiht timeout, but didn't"

+     exit 1

+ fi

+ set -e

+ timeout 2 sleep 1

@@ -6,7 +6,9 @@ 

  

  rlJournalStart

      rlPhaseStartTest "beakerlib timeout test"

-         rlRun "ls /; sleep 5"

+         rlRun "bash -lic \"echo OK\" | grep OK" 0 "Interactive shell"

+         rlRun "timeout 2 sleep 1"

+         rlRun "timeout 1 sleep 3" 124

      rlPhaseEnd

  rlJournalPrintText

  rlJournalEnd