mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
More reliable log expect in common/log test.
The exact message is platform dependent so get the platform error to use in the expect. It doesn't matter what the message is as long as there is an error and it is logged.
This commit is contained in:
parent
cbccae05b8
commit
88e54ee6c7
@ -257,6 +257,11 @@ testRun(void)
|
||||
TEST_RESULT_BOOL(logFileSet("/" BOGUS_STR), false, "attempt to open bogus file");
|
||||
TEST_RESULT_INT(logFdFile, -1, "log file is closed");
|
||||
|
||||
// Get the error message from above to use for the expect log test
|
||||
int testFdFile = open("/" BOGUS_STR, O_CREAT | O_APPEND, 0640);
|
||||
const char *testErrorFile = strerror(errno);
|
||||
TEST_RESULT_INT(testFdFile, -1, "got error message");
|
||||
|
||||
// Close logging again
|
||||
TEST_RESULT_VOID(logInit(logLevelDebug, logLevelDebug, logLevelDebug, false, 0, 99, false), "reduce log size");
|
||||
TEST_RESULT_BOOL(logFileSet(fileFile), true, "open valid file");
|
||||
@ -277,14 +282,19 @@ testRun(void)
|
||||
" message2");
|
||||
|
||||
// Check stderr
|
||||
testLogResult(
|
||||
stderrFile,
|
||||
char buffer[4096];
|
||||
|
||||
sprintf(
|
||||
buffer,
|
||||
"DEBUG: test::test_func: message\n"
|
||||
" message2\n"
|
||||
"INFO: [DRY-RUN] info message\n"
|
||||
"INFO: [DRY-RUN] info message 2\n"
|
||||
"WARN: [DRY-RUN] unable to open log file '/BOGUS': Permission denied\n"
|
||||
" NOTE: process will continue without log file.");
|
||||
"WARN: [DRY-RUN] unable to open log file '/BOGUS': %s\n"
|
||||
" NOTE: process will continue without log file.",
|
||||
testErrorFile);
|
||||
|
||||
testLogResult(stderrFile, buffer);
|
||||
|
||||
// Check file
|
||||
testLogResult(
|
||||
|
Loading…
x
Reference in New Issue
Block a user