← Back to team overview

sikuli-driver team mailing list archive

[Bug 1948708] [NEW] Getting a return code of 1 in Linux when I'm expecting 0

 

Public bug reported:

Hello,

We're using:
sikulixide-2.0.5.jar
Ubuntu 20.04.3 LTS, x86_64
openjdk version "14.0.2" 2020-07-14


We have code similar to the following that we're running in Linux (Ubuntu 20.04) via bash:
----------------------------------------------
  echo "Testing $d"
  export DISPLAY=:0 && java -jar $TEST_PATH/../../sikulixide-2.0.5.jar -r $d
	
  # Store return code from the Sikuli script before running any other commands.
  RESULT=$?
    
  EPOCH=$(date +%s)

  # check the return code of the Sikuli script and exit with 1 if it failed
  if [ $RESULT -ne 0 ]; then
     echo "The result code from the failed test was $RESULT."
     echo "__TEST_RESULT__: $EPOCH, FAILED"
     exit 1
  else
     echo "__TEST_RESULT__: $EPOCH, PASSED"
  fi
----------------------------------------------

We're running these Sikuli scripts on Windows, macOS, and Linux. Only
the Linux ones are giving us this issue. Also, this is only seen
intermittently on Linux.

We're running them over SSH, hence the "export DISPLAY=:0". The system
is a laptop that has its internal LCD left on all the time.

We originally had our scripts just "run to completion" to get a return
code of 0. However, due to this issue we tried Python's "sys.exit(0)"
and also Sikuli's "exit(0)". However, we're still having this issue
intermittently.

Usually the scripts exit and return 0 as expected. However, lately we've
been having an issue where the scripts will fail with a return code of 1
even though they reach the end (or even use exit(0) a the end).

For example:
----------------------------------------------
"[info (2021-10-25, 1:44:16 p.m.)] Exit code: 0
The result code from the failed test was 1.
__TEST_RESULT__: 1635183856, FAILED
----------------------------------------------

How can Sikuli use exit(0) but have a return code of 1? Is there another
way to have a Sikuli script return a 0 code on exit?

As a work around, we might instead log the output from Sikuli to a file
and then grep it for "Exit code: 0" to check if it passed instead of
checking the return code. My preference would be to check the return
code instead though.

Is there something wrong with our bash code that stores the Sikuli
return code? Or is it a bug in Linux/Sikuli that's causing it to return
the wrong return code (1 instead of 0)?

Thanks,
Devin

** Affects: sikuli
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to SikuliX.
https://bugs.launchpad.net/bugs/1948708

Title:
  Getting a return code of 1 in Linux when I'm expecting 0

Status in SikuliX:
  New

Bug description:
  Hello,

  We're using:
  sikulixide-2.0.5.jar
  Ubuntu 20.04.3 LTS, x86_64
  openjdk version "14.0.2" 2020-07-14

  
  We have code similar to the following that we're running in Linux (Ubuntu 20.04) via bash:
  ----------------------------------------------
    echo "Testing $d"
    export DISPLAY=:0 && java -jar $TEST_PATH/../../sikulixide-2.0.5.jar -r $d
  	
    # Store return code from the Sikuli script before running any other commands.
    RESULT=$?
      
    EPOCH=$(date +%s)

    # check the return code of the Sikuli script and exit with 1 if it failed
    if [ $RESULT -ne 0 ]; then
       echo "The result code from the failed test was $RESULT."
       echo "__TEST_RESULT__: $EPOCH, FAILED"
       exit 1
    else
       echo "__TEST_RESULT__: $EPOCH, PASSED"
    fi
  ----------------------------------------------

  We're running these Sikuli scripts on Windows, macOS, and Linux. Only
  the Linux ones are giving us this issue. Also, this is only seen
  intermittently on Linux.

  We're running them over SSH, hence the "export DISPLAY=:0". The system
  is a laptop that has its internal LCD left on all the time.

  We originally had our scripts just "run to completion" to get a return
  code of 0. However, due to this issue we tried Python's "sys.exit(0)"
  and also Sikuli's "exit(0)". However, we're still having this issue
  intermittently.

  Usually the scripts exit and return 0 as expected. However, lately
  we've been having an issue where the scripts will fail with a return
  code of 1 even though they reach the end (or even use exit(0) a the
  end).

  For example:
  ----------------------------------------------
  "[info (2021-10-25, 1:44:16 p.m.)] Exit code: 0
  The result code from the failed test was 1.
  __TEST_RESULT__: 1635183856, FAILED
  ----------------------------------------------

  How can Sikuli use exit(0) but have a return code of 1? Is there
  another way to have a Sikuli script return a 0 code on exit?

  As a work around, we might instead log the output from Sikuli to a
  file and then grep it for "Exit code: 0" to check if it passed instead
  of checking the return code. My preference would be to check the
  return code instead though.

  Is there something wrong with our bash code that stores the Sikuli
  return code? Or is it a bug in Linux/Sikuli that's causing it to
  return the wrong return code (1 instead of 0)?

  Thanks,
  Devin

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1948708/+subscriptions



Follow ups