Make test_event more reliable
Look for the expected message several times, with short sleeps in between. That way we will not sleep more than necessary, yet will not immediately give up either.
This commit is contained in:
@ -481,13 +481,21 @@ int test_logging()
|
|||||||
|
|
||||||
MXS_LOG_EVENT(event::AUTHENTICATION_FAILURE, "%s", id.c_str());
|
MXS_LOG_EVENT(event::AUTHENTICATION_FAILURE, "%s", id.c_str());
|
||||||
|
|
||||||
// Short sleep to increase the likelyhood that the logged message ends
|
// We have no control over how quickly syslog messages are flushed
|
||||||
// ends up where we expect it to be.
|
// to the file. So, we try a few times before giving up.
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
int attempts = 0;
|
||||||
|
const int MAX_ATTEMPTS = 10;
|
||||||
|
|
||||||
ifstream in("/var/log/auth.log");
|
do
|
||||||
|
{
|
||||||
|
++attempts;
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
const char* zName = "/var/log/auth.log";
|
||||||
|
ifstream in(zName);
|
||||||
|
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
@ -501,6 +509,13 @@ int test_logging()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "error: Could not open '" << zName << "'." << endl;
|
||||||
|
attempts = MAX_ATTEMPTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!found && (attempts < MAX_ATTEMPTS));
|
||||||
|
|
||||||
return found ? 0 : 1;
|
return found ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user