logd: instrument tests better for failure

Failure to open socket misbehaved and told us nothing.

Test: gTest logd-unit-tests
Bug: 37378309
Change-Id: Iec369a50ccb1027e96947465e90d9572c9f4047f
This commit is contained in:
Mark Salyzyn 2017-04-17 12:39:13 -07:00
parent d87d47f7dd
commit 24aa9a41e1
1 changed files with 12 additions and 4 deletions

View File

@ -670,8 +670,12 @@ TEST(logd, timeout) {
while (--i) {
int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_SEQPACKET);
EXPECT_LT(0, fd);
if (fd < 0) _exit(fd);
int save_errno = errno;
if (fd < 0) {
fprintf(stderr, "failed to open /dev/socket/logdr %s\n",
strerror(save_errno));
_exit(fd);
}
std::string ask = android::base::StringPrintf(
"dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=%" PRIu32
@ -723,8 +727,12 @@ TEST(logd, timeout) {
// active _or_ inactive during the test.
if (content_timeout) {
log_time msg(msg_timeout.entry.sec, msg_timeout.entry.nsec);
EXPECT_FALSE(msg < now);
if (msg < now) _exit(-1);
if (msg < now) {
fprintf(stderr, "%u.%09u < %u.%09u\n", msg_timeout.entry.sec,
msg_timeout.entry.nsec, (unsigned)now.tv_sec,
(unsigned)now.tv_nsec);
_exit(-1);
}
if (msg > now) {
now = msg;
now.tv_sec += 30;