Attention is currently required from: pespin.
fixeria has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38208?usp=email )
Change subject: library: as_pfcp_ignore(): log SeqNr of received PDUs
......................................................................
Patch Set 2:
(1 comment)
File library/PFCP_Emulation.ttcn:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38208/comment/38167f1f_f42d… :
PS2, Line 398: log("Ignoring PFCP PDU (SeqNr := ", pdu.sequence_number, ")");
> ... we end up every week during weekly meeting looking at Junit output from jenkins with totally meaningless error reports.
This is an unrelated problem, IMO. This logging line will not be part of the JUnit output anyway, because it's not a verdict operation. It's here purely for debugging.
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38208?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I803ff46def4ae0182310bc01e753fe0c05112836
Gerrit-Change-Number: 38208
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 20 Sep 2024 14:58:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Attention is currently required from: pespin.
fixeria has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38207?usp=email )
Change subject: library/PFCP_Emulation: a better PDU routing concept
......................................................................
Patch Set 2:
(1 comment)
File hnbgw/HNBGW_Tests.ttcn:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38207/comment/9cb88e3d_ba17… :
PS2, Line 1967: f_PFCPEM_subscribe_seid(c_SEID0);
> Yes, that's the point. You don't expect, but then if IUT misbehaves and sends one, you won't see it in the test since it will be discarded by the emulation :)
Not really convinced about saving lines, as TITAN fortunately does not impose the limits on that ;) But I see your point about catching messages that are not normally expected and ACKnowledge that.
In this specific case the problem can be solved a lot simpler, simply by swapping these two functions, i.e. calling `f_PFCPEM_subscribe_seid()` before `f_PFCPEM_unsubscribe_bcast()`. This way we have no gap and keep the subscription API simple. I'll do this.
An alternative solution would be adding an option to the PFCPEM component, that would make it declare a failure if an incoming PDU was not delivered to any `ConnHdlr` and has been dropped. This is a more generic approach, IMO.
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38207?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I25802471519fa297ad4cb2b056adaa6748b00af2
Gerrit-Change-Number: 38207
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 20 Sep 2024 14:53:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38203?usp=email )
Change subject: osmocom.utils: Return hexstr type form argparse helpers
......................................................................
osmocom.utils: Return hexstr type form argparse helpers
Change-Id: Ide9f3c6b364d867f2dfc1b7dfda40dbab03c5130
---
M src/osmocom/utils.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/src/osmocom/utils.py b/src/osmocom/utils.py
index 6c91783..a218e1b 100644
--- a/src/osmocom/utils.py
+++ b/src/osmocom/utils.py
@@ -203,16 +203,16 @@
raise ValueError('Input must be [hexa]decimal')
if len(instr) & 1:
raise ValueError('Input has un-even number of hex digits')
- return instr
+ return hexstr(instr)
-def is_hexstr(instr: str) -> str:
+def is_hexstr(instr: str) -> hexstr:
"""Method that can be used as 'type' in argparse.add_argument() to validate the value consists of
an even sequence of hexadecimal digits only."""
if not all(c in string.hexdigits for c in instr):
raise ValueError('Input must be hexadecimal')
if len(instr) & 1:
raise ValueError('Input has un-even number of hex digits')
- return instr
+ return hexstr(instr)
def is_decimal(instr: str) -> str:
"""Method that can be used as 'type' in argparse.add_argument() to validate the value consists of
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38203?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Ide9f3c6b364d867f2dfc1b7dfda40dbab03c5130
Gerrit-Change-Number: 38203
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-Reviewer: laforge <laforge(a)osmocom.org>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38202?usp=email )
Change subject: osmocom.utils: Make b2h/i2h/swap_nibbles return hexstr type
......................................................................
osmocom.utils: Make b2h/i2h/swap_nibbles return hexstr type
Change-Id: I4c72c33baf6e4b3a39fb28d72ad66fbd3e957e95
---
M src/osmocom/utils.py
1 file changed, 40 insertions(+), 38 deletions(-)
Approvals:
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/osmocom/utils.py b/src/osmocom/utils.py
index 183bbb8..6c91783 100644
--- a/src/osmocom/utils.py
+++ b/src/osmocom/utils.py
@@ -27,7 +27,39 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# just to differentiate strings of hex nibbles from everything else
+class hexstr(str):
+ """Class derived from 'str', represeting a string of hexadecimal digits. It differs in that
+ comparisons are case-insensitive, and it offers encoding-free conversion from hexstr to bytes
+ and vice-versa."""
+ def __new__(cls, s: str):
+ if not all(c in string.hexdigits for c in s):
+ raise ValueError('Input must be hexadecimal digits only')
+ # store as lower case digits
+ return super().__new__(cls, s.lower())
+
+ def __eq__(self, other: str) -> bool:
+ # make sure comparison is done case-insensitive
+ return str(self) == other.lower()
+
+ def __getitem__(self, val) -> 'hexstr':
+ # make sure slicing a hexstr will return a hexstr
+ return hexstr(super().__getitem__(val))
+
+ def to_bytes(self) -> bytes:
+ """return hex-string converted to bytes"""
+ s = str(self)
+ if len(s) & 1:
+ raise ValueError('Cannot convert hex string with odd number of digits')
+ return h2b(s)
+
+ @classmethod
+ def from_bytes(cls, bt: bytes) -> 'hexstr':
+ """instantiate hex-string from bytes"""
+ return cls(b2h(bt))
+
+# just to differentiate strings of hex nibbles from everything else; only used for typing
+# hints. New code should typically use the 'class hexstr' type above to get the benefit
+# of case-insensitive comparison.
Hexstr = NewType('Hexstr', str)
def h2b(s: Hexstr) -> bytearray:
@@ -35,9 +67,9 @@
return bytearray.fromhex(s)
-def b2h(b: bytearray) -> Hexstr:
+def b2h(b: bytearray) -> hexstr:
"""convert from a sequence of bytes to a string of hex nibbles"""
- return ''.join(['%02x' % (x) for x in b])
+ return hexstr(''.join(['%02x' % (x) for x in b]))
def h2i(s: Hexstr) -> List[int]:
@@ -45,9 +77,9 @@
return [(int(x, 16) << 4)+int(y, 16) for x, y in zip(s[0::2], s[1::2])]
-def i2h(s: List[int]) -> Hexstr:
+def i2h(s: List[int]) -> hexstr:
"""convert from a list of integers to a string of hex nibbles"""
- return ''.join(['%02x' % (x) for x in s])
+ return hexstr(''.join(['%02x' % (x) for x in s]))
def h2s(s: Hexstr) -> str:
@@ -56,7 +88,7 @@
if int(x + y, 16) != 0xff])
-def s2h(s: str) -> Hexstr:
+def s2h(s: str) -> hexstr:
"""convert from an ASCII string to a string of hex nibbles"""
b = bytearray()
b.extend(map(ord, s))
@@ -68,9 +100,9 @@
return ''.join([chr(x) for x in s])
-def swap_nibbles(s: Hexstr) -> Hexstr:
+def swap_nibbles(s: Hexstr) -> hexstr:
"""swap the nibbles in a hex string"""
- return ''.join([x+y for x, y in zip(s[1::2], s[0::2])])
+ return hexstr(''.join([x+y for x, y in zip(s[1::2], s[0::2])]))
def rpad(s: str, l: int, c='f') -> str:
@@ -138,36 +170,6 @@
except:
return False
-class hexstr(str):
- """Class derived from 'str', represeting a string of hexadecimal digits. It differs in that
- comparisons are case-insensitive, and it offers encoding-free conversion from hexstr to bytes
- and vice-versa."""
- def __new__(cls, s: str):
- if not all(c in string.hexdigits for c in s):
- raise ValueError('Input must be hexadecimal digits only')
- # store as lower case digits
- return super().__new__(cls, s.lower())
-
- def __eq__(self, other: str) -> bool:
- # make sure comparison is done case-insensitive
- return str(self) == other.lower()
-
- def __getitem__(self, val) -> 'hexstr':
- # make sure slicing a hexstr will return a hexstr
- return hexstr(super().__getitem__(val))
-
- def to_bytes(self) -> bytes:
- """return hex-string converted to bytes"""
- s = str(self)
- if len(s) & 1:
- raise ValueError('Cannot convert hex string with odd number of digits')
- return h2b(s)
-
- @classmethod
- def from_bytes(cls, bt: bytes) -> 'hexstr':
- """instantiate hex-string from bytes"""
- return cls(b2h(bt))
-
#########################################################################
# ARGPARSE HELPERS
#########################################################################
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38202?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I4c72c33baf6e4b3a39fb28d72ad66fbd3e957e95
Gerrit-Change-Number: 38202
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-Reviewer: laforge <laforge(a)osmocom.org>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38204?usp=email )
Change subject: osmocom.utils: Make 'hexstr' type hashable
......................................................................
osmocom.utils: Make 'hexstr' type hashable
otherwise we couldn't use hexstr values as dict keys, for example
Change-Id: Ic9e1f8af1db436af5456fe5964133a144c9e066b
---
M src/osmocom/utils.py
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/src/osmocom/utils.py b/src/osmocom/utils.py
index a218e1b..009eb04 100644
--- a/src/osmocom/utils.py
+++ b/src/osmocom/utils.py
@@ -41,6 +41,10 @@
# make sure comparison is done case-insensitive
return str(self) == other.lower()
+ def __hash__(self):
+ # having a custom __eq__ method will make the type unhashable by default, lets fix that
+ return hash(str(self))
+
def __getitem__(self, val) -> 'hexstr':
# make sure slicing a hexstr will return a hexstr
return hexstr(super().__getitem__(val))
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38204?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Ic9e1f8af1db436af5456fe5964133a144c9e066b
Gerrit-Change-Number: 38204
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-Reviewer: laforge <laforge(a)osmocom.org>
laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38205?usp=email )
Change subject: bump version to 0.0.4 for the recent hexstr improvements
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38205?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I4bc48a5c3546bd8d170bc97f77a9ecf557f933ae
Gerrit-Change-Number: 38205
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 20 Sep 2024 14:39:02 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes