diff --git a/linux/ibus-keyman/tests/scripts/test-helper.inc.sh b/linux/ibus-keyman/tests/scripts/test-helper.inc.sh index 8f833bd54a2..01626a04909 100755 --- a/linux/ibus-keyman/tests/scripts/test-helper.inc.sh +++ b/linux/ibus-keyman/tests/scripts/test-helper.inc.sh @@ -323,14 +323,9 @@ function exit_on_package_build() { fi } -function check_processes_running() { - local DISPLAY_SERVER ENV_FILE CLEANUP_FILE PID_FILE LINE PID MISSING MISSING_PROCS TEST_NAME - DISPLAY_SERVER=$1 - ENV_FILE=$2 - CLEANUP_FILE=$3 - PID_FILE=$4 - TEST_NAME=$5 - MISSING=false +function _get_missing_processes() { + local PID_FILE MISSING_PROCS PID LINE + PID_FILE=$1 MISSING_PROCS="" while read -r LINE; do @@ -339,13 +334,22 @@ function check_processes_running() { fi PID=$(echo "$LINE" | cut -d' ' -f1) if ! ps --no-headers --pid="$PID" > /dev/null; then - MISSING=true MISSING_PROCS="${MISSING_PROCS} $(echo "$LINE" | cut -d' ' -f2)" break fi done < "${PID_FILE}" +} + +function check_processes_running() { + local DISPLAY_SERVER ENV_FILE CLEANUP_FILE PID_FILE MISSING_PROCS TEST_NAME + DISPLAY_SERVER=$1 + ENV_FILE=$2 + CLEANUP_FILE=$3 + PID_FILE=$4 + TEST_NAME=$5 + MISSING_PROCS=$(_get_missing_processes "$PID_FILE") - if $MISSING; then + if [ "$MISSING_PROCS" != "" ]; then echo "# Some background processes no longer running. Restarting..." { echo "Some background processes no longer running (running ${TEST_NAME}):" ; \ echo "$MISSING_PROCS" ; \ @@ -354,4 +358,9 @@ function check_processes_running() { cleanup "${CLEANUP_FILE}" > /dev/null 2>&1 setup "${DISPLAY_SERVER}" "${ENV_FILE}" "${CLEANUP_FILE}" "${PID_FILE}" > /dev/null 2>&1 fi + + if [ "$(_get_missing_processes "$PID_FILE")" != "" ]; then + echo "# WARNING: Expected background processes are still missing after restart: ${MISSING_PROCS}" + echo "# Maybe an old process is still running?" + fi }