Commit Graph
16 Commits
Author SHA1 Message Date
Joachim Nilsson 2bea4192db Handle UEV_HUP properly in examples and unit tests
If an I/O watcher callback fails to read(), returning zero, we check
events for UEV_HUP to detect EOF or socket remote end shutdown().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:56:39 +01:00
Joachim Nilsson ebb574136b Make sure to restart I/O watcher when event loop returns error
This patch adds UEV_ERROR handling to the test I/O watcher, restarting
the watcher properly.  Also, additional error handling to read(), which
was unchecked and failed when fuzzing the libc read() function.

We also take the opportunity to document the reasons for when using the
w->fd (watcher descriptor) and when *not* to in the test.  Even to the
author this was confusing and looked suspicious.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson d7485c59ec Fix logical error, read before set, found by Valgrind
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson 505a7214a8 tests: Add basic error handling to callbacks, for reference
Many users look at both examples *and* unit tests to learn how to use a
library.  We should pride ourselves in that we have not just working but
also correct and readable tests.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 12:17:41 +01:00
Joachim Nilsson ed5c9bb06c Relocate source fiiles to src/ subdirectory
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-19 08:12:21 +02:00
Joachim Nilsson aa62e60137 Ensure check.h is included for all unit tests
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-27 20:30:19 +01:00
Joachim Nilsson e765e42eb9 Verify that a timer can be stopped *before* uev_run()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-25 17:28:15 +01:00
Joachim Nilsson 56a2e7ff30 Unit test for new active API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-23 23:20:48 +01:00
Joachim Nilsson 73ae8ba098 complete: Update test for unit test framework
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 01:30:40 +01:00
Joachim Nilsson 6a19fa7e93 cronrun: Update cron test to verify interval as well
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 01:27:49 +01:00
Joachim Nilsson de4d969ca0 Move complete test from examples/ --> tests/
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 01:12:47 +01:00
Joachim Nilsson 389c3b27ab Move cronrun test from examples/ --> tests/
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 01:09:38 +01:00
Joachim Nilsson 03a29440ef Move signal test from examples/ --> tests/
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 01:06:48 +01:00
Joachim Nilsson 9b3af80082 Add .gitignore for unit tests
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 00:37:39 +01:00
Joachim Nilsson 8f2c9f7f0e Add timer.c unit test
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 00:36:21 +01:00
Joachim Nilsson 6a21b7a90b Add unit testing framework from libite (-lite)
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2016-11-22 00:35:19 +01:00