Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'thread' test application #1557

Closed
fpagliughi opened this issue Jan 9, 2025 · 2 comments
Closed

The 'thread' test application #1557

fpagliughi opened this issue Jan 9, 2025 · 2 comments

Comments

@fpagliughi
Copy link
Contributor

Do we know if the thread test is currently working properly?
https://github.com/eclipse-paho/paho.mqtt.c/blob/master/test/thread.c

When I run it, on Mint/Ubuntu Linux, I get errors reported:

$ ./test/thread 
20250108 231907.694 Starting mutex test
20250108 231907.694 Lock duration was 0
20250108 231909.694 Lock duration was 0
20250108 231909.694 passed: test test_mutex. 5 tests run, 0 failures.
20250108 231909.694 Starting semaphore test
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 303, description: rc ETIMEDOUT from lock mutex, rc was 11
20250108 231911.207 Lock duration was 1513
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 313, description: rc 1 from post_sem, rc was 0
20250108 231913.217 Lock duration was 2009
20250108 231914.208 failed: test test_sem. 36 tests run, 11 failures.
20250108 231914.208 Starting condition variable test
20250108 231914.210 Lock duration was 2
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 377, description: duration is 2s, duration was 2
20250108 231914.212 Lock duration was 1
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 339, description: duration is about 1s, duration was 1
20250108 231914.212 Lock duration was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 347, description: duration is around 1s, duration was 0
Assertion failed, file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 348, description: rc 9 from wait_cond, rc was 22
20250108 231917.211 failed: test test_cond. 66 tests run, 4 failures.
20250108 231917.211 verdict fail

$ echo $?
4

$ cat TEST-thread.xml 
<testsuite name="thread" tests="3">
<testcase classname="test" name="test_mutex" time="2.000" >
</testcase>
<testcase classname="test" name="test_sem" time="4.513" >
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc 1 from check_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 294 </failure>
<failure type="rc ETIMEDOUT from lock mutex">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 303 </failure>
<failure type="rc 1 from post_sem">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 313 </failure>
</testcase>
<testcase classname="cond" name="test_cond" time="3.003" >
<failure type="duration is 2s">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 377 </failure>
<failure type="duration is about 1s">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 339 </failure>
<failure type="duration is around 1s">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 347 </failure>
<failure type="rc 9 from wait_cond">file /home/fmp/mqtt/paho.mqtt.c-pers/test/thread.c, line 348 </failure>
</testcase>
</testsuite>
@fpagliughi
Copy link
Contributor Author

And on Windows...

20250109 083233.470 Starting mutex test
20250109 083233.470 Lock duration was 0
20250109 083235.471 Lock duration was 2000
20250109 083235.471 Lock duration was 0
20250109 083235.471 passed: test test_mutex. 8 tests run, 0 failures.
20250109 083235.471 Starting semaphore test
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 294, description: rc 1 from check_sem, rc was 0
20250109 083236.986 Lock duration was 1516
Assertion failed, file D:\mqtt\paho.mqtt.c-pers\test\thread.c, line 313, description: rc 1 from post_sem, rc was 0
20250109 083238.995 Lock duration was 2016
20250109 083240.011 failed: test test_sem. 39 tests run, 10 failures.
20250109 083240.011 verdict fail

@fpagliughi
Copy link
Contributor Author

To answer my own question...

It appears that test/thread.c no longer matches the implementation of the sync objects in the code base. For example the implementation of a semaphore in Thread.c is for a binary semaphore, while the test is for counting semaphores. So the test fails, because no matter how many times you post the sem, the count never goes above 1.

There is a fix for the test included in PR #1560.

I'll close this, and we can move the discussion to that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant