diff --git a/src/systemcmds/tests/test_file2.c b/src/systemcmds/tests/test_file2.c index eeb52b9a6c..458bb7809f 100644 --- a/src/systemcmds/tests/test_file2.c +++ b/src/systemcmds/tests/test_file2.c @@ -69,7 +69,7 @@ static uint8_t get_value(uint32_t ofs) return u.buf[ofs % 4]; } -static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t write_size, uint16_t flags) +static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t write_size, uint16_t flags) { printf("Testing on %s with write_chunk=%u write_size=%u\n", filename, (unsigned)write_chunk, (unsigned)write_size); @@ -79,7 +79,7 @@ static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t if (fd == -1) { perror(filename); - exit(1); + return 1; } // create a file of size write_size, in write_chunk blocks @@ -95,7 +95,7 @@ static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t if (write(fd, buffer, sizeof(buffer)) != (int)sizeof(buffer)) { printf("write failed at offset %u\n", ofs); - exit(1); + return 1; } if (flags & FLAG_FSYNC) { @@ -118,7 +118,7 @@ static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t if (fd == -1) { perror(filename); - exit(1); + return 1; } counter = 0; @@ -136,14 +136,14 @@ static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t if (read(fd, buffer, sizeof(buffer)) != (int)sizeof(buffer)) { printf("read failed at offset %u\n", ofs); close(fd); - return; + return 1; } for (uint16_t j = 0; j < write_chunk; j++) { if (buffer[j] != get_value(ofs)) { printf("corruption at ofs=%u got %u\n", ofs, buffer[j]); close(fd); - return; + return 1; } ofs++; @@ -158,6 +158,7 @@ static void test_corruption(const char *filename, uint32_t write_chunk, uint32_t close(fd); unlink(filename); printf("All OK\n"); + return 0; } static void usage(void) @@ -221,7 +222,6 @@ int test_file2(int argc, char *argv[]) return 1; } - test_corruption(filename, write_chunk, write_size, flags); - return 0; + return test_corruption(filename, write_chunk, write_size, flags); } diff --git a/src/systemcmds/tests/test_uart_loopback.c b/src/systemcmds/tests/test_uart_loopback.c index 046d51ecaa..6f97cebb79 100644 --- a/src/systemcmds/tests/test_uart_loopback.c +++ b/src/systemcmds/tests/test_uart_loopback.c @@ -82,7 +82,7 @@ int test_uart_loopback(int argc, char *argv[]) } printf("ERROR opening UART5, aborting..\n"); - exit(uart5); + return 1; } uint8_t sample_stdout_fd[] = {'C', 'O', 'U', 'N', 'T', ' ', '#', '\n'};