Attention is currently required from: dexter, fixeria, laforge.
Hello Jenkins Builder, fixeria, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/37819?usp=email
to look at the new patch set (#23).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: Add testsuite for pySim-shell with real cards
......................................................................
Add testsuite for pySim-shell with real cards
This patch adds a comprehensive testsuite for pySim-shell. The testsuite
is based on python's unittest framework in combination with pySim-shell
scripts.
Related: OS#6531
Change-Id: Ieae1330767a6e55e62437f5f988a0d33b727b5de
---
M contrib/jenkins.sh
A tests/pySim-shell_test/README.txt
A tests/pySim-shell_test/__init__.py
A tests/pySim-shell_test/ara_m/__init__.py
A tests/pySim-shell_test/ara_m/adf_ara-m.cfg.ok
A tests/pySim-shell_test/ara_m/adf_ara-m.script.ok
A tests/pySim-shell_test/ara_m/adf_ara-m_empty.cfg.ok
A tests/pySim-shell_test/ara_m/test.py
A tests/pySim-shell_test/ara_m/test.script
A tests/pySim-shell_test/authenticate/__init__.py
A tests/pySim-shell_test/authenticate/auth_result.ok
A tests/pySim-shell_test/authenticate/test.py
A tests/pySim-shell_test/authenticate/test.script
A tests/pySim-shell_test/card_data.csv
A tests/pySim-shell_test/cardinfo/__init__.py
A tests/pySim-shell_test/cardinfo/sysmoEUICC1-C2T-cardinfo.ok
A tests/pySim-shell_test/cardinfo/sysmoISIM-SJA2-cardinfo.ok
A tests/pySim-shell_test/cardinfo/sysmoISIM-SJA5-S17-cardinfo.ok
A tests/pySim-shell_test/cardinfo/sysmoSIM-GR1-cardinfo.ok
A tests/pySim-shell_test/cardinfo/test.py
A tests/pySim-shell_test/cardinfo/test.template
A tests/pySim-shell_test/chv/__init__.py
A tests/pySim-shell_test/chv/test.py
A tests/pySim-shell_test/chv/test_manage_csv.ok
A tests/pySim-shell_test/chv/test_manage_csv.template
A tests/pySim-shell_test/chv/test_manage_direct.ok
A tests/pySim-shell_test/chv/test_manage_direct.template
A tests/pySim-shell_test/chv/test_unblock_csv.ok
A tests/pySim-shell_test/chv/test_unblock_csv.script
A tests/pySim-shell_test/chv/test_unblock_direct.ok
A tests/pySim-shell_test/chv/test_unblock_direct.template
A tests/pySim-shell_test/config.yaml
A tests/pySim-shell_test/euicc/__init__.py
A tests/pySim-shell_test/euicc/enable_disable_profile.ok
A tests/pySim-shell_test/euicc/euicc_info1.ok
A tests/pySim-shell_test/euicc/euicc_info2.ok
A tests/pySim-shell_test/euicc/get_eid.ok
A tests/pySim-shell_test/euicc/get_profiles_info.ok
A tests/pySim-shell_test/euicc/notifications.ok
A tests/pySim-shell_test/euicc/set_nickname.ok
A tests/pySim-shell_test/euicc/test.py
A tests/pySim-shell_test/euicc/test_enable_disable_profile.script
A tests/pySim-shell_test/euicc/test_gen_notif.script
A tests/pySim-shell_test/euicc/test_get_eid.script
A tests/pySim-shell_test/euicc/test_get_euicc_info.script
A tests/pySim-shell_test/euicc/test_get_profiles_info.script
A tests/pySim-shell_test/euicc/test_list_notif.script
A tests/pySim-shell_test/euicc/test_rm_notif.template
A tests/pySim-shell_test/euicc/test_set_nickname.script
A tests/pySim-shell_test/export/__init__.py
A tests/pySim-shell_test/export/export.script.ok
A tests/pySim-shell_test/export/test.py
A tests/pySim-shell_test/export/test_export.script
A tests/pySim-shell_test/export/test_import.script
A tests/pySim-shell_test/file_admin/__init__.py
A tests/pySim-shell_test/file_admin/activate_deactivate_file.ok
A tests/pySim-shell_test/file_admin/test.py
A tests/pySim-shell_test/file_admin/test_activate_deactivate_file.script
A tests/pySim-shell_test/file_admin/test_create_delete_df.script
A tests/pySim-shell_test/file_admin/test_create_resize_delete_linear_fixed_ef.script
A tests/pySim-shell_test/file_admin/test_create_resize_delete_transparent_ef.script
A tests/pySim-shell_test/file_content/__init__.py
A tests/pySim-shell_test/file_content/test.py
A tests/pySim-shell_test/file_content/test_ber_tlv_uicc.ok
A tests/pySim-shell_test/file_content/test_ber_tlv_uicc.script
A tests/pySim-shell_test/file_content/test_binary_sim.ok
A tests/pySim-shell_test/file_content/test_binary_sim.script
A tests/pySim-shell_test/file_content/test_binary_uicc.ok
A tests/pySim-shell_test/file_content/test_binary_uicc.script
A tests/pySim-shell_test/file_content/test_record_sim.ok
A tests/pySim-shell_test/file_content/test_record_sim.script
A tests/pySim-shell_test/file_content/test_record_uicc.ok
A tests/pySim-shell_test/file_content/test_record_uicc.script
A tests/pySim-shell_test/file_specific/__init__.py
A tests/pySim-shell_test/file_specific/ef_imsi.ok
A tests/pySim-shell_test/file_specific/test.py
A tests/pySim-shell_test/file_specific/test_ef_ist.ok
A tests/pySim-shell_test/file_specific/test_ef_ist.script
A tests/pySim-shell_test/file_specific/test_ef_ust.ok
A tests/pySim-shell_test/file_specific/test_ef_ust.script
A tests/pySim-shell_test/file_specific/test_update_imsi_plmn.script
A tests/pySim-shell_test/fsdump/__init__.py
A tests/pySim-shell_test/fsdump/fsdump.json.ok
A tests/pySim-shell_test/fsdump/test.py
A tests/pySim-shell_test/fsdump/test.script
A tests/pySim-shell_test/get_identity/__init__.py
A tests/pySim-shell_test/get_identity/test.py
A tests/pySim-shell_test/get_identity/test.script
A tests/pySim-shell_test/gp/__init__.py
A tests/pySim-shell_test/gp/get_status_isd.ok
A tests/pySim-shell_test/gp/key_information.ok
A tests/pySim-shell_test/gp/test.py
A tests/pySim-shell_test/gp/test_est_scp02_csv.script
A tests/pySim-shell_test/gp/test_est_scp02_direct.template
A tests/pySim-shell_test/gp/test_est_scp03_csv.script
A tests/pySim-shell_test/gp/test_est_scp03_direct.template
A tests/pySim-shell_test/gp/test_get_status.script
A tests/pySim-shell_test/gp/test_put_delete_key.script
A tests/pySim-shell_test/lchan/__init__.py
A tests/pySim-shell_test/lchan/test.ok
A tests/pySim-shell_test/lchan/test.py
A tests/pySim-shell_test/lchan/test.script
A tests/pySim-shell_test/navigate_fs/__init__.py
A tests/pySim-shell_test/navigate_fs/checkpoints_sim.ok
A tests/pySim-shell_test/navigate_fs/checkpoints_uicc.ok
A tests/pySim-shell_test/navigate_fs/test.py
A tests/pySim-shell_test/navigate_fs/test_sim.script
A tests/pySim-shell_test/navigate_fs/test_uicc.script
A tests/pySim-shell_test/utils.py
A tests/pySim-shell_test/verify_adm/__init__.py
A tests/pySim-shell_test/verify_adm/test.py
A tests/pySim-shell_test/verify_adm/test_cmdline.script
A tests/pySim-shell_test/verify_adm/test_csv.script
A tests/pySim-shell_test/verify_adm/test_direct.template
114 files changed, 22,424 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/19/37819/23
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37819?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ieae1330767a6e55e62437f5f988a0d33b727b5de
Gerrit-Change-Number: 37819
Gerrit-PatchSet: 23
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>
Attention is currently required from: dexter.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/38232?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: pySim-prog_test: add test vectors for sysmoISIM-SJA5
......................................................................
pySim-prog_test: add test vectors for sysmoISIM-SJA5
The sysmoISIM-SJA5 has no testvectors yet
Change-Id: Ia6684ab3ee6c85cfe7bc0ab80d34a26e3499907a
---
A tests/pySim-prog_test/sysmoISIM-SJA5.data
A tests/pySim-prog_test/sysmoISIM-SJA5.ok
2 files changed, 220 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/38232/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38232?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia6684ab3ee6c85cfe7bc0ab80d34a26e3499907a
Gerrit-Change-Number: 38232
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/38232?usp=email )
Change subject: pySim-prog_test: add test vectors for sysmoISIM-SJA5
......................................................................
pySim-prog_test: add test vectors for sysmoISIM-SJA5
The sysmoISIM-SJA5 has no testvectors yet
Change-Id: Ia6684ab3ee6c85cfe7bc0ab80d34a26e3499907a
---
A tests/pySim-prog_test/sysmoISIM-SJA5.data
A tests/pySim-prog_test/sysmoISIM-SJA5.ok
2 files changed, 220 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/38232/1
diff --git a/tests/pySim-prog_test/sysmoISIM-SJA5.data b/tests/pySim-prog_test/sysmoISIM-SJA5.data
new file mode 100644
index 0000000..8bbf7d7
--- /dev/null
+++ b/tests/pySim-prog_test/sysmoISIM-SJA5.data
@@ -0,0 +1,6 @@
+MCC=001
+MNC=01
+KI=AABBCCDDEEFFAABBCCDDEEFFAABBCCDD
+OPC=12345678901234567890123456789012
+IMSI=001010000000102
+ADM=34173960
diff --git a/tests/pySim-prog_test/sysmoISIM-SJA5.ok b/tests/pySim-prog_test/sysmoISIM-SJA5.ok
new file mode 100644
index 0000000..e05dbf3
--- /dev/null
+++ b/tests/pySim-prog_test/sysmoISIM-SJA5.ok
@@ -0,0 +1,214 @@
+Using PC/SC reader interface
+Reading ...
+Autodetected card type: sysmoISIM-SJA5
+ICCID: 8949440000001155314
+IMSI: 001010000000102
+GID1: ffffffffffffffffffff
+GID2: ffffffffffffffffffff
+SMSP: ffffffffffffffffffffffffffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
+SPN: Magic
+Show in HPLMN: True
+Hide in OPLMN: True
+PLMNsel: 00f110ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+PLMNwAcT:
+ 00f110ffff # MCC: 001 MNC: 01 AcT: E-UTRAN NB-S1, E-UTRAN WB-S1, EC-GSM-IoT, GSM, GSM COMPACT, NG-RAN, UTRAN, cdma2000 1xRTT, cdma2000 HRPD
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+
+OPLMNwAcT:
+ 00f110ffff # MCC: 001 MNC: 01 AcT: E-UTRAN NB-S1, E-UTRAN WB-S1, EC-GSM-IoT, GSM, GSM COMPACT, NG-RAN, UTRAN, cdma2000 1xRTT, cdma2000 HRPD
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+
+HPLMNAcT:
+ 00f110ffff # MCC: 001 MNC: 01 AcT: E-UTRAN NB-S1, E-UTRAN WB-S1, EC-GSM-IoT, GSM, GSM COMPACT, NG-RAN, UTRAN, cdma2000 1xRTT, cdma2000 HRPD
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+ ffffff0000 # unused
+
+ACC: 0001
+MSISDN (NPI=1 ToN=3): 6766266
+Administrative data: 00000002
+ MS operation mode: normal
+ Ciphering Indicator: disabled
+SIM Service Table: ff33ffff3f003f0f300cf0c3f00000
+ Service 1 - CHV1 disable function
+ Service 2 - Abbreviated Dialling Numbers (ADN)
+ Service 3 - Fixed Dialling Numbers (FDN)
+ Service 4 - Short Message Storage (SMS)
+ Service 5 - Advice of Charge (AoC)
+ Service 6 - Capability Configuration Parameters (CCP)
+ Service 7 - PLMN selector
+ Service 8 - RFU
+ Service 9 - MSISDN
+ Service 10 - Extension1
+ Service 13 - Last Number Dialled (LND)
+ Service 14 - Cell Broadcast Message Identifier
+ Service 17 - Service Provider Name
+ Service 18 - Service Dialling Numbers (SDN)
+ Service 19 - Extension3
+ Service 20 - RFU
+ Service 21 - VGCS Group Identifier List (EFVGCS and EFVGCSS)
+ Service 22 - VBS Group Identifier List (EFVBS and EFVBSS)
+ Service 23 - enhanced Multi-Level Precedence and Pre-emption Service
+ Service 24 - Automatic Answer for eMLPP
+ Service 25 - Data download via SMS-CB
+ Service 26 - Data download via SMS-PP
+ Service 27 - Menu selection
+ Service 28 - Call control
+ Service 29 - Proactive SIM
+ Service 30 - Cell Broadcast Message Identifier Ranges
+ Service 31 - Barred Dialling Numbers (BDN)
+ Service 32 - Extension4
+ Service 33 - De-personalization Control Keys
+ Service 34 - Co-operative Network List
+ Service 35 - Short Message Status Reports
+ Service 36 - Network's indication of alerting in the MS
+ Service 37 - Mobile Originated Short Message control by SIM
+ Service 38 - GPRS
+ Service 49 - MExE
+ Service 50 - Reserved and shall be ignored
+ Service 51 - PLMN Network Name
+ Service 52 - Operator PLMN List
+ Service 53 - Mailbox Dialling Numbers
+ Service 54 - Message Waiting Indication Status
+ Service 57 - Multimedia Messaging Service (MMS)
+ Service 58 - Extension 8
+ Service 59 - MMS User Connectivity Parameters
+
+FPLMN:
+ ffffff # unused
+ ffffff # unused
+ ffffff # unused
+ ffffff # unused
+
+USIM Service Table: beff9f9de73e04080000ff330000000600000000
+ Service 2 - Fixed Dialling Numbers (FDN)
+ Service 3 - Extension 2
+ Service 4 - Service Dialling Numbers (SDN)
+ Service 5 - Extension3
+ Service 6 - Barred Dialling Numbers (BDN)
+ Service 8 - Outgoing Call Information (OCI and OCT)
+ Service 9 - Incoming Call Information (ICI and ICT)
+ Service 10 - Short Message Storage (SMS)
+ Service 11 - Short Message Status Reports (SMSR)
+ Service 12 - Short Message Service Parameters (SMSP)
+ Service 13 - Advice of Charge (AoC)
+ Service 14 - Capability Configuration Parameters 2 (CCP2)
+ Service 15 - Cell Broadcast Message Identifier
+ Service 16 - Cell Broadcast Message Identifier Ranges
+ Service 17 - Group Identifier Level 1
+ Service 18 - Group Identifier Level 2
+ Service 19 - Service Provider Name
+ Service 20 - User controlled PLMN selector with Access Technology
+ Service 21 - MSISDN
+ Service 24 - Enhanced Multi-Level Precedence and Pre-emption Service
+ Service 25 - Automatic Answer for eMLPP
+ Service 27 - GSM Access
+ Service 28 - Data download via SMS-PP
+ Service 29 - Data download via SMS-CB
+ Service 32 - RUN AT COMMAND command
+ Service 33 - shall be set to 1
+ Service 34 - Enabled Services Table
+ Service 35 - APN Control List (ACL)
+ Service 38 - GSM security context
+ Service 39 - CPBCCH Information
+ Service 40 - Investigation Scan
+ Service 42 - Operator controlled PLMN selector with Access Technology
+ Service 43 - HPLMN selector with Access Technology
+ Service 44 - Extension 5
+ Service 45 - PLMN Network Name
+ Service 46 - Operator PLMN List
+ Service 51 - Service Provider Display Information
+ Service 60 - User Controlled PLMN selector for I-WLAN access
+ Service 81 - Home I-WLAN Specific Identifier List
+ Service 82 - I-WLAN Equivalent HPLMN Presentation Indication
+ Service 83 - I-WLAN HPLMN Priority Indication
+ Service 84 - I-WLAN Last Registered PLMN
+ Service 85 - EPS Mobility Management Information
+ Service 86 - Allowed CSG Lists and corresponding indications
+ Service 87 - Call control on EPS PDN connection by USIM
+ Service 88 - HPLMN Direct Access
+ Service 89 - eCall Data
+ Service 90 - Operator CSG Lists and corresponding indications
+ Service 93 - Communication Control for IMS by USIM
+ Service 94 - Extended Terminal Applications
+ Service 122 - 5GS Mobility Management Information
+ Service 123 - 5G Security Parameters
+
+ePDGId:
+ Not available
+
+ePDGSelection:
+ ffffffffffff # unused
+ ffffffffffff # unused
+ ffffffffffff # unused
+ ffffffffffff # unused
+
+P-CSCF:
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+
+Home Network Domain Name: Not available
+IMS private user identity: Not available
+IMS public user identity:
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+
+UICC IARI:
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+ Not available
+
+ISIM Service Table: 190208
+ Service 1 - P-CSCF address
+ Service 4 - GBA-based Local Key Establishment Mechanism
+ Service 5 - Support of P-CSCF discovery for IMS Local Break Out
+ Service 10 - Support of UICC access to IMS
+ Service 20 - WebRTC URI
+
+Done !
+
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38232?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia6684ab3ee6c85cfe7bc0ab80d34a26e3499907a
Gerrit-Change-Number: 38232
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(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/+/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>