diff options
authorPau Espin Pedrol <>2017-08-28 13:29:28 +0200
committerPau Espin Pedrol <>2017-09-10 12:30:35 +0000
commit4e36f7c0c7b7be972d4342a092bfb3b999ffdac2 (patch)
parent77631215f79997b2406e796fba8087d32841e674 (diff)
resource: Fix list comparison in item_matches
In following commits, cipher attribute containing a list of supported ciphers is introdued in osmo-gsm-tester. While developing the feature, it was found that resources containing lists are not being handled correctly. Previous implementation regarding lists in several ways: - In the list coe path, both item and wanted_item are expected to be lists. Python doesn't support to check for sublists using the "in" operand. - want_item basically contains the scenario dic, and item is each of the items available as resource of a given type. Thus, we want to check that item supports the subset of features requested by the scenario, ie. that the list in the scenario is a subset of the ones in the3 item and not the opposite. The following failing scenario is going to be checked during "make check" when the cipher attribute is added: BTS supporting cipher a50 and a51, and scenario requesting a50 succeeds. If this commit is remove, the test no longer passes, and it fails with: osmo_gsm_tester.resource.NoResourceExn: No matching resource available for bts = {'type': 'osmo-bts-sysmo', 'ciphers': ['a5 1']} Change-Id: I27b372aa5906feac2843f24f5cdd0d9578d44b4d
1 files changed, 5 insertions, 2 deletions
diff --git a/src/osmo_gsm_tester/ b/src/osmo_gsm_tester/
index c55140a..da543f7 100644
--- a/src/osmo_gsm_tester/
+++ b/src/osmo_gsm_tester/
@@ -441,9 +441,12 @@ def item_matches(item, wanted_item, ignore_keys=None):
return True
if is_list(wanted_item):
- # multiple possible values
- if item not in wanted_item:
+ if not is_list(item):
return False
+ # multiple possible values
+ for val in wanted_item:
+ if val not in item:
+ return False
return True
return item == wanted_item