Clean up QNX platform configs and improve testrunner scripts

QNX requires its own TESTRUNNER script in order to SSH to the QEMU guest
and run the tests. Simplify it a lot and fix the way it passes arguments
so that they retain spaces and quotation.

Also wrap it with the generic TESTRUNNER script for CI, which is
qt-testrunner.py, so that tests can re-run in case of flakiness.

Delete prefix.sh as the environment variables are now properly set in
the Coin platform config files.

Avoid executing extra chmod commands to make scripts executable,
but use the right Coin instruction for that. For reference, we
use 493 for file mode which equals to 755 in octal, as Coin expects
the file mode in decimal.

Change-Id: Ife4d1caef606f48b92ba1da1cfb14ec0dea11ef2
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
This commit is contained in:
Dimitrios Apostolou 2022-01-13 13:28:55 +01:00
parent d6c4a3edf9
commit c37d0e84bc
5 changed files with 32 additions and 54 deletions

View File

@ -15,6 +15,13 @@ instructions:
condition: property
property: host.os
equals_value: Windows
- type: AppendToEnvironmentVariable
variableName: TESTRUNNER
variableValue: " {{.SourceDir}}/coin_qnx_qemu_runner.sh"
enable_if:
condition: property
property: target.osVersion
in_values: [QNX_710]
- type: EnvironmentVariable
variableName: TESTRUNNER
variableValue: "{{.InstallDir}}\\bin\\qt-testrunner.py --"

View File

@ -1,40 +1,20 @@
type: Group
instructions:
- type: WriteFile
filename: "{{.SourceDir}}/coin_qnx_qemu_runner.sh"
fileMode: 493
fileContents: |
#!/usr/bin/python3
import subprocess
import calendar
import datetime
import time
import sys
import os
import re
#!/bin/sh
file=os.path.basename(sys.argv[1])
timestamp = str(round(time.time() * 1000))
resultdir = os.getenv('COIN_CTEST_RESULTSDIR')
results_file = resultdir + "/testresults/" + file +"-" + timestamp + ".xml,xml"
testargs = [" -o", results_file, "-o", "-,txt"]
if re.search("testlib.selftests.tst_selftests", sys.argv[1]):
testargs = []
testcmd = sys.argv[1]
testcmd += ' '.join(testargs)
qemuargs = os.getenv('TESTARGS')
sshcmd, ldenv, backend, qpa = qemuargs.split()
testdir = sys.argv[1][::-1].split('/', 1)[1][::-1]
testcmd = "cd " + testdir + ";" + ldenv + " " + backend + " " + qpa + " " + testcmd
proc = subprocess.run(["ssh", sshcmd, testcmd])
exit(proc.returncode)
filename: "{{.SourceDir}}/coin_qnx_qemu_runner.py"
fileMode: 755
- type: ExecuteCommand
command: "chmod 755 {{.SourceDir}}/coin_qnx_qemu_runner.py"
maxTimeInSeconds: 10
maxTimeBetweenOutput: 10
userMessageOnFailure: >
Failed to change file permission.
disable_if:
condition: property
property: host.os
equals_value: Windows
# Many tests require changing into their directory, in order to find
# files they depend on.
testdir=`dirname "$1"`
# The remote SSH server executes everything we send under "sh -c". So
# the only way to preserve arguments is to shell-quote them and send
# them as a single string. We use python's shlex module for that.
quoted_args=`python3 -c 'import sys, shlex; print(shlex.join(sys.argv[1:]))' "$@"`
ssh "$QNX_QEMU_SSH" \
cd "$testdir" \; $QNX_TEST_ENV "$quoted_args"

View File

@ -56,19 +56,9 @@ instructions:
done
exit $RESULT
filename: "{{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
fileMode: 755
fileMode: 493
- type: ChangeDirectory
directory: "{{.Env.QNX_QEMU}}"
- type: ExecuteCommand
command: "chmod 755 {{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
maxTimeInSeconds: 10
maxTimeBetweenOutput: 10
userMessageOnFailure: >
Failed to change file permission.
disable_if:
condition: property
property: host.os
equals_value: Windows
- type: ExecuteCommand
command: "{{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
maxTimeInSeconds: 100

View File

@ -280,14 +280,14 @@ instructions:
enable_if:
condition: property
property: target.osVersion
in_values: [QEMU, QNX_710]
in_values: [QEMU]
- type: EnvironmentVariable
variableName: TARGET_ENV_PREFIX
variableValue: ""
disable_if:
condition: property
property: target.osVersion
in_values: [QEMU, QNX_710]
in_values: [QEMU]
# Windows on Arm, cross-compilation with MSVC
- type: Group
@ -312,12 +312,6 @@ instructions:
property: target.os
equals_value: QNX
instructions:
- type: WriteFile
fileContents: "#!/bin/bash\nexport TESTARGS={{.Env.TESTARGS}}\nexport TESTRUNNER={{.Env.TESTRUNNER}}\nexport COIN_CTEST_RESULTSDIR={{.Env.COIN_CTEST_RESULTSDIR}}\n$*"
filename: "{{.Env.HOME}}/prefix.sh"
fileMode: 493
maxTimeInSeconds: 20
maxTimeBetweenOutput: 20
- type: EnvironmentVariable
variableName: QNX_TARGET
variableValue: "{{.Env.QNX_710}}/target/qnx7"

View File

@ -157,9 +157,16 @@ Default flags: --max-repeats 5 --passes-needed 1
args.log_dir = "."
args.test_basename = os.path.basename(args.testargs[0])
if args.test_basename.endswith(".exe"):
args.test_basename = args.test_basename[:-4]
# QNX test wrapper just needs to be skipped to figure out test_basename
if args.test_basename == "coin_qnx_qemu_runner.sh":
args.test_basename = os.path.basename(args.testargs[1])
L.info("Detected coin_qnx_qemu_runner, test will be handled specially. Detected test basename: %s",
args.test_basename)
# On Android emulated platforms, "androidtestrunner" is invoked by CMake
# to wrap the tests. We have to append the test arguments to it after
# "--". Besides that we have to detect the basename to avoid saving the