I did some analysis, and this bug was quite interesting...
Patch which fixes it (and probably armel too) is below.

a) The "unit-test-server: no process found" error is misleading.
It does not indicate that the server or client test program did
not start, but it just means the "killall" program in the unit-tests.sh
shell script could not find the "unit-test-server" process any longer
(which is correct, since it executed and exited quite fine).
The patch below pipes errors of killall to /dev/null to avoid it.

b)
The main problem, is the timeout of 7ms in unit-test-client.c around
line 681.
On SMP parisc machines where more than one CPU is running, the internal
timers are not as fine-grained as on single-CPU machines, or as x86
machines. That leads that it's not guaranteed, that chars gets delivered
in a 2ms boundary timeframe (7ms total - 5ms wait time = 2ms delivery time max).
I increased the timeout to 15ms, and now the tests succeed.


Can you please include the patch below and bring it upstream?

Thanks,
Helge


diff -up ./tests/unit-test-client.c.org ./tests/unit-test-client.c
--- ./tests/unit-test-client.c.org      2024-05-19 12:40:47.232000000 +0000
+++ ./tests/unit-test-client.c  2024-05-19 12:43:34.644000000 +0000
@@ -679,11 +679,12 @@ int main(int argc, char *argv[])
         usleep(11 * 5000);
         modbus_flush(ctx);
 
-        /* Timeout of 7ms between bytes */
-        modbus_set_byte_timeout(ctx, 0, 7000);
+        /* Timeout of 15ms between bytes (allow slow machines or machines
+          with unreliable SMP timers to succeed) */
+        modbus_set_byte_timeout(ctx, 0, 15000);
         rc = modbus_read_registers(
             ctx, UT_REGISTERS_ADDRESS_BYTE_SLEEP_5_MS, 1, tab_rp_registers);
-        printf("2/2 Adapted byte timeout (7ms > 5ms): ");
+        printf("2/2 Adapted byte timeout (15ms > 5ms): ");
         ASSERT_TRUE(rc == 1, "");
     }
 
diff -up ./tests/unit-tests.sh.org ./tests/unit-tests.sh
--- ./tests/unit-tests.sh.org   2024-05-19 12:39:00.572000000 +0000
+++ ./tests/unit-tests.sh       2024-05-19 12:39:22.904000000 +0000
@@ -14,6 +14,6 @@ echo "Starting client"
 ./unit-test-client > $client_log 2>&1
 rc=$?
 
-killall unit-test-server
+killall unit-test-server 2>/dev/null
 exit $rc
 

Reply via email to