diff mbox series

[meta-oe,master,1/2] linux-serial-test: add patch to fix returned error code

Message ID 20251017094636.2976738-2-ghidoliemanuele@gmail.com
State Under Review
Headers show
Series linux-serial-test: fix returned error code and potential hang in while loop | expand

Commit Message

Emanuele Ghidoli Oct. 17, 2025, 9:46 a.m. UTC
From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>

After commit 392f0f0ea76d ("linux-serial-test: Bump SRCREV to allow CMake 4+ compatibility"),
the behavior of linux-serial-test changed: it now returns 125 instead of 0
when the number of read characters differs from the written ones.

This patch fixes that regression.

Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
---
 ...erial-test.c-fix-returned-error-code.patch | 62 +++++++++++++++++++
 .../linux-serial-test_git.bb                  |  4 +-
 2 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-test/linux-serial-test/files/0001-linux-serial-test.c-fix-returned-error-code.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-test/linux-serial-test/files/0001-linux-serial-test.c-fix-returned-error-code.patch b/meta-oe/recipes-test/linux-serial-test/files/0001-linux-serial-test.c-fix-returned-error-code.patch
new file mode 100644
index 000000000000..91fdcf07ad63
--- /dev/null
+++ b/meta-oe/recipes-test/linux-serial-test/files/0001-linux-serial-test.c-fix-returned-error-code.patch
@@ -0,0 +1,62 @@ 
+From 1add8f3d228368665c3abd452640b91a86f41976 Mon Sep 17 00:00:00 2001
+From: Max Krummenacher <max.krummenacher@toradex.com>
+Date: Mon, 4 Aug 2025 14:57:22 +0200
+Subject: [PATCH 1/2] linux-serial-test.c: fix returned error code
+
+_cl_no_rx/_cl_no_rx are true in two cases, first when the relevant
+command line paramter is set and second when a rx or tx time is set
+and that time expired.
+
+This fixes the second case in a loopback test. With the change the
+application now correctly returns 125 if the number of written and
+read chars differ.
+
+E.g. `./linux-serial-test -o2 -i3 -b 115200 -p /dev/ttyS1 ; echo $?`
+returns now 0 with a loopback and 125 without, before it returned 0
+with or without a loopback.
+
+Upstream-Status: Submitted [https://github.com/cbrake/linux-serial-test/pull/61/]
+Fixes: 4e57f58c58ae ("compute error count valid when no_tx or no_rx")
+Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
+Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
+---
+ linux-serial-test.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/linux-serial-test.c b/linux-serial-test.c
+index d8f66c16c72f..c2c8882d601b 100644
+--- a/linux-serial-test.c
++++ b/linux-serial-test.c
+@@ -55,6 +55,8 @@ int _cl_loopback = 0;
+ int _cl_dump_err = 0;
+ int _cl_no_rx = 0;
+ int _cl_no_tx = 0;
++int _cl_no_rx_param = 0;
++int _cl_no_tx_param = 0;
+ int _cl_rx_delay = 0;
+ int _cl_tx_delay = 0;
+ int _cl_tx_bytes = 0;
+@@ -442,9 +444,11 @@ static void process_options(int argc, char * argv[])
+ 			break;
+ 		case 'r':
+ 			_cl_no_rx = 1;
++			_cl_no_rx_param = 1;
+ 			break;
+ 		case 't':
+ 			_cl_no_tx = 1;
++			_cl_no_tx_param = 1;
+ 			break;
+ 		case 'l': {
+ 			char *endptr;
+@@ -745,7 +749,7 @@ static int diff_s(const struct timespec *t1, const struct timespec *t2)
+ static int compute_error_count(void)
+ {
+ 	long long int result;
+-	if (_cl_no_rx == 1 || _cl_no_tx == 1)
++	if (_cl_no_rx_param == 1 || _cl_no_tx_param == 1)
+ 		result = _error_count;
+ 	else
+ 		result = llabs(_write_count - _read_count) + _error_count;
+-- 
+2.43.0
+
diff --git a/meta-oe/recipes-test/linux-serial-test/linux-serial-test_git.bb b/meta-oe/recipes-test/linux-serial-test/linux-serial-test_git.bb
index 888b13e2f6fa..66511bd9c312 100644
--- a/meta-oe/recipes-test/linux-serial-test/linux-serial-test_git.bb
+++ b/meta-oe/recipes-test/linux-serial-test/linux-serial-test_git.bb
@@ -3,7 +3,9 @@  HOMEPAGE = "https://github.com/cbrake/linux-serial-test"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSES/MIT;md5=544799d0b492f119fa04641d1b8868ed"
 
-SRC_URI = "git://github.com/cbrake/linux-serial-test.git;protocol=https;branch=master"
+SRC_URI = "git://github.com/cbrake/linux-serial-test.git;protocol=https;branch=master \
+           file://0001-linux-serial-test.c-fix-returned-error-code.patch \
+"
 PV = "0+git"
 SRCREV = "1a81f3c7be086ee01a9be8589a606426276c86d5"