logger-test: more intensive tests 32/256832/3 accepted/tizen/unified/20210419.153507 submit/tizen/20210419.020922
authorŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 8 Apr 2021 13:36:04 +0000 (15:36 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 16 Apr 2021 03:37:17 +0000 (03:37 +0000)
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 <l.stelmach@samsung.com>
tools/testing/selftests/logger/logger.c

index 18a3ea7..c3e4281 100644 (file)
@@ -1,9 +1,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <linux/const.h>
 #include <linux/logger.h>
 #include <pthread.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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");