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:
Philipp Maier
2024-08-12 17:56:43 +02:00
parent d7032955c5
commit f87a00c04f
114 changed files with 22424 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
{
"imsi": "262421414141414"
}

View File

@@ -0,0 +1,45 @@
# 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
from utils import *
class test_case(UnittestUtils):
def test_update_imsi_plmn(self):
cardname = 'sysmoISIM-SJA5-S17'
self.runPySimShell(cardname, "test_update_imsi_plmn.script", add_adm = True)
self.assertEqualFiles("ef_imsi.tmp")
def test_ef_ust(self):
cardname = 'sysmoISIM-SJA5-S17'
self.runPySimShell(cardname, "test_ef_ust.script", add_adm = True)
self.assertEqualFiles("test_ef_ust.tmp")
def test_ef_ist(self):
cardname = 'sysmoISIM-SJA5-S17'
self.runPySimShell(cardname, "test_ef_ist.script", add_adm = True)
self.assertEqualFiles("test_ef_ist.tmp")
if __name__ == "__main__":
unittest.main()

View File

@@ -0,0 +1,16 @@
Checking service No 2 (inactive)
Checking service No 5 (active)
Checking service No 6 (inactive)
Checking service No 7 (inactive)
Checking service No 8 (inactive)
Checking service No 10 (active)
Checking service No 17 (inactive)
Checking service No 18 (inactive)
Checking service No 19 (inactive)
Checking service No 20 (active)
Checking service No 21 (inactive)
Checking service No 22 (inactive)
===> 7 service / file inconsistencies detected
190208
190208
190208

View File

@@ -0,0 +1,22 @@
set debug true
set echo true
# Create a backup the files we will modify
export --filename MF/ADF.ISIM/EF.IST > restore_ef_ist.script.tmp
# Write some known default
select MF/ADF.ISIM/EF.IST
update_binary 190208
# Run check
ist_service_check > test_ef_ist.tmp
# Make changes and see if they were applied
read_binary >> test_ef_ist.tmp
ust_service_activate 7
read_binary >> test_ef_ist.tmp
ust_service_deactivate 7
read_binary >> test_ef_ist.tmp
# Restore modified files to their original state
run_script restore_ef_ist.script.tmp

View File

@@ -0,0 +1,110 @@
Checking service No 1 (inactive)
Checking service No 2 (active)
Checking service No 3 (active)
Checking service No 4 (active)
Checking service No 5 (active)
Checking service No 6 (active)
Checking service No 7 (inactive)
Checking service No 8 (active)
Checking service No 9 (active)
Checking service No 10 (active)
Checking service No 11 (active)
Checking service No 12 (active)
Checking service No 13 (active)
Checking service No 14 (active)
Checking service No 15 (active)
Checking service No 16 (active)
Checking service No 17 (active)
Checking service No 18 (active)
Checking service No 19 (active)
Checking service No 20 (active)
Checking service No 21 (active)
Checking service No 24 (active)
Checking service No 25 (active)
Checking service No 27 (active)
Checking service No 29 (active)
Checking service No 34 (active)
Checking service No 35 (active)
Checking service No 36 (inactive)
Checking service No 37 (inactive)
Checking service No 39 (active)
Checking service No 40 (active)
Checking service No 42 (active)
Checking service No 43 (active)
Checking service No 44 (active)
Checking service No 45 (active)
Checking service No 46 (active)
Checking service No 47 (inactive)
Checking service No 48 (inactive)
Checking service No 49 (inactive)
Checking service No 51 (active)
Checking service No 52 (inactive)
Checking service No 53 (inactive)
Checking service No 55 (inactive)
Checking service No 56 (inactive)
Checking service No 57 (inactive)
Checking service No 58 (inactive)
Checking service No 59 (inactive)
Checking service No 60 (active)
Checking service No 61 (inactive)
Checking service No 62 (inactive)
Checking service No 63 (inactive)
Checking service No 64 (inactive)
Checking service No 65 (inactive)
Checking service No 66 (inactive)
Checking service No 68 (inactive)
Checking service No 69 (inactive)
Checking service No 71 (inactive)
Checking service No 73 (inactive)
Checking service No 76 (inactive)
Checking service No 78 (inactive)
Checking service No 79 (inactive)
Checking service No 80 (inactive)
Checking service No 81 (active)
Checking service No 82 (active)
Checking service No 83 (active)
Checking service No 84 (active)
Checking service No 85 (active)
Checking service No 86 (active)
Checking service No 88 (active)
Checking service No 89 (active)
Checking service No 90 (active)
Checking service No 96 (inactive)
Checking service No 97 (inactive)
Checking service No 99 (inactive)
Checking service No 101 (inactive)
Checking service No 106 (inactive)
Checking service No 107 (inactive)
Checking service No 110 (inactive)
Checking service No 111 (inactive)
Checking service No 114 (inactive)
Checking service No 115 (inactive)
Checking service No 120 (inactive)
Checking service No 122 (active)
Checking service No 123 (active)
Checking service No 124 (inactive)
Checking service No 125 (inactive)
Checking service No 126 (inactive)
Checking service No 127 (inactive)
Checking service No 129 (inactive)
Checking service No 130 (inactive)
Checking service No 132 (inactive)
Checking service No 133 (inactive)
Checking service No 134 (inactive)
Checking service No 137 (inactive)
Checking service No 138 (inactive)
Checking service No 139 (inactive)
Checking service No 140 (inactive)
Checking service No 141 (inactive)
Checking service No 142 (inactive)
Checking service No 143 (inactive)
Checking service No 144 (inactive)
Checking service No 145 (inactive)
Checking service No 146 (inactive)
Checking service No 147 (inactive)
Checking service No 148 (inactive)
Checking service No 150 (inactive)
===> 75 service / file inconsistencies detected
beff9f9de73e04080000ff730000000600000000
beff9f9de73e04080000ff730000000600002000
beff9f9de73e04080000ff730000000600000000

View File

@@ -0,0 +1,22 @@
set debug true
set echo true
# Create a backup the files we will modify
export --filename MF/ADF.USIM/EF.UST > restore_ef_ust.script.tmp
# Write some known default
select MF/ADF.USIM/EF.UST
update_binary beff9f9de73e04080000ff730000000600000000
# Run check
ust_service_check > test_ef_ust.tmp
# Make changes and see if they were applied
read_binary >> test_ef_ust.tmp
ust_service_activate 150
read_binary >> test_ef_ust.tmp
ust_service_deactivate 150
read_binary >> test_ef_ust.tmp
# Restore modified files to their original state
run_script restore_ef_ust.script.tmp

View File

@@ -0,0 +1,13 @@
set debug true
set echo true
# Create a backup the files we will modify
export --filename MF/ADF.USIM/EF.IMSI > restore_ef_imsi.script.tmp
select MF/ADF.USIM/EF.IMSI
update_binary 084941414141414141
update_imsi_plmn 26242
read_binary_decoded > ef_imsi.tmp
# Restore modified files to their original state
run_script restore_ef_imsi.script.tmp