[PATCH] test: fix list-modems hang & simplify handling of Byte/Bool properties
Andres Salomon <[email protected]> Tue, 9 Dec 2025 22:59:59 -0500
| Newsgroups | dev.linux.lists.ofono |
|---|---|
| Message-ID | <20251209225959.2355f276@5400> |
=46rom 690d6af7b672d883bd7d7b86435ddcfad5bdc15d Mon Sep 17 00:00:00 2001 From: Andres Salomon <[email protected]> Date: Tue, 9 Dec 2025 22:36:16 -0500 Subject: [PATCH] test: fix list-modems hang & simplify handling of Byte/Bool properties Using list-modems with current phonesim (2.0) results in list-modems hanging while trying to print SimToolkit's IdleModeIcon property. No errors; it just silently hangs. The issue is that it's a dbus.Byte with the value b'0' (which python implicitly converts to something that makes its i/o and string handling deeply unhappy). It's unpleasant to have to special-case every dbus.Byte property value, so instead let's display Bytes based on their type. That will help future-proof this script as new properties get added to interfaces. While we're at it, also stop implicitly converting dbus.Boolean values to "1"/"0", and use "TRUE"/"FALSE" to make it clearer that they are bools. A small sample of what list-modem's output looks like with phonesim: task-0: [ org.ofono.SimToolkit ] task-0: IdleModeText =3D=20 task-0: IdleModeIcon =3D 0 task-0: MainMenuTitle =3D=20 task-0: MainMenuIcon =3D 0 task-0: MainMenu =3D=20 task-0: [ org.ofono.MessageWaiting ] task-0: VoicemailWaiting =3D TRUE task-0: VoicemailMessageCount =3D 1 task-0: VoicemailMailboxNumber =3D 6789 task-0: [ org.ofono.SimAuthentication ] task-0: NetworkAccessIdentity =3D [email protected] --- test/list-modems | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/list-modems b/test/list-modems index a163791e..1b262482 100755 --- a/test/list-modems +++ b/test/list-modems @@ -50,14 +50,6 @@ for path, properties in modems: for i in properties[key]: val +=3D "[" + i + "] =3D '" val +=3D properties[key][i] + "' " - elif key in ["MobileNetworkCodeLength", - "VoicemailMessageCount", - "MicrophoneVolume", - "SpeakerVolume", - "Strength", - "DataStrength", - "BatteryChargeLevel"]: - val =3D int(properties[key]) elif key in ["MainMenu"]: val =3D ", ".join([ text + " (" + str(int(icon)) + ")" for text, icon in properties[key] ]) @@ -76,6 +68,10 @@ for path, properties in modems: else: val +=3D properties[key][i] val +=3D " }" + elif type(properties[key]) =3D=3D dbus.Byte: + val =3D int(properties[key]) + elif type(properties[key]) =3D=3D dbus.Boolean: + val =3D str(bool(properties[key])).upper() else: val =3D properties[key] print(" %s =3D %s" % (key, val)) --=20 2.47.3