aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* tests: nv_data-imei: cleanup after creating fileDenis 'GNUtoo' Carikli2022-08-251-0/+4
| | | | | | | Without that fix, the file being created isn't deleted at the end of the test, so over time the leftover files accumulate in /tmp. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: nv_data-md5: cleanup after creating fileDenis 'GNUtoo' Carikli2022-08-251-0/+2
| | | | | | | Without that fix, the file being created isn't deleted at the end of the test, so over time the leftover files accumulate in /tmp. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* autotools: ship python test programsDenis 'GNUtoo' Carikli2022-07-262-0/+4
| | | | | | | | | | | | | | Without that fix, we don't ship any of the python test programs: $ make dist $ tar tf libsamsung-ipc-0.7.0.tar.xz | grep "\.py$" so 'make check' fail with the following error when building from a tarball: make[4]: Leaving directory '/tmp/libsamsung-ipc/libsamsung-ipc-0.7.0/samsung-ipc/tests' fatal: making test-suite.log: failed to create libsamsung-ipc-test.trs fatal: making test-suite.log: failed to create libsamsung-ipc-test.log Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: autotools: fix missing headerDenis 'GNUtoo' Carikli2022-07-261-1/+6
| | | | | | | | | | | | | | | | | | | Without that fix, nv_data-imei compiles fine in git, but if we build from a tarball, nv_data-imei.h is missing from the tarball: $ make dist $ tar tf libsamsung-ipc-0.7.0.tar.xz | grep "ipc-modem.*\.[ch]" libsamsung-ipc-0.7.0/tools/ipc-modem/ipc-modem-sms.c libsamsung-ipc-0.7.0/tools/ipc-modem/ipc-modem-log.c libsamsung-ipc-0.7.0/tools/ipc-modem/ipc-modem.c libsamsung-ipc-0.7.0/tools/ipc-modem/tests/ipc-modem-sms-test.c libsamsung-ipc-0.7.0/tools/ipc-modem/tests/ipc-modem-sms-fuzz.c which then results in a compilation failure: ipc-modem-log.c:28:10: fatal error: ipc-modem-log.h: No such file or directory 28 | #include "ipc-modem-log.h" | ^~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: autotools: fix missing headerDenis 'GNUtoo' Carikli2022-07-261-1/+1
| | | | | | | | | | | | | | | | | Without that fix, nv_data-imei compiles fine in git, but if we build from a tarball, nv_data-imei.h is missing from the tarball: $ make dist $ tar tf libsamsung-ipc-0.7.0.tar.xz | grep nv_data-imei libsamsung-ipc-0.7.0/tools/nv_data-imei.c which then results in a compilation failure: CC nv_data-imei.o nv_data-imei.c:39:10: fatal error: nv_data-imei.h: No such file or directory 39 | #include "nv_data-imei.h" | ^~~~~~~~~~~~~~~~ compilation terminated. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* configure.ac: Add an option to use scripts/guix.scm's strict CFLAGSDenis 'GNUtoo' Carikli2022-07-222-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CFLAGS that are in the %common-strict-cflags in scripts/guix.scm have been validated with both GCC and CLANG and they are useful to find potential issues in the code or code that won't compile on Android. However while the scripts/guix.scm script is really useful to test commits once they are ready, it is less convenient to use it when fixing issues in commits that are still being worked on. This is because it is not as fast as building libsamsung-ipc directly because: - it requires a clean source directory to work (this can be done with make distclean) so we can't reuse the current build output - libsamsung-ipc source code is copied and built 5 times (in different configurations) As for the implementation, AM_CFLAGS was used instead of appending to the default CFLAGS as CFLAGS is meant to be a variable for users. The effect is that both are independent, so if users don't want strict CFLAGS, they would need to not use --enable-strict-cflags. And it was implemented as a shell script to at the same time: - Enable to have comments, and good formating of the flags. - Enable to share the cflags between guix.scm and the autotools. - Keep the complexity low to keep it working in most situations. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc-modem: fix duplicated codeDenis 'GNUtoo' Carikli2022-06-261-5/+2
| | | | | | | | | | | If the following fails: data.client = ipc_client_create(IPC_CLIENT_TYPE_DUMMY); then we cannot use ipc_modem_log, but we can use printf instead. This bug was introduced in commit aa738074f34c ("tools: ipc-modem: convert to sysexits.h"). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: Fix unused result warningDenis 'GNUtoo' Carikli2022-06-261-1/+5
| | | | | | | | | | | | | | | Without that fix, when running the following commands: $ cd tools $ makepkg we have: ../../../tools/nv_data-imei.c: In function ‘write_imei’: ../../../tools/nv_data-imei.c:769:9: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 769 | asprintf(&md5_path, "%s.md5", nv_data_path); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: https-send-sms: handle http return codesDenis 'GNUtoo' Carikli2022-06-141-15/+43
| | | | | | This handles documented return codes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: https-send-sms: don't depend on CURLU_ALLOW_SPACEDenis 'GNUtoo' Carikli2022-06-141-21/+35
| | | | | | | | | | CURLU_ALLOW_SPACE is available since curl 7.78.0, and not using it could enable us to be compatible with curl 7.62.0. Since Replicant 11 has curl 7.67.0, this should enable to run https-send-sms on Replicant 11. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: Add tool to send SMS from a provider HTTPS interfaceDenis 'GNUtoo' Carikli2022-06-142-0/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can then be used during automatic tests, but the downside is that for now this tool only works with one provider. The following symbols from (lib)curl (along with their corresponding minimal (lib)curl version) have been used: +------------------------+---------------------------+ | curl symbols | minimum (lib)curl version | +------------------------+---------------------------+ | CURL_HTTP_VERSION_2TLS | 7.47.0 | | CURLUPART_URL | 7.62.0 | | CURLUPART_QUERY | 7.62.0 | | CURLU_URLENCODE | 7.62.0 | | CURLU_APPENDQUERY | 7.62.0 | | CURLU | 7.62.0 | | CURLU_ALLOW_SPACE | 7.78.0 | +------------------------+---------------------------+ So we need to depend on curl 7.78.0. And we currently have the following curl version: +----------------------------+--------------------+------------+ | Distribution | (lib)curl version | Compatible | +----------------------------+--------------------+------------+ | Replicant 4.2 | Doesn't have curl | No | | Guix 6b9105e557 | 7.28.1 | No | | Trisquel 7 x86_64 | 7.35.0-1ubuntu2.20 | No | | Replicant 6 | 7.43.0 | No | | Debian stretch x86_64 | 7.52.1-5+deb9u10 | No | | Replicant 11 | 7.67.0 | No | | Parabola i686 (07/04/2022) | 7.79.0-3.0 | Yes | | Guix i686 (07/04/2022) | 7.79.1 | Yes | +----------------------------+--------------------+------------+ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: help: the phone number is mandatory when using --call=Denis 'GNUtoo' Carikli2022-05-231-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: help: the pin code is mandatory when using --pin=Denis 'GNUtoo' Carikli2022-05-231-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Move log functions in their own fileDenis 'GNUtoo' Carikli2022-05-235-66/+128
| | | | | | | | | | This has several advantages: - This makes the code cleaner as we now have a more abstract logging and less code in the main c file. - If new files are added, this will enable to use logging functions in the new files. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: Move ipc-modem in its own directoryDenis 'GNUtoo' Carikli2022-05-235-6/+18
| | | | | | This enables to then split ipc-modem in several files in a clean way. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Autotools: add support for Valgrind for checksDenis 'GNUtoo' Carikli2022-05-234-10/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables contributors to run Valgrind when running 'make check' for instance before sending patches. The --enable-valgrind option was used instead of using --enable-checking=valgrind like GCC uses as the code for that is much easier to get right. As Valgrind is very slow, I had to increase the timeouts in the ipc-modem tests. For now I settled on 60 seconds to have some margin for machines or setups that are potentially slower than the one I use. For the guix.scm, with Guix 1.3.0, Valgrind needs the ld.so .symtab to work, so as Valgrind doesn't know where to find them, so we had to use --extra-debuginfo-path for that. This is also why we pass '-v' to valgrind as it prints message explaining the issue when it doesn't find the required symbols. And we also needed a trick mentioned in the Guix mailing list[1] to find the right path for the debug information as the glibc being used by packages isn't exported publicly. [1]https://lists.gnu.org/archive/html/help-guix/2022-03/msg00036.html The proper fix will be merged in the next Guix release (merging it now is not possible since it would require to rebuild everything, and that is only possible with new releases). A temporary workaround with 4d1a88312cbebb10d47905d6d023953ac85bcd04 (gnu: valgrind: Allow ld.so symbols to be found.) was also merged in the current Guix so it is possible to get it with guix pull, but here it's probably better to stick with a workaround in the guix.scm for now as this also enables to use older guix revisions for testing. Thanks to the people on #guix on Liberachat for helping me to solve this Valgrind issue. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: move the tests in their own directoryDenis 'GNUtoo' Carikli2022-03-284-3/+9
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: handle --call= and --call startDenis 'GNUtoo' Carikli2022-03-282-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tools: ipc-modem: convert to sysexits.hDenis 'GNUtoo' Carikli2022-03-282-25/+58
| | | | | | | Using sysexits.h helps making testing easier by differentiating between different types of errors. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move command line parsing in its own functionDenis 'GNUtoo' Carikli2022-03-281-35/+51
| | | | | | | | This makes the code easier to read as the command line parsing code is quite big, and now it's not mixed in the main function anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of seq global variableDenis 'GNUtoo' Carikli2022-03-282-58/+64
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of state global variableDenis 'GNUtoo' Carikli2022-03-282-19/+20
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of out_call global variableDenis 'GNUtoo' Carikli2022-03-282-10/+11
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of call_done global variableDenis 'GNUtoo' Carikli2022-03-282-4/+3
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of in_call global variableDenis 'GNUtoo' Carikli2022-03-282-20/+21
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of sim_pin global variableDenis 'GNUtoo' Carikli2022-03-282-17/+18
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of call_number global variableDenis 'GNUtoo' Carikli2022-03-282-22/+23
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move ipc_client struct in private data structDenis 'GNUtoo' Carikli2022-03-282-55/+53
| | | | | | | Having everything needed in the same struct will simplify the code later on as we could also move the global variables there as well. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add syslog supportDenis 'GNUtoo' Carikli2022-03-282-20/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is ongoing work to make libsamsung-ipc and the modem drivers of the Galaxy SIII (GT-I9300) work on top of an upstream kernel instead of kernels derived from the vendor kernels. For that work it's convenient to be able to store the kernel the kernel logs in systemd-journald along with the output of ipc-modem. If the kernel is built with CONFIG_LOCALVERSION_AUTO, we can track the exact kernel revision used. And if the modem driver crashed, we can still have the logs in journald at the next reboot. It also enables us to store logs over a long period of time and get back to old logs. However when running ipc-modem through a systemd service unit, the output is piped to systemd, and we only get the following output with journalctl -u <service> .service: Started [Service Unit Description]. This is because when a program is piped, line buffering changes from line buffered (the default when outputing to stdout on a terminal according to setbuf(3)) to fully buffered. To fix that we add a syslog log-target. Several programs already have a --syslog (like OpenVPN) or --log-target= (like PulseAudio) command line argument. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: use the log callback instead of printfDenis 'GNUtoo' Carikli2022-03-282-86/+173
| | | | | | | | | | This enables to add other log callbacks than printf / stdout later on. The ipc_modem_log function is inspired from ipc_client_log. This change should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: group contiguous printf callsDenis 'GNUtoo' Carikli2022-03-281-17/+17
| | | | | | | | | | | | There is no use in making multiple calls to printf when only one call is sufficient. It's also a good practice to do that in general, especially when part of the code can print to the console at any time, to ensure that that all the buffer is printed contiguously and not interleaved with other prints. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move definitions in ipc-modem.hDenis 'GNUtoo' Carikli2022-03-282-17/+43
| | | | | | | | | This enables to add more definitions later and to also add functions prototypes there. This change contains no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: getopt_long: shorten nested ifsDenis 'GNUtoo' Carikli2022-03-281-36/+29
| | | | | | | This makes the code more readable. It should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: ipc-modem: add phone number argument testDenis 'GNUtoo' Carikli2022-03-281-0/+14
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data_imei: use const arrays of structs with static storage durationDenis 'GNUtoo' Carikli2022-03-282-21/+21
| | | | | | | This ensures that the content of theses arrays cannot be changed at runtime. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data_imei: get rid of missing initializer warningDenis 'GNUtoo' Carikli2022-03-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix, we have the following warnings on Replicant 6.0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:245:2: warning: missing initializer for field 'option' of 'struct command_option' [-Wmissing-field-initializers] { /* Sentinel */ }, ^ In file included from hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:39:0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.h:65:10: note: 'option' declared here uint8_t option; ^ hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:277:2: warning: missing initializer for field 'name' of 'struct command' [-Wmissing-field-initializers] { /* Sentinel */ }, ^ In file included from hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:39:0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.h:57:14: note: 'name' declared here const char *name; ^ Note that even if the code isn't valid C17 code, the warning is harmless since the arrays of struct is declared outside functions (static storage duration), so the "Sentinel" will be filled with zeros anyway. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-imei: fix printf size_t integer conversionDenis 'GNUtoo' Carikli2022-03-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix we have compilation errors: nv_data-imei.c: In function ‘get_imei’: nv_data-imei.c:181:12: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 181 | printf("In addition it is also invalid" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 184 | len, IMEI_LENGTH); | ~~~ | | | size_t {aka long unsigned int} nv_data-imei.c:183:14: note: format string is defined here 183 | "%d digits instead of %d.\n", | ~^ | | | int | %ld nv_data-imei.c:193:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 193 | printf("The '%s' " | ^~~~~~~~~~~ ...... 196 | imei->optarg, len, IMEI_LENGTH); | ~~~ | | | size_t {aka long unsigned int} nv_data-imei.c:195:14: note: format string is defined here 195 | "%d digits instead of %d.\n", | ~^ | | | int | %ld This issue was introduced in commit 1cd1a569bef21ed3bfaeda15fb210ef6fd218152 (tools: Add a new nv_data-imei tool based on rfs-imei) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: nv_data-md5: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-4/+10
| | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': FAIL: nv_data-md5 ================= Traceback (most recent call last): File "[...]/scripts/src/tools/../../../tools/nv_data-md5.py", line 69, in <module> rc = main() File "[...]/scripts/src/tools/../../../tools/nv_data-md5.py", line 64, in main nv_data_md5 = NvDataMD5() File "[...]/scripts/src/tools/../../../tools/nv_data-md5.py", line 39, in __init__ self.nv_data_md5 = sh.Command(srcdir + os.sep + 'nv_data-md5') File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../tools/nv_data-md5 FAIL nv_data-md5.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: nv_data-imei: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-4/+11
| | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': FAIL: nv_data-imei ================== Traceback (most recent call last): File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 122, in <module> rc = main() File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 117, in main nv_data_imei = NvDataImei() File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 53, in __init__ self.nv_data_imei = sh.Command(srcdir + os.sep + 'nv_data-imei') File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../tools/nv_data-imei FAIL nv_data-imei.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: ipc-modem: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-4/+10
| | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': FAIL: ipc-modem =============== Traceback (most recent call last): File "[...]/scripts/src/tools/../../../tools/ipc-modem.py", line 79, in <module> rc = main() File "[...]/scripts/src/tools/../../../tools/ipc-modem.py", line 74, in main ipc_modem = IpcModem() File "[...]/scripts/src/tools/../../../tools/ipc-modem.py", line 39, in __init__ ipc_modem = sh.Command(srcdir + os.sep + 'ipc-modem') File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../tools/ipc-modem FAIL ipc-modem.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: python: unify string quotes as per PEP 8Denis 'GNUtoo' Carikli2022-01-243-41/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having a code style makes the code easier to read. As for which code style to use, the code style defined by the PEP 8 [1] is used in the python standard library and in the main Python distribution. Its official nature (it's standardized by python) probably makes it the most well known and used code style adopted by python programmers. In it we have a section about string quotes: String Quotes ------------- In Python, single-quoted strings and double-quoted strings are the same. This PEP does not make a recommendation for this. Pick a rule and stick to it. When a string contains single or double quote characters, however, use the other one to avoid backslashes in the string. It improves readability. For triple-quoted strings, always use double quote characters to be consistent with the docstring convention in PEP 257. Since "if __name__ == '__main__':" is widely used, we choose to use the single quotes. [1]https://www.python.org/dev/peps/pep-0008/ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add testsreplicant-6.0-0004-transitionreplicant-6.0-0004-rc6replicant-6.0-0004Denis 'GNUtoo' Carikli2021-09-012-2/+83
| | | | | | | While the tests don't talk to a real modem, they are still useful to detect regressions with the use of threads. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add dry-run mode for automatic testingDenis 'GNUtoo' Carikli2021-09-011-2/+41
| | | | | | | | This enables to test things like the threads usage without the need for a real modem implementing the samsung-ipc protocol. This could for instance be used in libsamsung-ipc automated tests. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move command line options prints in its own functionDenis 'GNUtoo' Carikli2021-09-011-1/+9
| | | | | | | As this is done once all options have been parsed, it enables to only print some options when debug is on. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move parsed command line arguments in a structDenis 'GNUtoo' Carikli2021-09-011-12/+22
| | | | | | | | This enables to more easily enables to share the parsed command line arguments across different functions and it also enables to add new command line arguments more easily. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Fail if there is no chosen commandDenis 'GNUtoo' Carikli2021-09-011-1/+11
| | | | | | | | | | | | | | | Without that fix, if some arguments were set and no command was given, ipc-modem would proceed anyway: $ ./tools/ipc-modem --debug [I] Debug enabled [...] As it's expected to at least be used with a command to do something meaningful, without that fix, it could misslead users into thinking that everything is fine when it's not or vice versa. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move ipc code outside of mainDenis 'GNUtoo' Carikli2021-09-011-48/+83
| | | | | | | | | | This makes the code easier to read as we separate the command line handling from the IPC code. In addition it also enables to more easily add RFS support later on as the IPC code is not mixed with command line handling. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add --help in the helpDenis 'GNUtoo' Carikli2021-09-011-0/+1
| | | | | | | While --help is parsed in the command line, it wasn't described in the help itself. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: small code cleanups for the command line interfaceDenis 'GNUtoo' Carikli2021-09-011-30/+30
| | | | | | | | The help and the code is sorted alphabetically. It should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: fix nv-data-md5 compilation with Replicant 6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5Denis 'GNUtoo' Carikli2021-03-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | When compiling nv-data-md5 under Replicant 6 we have: hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c: In function 'main': hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c:103:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: some warnings being treated as errors So we simply need to add a return in the error path. While we're at it, we use an exit code referenced in sysexits.h to follow a standard. This can help differentiating between different types of errors. Thanks to that, it can also simplify the code when writing tests. As Android doesn't have sysexits.h, we also need to use the one that has been copied inside libsamsung-ipc in tools/include/glibc, else it would also fail to compile because of the missing header file. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>