aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-06 19:44:32 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-07 19:53:24 +0200
commit31e83200b21ab0c09112cb2815438e6259f1c874 (patch)
treed8ad53e332661215c5a2b7775caaca183053bda6
parentd3a33e393ed8aba2df26cf0d4473cf46c5182090 (diff)
fix problem in origin ancestry: don't add self twice
Also add various comments to illustrate what is going on during origin resolution. In the regression tests' expectations, some duplicate entries in the origins are removed, and hence no list of deeper origin ancestry is printed anymore. Change-Id: I42c3b8635b54c31c27699140e200c1f75a6ada29
-rw-r--r--selftest/process_test.ok8
-rw-r--r--selftest/suite_test.ok15
-rw-r--r--src/osmo_gsm_tester/log.py10
3 files changed, 20 insertions, 13 deletions
diff --git a/selftest/process_test.ok b/selftest/process_test.ok
index 4245eeb..f168ee3 100644
--- a/selftest/process_test.ok
+++ b/selftest/process_test.ok
@@ -1,7 +1,7 @@
-run foo: DBG: cd '[TMP]'; PATH=[$PATH] foo.py arg1 arg2 [foo↪foo]
-run foo: DBG: [TMP]/stdout [foo↪foo]
-run foo: DBG: [TMP]/stderr [foo↪foo]
-run foo(pid=[PID]): Launched [foo(pid=[PID])↪foo(pid=[PID])]
+run foo: DBG: cd '[TMP]'; PATH=[$PATH] foo.py arg1 arg2
+run foo: DBG: [TMP]/stdout
+run foo: DBG: [TMP]/stderr
+run foo(pid=[PID]): Launched
stdout:
(launched: [DATETIME])
foo stdout
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index b9a8fb3..fd4d743 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -6,11 +6,11 @@ cnf -: DBG: Found path suites_dir as [PATH]/selftest/suite_test
--- -: ERR: RuntimeError: Suite not found: 'does_not_exist' in [PATH]/selftest/suite_test
- no suite.conf
cnf -: DBG: Found path suites_dir as [PATH]/selftest/suite_test
-cnf empty_dir: DBG: reading suite.conf [empty_dir↪empty_dir]
+cnf empty_dir: DBG: reading suite.conf
--- [PATH]/selftest/suite_test/empty_dir/suite.conf: ERR: FileNotFoundError: [Errno 2] No such file or directory: '[PATH]/selftest/suite_test/empty_dir/suite.conf' [empty_dir↪[PATH]/selftest/suite_test/empty_dir/suite.conf]
- valid suite dir
cnf -: DBG: Found path suites_dir as [PATH]/selftest/suite_test
-cnf test_suite: DBG: reading suite.conf [test_suite↪test_suite]
+cnf test_suite: DBG: reading suite.conf
defaults:
timeout: 60s
resources:
@@ -26,21 +26,19 @@ cnf -: DBG: Found config file resources.conf as [PATH]/selftest/suite_test/resou
cnf -: DBG: Found path state_dir as [PATH]/selftest/suite_test/test_work/state_dir
tst test_suite: Suite run start
tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ...
-tst test_suite: DBG: {combining='resources'} [test_suite↪test_suite]
+tst test_suite: DBG: {combining='resources'}
tst test_suite: DBG: {definition_conf={bts=[{'times': '1'}], ip_address=[{'times': '1'}], modem=[{'times': '2'}]}} [test_suite↪(combining_scenarios='resources')↪test_suite]
-tst test_suite: Reserving 1 x bts (candidates: 3) [test_suite↪test_suite]
+tst test_suite: Reserving 1 x bts (candidates: 3)
tst test_suite: DBG: Picked - _hash: 07d9c8aaa940b674efcbbabdd69f58a6ce4e94f9
addr: 10.42.42.114
band: GSM-1800
ipa_unit_id: '1'
label: sysmoBTS 1002
type: sysmo
- [test_suite↪test_suite]
-tst test_suite: Reserving 1 x ip_address (candidates: 3) [test_suite↪test_suite]
+tst test_suite: Reserving 1 x ip_address (candidates: 3)
tst test_suite: DBG: Picked - _hash: cde1debf28f07f94f92c761b4b7c6bf35785ced4
addr: 10.42.42.1
- [test_suite↪test_suite]
-tst test_suite: Reserving 2 x modem (candidates: 16) [test_suite↪test_suite]
+tst test_suite: Reserving 2 x modem (candidates: 16)
tst test_suite: DBG: Picked - _hash: 19c69e45aa090fb511446bd00797690aa82ff52f
imsi: '901700000007801'
ki: D620F48487B1B782DA55DF6717F08FF9
@@ -51,7 +49,6 @@ tst test_suite: DBG: Picked - _hash: 19c69e45aa090fb511446bd00797690aa82ff52f
ki: 47FDB2D55CE6A10A85ABDAD034A5B7B3
label: m7802
path: /wavecom_1
- [test_suite↪test_suite]
tst hello_world.py:[LINENR] START [test_suite↪hello_world.py]
tst hello_world.py:[LINENR]: hello world [test_suite↪hello_world.py:[LINENR]]
tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]' [test_suite↪hello_world.py:[LINENR]]
diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py
index ede3b16..fb6d55b 100644
--- a/src/osmo_gsm_tester/log.py
+++ b/src/osmo_gsm_tester/log.py
@@ -352,10 +352,20 @@ class Origin:
def gather_origins(self):
origins = Origins()
+ # this object shall always be seen as the immediate origin of the log message.
origins.add(self)
+ # now go through the parents of this object.
origin = self._parent_origin
+ # but if this object is "loose" and not set up with cascaded 'with' statements,
+ # take the last seen 'with' statement's object as next parent:
if origin is None and Origin._global_current_origin is not None:
origin = Origin._global_current_origin
+ # if this object is currently the _global_current_origin, we don't
+ # need to add it twice.
+ if origin is self:
+ origin = origin._parent_origin
+ # whichever we determined to be the parent above, go up through all its
+ # ancestors.
while origin is not None:
origins.add(origin)
origin = origin._parent_origin