test-journal-append: use DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE
Negative return values, e.g. from option parsing, were propagated verbatim as the exit status of main() and truncated to meaningless values (-EINVAL became 234). The positive-failure variant is needed because the binary may exit with EXIT_TEST_SKIP. Also propagate EXIT_TEST_SKIP instead of suppressing it.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "iovec-util.h"
|
||||
#include "journal-file-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "mmap-cache.h"
|
||||
#include "options.h"
|
||||
#include "parse-util.h"
|
||||
@@ -141,7 +142,7 @@ static int journal_corrupt_and_append(uint64_t start_offset, uint64_t step) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
static int run(int argc, char *argv[]) {
|
||||
uint64_t start_offset = UINT64_MAX;
|
||||
uint64_t iterations = 100;
|
||||
uint64_t iteration_step = 1;
|
||||
@@ -235,12 +236,11 @@ int main(int argc, char *argv[]) {
|
||||
offset = (start_offset == UINT64_MAX ? 0 : start_offset) + i * iteration_step;
|
||||
|
||||
r = journal_corrupt_and_append(offset, corrupt_step);
|
||||
if (r < 0)
|
||||
return EXIT_FAILURE;
|
||||
if (r > 0)
|
||||
/* Reached the end of the journal file */
|
||||
break;
|
||||
if (r != 0) /* Either error or EXIT_TEST_SKIP */
|
||||
return r;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
|
||||
|
||||
Reference in New Issue
Block a user