Change in osmo-gsm-tester[master]: selftest/process_test: Fix output changing in new python version

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed May 6 16:01:25 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/18085 )


Change subject: selftest/process_test: Fix output changing in new python version
......................................................................

selftest/process_test: Fix output changing in new python version

On older versions apparently upon child termination due to SIGINT
subprocess.poll() returned 1. On new python versions (such as 3.8.2),
-2 is returned, according to documentation:

A negative value -N indicates that the child was terminated by signal N (Unix only).

Let's catch the SIGINT in the child process and exit with a known 42
value to fix different behavior.

Change-Id: I7949ff2b435e91e890061e6840b0f411f8b0a817
---
M selftest/process_test.ok
M selftest/process_test/foo.py
2 files changed, 9 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/85/18085/1

diff --git a/selftest/process_test.ok b/selftest/process_test.ok
index f168ee3..e40a461 100644
--- a/selftest/process_test.ok
+++ b/selftest/process_test.ok
@@ -13,21 +13,18 @@
 
 run foo(pid=[PID]): Terminating (SIGINT)
 run foo(pid=[PID]): DBG: Cleanup
-run foo(pid=[PID]): Terminated {rc=1}
-result: 1
+run foo(pid=[PID]): Terminated {rc=42}
+result: 42
 stdout:
 (launched: [DATETIME])
 foo stdout
 [[$0], 'arg1', 'arg2']
+SIGINT received
 Exiting (stdout)
 
 stderr:
 (launched: [DATETIME])
 foo stderr
-Traceback (most recent call last):
-  File [$0], line [LINE], in <module>
-    time.sleep(1)
-KeyboardInterrupt
 Exiting (stderr)
 
 done.
diff --git a/selftest/process_test/foo.py b/selftest/process_test/foo.py
index 4abe887..0931c9b 100755
--- a/selftest/process_test/foo.py
+++ b/selftest/process_test/foo.py
@@ -3,7 +3,13 @@
 import sys
 import atexit
 import time
+import signal
 
+def signal_handler(sig, frame):
+    print('SIGINT received')
+    sys.exit(42)
+
+signal.signal(signal.SIGINT, signal_handler)
 
 sys.stdout.write('foo stdout\n')
 sys.stderr.write('foo stderr\n')

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/18085
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I7949ff2b435e91e890061e6840b0f411f8b0a817
Gerrit-Change-Number: 18085
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200506/efb3ff25/attachment.htm>


More information about the gerrit-log mailing list