CHROMIUM: test_dbus: Handle read() EINTR
We've finally got a proper error dump of a failing case:
BAD: Error reading dbus-daemon status: 4, Interrupted system call
at tests/test_initctl.c:18533 (test_dbus_connection).
FAIL test_initctl (exit status: 134)
We should retry reads here if they see EINTR.
BUG=b:342438425
TEST=cros_run_unit_tests
Change-Id: I0425907f814503c03abfd03688ed0726cc2fc0fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/libnih/+/5696177
Reviewed-by: Allen Webb <[email protected]>
Commit-Queue: Brian Norris <[email protected]>
Auto-Submit: Brian Norris <[email protected]>
Tested-by: Brian Norris <[email protected]>
diff --git a/nih-dbus/test_dbus.h b/nih-dbus/test_dbus.h
index 7329977..407c9be 100644
--- a/nih-dbus/test_dbus.h
+++ b/nih-dbus/test_dbus.h
@@ -55,11 +55,15 @@
int _ret; \
char _test_address[128] = { 0 }; \
close (_test_fds[1]); \
- _ret = read (_test_fds[0], _test_address, \
- sizeof (_test_address)); \
- if (_ret == 0) { \
- TEST_FAILED ("Unexpected EOF when reading dbus-daemon status"); \
- } else if (_ret < 0) { \
+ while (1) { \
+ _ret = read (_test_fds[0], \
+ _test_address, \
+ sizeof (_test_address)); \
+ if (_ret > 0) \
+ break; \
+ TEST_NE (_ret, 0); \
+ if (errno == EINTR) \
+ continue; \
TEST_FAILED ("Error reading dbus-daemon status: %d, %s", \
errno, strerror (errno)); \
} \