laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35450?usp=email )
Change subject: global_platform: Add support for key types of v2.3.1 (including AES)
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35450?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iae30f18435c2b0a349bfd9240b9c7cca06674534
Gerrit-Change-Number: 35450
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Wed, 27 Dec 2023 15:40:52 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35449?usp=email )
Change subject: global_platform: Add TLV test data for Key Information Data
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35449?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib7b73cb28abea98986a66264a0779263873d7fb2
Gerrit-Change-Number: 35449
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Wed, 27 Dec 2023 15:40:46 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35448?usp=email )
Change subject: global_platform: Correctly decode Key Information Data
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35448?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icf367827d62ed67afa27ee3d0ba9d5cd5bc65c99
Gerrit-Change-Number: 35448
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Wed, 27 Dec 2023 15:40:43 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35447?usp=email )
Change subject: tlv: Fix from_dict() symmetry
......................................................................
tlv: Fix from_dict() symmetry
the to_dict() method generates a {class_name: value} dictionary,
for both the nested and non-nested case. However, before this patch,
the from_dict() method expects a plain list of child IE dicts
in the nested case. This is illogical.
Let's make sure from_dict always expectes a {class_name: value} dict
for both nested and non-nested situations.
Change-Id: I07e4feb3800b420d8be7aae8911f828f1da9dab8
---
M pySim/tlv.py
1 file changed, 21 insertions(+), 4 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/pySim/tlv.py b/pySim/tlv.py
index 6ea7dd1..4ac5ebf 100644
--- a/pySim/tlv.py
+++ b/pySim/tlv.py
@@ -157,13 +157,13 @@
def from_dict(self, decoded: dict):
"""Set the IE internal decoded representation to data from the argument.
If this is a nested IE, the child IE instance list is re-created."""
+ expected_key_name = camel_to_snake(type(self).__name__)
+ if not expected_key_name in decoded:
+ raise ValueError("Dict %s doesn't contain expected key %s" % (decoded, expected_key_name))
if self.nested_collection:
- self.children = self.nested_collection.from_dict(decoded)
+ self.children = self.nested_collection.from_dict(decoded[expected_key_name])
else:
self.children = []
- expected_key_name = camel_to_snake(type(self).__name__)
- if not expected_key_name in decoded:
- raise ValueError("Dict %s doesn't contain expected key %s" % (decoded, expected_key_name))
self.decoded = decoded[expected_key_name]
def is_constructed(self):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35447?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I07e4feb3800b420d8be7aae8911f828f1da9dab8
Gerrit-Change-Number: 35447
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35441?usp=email )
Change subject: data-driven TLV unit data test support
......................................................................
data-driven TLV unit data test support
While we do have the _test_de_encode data driven tests for file
definitions, we don't yet have something similar for derived classes of
BER_TLV_IE. This means that TLVs used outside of the filesystem context
(for example, decoding the SELECT/STATUS response, but also eUICC and
other stuff) do not yet have test coverage.
This commit just adds the related test code, but no test data yet.
Related: OS#6317
Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
---
A tests/test_tlvs.py
1 file changed, 140 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/tests/test_tlvs.py b/tests/test_tlvs.py
new file mode 100755
index 0000000..b0ad48a
--- /dev/null
+++ b/tests/test_tlvs.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+
+# (C) 2023 by Harald Welte <laforge(a)osmocom.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import unittest
+import logging
+
+from pySim.utils import b2h, h2b, all_subclasses
+from pySim.tlv import *
+
+import pySim.iso7816_4
+import pySim.ts_102_221
+import pySim.ts_102_222
+import pySim.ts_31_102
+import pySim.ts_31_103
+import pySim.ts_51_011
+import pySim.sysmocom_sja2
+import pySim.gsm_r
+import pySim.cdma_ruim
+
+if 'unittest.util' in __import__('sys').modules:
+ # Show full diff in self.assertEqual.
+ __import__('sys').modules['unittest.util']._MAX_LENGTH = 999999999
+
+def get_qualified_name(c):
+ """return the qualified (by module) name of a class."""
+ return "%s.%s" % (c.__module__, c.__name__)
+
+class TLV_IE_Test(unittest.TestCase):
+ maxDiff = None
+
+ @classmethod
+ def get_classes(cls):
+ """get list of TLV_IE sub-classes."""
+ return all_subclasses(TLV_IE)
+
+ @classmethod
+ def setUpClass(cls):
+ """set-up method called once for this class by unittest framework"""
+ cls.classes = cls.get_classes()
+
+ def test_decode_tlv(self):
+ """Test the decoder for a TLV_IE. Requires the given TLV_IE subclass
+ to have a '_test_decode' attribute, containing a list of tuples. Each tuple
+ is a 2-tuple (hexstring, decoded_dict).
+ """
+ for c in self.classes:
+ name = get_qualified_name(c)
+ if hasattr(c, '_test_decode'):
+ for t in c._test_decode:
+ with self.subTest(name, test_decode=t):
+ inst = c()
+ encoded = t[0]
+ decoded = { camel_to_snake(c.__name__): t[1] }
+ context = t[2] if len(t) == 3 else {}
+ logging.debug("Testing decode of %s", name)
+ inst.from_tlv(h2b(encoded), context=context)
+ re_dec = inst.to_dict()
+ self.assertEqual(decoded, re_dec)
+
+ def test_encode_tlv(self):
+ """Test the encoder for a TLV_IE. Requires the given TLV_IE subclass
+ to have a '_test_encode' attribute, containing a list of tuples. Each tuple
+ is a 2-tuple (hexstring, decoded_dict).
+ """
+ for c in self.classes:
+ name = get_qualified_name(c)
+ if hasattr(c, '_test_encode'):
+ for t in c._test_encode:
+ with self.subTest(name, test_encode=t):
+ inst = c()
+ encoded = t[0]
+ decoded = { camel_to_snake(c.__name__): t[1] }
+ context = t[2] if len(t) == 3 else {}
+ logging.debug("Testing encode of %s", name)
+ inst.from_dict(decoded)
+ re_enc = b2h(inst.to_tlv(context))
+ self.assertEqual(encoded.upper(), re_enc.upper())
+
+ def test_de_encode_tlv(self):
+ """Test the decoder and encoder for a TLV_IE. Performs first a decoder
+ test, and then re-encodes the decoded data, comparing the re-encoded data with the
+ initial input data.
+
+ Requires the given TLV_IE subclass to have a '_test_de_encode' attribute,
+ containing a list of tuples. Each tuple is a 2-tuple (hexstring, decoded_dict).
+ """
+ for c in self.classes:
+ name = get_qualified_name(c)
+ if hasattr(c, '_test_de_encode'):
+ for t in c._test_de_encode:
+ with self.subTest(name, test_de_encode=t):
+ inst = c()
+ encoded = t[0]
+ decoded = { camel_to_snake(c.__name__): t[1] }
+ context = t[2] if len(t) == 3 else {}
+ logging.debug("Testing decode of %s", name)
+ inst.from_tlv(h2b(encoded), context=context)
+ re_dec = inst.to_dict()
+ self.assertEqual(decoded, re_dec)
+ logging.debug("Testing re-encode of %s", name)
+ re_enc = b2h(inst.to_tlv(context=context))
+ self.assertEqual(encoded.upper(), re_enc.upper())
+
+
+if __name__ == '__main__':
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG)
+ unittest.main()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35441?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
Gerrit-Change-Number: 35441
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: dexter.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35441?usp=email )
Change subject: data-driven TLV unit data test support
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35441?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
Gerrit-Change-Number: 35441
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 27 Dec 2023 15:27:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: dexter, fixeria.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35440?usp=email )
Change subject: Fix enumeration of GlobbalPlatformISDR during card_init()
......................................................................
Patch Set 1:
(1 comment)
File pySim/global_platform.py:
https://gerrit.osmocom.org/c/pysim/+/35440/comment/64b31f36_d293ac57
PS1, Line 262: intermediate = False
it's rather ugly that we have to explicitly set this to False in the "leaf" class[es]. Ideally we'd have some kind of attribute that is not inheritable. Something that only exists in CardApplicationSD but not any derived classes.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35440?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7fb1637f8f7a149b536c4d77dac92736c526aa6c
Gerrit-Change-Number: 35440
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 27 Dec 2023 15:12:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: dexter, fixeria.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35440?usp=email )
Change subject: Fix enumeration of GlobbalPlatformISDR during card_init()
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
not sure if there's a more elegant way to resolve this other than the manual/explicit 'intermediate' class atrribute
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35440?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7fb1637f8f7a149b536c4d77dac92736c526aa6c
Gerrit-Change-Number: 35440
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 27 Dec 2023 15:09:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35447?usp=email )
Change subject: tlv: Fix from_dict() symmetry
......................................................................
tlv: Fix from_dict() symmetry
the to_dict() method generates a {class_name: value} dictionary,
for both the nested and non-nested case. However, before this patch,
the from_dict() method expects a plain list of child IE dicts
in the nested case. This is illogical.
Let's make sure from_dict always expectes a {class_name: value} dict
for both nested and non-nested situations.
Change-Id: I07e4feb3800b420d8be7aae8911f828f1da9dab8
---
M pySim/tlv.py
1 file changed, 21 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/47/35447/1
diff --git a/pySim/tlv.py b/pySim/tlv.py
index 6ea7dd1..4ac5ebf 100644
--- a/pySim/tlv.py
+++ b/pySim/tlv.py
@@ -157,13 +157,13 @@
def from_dict(self, decoded: dict):
"""Set the IE internal decoded representation to data from the argument.
If this is a nested IE, the child IE instance list is re-created."""
+ expected_key_name = camel_to_snake(type(self).__name__)
+ if not expected_key_name in decoded:
+ raise ValueError("Dict %s doesn't contain expected key %s" % (decoded, expected_key_name))
if self.nested_collection:
- self.children = self.nested_collection.from_dict(decoded)
+ self.children = self.nested_collection.from_dict(decoded[expected_key_name])
else:
self.children = []
- expected_key_name = camel_to_snake(type(self).__name__)
- if not expected_key_name in decoded:
- raise ValueError("Dict %s doesn't contain expected key %s" % (decoded, expected_key_name))
self.decoded = decoded[expected_key_name]
def is_constructed(self):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35447?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I07e4feb3800b420d8be7aae8911f828f1da9dab8
Gerrit-Change-Number: 35447
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: dexter.
Hello Jenkins Builder, dexter,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/35441?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: data-driven TLV unit data test support
......................................................................
data-driven TLV unit data test support
While we do have the _test_de_encode data driven tests for file
definitions, we don't yet have something similar for derived classes of
BER_TLV_IE. This means that TLVs used outside of the filesystem context
(for example, decoding the SELECT/STATUS response, but also eUICC and
other stuff) do not yet have test coverage.
This commit just adds the related test code, but no test data yet.
Related: OS#6317
Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
---
A tests/test_tlvs.py
1 file changed, 140 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/41/35441/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35441?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
Gerrit-Change-Number: 35441
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: keith.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email )
Change subject: VTY: fix config indentation for pcu-socket
......................................................................
Patch Set 2: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
Gerrit-Change-Number: 35443
Gerrit-PatchSet: 2
Gerrit-Owner: keith <keith(a)rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: keith <keith(a)rhizomatica.org>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: keith <keith(a)rhizomatica.org>
Gerrit-Comment-Date: Wed, 27 Dec 2023 11:26:36 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35445?usp=email )
Change subject: tests/fsm: also test .onenter and .onleave callbacks
......................................................................
tests/fsm: also test .onenter and .onleave callbacks
Extend the existing testing coverage to check per-state enter/leave
callbacks. An interesting behavior can be seen from the test output:
when allocating an FSM instance, the .onenter callback is not being
called for the initial FSM state (ST_NULL). Likewise, the .onleave
callback is not being called when free()ing an FSM instance.
Change-Id: I22edcf91375a09854f0dab1e2e02e034629310f7
---
M tests/fsm/fsm_test.c
M tests/fsm/fsm_test.err
2 files changed, 57 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/tests/fsm/fsm_test.c b/tests/fsm/fsm_test.c
index 960042c..3b83941 100644
--- a/tests/fsm/fsm_test.c
+++ b/tests/fsm/fsm_test.c
@@ -41,6 +41,18 @@
{ 0, NULL }
};
+static void test_fsm_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ LOGPFSM(fi, "%s() prev_state=%s\n",
+ __func__, osmo_fsm_state_name(fi->fsm, prev_state));
+}
+
+static void test_fsm_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
+{
+ LOGPFSM(fi, "%s() next_state=%s\n",
+ __func__, osmo_fsm_state_name(fi->fsm, next_state));
+}
+
static void test_fsm_null(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
switch (event) {
@@ -86,17 +98,23 @@
.out_state_mask = (1 << ST_ONE),
.name = "NULL",
.action = test_fsm_null,
+ .onenter = test_fsm_onenter,
+ .onleave = test_fsm_onleave,
},
[ST_ONE]= {
.in_event_mask = (1 << EV_B),
.out_state_mask = (1 << ST_TWO),
.name = "ONE",
.action= test_fsm_one,
+ .onenter = test_fsm_onenter,
+ .onleave = test_fsm_onleave,
},
[ST_TWO]= {
.in_event_mask = 0,
.name = "TWO",
.action = NULL,
+ .onenter = test_fsm_onenter,
+ .onleave = test_fsm_onleave,
},
};
diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err
index 51bf5da..fffb913 100644
--- a/tests/fsm/fsm_test.err
+++ b/tests/fsm/fsm_test.err
@@ -3,9 +3,13 @@
Test_FSM(my_id){NULL}: Received Event EV_B
Test_FSM(my_id){NULL}: Event EV_B not permitted
Test_FSM(my_id){NULL}: Received Event EV_A
+Test_FSM(my_id){NULL}: test_fsm_onleave() next_state=ONE
Test_FSM(my_id){NULL}: State change to ONE (no timeout)
+Test_FSM(my_id){ONE}: test_fsm_onenter() prev_state=NULL
Test_FSM(my_id){ONE}: Received Event EV_B
+Test_FSM(my_id){ONE}: test_fsm_onleave() next_state=TWO
Test_FSM(my_id){ONE}: State change to TWO (T2342, 1s)
+Test_FSM(my_id){TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM(my_id){TWO}: Timeout of T2342
Timer
Test_FSM(my_id){TWO}: Deallocated
@@ -83,16 +87,24 @@
--- test_state_chg_keep_timer()
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (no timeout)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
Total time passed: 0.000000 s
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T10, 10s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
Total time passed: 2.000342 s
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (keeping T10, 7.999s remaining)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Total time passed: 2.000342 s
Total time passed: 9.999999 s
Total time passed: 10.000000 s
@@ -104,14 +116,22 @@
--- test_state_chg_T()
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T42, 23s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T42, 23s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
@@ -120,7 +140,9 @@
--- test_state_chg_Ts()
Total time passed: 0.000000 s
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T4242, 8s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
Total time passed: 3.000000 s
Total time passed: 5.500000 s
Total time passed: 8.000000 s
@@ -133,7 +155,9 @@
--- test_state_chg_Tms()
Total time passed: 0.000000 s
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T4242, 1337ms)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
Total time passed: 0.500000 s
Total time passed: 0.750000 s
Total time passed: 1.100000 s
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35445?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I22edcf91375a09854f0dab1e2e02e034629310f7
Gerrit-Change-Number: 35445
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: fixeria.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35445?usp=email )
Change subject: tests/fsm: also test .onenter and .onleave callbacks
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35445?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I22edcf91375a09854f0dab1e2e02e034629310f7
Gerrit-Change-Number: 35445
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 27 Dec 2023 11:26:05 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: matanp.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35446?usp=email )
Change subject: ctrl: Add rxlev access min control
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35446?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I25bf4bb11bf8e34e80f740fb89a467fc6e491962
Gerrit-Change-Number: 35446
Gerrit-PatchSet: 1
Gerrit-Owner: matanp <matan1008(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: matanp <matan1008(a)gmail.com>
Gerrit-Comment-Date: Wed, 27 Dec 2023 10:23:07 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: keith.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email )
Change subject: VTY: fix config indentation for pcu-socket
......................................................................
Patch Set 2:
(1 comment)
File src/osmo-bsc/bsc_vty.c:
https://gerrit.osmocom.org/c/osmo-bsc/+/35443/comment/922422d3_f1f7133d
PS2, Line 420: pcu-socket-wqueue-length
please also fix this one
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
Gerrit-Change-Number: 35443
Gerrit-PatchSet: 2
Gerrit-Owner: keith <keith(a)rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: keith <keith(a)rhizomatica.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: keith <keith(a)rhizomatica.org>
Gerrit-Comment-Date: Wed, 27 Dec 2023 10:16:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35445?usp=email )
Change subject: tests/fsm: also test .onenter and .onleave callbacks
......................................................................
tests/fsm: also test .onenter and .onleave callbacks
Extend the existing testing coverage to check per-state enter/leave
callbacks. An interesting behavior can be seen from the test output:
when allocating an FSM instance, the .onenter callback is not being
called for the initial FSM state (ST_NULL). Likewise, the .onleave
callback is not being called when free()ing an FSM instance.
Change-Id: I22edcf91375a09854f0dab1e2e02e034629310f7
---
M tests/fsm/fsm_test.c
M tests/fsm/fsm_test.err
2 files changed, 57 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/35445/1
diff --git a/tests/fsm/fsm_test.c b/tests/fsm/fsm_test.c
index 960042c..3b83941 100644
--- a/tests/fsm/fsm_test.c
+++ b/tests/fsm/fsm_test.c
@@ -41,6 +41,18 @@
{ 0, NULL }
};
+static void test_fsm_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ LOGPFSM(fi, "%s() prev_state=%s\n",
+ __func__, osmo_fsm_state_name(fi->fsm, prev_state));
+}
+
+static void test_fsm_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
+{
+ LOGPFSM(fi, "%s() next_state=%s\n",
+ __func__, osmo_fsm_state_name(fi->fsm, next_state));
+}
+
static void test_fsm_null(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
switch (event) {
@@ -86,17 +98,23 @@
.out_state_mask = (1 << ST_ONE),
.name = "NULL",
.action = test_fsm_null,
+ .onenter = test_fsm_onenter,
+ .onleave = test_fsm_onleave,
},
[ST_ONE]= {
.in_event_mask = (1 << EV_B),
.out_state_mask = (1 << ST_TWO),
.name = "ONE",
.action= test_fsm_one,
+ .onenter = test_fsm_onenter,
+ .onleave = test_fsm_onleave,
},
[ST_TWO]= {
.in_event_mask = 0,
.name = "TWO",
.action = NULL,
+ .onenter = test_fsm_onenter,
+ .onleave = test_fsm_onleave,
},
};
diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err
index 51bf5da..fffb913 100644
--- a/tests/fsm/fsm_test.err
+++ b/tests/fsm/fsm_test.err
@@ -3,9 +3,13 @@
Test_FSM(my_id){NULL}: Received Event EV_B
Test_FSM(my_id){NULL}: Event EV_B not permitted
Test_FSM(my_id){NULL}: Received Event EV_A
+Test_FSM(my_id){NULL}: test_fsm_onleave() next_state=ONE
Test_FSM(my_id){NULL}: State change to ONE (no timeout)
+Test_FSM(my_id){ONE}: test_fsm_onenter() prev_state=NULL
Test_FSM(my_id){ONE}: Received Event EV_B
+Test_FSM(my_id){ONE}: test_fsm_onleave() next_state=TWO
Test_FSM(my_id){ONE}: State change to TWO (T2342, 1s)
+Test_FSM(my_id){TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM(my_id){TWO}: Timeout of T2342
Timer
Test_FSM(my_id){TWO}: Deallocated
@@ -83,16 +87,24 @@
--- test_state_chg_keep_timer()
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (no timeout)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
Total time passed: 0.000000 s
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T10, 10s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
Total time passed: 2.000342 s
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (keeping T10, 7.999s remaining)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Total time passed: 2.000342 s
Total time passed: 9.999999 s
Total time passed: 10.000000 s
@@ -104,14 +116,22 @@
--- test_state_chg_T()
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T42, 23s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T42, 23s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
+Test_FSM{ONE}: test_fsm_onleave() next_state=TWO
Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: test_fsm_onenter() prev_state=ONE
Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
Test_FSM{TWO}: Freeing instance
Test_FSM{TWO}: Deallocated
@@ -120,7 +140,9 @@
--- test_state_chg_Ts()
Total time passed: 0.000000 s
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T4242, 8s)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
Total time passed: 3.000000 s
Total time passed: 5.500000 s
Total time passed: 8.000000 s
@@ -133,7 +155,9 @@
--- test_state_chg_Tms()
Total time passed: 0.000000 s
Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: test_fsm_onleave() next_state=ONE
Test_FSM{NULL}: State change to ONE (T4242, 1337ms)
+Test_FSM{ONE}: test_fsm_onenter() prev_state=NULL
Total time passed: 0.500000 s
Total time passed: 0.750000 s
Total time passed: 1.100000 s
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35445?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I22edcf91375a09854f0dab1e2e02e034629310f7
Gerrit-Change-Number: 35445
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
keith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email )
Change subject: VTY: fix config indentation for pcu-socket
......................................................................
Patch Set 2:
(1 comment)
Patchset:
PS2:
I'd be tempted to just merge this based on
https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit#Exceptions…
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
Gerrit-Change-Number: 35443
Gerrit-PatchSet: 2
Gerrit-Owner: keith <keith(a)rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: keith <keith(a)rhizomatica.org>
Gerrit-Comment-Date: Tue, 26 Dec 2023 00:35:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
keith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email )
Change subject: VTY: fix config indentation for pcu-socket
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
Gerrit-Change-Number: 35443
Gerrit-PatchSet: 2
Gerrit-Owner: keith <keith(a)rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: keith <keith(a)rhizomatica.org>
Gerrit-Comment-Date: Tue, 26 Dec 2023 00:33:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
keith has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email )
Change subject: VTY: fix config indentation for pcu-socket
......................................................................
VTY: fix config indentation for pcu-socket
osmo-bsc would not start with a config written from the vty due
to incorrect identation on the pcu-socket parameter.
Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
---
M src/osmo-bsc/bsc_vty.c
1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/43/35443/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
Gerrit-Change-Number: 35443
Gerrit-PatchSet: 2
Gerrit-Owner: keith <keith(a)rhizomatica.org>
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset
keith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email )
Change subject: VTY: fix config indentation for pcu-socket
......................................................................
VTY: fix config indentation for pcu-socket
osmo-bsc would not start with a config written from the vty due
to incorrect identation on the pcu-socket parameter.
Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
---
M src/osmo-bsc/bsc_vty.c
1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/43/35443/1
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index bdc18b6..cc0a61a 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -415,7 +415,7 @@
}
if (gsmnet->pcu_sock_path)
- vty_out(vty, " pcu-socket %s%s", gsmnet->pcu_sock_path, VTY_NEWLINE);
+ vty_out(vty, " pcu-socket %s%s", gsmnet->pcu_sock_path, VTY_NEWLINE);
neighbor_ident_vty_write_network(vty, " ");
mgcp_client_pool_config_write(vty, " ");
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35443?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I36a66794e654989b4b8bf54bb3727ccbfc2131fa
Gerrit-Change-Number: 35443
Gerrit-PatchSet: 1
Gerrit-Owner: keith <keith(a)rhizomatica.org>
Gerrit-MessageType: newchange
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35441?usp=email )
Change subject: data-driven TLV unit data test support
......................................................................
data-driven TLV unit data test support
While we do have the _test_de_encode data driven tests for file
definitions, we don't yet have something similar for derived classes of
BER_TLV_IE. This means that TLVs used outside of the filesystem context
(for example, decoding the SELECT/STATUS response, but also eUICC and
other stuff) do not yet have test coverage.
This commit just adds the related test code, but no test data yet.
Related: OS#6317
Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
---
A tests/test_tlvs.py
1 file changed, 138 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/41/35441/1
diff --git a/tests/test_tlvs.py b/tests/test_tlvs.py
new file mode 100755
index 0000000..d35be3b
--- /dev/null
+++ b/tests/test_tlvs.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python3
+
+# (C) 2023 by Harald Welte <laforge(a)osmocom.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import unittest
+import logging
+
+from pySim.utils import b2h, h2b, all_subclasses
+from pySim.tlv import *
+
+import pySim.iso7816_4
+import pySim.ts_102_221
+import pySim.ts_102_222
+import pySim.ts_31_102
+import pySim.ts_31_103
+import pySim.ts_51_011
+import pySim.sysmocom_sja2
+import pySim.gsm_r
+import pySim.cdma_ruim
+
+if 'unittest.util' in __import__('sys').modules:
+ # Show full diff in self.assertEqual.
+ __import__('sys').modules['unittest.util']._MAX_LENGTH = 999999999
+
+def get_qualified_name(c):
+ """return the qualified (by module) name of a class."""
+ return "%s.%s" % (c.__module__, c.__name__)
+
+class TLV_IE_Test(unittest.TestCase):
+ maxDiff = None
+
+ @classmethod
+ def get_classes(cls):
+ """get list of TLV_IE sub-classes."""
+ return all_subclasses(TLV_IE)
+
+ @classmethod
+ def setUpClass(cls):
+ """set-up method called once for this class by unittest framework"""
+ cls.classes = cls.get_classes()
+
+ def test_decode_tlv(self):
+ """Test the decoder for a TLV_IE. Requires the given TLV_IE subclass
+ to have a '_test_decode' attribute, containing a list of tuples. Each tuple
+ is a 2-tuple (hexstring, decoded_dict).
+ """
+ for c in self.classes:
+ name = get_qualified_name(c)
+ if hasattr(c, '_test_decode'):
+ for t in c._test_decode:
+ with self.subTest(name, test_decode=t):
+ inst = c()
+ encoded = t[0]
+ decoded = t[1]
+ context = t[2] if len(t) == 3 else {}
+ logging.debug("Testing decode of %s", name)
+ re_dec, remainder = inst.from_tlv(h2b(encoded), context=context)
+ self.assertEqual(decoded, re_dec)
+
+ def test_encode_tlv(self):
+ """Test the encoder for a TLV_IE. Requires the given TLV_IE subclass
+ to have a '_test_encode' attribute, containing a list of tuples. Each tuple
+ is a 2-tuple (hexstring, decoded_dict).
+ """
+ for c in self.classes:
+ name = get_qualified_name(c)
+ if hasattr(c, '_test_encode'):
+ for t in c._test_encode:
+ with self.subTest(name, test_encode=t):
+ inst = c()
+ encoded = t[0]
+ decoded = t[1]
+ context = t[2] if len(t) == 3 else {}
+ logging.debug("Testing encode of %s", name)
+ inst.from_dict(decoded)
+ re_enc = b2h(inst.to_tlv(context))
+ self.assertEqual(encoded.upper(), re_enc.upper())
+
+ def test_de_encode_tlv(self):
+ """Test the decoder and encoder for a TLV_IE. Performs first a decoder
+ test, and then re-encodes the decoded data, comparing the re-encoded data with the
+ initial input data.
+
+ Requires the given TLV_IE subclass to have a '_test_de_encode' attribute,
+ containing a list of tuples. Each tuple is a 2-tuple (hexstring, decoded_dict).
+ """
+ for c in self.classes:
+ name = get_qualified_name(c)
+ if hasattr(c, '_test_de_encode'):
+ for t in c._test_de_encode:
+ with self.subTest(name, test_de_encode=t):
+ inst = c()
+ encoded = t[0]
+ decoded = t[1]
+ context = t[2] if len(t) == 3 else {}
+ logging.debug("Testing decode of %s", name)
+ re_dec, remainder = inst.from_tlv(h2b(encoded), context=context)
+ self.assertEqual(decoded, re_dec)
+ logging.debug("Testing re-encode of %s", name)
+ re_enc = b2h(inst.to_tlv(context=context))
+ self.assertEqual(encoded.upper(), re_enc.upper())
+
+
+if __name__ == '__main__':
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG)
+ unittest.main()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35441?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ied85f292bb57fde11dc188be84e3384dc3ff1601
Gerrit-Change-Number: 35441
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35440?usp=email )
Change subject: Fix enumeration of GlobbalPlatformISDR during card_init()
......................................................................
Fix enumeration of GlobbalPlatformISDR during card_init()
We used __subclasses__(), but this only returns the immediate
subclasses and not all further/nested subclasses. Instead, we must
use the pySim.utils.all_subclasses() function to really get all of them.
The hack to use the method signature of the constructor to determine if
it's an intermediate class didn't work, as even GlobbalPlatformISDR
has a optional argument for non-default AIDs. So let's introduce an
explicit class attribute for that purpose.
Change-Id: I7fb1637f8f7a149b536c4d77dac92736c526aa6c
---
M pySim/app.py
M pySim/global_platform.py
2 files changed, 23 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/40/35440/1
diff --git a/pySim/app.py b/pySim/app.py
index b0df85f..421cb4d 100644
--- a/pySim/app.py
+++ b/pySim/app.py
@@ -14,7 +14,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import inspect
from typing import Tuple
from pySim.transport import LinkBase
@@ -26,6 +25,7 @@
from pySim.profile import CardProfile
from pySim.cdma_ruim import CardProfileRUIM
from pySim.ts_102_221 import CardProfileUICC
+from pySim.utils import all_subclasses
# we need to import this module so that the SysmocomSJA2 sub-class of
# CardModel is created, which will add the ATR-based matching and
@@ -87,10 +87,9 @@
# We cannot do it within pySim/profile.py as that would create circular
# dependencies between the individual profiles and profile.py.
if isinstance(profile, CardProfileUICC):
- for app_cls in CardApplication.__subclasses__():
- constr_sig = inspect.signature(app_cls.__init__)
+ for app_cls in all_subclasses(CardApplication):
# skip any intermediary sub-classes such as CardApplicationSD
- if len(constr_sig.parameters) != 1:
+ if hasattr(app_cls, 'intermediate') and app_cls.intermediate:
continue
profile.add_application(app_cls())
# We have chosen SimCard() above, but we now know it actually is an UICC
diff --git a/pySim/global_platform.py b/pySim/global_platform.py
index 136cccc..5382f93 100644
--- a/pySim/global_platform.py
+++ b/pySim/global_platform.py
@@ -253,11 +253,13 @@
# Card Application of a Security Domain
class CardApplicationSD(CardApplication):
+ intermediate = True
def __init__(self, aid: str, name: str, desc: str):
super().__init__(name, adf=ADF_SD(aid, name, desc), sw=sw_table)
# Card Application of Issuer Security Domain
class CardApplicationISD(CardApplicationSD):
+ intermediate = False
# FIXME: ISD AID is not static, but could be different. One can select the empty
# application using '00a4040000' and then parse the response FCI to get the ISD AID
def __init__(self, aid='a000000003000000'):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35440?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7fb1637f8f7a149b536c4d77dac92736c526aa6c
Gerrit-Change-Number: 35440
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/35439?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: filesystem: use pySim.utils.build_construct()
......................................................................
filesystem: use pySim.utils.build_construct()
We recently introduced a pySim.utils.build_construct() wrapper around
the raw call of the construct.build() method. So far, this wrapper
was only used from pySim.tlv, but let's also use it from
pySim.filesystem.
Basically, whenever we use parse_construct(), we should use
build_construct() as the inverse operation.
Change-Id: Ibfd61cd87edc72882aa66d6ff17861a3e918affb
---
M pySim/filesystem.py
M pySim/sysmocom_sja2.py
2 files changed, 26 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/39/35439/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35439?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ibfd61cd87edc72882aa66d6ff17861a3e918affb
Gerrit-Change-Number: 35439
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset
Attention is currently required from: dexter, fixeria.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35363?usp=email )
The change is no longer submittable: Code-Review is unsatisfied now.
Change subject: decode security attributes compact field in FCP
......................................................................
Patch Set 6: -Code-Review
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35363?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iaa1167349027222e69a561d20a4c595fba2fdd2b
Gerrit-Change-Number: 35363
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Sat, 23 Dec 2023 13:24:56 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: dexter, fixeria, laforge.
laforge has uploaded a new patch set (#6) to the change originally created by dexter. ( https://gerrit.osmocom.org/c/pysim/+/35363?usp=email )
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: decode security attributes compact field in FCP
......................................................................
decode security attributes compact field in FCP
When we select files, we currently display the security attributes
compact field as raw bytes only. Let's decode this field using construct
so that it gets displayed in human readable form.
Change-Id: Iaa1167349027222e69a561d20a4c595fba2fdd2b
Related: OS#6211
---
M pySim/ts_102_221.py
1 file changed, 44 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/63/35363/6
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35363?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iaa1167349027222e69a561d20a4c595fba2fdd2b
Gerrit-Change-Number: 35363
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: dexter, fixeria, laforge.
laforge has uploaded a new patch set (#5) to the change originally created by dexter. ( https://gerrit.osmocom.org/c/pysim/+/35363?usp=email )
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: decode security attributes compact field in FCP
......................................................................
decode security attributes compact field in FCP
When we select files, we currently display the security attributes
compact field as raw bytes only. Let's decode this field using construct
so that it gets displayed in human readable form.
Change-Id: Iaa1167349027222e69a561d20a4c595fba2fdd2b
Related: OS#6211
---
M pySim/ts_102_221.py
1 file changed, 44 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/63/35363/5
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35363?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iaa1167349027222e69a561d20a4c595fba2fdd2b
Gerrit-Change-Number: 35363
Gerrit-PatchSet: 5
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newpatchset
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35438?usp=email )
Change subject: pySim-trace_test.sh: Force termcolor to suppress color generation
......................................................................
pySim-trace_test.sh: Force termcolor to suppress color generation
on some systems, the output would otherwise contain colored status
words, which in turn mean the test otuput no longer matches the expected
output.
Change-Id: Icb700f6e85a285748e00367a398975aa5e75dec5
---
M tests/pySim-trace_test.sh
1 file changed, 15 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/tests/pySim-trace_test.sh b/tests/pySim-trace_test.sh
index f7b97e8..3e200c3 100755
--- a/tests/pySim-trace_test.sh
+++ b/tests/pySim-trace_test.sh
@@ -25,6 +25,8 @@
TEMPFILE=temp.tmp
export PYSIM_INTEGRATION_TEST=1
+# to avoid termcolor.colored generating colors; https://github.com/termcolor/termcolor
+export ANSI_COLORS_DISABLED=1
echo "pySim-trace_test - a test program to test pySim-trace.py"
echo "========================================================"
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35438?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icb700f6e85a285748e00367a398975aa5e75dec5
Gerrit-Change-Number: 35438
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35438?usp=email )
Change subject: pySim-trace_test.sh: Force termcolor to suppress color generation
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35438?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icb700f6e85a285748e00367a398975aa5e75dec5
Gerrit-Change-Number: 35438
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Sat, 23 Dec 2023 10:08:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35438?usp=email )
Change subject: pySim-trace_test.sh: Force termcolor to suppress color generation
......................................................................
pySim-trace_test.sh: Force termcolor to suppress color generation
on some systems, the output would otherwise contain colored status
words, which in turn mean the test otuput no longer matches the expected
output.
Change-Id: Icb700f6e85a285748e00367a398975aa5e75dec5
---
M tests/pySim-trace_test.sh
1 file changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/38/35438/1
diff --git a/tests/pySim-trace_test.sh b/tests/pySim-trace_test.sh
index f7b97e8..3e200c3 100755
--- a/tests/pySim-trace_test.sh
+++ b/tests/pySim-trace_test.sh
@@ -25,6 +25,8 @@
TEMPFILE=temp.tmp
export PYSIM_INTEGRATION_TEST=1
+# to avoid termcolor.colored generating colors; https://github.com/termcolor/termcolor
+export ANSI_COLORS_DISABLED=1
echo "pySim-trace_test - a test program to test pySim-trace.py"
echo "========================================================"
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35438?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icb700f6e85a285748e00367a398975aa5e75dec5
Gerrit-Change-Number: 35438
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange