osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40314?usp=email )
Change subject: testenv: fix not aborting on build_initrd error
......................................................................
testenv: fix not aborting on build_initrd error
Without this patch the build_initrd function keeps going on errors:
+ cp -a --parents /lib/modules/6.1.0-34-amd64/kernel/drivers/net/net_failover.ko /tmp/testenv-ggsn_tests-osmo_ggsn_v4_only-20250509-1040-a21668df-euc9e2fs/ggsn/_initrd/usr
cp: 'lib/modules/6.1.0-34-amd64/kernel/drivers/net': No such file or directory
+ cp -a --parents /lib/modules/6.1.0-34-amd64/kernel/drivers/net/virtio_net.ko /tmp/testenv-ggsn_tests-osmo_ggsn_v4_only-20250509-1040-a21668df-euc9e2fs/ggsn/_initrd/usr
…
The reason for that is that even though the script runs with set -e, the
-e flag gets ignored between if…then where the build_initrd shell
function gets called:
if ! build_initrd >build_initrd.log 2>&1; then
qemu_initrd_exit_error "build_initrd.log"
fi
Fix it by using a trap instead.
Related: https://unix.stackexchange.com/a/65564
Change-Id: I2870b7e7ba28b2afc72e86b7a3bc389103564c80
---
M _testenv/data/scripts/qemu/qemu_functions.sh
M ggsn_tests/osmo-ggsn/run.sh
2 files changed, 18 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/14/40314/1
diff --git a/_testenv/data/scripts/qemu/qemu_functions.sh b/_testenv/data/scripts/qemu/qemu_functions.sh
index 9c92a37..46e7273 100755
--- a/_testenv/data/scripts/qemu/qemu_functions.sh
+++ b/_testenv/data/scripts/qemu/qemu_functions.sh
@@ -136,10 +136,12 @@
| gzip -1 > "$INITRD_DIR".gz )
}
+# Trap for qemu_build_initrd_with_log_redirect
+# Building the initrd is quite verbose, therefore put it in a log file
+# and only output its contents on error (see e.g. osmo-ggsn/run.sh)
qemu_initrd_exit_error() {
- # Building the initrd is quite verbose, therefore put it in a log file
- # and only output its contents on error (see e.g. osmo-ggsn/run.sh)
- cat "$1"
+ trap - EXIT INT TERM 0
+ cat "build_initrd.log"
set +x
echo
echo "ERROR: failed to build the initrd!"
@@ -147,6 +149,18 @@
exit 1
}
+# Users of qemu_functions should define a build_initrd function that calls
+# qemu_initrd_init, qemu_initrd_add_* and qemu_initrd_finish. See ggsn's run.sh
+# as example. The function here redirects the very verbose output of building
+# the initrd to a separate log file, and aborts and display the log on error.
+qemu_build_initrd_with_log_redirect() {
+ # Use a trap instead of "if !build_initrd; then ..." logic as "set -e"
+ # gets otherwise: https://unix.stackexchange.com/a/65564
+ trap qemu_initrd_exit_error EXIT INT TERM 0
+ build_initrd >build_initrd.log 2>&1
+ trap - EXIT INT TERM 0
+}
+
qemu_random_mac() {
printf "52:54:"
date "+%c %N" | sha1sum | sed 's/\(.\{2\}\)/\1:/g' | cut -d: -f 1-4
diff --git a/ggsn_tests/osmo-ggsn/run.sh b/ggsn_tests/osmo-ggsn/run.sh
index ae77484..27e633e 100755
--- a/ggsn_tests/osmo-ggsn/run.sh
+++ b/ggsn_tests/osmo-ggsn/run.sh
@@ -32,9 +32,5 @@
}
. qemu_functions.sh
-
-if ! build_initrd >build_initrd.log 2>&1; then
- qemu_initrd_exit_error "build_initrd.log"
-fi
-
+qemu_build_initrd_with_log_redirect
qemu_run
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40314?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I2870b7e7ba28b2afc72e86b7a3bc389103564c80
Gerrit-Change-Number: 40314
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40315?usp=email )
Change subject: testenv: qemu: initrd build fail: stop immediately
......................................................................
testenv: qemu: initrd build fail: stop immediately
Let qemu_wait.sh fail immediately when building the initrd has failed,
instead of waiting until it runs into a timeout.
Change-Id: I6de4d1c31385af52ee0fd55378adb10a9e2c2154
---
M _testenv/data/scripts/qemu/qemu_functions.sh
M _testenv/data/scripts/qemu/qemu_wait.sh
2 files changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/15/40315/1
diff --git a/_testenv/data/scripts/qemu/qemu_functions.sh b/_testenv/data/scripts/qemu/qemu_functions.sh
index 46e7273..a984ff9 100755
--- a/_testenv/data/scripts/qemu/qemu_functions.sh
+++ b/_testenv/data/scripts/qemu/qemu_functions.sh
@@ -146,6 +146,7 @@
echo
echo "ERROR: failed to build the initrd!"
echo
+ touch build_initrd_failed
exit 1
}
diff --git a/_testenv/data/scripts/qemu/qemu_wait.sh b/_testenv/data/scripts/qemu/qemu_wait.sh
index fb45c7e..2d42701 100755
--- a/_testenv/data/scripts/qemu/qemu_wait.sh
+++ b/_testenv/data/scripts/qemu/qemu_wait.sh
@@ -8,6 +8,12 @@
i=0
for i in $(seq 1 600); do
sleep 0.1
+
+ # Check for the marker from qemu_initrd_exit_error
+ if [ -e build_initrd_failed ]; then
+ exit 1
+ fi
+
if grep -q KERNEL_TEST_VM_IS_READY "$LOGFILE"; then
# Wait some more for SUT to become ready
sleep 1
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40315?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I6de4d1c31385af52ee0fd55378adb10a9e2c2154
Gerrit-Change-Number: 40315
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40318?usp=email )
Change subject: testenv: qemu_initrd_add_bin: support adding so
......................................................................
testenv: qemu_initrd_add_bin: support adding so
Erlang has its own library loading mechanism, so we need to explicitly
add the depending libraries to the initramfs instead of just pointing at
binaries.
Change-Id: I1b9f06e7bff22b9260fbe0bd765177a25e97b557
---
M _testenv/data/scripts/qemu/qemu_functions.sh
1 file changed, 15 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/18/40318/1
diff --git a/_testenv/data/scripts/qemu/qemu_functions.sh b/_testenv/data/scripts/qemu/qemu_functions.sh
index efbdd2d..c1ef8b8 100755
--- a/_testenv/data/scripts/qemu/qemu_functions.sh
+++ b/_testenv/data/scripts/qemu/qemu_functions.sh
@@ -51,19 +51,27 @@
done
}
-# Add binaries with depending libraries
-# $@: paths to binaries
+# Add binaries/libraries with depending libraries
+# $@: paths to binaries/libraries
qemu_initrd_add_bin() {
local bin
local bin_path
local file
for bin in "$@"; do
- local bin_path="$(which "$bin")"
- if [ -z "$bin_path" ]; then
- echo "ERROR: file not found: $bin"
- exit 1
- fi
+ local bin_path
+ case "$bin" in
+ /*)
+ bin_path="$bin"
+ ;;
+ *)
+ bin_path="$(which "$bin")"
+ if [ -z "$bin_path" ]; then
+ echo "ERROR: file not found: $bin"
+ exit 1
+ fi
+ ;;
+ esac
lddtree_out="$(lddtree -l "$bin_path")"
if [ -z "$lddtree_out" ]; then
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40318?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I1b9f06e7bff22b9260fbe0bd765177a25e97b557
Gerrit-Change-Number: 40318
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40317?usp=email )
Change subject: testenv: support qemu=required in testenv.cfg
......................................................................
testenv: support qemu=required in testenv.cfg
Make it possible to set qemu=required in addition to the existing
possibility of qemu=optional in the testenv configs and verify that
either the debian kernel (from the podman container) or a custom kernel
gets used for such configs.
This is in preparation for adding a testenv config for osmo-epdg, which
uses kernel-gtp and unlike osmo-ggsn doesn't have userspace fallback
code. With testenv using the hosts gtp kernel device for this is not
supported (it would have several downsides anyway, such as not being in
control what exact kernel version is used leading to different test
outcomes for different users, not being easily able to compare different
kernel versions, having a harder time getting debug logs from the module
etc.).
Change-Id: If4abdf1f9248fee0915603a9b3c6e3e5e5083057
---
M _testenv/README.md
M _testenv/testenv/testenv_cfg.py
2 files changed, 21 insertions(+), 14 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/17/40317/1
diff --git a/_testenv/README.md b/_testenv/README.md
index 66158c4..1b62d65 100644
--- a/_testenv/README.md
+++ b/_testenv/README.md
@@ -122,10 +122,11 @@
* `vty_host=`: optionally set the VTY host for the SUT component to be used
when obtaining a talloc report. If this is not set, `127.0.0.1` is used.
-* `qemu=`: set to `optional` to allow running this test component in QEMU.
- Additional logic must be added to build an initrd with the test component and
- actually run it in QEMU, this is done by sourcing `qemu_functions.sh` and
- using functions from there. See the `ggsn` testsuite for reference.
+* `qemu=`: set to `optional`/`required` to allow/require running this test
+ component in QEMU. Additional logic must be added to build an initrd with the
+ test component and actually run it in QEMU, this is done by sourcing
+ `qemu_functions.sh` and using functions from there. See the `ggsn` testsuite
+ for reference.
### Executables
diff --git a/_testenv/testenv/testenv_cfg.py b/_testenv/testenv/testenv_cfg.py
index 70d64c8..fc28d84 100644
--- a/_testenv/testenv/testenv_cfg.py
+++ b/_testenv/testenv/testenv_cfg.py
@@ -76,31 +76,37 @@
def verify_qemu_cfgs():
- """Check if -C or -K is set, but any of the selected configs can't run with
- QEMU."""
- if not testenv.args.kernel:
- return
+ """Check if passed -C or -K args make sense with the testenv configs."""
+ testsuite = testenv.args.testsuite
+ qemu_supported = False
+ qemu_required = False
for basename, cfg in cfgs.items():
- missing = True
-
for section in cfg.keys():
if "qemu" in cfg[section]:
- missing = False
+ qemu_supported = True
+ if cfg[section]["qemu"] == "required":
+ qemu_required = True
break
- if missing:
- testsuite = testenv.args.testsuite
+ if testenv.args.kernel and not qemu_supported:
logging.critical(f"{testsuite}/{basename}: doesn't support running in QEMU")
exit_error_readme()
+ if not testenv.args.kernel and qemu_required:
+ logging.error(f"{testsuite}/{basename}: {section} must run in QEMU")
+ logging.error("Use one of:")
+ logging.error(" -D, --debian-kernel")
+ logging.error(" -C, --custom-kernel")
+ exit_error_readme()
+
def verify_qemu_section(path, cfg, section):
"""Verify that qemu= has proper values."""
if "qemu" not in cfg[section]:
return
- valid = ["optional"]
+ valid = ["optional", "required"]
value = cfg[section]["qemu"]
if value not in valid:
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40317?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: If4abdf1f9248fee0915603a9b3c6e3e5e5083057
Gerrit-Change-Number: 40317
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40309?usp=email )
Change subject: testenv: cfg: check for multiple spaces in lists
......................................................................
testenv: cfg: check for multiple spaces in lists
Pau ran into an unexpected bug while having entries in copy= separated
by multiple spaces ("copy=osmo-stp.cfg osmo-stp-m3ua.confmerge"):
[testenv][m3ua] + ['cp', '-a', 'osmo-stp.cfg', '', 'osmo-stp-m3ua.confmerge', '/tmp/testenv-stp-m3ua-20250516-1349-e4103924-bfvi_syt/stp']
cp: cannot stat '': No such file or directory
Catch this early and print a more useful error:
[testenv] /home/user/code/osmo-dev/src/osmo-ttcn3-hacks/stp/testenv.cfg: copy= in section [stp] has multiple spaces:
[testenv] "osmo-stp.cfg osmo-stp-m3ua.confmerge"
[testenv] Please separate elements with only one space.
Change-Id: Ie47cf5482ba479457a662759ce87611a7c41e29c
---
M _testenv/testenv/testenv_cfg.py
1 file changed, 11 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/09/40309/1
diff --git a/_testenv/testenv/testenv_cfg.py b/_testenv/testenv/testenv_cfg.py
index 70d64c8..1ff662f 100644
--- a/_testenv/testenv/testenv_cfg.py
+++ b/_testenv/testenv/testenv_cfg.py
@@ -133,6 +133,10 @@
"packages": "package",
"programs": "program",
}
+ keys_lists = [
+ "copy",
+ "package",
+ ]
if "testsuite" not in cfg:
logging.error(f"{path}: missing [testsuite] section")
@@ -173,6 +177,13 @@
logging.error("If this is on purpose, set make=no.")
exit_error_readme()
+ for key in keys_lists:
+ if key in cfg[section] and " " in cfg[section][key]:
+ logging.error(f"{path}: {key}= in section [{section}] has multiple spaces:")
+ logging.error(f' "{cfg[section][key]}"')
+ logging.error("Please separate elements with only one space.")
+ sys.exit(1)
+
get_vty_host_port(cfg, path)
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40309?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie47cf5482ba479457a662759ce87611a7c41e29c
Gerrit-Change-Number: 40309
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40308?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: stp: Rename STP_Tests.ttcn -> STP_Tests_IPA_M3UA.ttcn
......................................................................
stp: Rename STP_Tests.ttcn -> STP_Tests_IPA_M3UA.ttcn
The previous name usually causes confusion since it seems to indicate
either:
* Some sort of common placeholder for STP_Tests_IPA and STP_Tests_M3UA
(it's not the case, we already have STP_Tests_Common.ttcn for that)
* A placeholder for tests not IPA or M3UA related (it's not the case,
since it only contains IPA<->M3UA tests).
Hence, rename it to denote better the aim of that file, ie. testing
forwarding between IPA and M3UA AS(P)s.
Change-Id: Id2963407adf11add01630c3899a062d764c8ad75
---
M stp/README.md
M stp/STP_Tests.cfg
M stp/STP_Tests_Common.ttcn
M stp/STP_Tests_IPA.ttcn
R stp/STP_Tests_IPA_M3UA.ttcn
M stp/STP_Tests_M3UA.ttcn
M stp/expected-results.xml
7 files changed, 11 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/08/40308/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40308?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id2963407adf11add01630c3899a062d764c8ad75
Gerrit-Change-Number: 40308
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder