diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2022-02-08 17:00:24 +0100 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2022-03-28 20:50:47 +0200 |
commit | dce23dddf37445f3e54be3adaddd65d2d933da2e (patch) | |
tree | ddf298377e273280553584d5da4992aab9b11e5c /tools | |
parent | aa738074f34c68d38a67cf0eafb6fca873eef82c (diff) | |
download | hardware_replicant_libsamsung-ipc-dce23dddf37445f3e54be3adaddd65d2d933da2e.tar.gz hardware_replicant_libsamsung-ipc-dce23dddf37445f3e54be3adaddd65d2d933da2e.tar.bz2 hardware_replicant_libsamsung-ipc-dce23dddf37445f3e54be3adaddd65d2d933da2e.zip |
tools: ipc-modem: handle --call= and --call start
Without that fix with --call= it picks an empty string as the number:
$ ipc-modem --debug --dry-run start --call=
CC ipc-modem.o
CCLD ipc-modem
[I] Got call number!
[I] Debug enabled
[I] dry-run mode
[1] Starting dummy modem_read_loop on FMT client
[I] modem_dummy_read_loop: looping
[...]
and with --call start, it things that "start" is the number and fails
because the "start" command is not found:
$ ipc-modem --debug --dry-run --call start
make: Nothing to be done for 'all'.
[I] Got call number!
Error: No command given. You need to use a command.
See the help below for more details.
usage: ipc-modem <command>
commands:
boot boot modem only
power-on power on the modem only
power-off power off the modem only
start boot modem and start read loop
arguments:
--call=[NUMBER] call NUMBER
--debug enable debug messages
--dry-run Test the ipc-modem program without talking to the modem.
--help print this help message
--pin=[PIN] provide SIM card PIN
With this fix it handles both situation by printing the right error:
$ipc-modem --debug --dry-run start --call=
make: Nothing to be done for 'all'.
[E] Missing call number
$ make ; ./ipc-modem --debug --dry-run --call start
make: Nothing to be done for 'all'.
[E] Missing call number
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ipc-modem.c | 7 | ||||
-rwxr-xr-x | tools/ipc-modem.py | 14 |
2 files changed, 18 insertions, 3 deletions
diff --git a/tools/ipc-modem.c b/tools/ipc-modem.c index 9990d4f..08f9c3a 100644 --- a/tools/ipc-modem.c +++ b/tools/ipc-modem.c @@ -686,7 +686,12 @@ int parse_cmdline_opts(struct ipc_modem_data *data, int argc, char *argv[]) if (strcmp(opt_l[opt_i].name, "call") == 0) { if (optarg) { - if (strlen(optarg) < 14) { + if (strlen(optarg) == 0) { + ipc_modem_log(data->client, + MODEM_LOG_ERROR, + "Missing call number\n"); + return EX_USAGE; + } else if (strlen(optarg) < 14) { assert(strlen(optarg) < sizeof(data->call_number)); ipc_modem_log(data->client, diff --git a/tools/ipc-modem.py b/tools/ipc-modem.py index 12ee774..0fe76d7 100755 --- a/tools/ipc-modem.py +++ b/tools/ipc-modem.py @@ -75,7 +75,7 @@ class IpcModem(object): else: raise Exception() - def test_call(self, timeout=3): + def test_call_with_number(self, timeout=3): expected_output = "[I] Got call number!" output = "" try: @@ -88,12 +88,22 @@ class IpcModem(object): if output != expected_output: raise Exception() + def test_call_without_number(self, timeout=3): + expected_output = "[E] Missing call number" + output = get_output(self.ipc_modem('power-on', + '--call=', + _timeout=timeout, + _ok_code=SysExit.EX_USAGE.exit_code)) + if output != expected_output: + raise Exception() + def test_commands(self): self.test_boot() self.test_power_on() self.test_power_off() self.test_start() - self.test_call() + self.test_call_with_number() + self.test_call_without_number() def main(): ipc_modem = IpcModem() |