osmith has uploaded this change for review.

View Change

testenv: podman.exec_cmd: better error if stopped

Testenv may try to run a comand in podman after the container was
stopped, if there is a bug in the shutdown logic. Give a meaningful
error in that case, instead of failing later on with a cryptic error in
subprocess.run() because None was passed inside cmd (for the container
name) instead of a string.

Change-Id: I29ebe200258a9a9ffb127ec8fa1260b7e2124c38
---
M _testenv/testenv/podman.py
1 file changed, 4 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/58/38258/1
diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py
index 6d801fa..53806a4 100644
--- a/_testenv/testenv/podman.py
+++ b/_testenv/testenv/podman.py
@@ -131,6 +131,10 @@


def exec_cmd(cmd, podman_opts=[], cwd=None, env={}, *args, **kwargs):
+ if not container_name:
+ raise RuntimeError("Attempting to execute a command in podman, but the"
+ f" container isn't running anymore: {cmd}")
+
podman_opts = list(podman_opts)
podman_opts += generate_env_podman(env)
# Attach a fake tty (eclipse-titan won't print colored output otherwise)

To view, visit change 38258. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I29ebe200258a9a9ffb127ec8fa1260b7e2124c38
Gerrit-Change-Number: 38258
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>