From ab1589b310fa83e64063f5615a635bad0f66b17c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Thu, 8 Apr 2021 15:36:04 +0200 Subject: [PATCH] logger-test: more intensive tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Send enough data to logger to fill the whole ring buffer. Test assembly of large messages without newline characters. Check return value from write(2). Remove some dead code. Change-Id: I165458f5c7831bd925164aa087f28fd319c9872f Signed-off-by: Łukasz Stelmach --- tools/testing/selftests/logger/logger.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/logger/logger.c b/tools/testing/selftests/logger/logger.c index 18a3ea7..c3e4281 100644 --- a/tools/testing/selftests/logger/logger.c +++ b/tools/testing/selftests/logger/logger.c @@ -1,9 +1,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -75,12 +75,6 @@ int main(int ac, char *av[]) { setlinebuf(stdout); fd = open(device, O_WRONLY); - if (ac >= 2) { - } - - if (ac == 3) { - } - if (test_mask & BIT(0)) { vec[0].iov_base = &prio; vec[0].iov_len = 1; @@ -103,8 +97,10 @@ int main(int ac, char *av[]) { ioctl(fd, LOGGER_SET_TAG, &struct_tag); if (test_mask & BIT(2)) { - - write(fd, "The Foo From STDIO\n", 19); + int count; + count = write(fd, "The Foo From STDIO\n", 19); + if (count != 19) + printf("count != 19\n"); write(fd, "LINE #1\nLINE #2", 15); write(fd, " CONTINUED\nONCE", 15); @@ -117,12 +113,21 @@ int main(int ac, char *av[]) { return 1; for (int i = 0; i < 8000; i++) - msg[i] = ' ' + (i % 96); + msg[i] = '!' + (i % 95); msg[7999] = '\n'; write(fd, msg, 8000); + + for (int i = 0; (test_mask & BIT(4)) && i < 40; i++) + write(fd, msg, 8000); + + for (int i = 0; (test_mask & BIT(5)) && i < 8000; i++) + write(fd, &msg[i], 1); + + free(msg); + msg = NULL; } - if (test_mask & BIT(4)) { + if (test_mask & BIT(6)) { child = fork(); if (child < 0) { return -1; @@ -140,7 +145,7 @@ int main(int ac, char *av[]) { wait(&s); } - if (test_mask & BIT(5)) { + if (test_mask & BIT(7)) { s = pthread_create(&tid, NULL, &tstart, &fd); if (s != 0) handle_error_en(s, "pthread_create"); -- 2.7.4