Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5251bab in mainline


Ignore:
Timestamp:
2009-03-22T21:50:09Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
8263c68
Parents:
8b48063
Message:

split printf test into several tests for better readability

Location:
kernel
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r8b48063 r5251bab  
    262262                test/synch/semaphore2.c \
    263263                test/print/print1.c \
     264                test/print/print2.c \
     265                test/print/print3.c \
     266                test/print/print4.c \
    264267                test/thread/thread1.c \
    265268                test/sysinfo/sysinfo1.c
  • kernel/test/print/print1.c

    r8b48063 r5251bab  
    3030#include <test.h>
    3131
    32 #define BUFFER_SIZE 32
    33 
    34 char * test_print1(bool quiet)
     32char *test_print1(bool quiet)
    3533{
    3634        if (!quiet) {
    37                 int retval;
    38                 unative_t nat = 0x12345678u;
     35                printf("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n");
     36                printf("Expected output: \"  tex\"\n");
     37                printf("Real output:     \"%*.*s\"\n\n", 5, 3, "text");
    3938               
    40                 char buffer[BUFFER_SIZE];
     39                printf("Testing printf(\"%%10.8s\", \"very long text\"):\n");
     40                printf("Expected output: \"  very lon\"\n");
     41                printf("Real output:     \"%10.8s\"\n\n", "very long text");
    4142               
    42                 printf(" text 10.8s %*.*s \n", 5, 3, "text");
    43                 printf(" very long text 10.8s %10.8s \n", "very long text");
    44                 printf(" text 8.10s %8.10s \n", "text");
    45                 printf(" very long text 8.10s %8.10s \n", "very long text");
     43                printf("Testing printf(\"%%8.10s\", \"text\"):\n");
     44                printf("Expected output: \"text\"\n");
     45                printf("Real output:     \"%8.10s\"\n\n", "text");
    4646               
    47                 printf(" char: c '%c', 3.2c '%3.2c', -3.2c '%-3.2c', 2.3c '%2.3c', -2.3c '%-2.3c' \n", 'a', 'b', 'c', 'd', 'e');
    48                 printf(" int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n", 1, 1, 1, 1, 1);
    49                 printf(" -int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n", -1, -1, -1, -1, -1);
    50                 printf(" 0xint: x '%#x', 5.3x '%#5.3x', -5.3x '%#-5.3x', 3.5x '%#3.5x', -3.5x '%#-3.5x' \n", 17, 17, 17, 17, 17);
     47                printf("Testing printf(\"%%8.10s\", \"very long text\"):\n");
     48                printf("Expected output: \"very long \"\n");
     49                printf("Real output:     \"%8.10s\"\n\n", "very long text");
    5150               
    52                 printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#" PRIxn "'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" );
    53                
    54                 printf(" Print to NULL '%s'\n", NULL);
    55                
    56                 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
    57                 printf("Result is: '%s', retval = %d\n", buffer, retval);
    58                
    59                 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
    60                 printf("Result is: '%s', retval = %d\n", buffer, retval);
    61                
    62                 printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
    63                 retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text");
    64                 printf("Result is: '%s', retval = %d\n", buffer, retval);
    65                
    66                 printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE);
    67                 retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text`s length is more than %d. We are interested in the result.", "text" , BUFFER_SIZE);
    68                 printf("Result is: '%s', retval = %d\n", buffer, retval);
     51                printf("Testing printf(\"%%s\", NULL):\n");
     52                printf("Expected output: \"(NULL)\"\n");
     53                printf("Real output:     \"%s\"\n\n", NULL);
    6954        }
    7055       
  • kernel/test/print/print1.def

    r8b48063 r5251bab  
    11{
    22        "print1",
    3         "Printf test",
     3        "String printf test",
    44        &test_print1,
    55        true
  • kernel/test/test.c

    r8b48063 r5251bab  
    5757#include <synch/semaphore2.def>
    5858#include <print/print1.def>
     59#include <print/print2.def>
     60#include <print/print3.def>
     61#include <print/print4.def>
    5962#include <thread/thread1.def>
    6063#include <sysinfo/sysinfo1.def>
    6164        {
    6265                .name = NULL,
    63                 .desc = NULL, 
     66                .desc = NULL,
    6467                .entry = NULL
    6568        }
  • kernel/test/test.h

    r8b48063 r5251bab  
    4848} test_t;
    4949
    50 extern char * test_atomic1(bool quiet);
    51 extern char * test_avltree1(bool quiet);
    52 extern char * test_btree1(bool quiet);
    53 extern char * test_mips1(bool quiet);
    54 extern char * test_fault1(bool quiet);
    55 extern char * test_fpu1(bool quiet);
    56 extern char * test_sse1(bool quiet);
    57 extern char * test_mips2(bool quiet);
    58 extern char * test_falloc1(bool quiet);
    59 extern char * test_falloc2(bool quiet);
    60 extern char * test_mapping1(bool quiet);
    61 extern char * test_purge1(bool quiet);
    62 extern char * test_slab1(bool quiet);
    63 extern char * test_slab2(bool quiet);
    64 extern char * test_rwlock1(bool quiet);
    65 extern char * test_rwlock2(bool quiet);
    66 extern char * test_rwlock3(bool quiet);
    67 extern char * test_rwlock4(bool quiet);
    68 extern char * test_rwlock5(bool quiet);
    69 extern char * test_semaphore1(bool quiet);
    70 extern char * test_semaphore2(bool quiet);
    71 extern char * test_print1(bool quiet);
    72 extern char * test_thread1(bool quiet);
    73 extern char * test_sysinfo1(bool quiet);
     50extern char *test_atomic1(bool quiet);
     51extern char *test_avltree1(bool quiet);
     52extern char *test_btree1(bool quiet);
     53extern char *test_mips1(bool quiet);
     54extern char *test_fault1(bool quiet);
     55extern char *test_fpu1(bool quiet);
     56extern char *test_sse1(bool quiet);
     57extern char *test_mips2(bool quiet);
     58extern char *test_falloc1(bool quiet);
     59extern char *test_falloc2(bool quiet);
     60extern char *test_mapping1(bool quiet);
     61extern char *test_purge1(bool quiet);
     62extern char *test_slab1(bool quiet);
     63extern char *test_slab2(bool quiet);
     64extern char *test_rwlock1(bool quiet);
     65extern char *test_rwlock2(bool quiet);
     66extern char *test_rwlock3(bool quiet);
     67extern char *test_rwlock4(bool quiet);
     68extern char *test_rwlock5(bool quiet);
     69extern char *test_semaphore1(bool quiet);
     70extern char *test_semaphore2(bool quiet);
     71extern char *test_print1(bool quiet);
     72extern char *test_print2(bool quiet);
     73extern char *test_print3(bool quiet);
     74extern char *test_print4(bool quiet);
     75extern char *test_thread1(bool quiet);
     76extern char *test_sysinfo1(bool quiet);
    7477
    7578extern test_t tests[];
Note: See TracChangeset for help on using the changeset viewer.