mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-18 03:18:34 +03:00
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
This commit is contained in:
0
tests/pySim-shell_test/file_admin/__init__.py
Normal file
0
tests/pySim-shell_test/file_admin/__init__.py
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"file_descriptor": {
|
||||
"file_descriptor_byte": {
|
||||
"shareable": true,
|
||||
"file_type": "working_ef",
|
||||
"structure": "transparent"
|
||||
},
|
||||
"record_len": null,
|
||||
"num_of_rec": null
|
||||
},
|
||||
"file_identifier": "6f7e",
|
||||
"proprietary_information": {
|
||||
"unknown_ber_tlv_ie_d0": {
|
||||
"raw": "20"
|
||||
},
|
||||
"toolkit_access_conditions": {
|
||||
"rfm_create": true,
|
||||
"rfm_delete_terminate": true,
|
||||
"other_applet_create": true,
|
||||
"other_applet_delete_terminate": true
|
||||
}
|
||||
},
|
||||
"life_cycle_status_integer": "operational_activated",
|
||||
"security_attrib_referenced": {
|
||||
"ef_arr_file_id": "6f06",
|
||||
"ef_arr_record_nr": 4
|
||||
},
|
||||
"file_size": 11,
|
||||
"short_file_identifier": 11
|
||||
}
|
||||
{
|
||||
"file_descriptor": {
|
||||
"file_descriptor_byte": {
|
||||
"shareable": true,
|
||||
"file_type": "working_ef",
|
||||
"structure": "transparent"
|
||||
},
|
||||
"record_len": null,
|
||||
"num_of_rec": null
|
||||
},
|
||||
"file_identifier": "6f7e",
|
||||
"proprietary_information": {
|
||||
"unknown_ber_tlv_ie_d0": {
|
||||
"raw": "20"
|
||||
},
|
||||
"toolkit_access_conditions": {
|
||||
"rfm_create": true,
|
||||
"rfm_delete_terminate": true,
|
||||
"other_applet_create": true,
|
||||
"other_applet_delete_terminate": true
|
||||
}
|
||||
},
|
||||
"life_cycle_status_integer": "operational_deactivated",
|
||||
"security_attrib_referenced": {
|
||||
"ef_arr_file_id": "6f06",
|
||||
"ef_arr_record_nr": 4
|
||||
},
|
||||
"file_size": 11,
|
||||
"short_file_identifier": 11
|
||||
}
|
||||
{
|
||||
"file_descriptor": {
|
||||
"file_descriptor_byte": {
|
||||
"shareable": true,
|
||||
"file_type": "working_ef",
|
||||
"structure": "transparent"
|
||||
},
|
||||
"record_len": null,
|
||||
"num_of_rec": null
|
||||
},
|
||||
"file_identifier": "6f7e",
|
||||
"proprietary_information": {
|
||||
"unknown_ber_tlv_ie_d0": {
|
||||
"raw": "20"
|
||||
},
|
||||
"toolkit_access_conditions": {
|
||||
"rfm_create": true,
|
||||
"rfm_delete_terminate": true,
|
||||
"other_applet_create": true,
|
||||
"other_applet_delete_terminate": true
|
||||
}
|
||||
},
|
||||
"life_cycle_status_integer": "operational_activated",
|
||||
"security_attrib_referenced": {
|
||||
"ef_arr_file_id": "6f06",
|
||||
"ef_arr_record_nr": 4
|
||||
},
|
||||
"file_size": 11,
|
||||
"short_file_identifier": 11
|
||||
}
|
||||
54
tests/pySim-shell_test/file_admin/test.py
Normal file
54
tests/pySim-shell_test/file_admin/test.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# Testsuite for pySim-shell.py
|
||||
#
|
||||
# (C) 2024 by sysmocom - s.f.m.c. GmbH
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Author: Philipp Maier
|
||||
#
|
||||
# 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 os
|
||||
import json
|
||||
from utils import *
|
||||
|
||||
class test_case(UnittestUtils):
|
||||
def test_activate_deactivate(self):
|
||||
cardname = 'sysmoISIM-SJA5-S17'
|
||||
|
||||
self.runPySimShell(cardname, "test_activate_deactivate_file.script", add_adm = True)
|
||||
self.assertEqualFiles("activate_deactivate_file.tmp",
|
||||
ignore_regex_list = ['.*'],
|
||||
interesting_regex_list = ['.*"life_cycle_status_integer.*"'])
|
||||
|
||||
def test_create_delete_df(self):
|
||||
cardname = 'sysmoISIM-SJA5-S17'
|
||||
|
||||
self.runPySimShell(cardname, "test_create_delete_df.script",
|
||||
add_adm = True, no_exceptions = True)
|
||||
|
||||
def test_create_resize_delete_transparent_ef(self):
|
||||
cardname = 'sysmoISIM-SJA5-S17'
|
||||
|
||||
self.runPySimShell(cardname, "test_create_resize_delete_transparent_ef.script",
|
||||
add_adm = True, no_exceptions = True)
|
||||
|
||||
def test_create_resize_delete_linear_fixed_ef(self):
|
||||
cardname = 'sysmoISIM-SJA5-S17'
|
||||
|
||||
self.runPySimShell(cardname, "test_create_resize_delete_linear_fixed_ef.script",
|
||||
add_adm = True, no_exceptions = True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,8 @@
|
||||
set debug true
|
||||
set echo true
|
||||
|
||||
select /ADF.USIM/EF.LOCI > activate_deactivate_file.tmp
|
||||
deactivate_file
|
||||
select /ADF.USIM/EF.LOCI >> activate_deactivate_file.tmp
|
||||
activate_file EF.LOCI
|
||||
select /ADF.USIM/EF.LOCI >> activate_deactivate_file.tmp
|
||||
@@ -0,0 +1,20 @@
|
||||
set debug true
|
||||
set echo true
|
||||
|
||||
# Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we
|
||||
# temporarily modify EF.ARR
|
||||
select /EF.ARR
|
||||
export --filename /EF.ARR > restore_ef_arr.script.tmp
|
||||
update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
||||
# Create a new DF and select it
|
||||
select MF
|
||||
create_df --ef-arr-file-id 2f06 --ef-arr-record-nr 1 1234
|
||||
select 1234
|
||||
|
||||
# Delete the DF that we have created
|
||||
select MF
|
||||
delete_file --force-delete 1234
|
||||
|
||||
# Restore EF.ARR to its original state
|
||||
run_script restore_ef_arr.script.tmp
|
||||
@@ -0,0 +1,25 @@
|
||||
set debug true
|
||||
set echo true
|
||||
|
||||
# Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we
|
||||
# temporarily modify EF.ARR
|
||||
select /EF.ARR
|
||||
export --filename /EF.ARR > restore_ef_arr.script.tmp
|
||||
update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
||||
# Create a new DF (10 records with 10 bytes each) and select it
|
||||
select MF
|
||||
create_ef --ef-arr-file-id 2f06 --ef-arr-record-nr 1 --file-size 100 --structure linear_fixed --record-length 10 4321
|
||||
select 4321
|
||||
|
||||
# Resize the new DF (double the number of available records) and select it again
|
||||
select MF
|
||||
resize_ef --file-size 200 4321
|
||||
select 4321
|
||||
|
||||
# Delete the DF that we have created
|
||||
select MF
|
||||
delete_file --force-delete 4321
|
||||
|
||||
# Restore EF.ARR to its original state
|
||||
run_script restore_ef_arr.script.tmp
|
||||
@@ -0,0 +1,25 @@
|
||||
set debug true
|
||||
set echo true
|
||||
|
||||
# Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we
|
||||
# temporarily modify EF.ARR
|
||||
select /EF.ARR
|
||||
export --filename /EF.ARR > restore_ef_arr.script.tmp
|
||||
update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
||||
# Create a new DF and select it
|
||||
select MF
|
||||
create_ef --ef-arr-file-id 2f06 --ef-arr-record-nr 1 --file-size 23 --structure transparent 5678
|
||||
select 5678
|
||||
|
||||
# Resize the new DF and select it again
|
||||
select MF
|
||||
resize_ef --file-size 42 5678
|
||||
select 5678
|
||||
|
||||
# Delete the DF that we have created
|
||||
select MF
|
||||
delete_file --force-delete 5678
|
||||
|
||||
# Restore EF.ARR to its original state
|
||||
run_script restore_ef_arr.script.tmp
|
||||
Reference in New Issue
Block a user