Changeset a35b458 in mainline for kernel/test/print
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/test/print
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/print/print1.c
r3061bc1 ra35b458 36 36 TPRINTF("Expected output: \" tex\"\n"); 37 37 TPRINTF("Real output: \"%*.*s\"\n\n", 5, 3, "text"); 38 38 39 39 TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n"); 40 40 TPRINTF("Expected output: \" very lon\"\n"); 41 41 TPRINTF("Real output: \"%10.8s\"\n\n", "very long text"); 42 42 43 43 TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n"); 44 44 TPRINTF("Expected output: \" text\"\n"); 45 45 TPRINTF("Real output: \"%8.10s\"\n\n", "text"); 46 46 47 47 TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n"); 48 48 TPRINTF("Expected output: \"very long \"\n"); 49 49 TPRINTF("Real output: \"%8.10s\"\n\n", "very long text"); 50 50 51 51 TPRINTF("Testing printf(\"%%-*.*s\", 7, 7, \"text\"):\n"); 52 52 TPRINTF("Expected output: \"text \"\n"); 53 53 TPRINTF("Real output: \"%-*.*s\"\n\n", 7, 7, "text"); 54 54 55 55 return NULL; 56 56 } -
kernel/test/print/print2.c
r3061bc1 ra35b458 36 36 TPRINTF("Expected output: [a]\n"); 37 37 TPRINTF("Real output: [%c]\n\n", 'a'); 38 38 39 39 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n"); 40 40 TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n"); 41 41 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5); 42 42 43 43 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n"); 44 44 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 45 45 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5); 46 46 47 47 TPRINTF("Testing printf(\"%%lld %%3.2lld %%-3.2lld %%2.3lld %%-2.3lld\", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5):\n"); 48 48 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 49 49 TPRINTF("Real output: [%lld] [%3.2lld] [%-3.2lld] [%2.3lld] [%-2.3lld]\n\n", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5); 50 50 51 51 TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n"); 52 52 TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n"); 53 53 TPRINTF("Real output: [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21); 54 54 55 55 char ch[12]; 56 56 ptrdiff_t d, neg_d; 57 57 58 58 d = &ch[0] - &ch[12]; 59 59 neg_d = (unsigned)(-d); … … 61 61 TPRINTF("Expected output: [-12] [12] [c] [-12] [14]\n"); 62 62 TPRINTF("Real output: [%td] [%tu] [%tx] [%ti] [%to]\n\n", d, neg_d, neg_d, d, neg_d); 63 63 64 64 sysarg_t nat = 0x12345678; 65 65 66 66 TPRINTF("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), \"Lovely string\"):\n"); 67 67 TPRINTF("Expected output: [0x1234567887654321] [0x12345678] [0x1234] [0x12] [0x12345678] [0x1234567887654321] \"Lovely string\"\n"); 68 68 TPRINTF("Real output: [%#" PRIx64 "] [%#" PRIx32 "] [%#" PRIx16 "] [%#" PRIx8 "] [%#" PRIxn "] [%#" PRIx64 "] \"%s\"\n\n", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), "Lovely string"); 69 69 70 70 return NULL; 71 71 } -
kernel/test/print/print3.c
r3061bc1 ra35b458 38 38 char buffer[BUFFER_SIZE]; 39 39 int retval; 40 40 41 41 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short text without parameters.\"):\n"); 42 42 TPRINTF("Expected result: retval=30 buffer=\"Short text without parameters.\"\n"); 43 43 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); 44 44 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 45 45 46 46 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very very very long text without parameters.\"):\n"); 47 47 TPRINTF("Expected result: retval=44 buffer=\"Very very very long text withou\"\n"); 48 48 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); 49 49 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 50 50 51 51 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short %%s.\", \"text\"):\n"); 52 52 TPRINTF("Expected result: retval=11 buffer=\"Short text.\"\n"); 53 53 retval = snprintf(buffer, BUFFER_SIZE, "Short %s.", "text"); 54 54 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 55 55 56 56 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very long %%s. This text's length is more than %%d. We are interested in the result.\", \"text\", " STRING(BUFFER_SIZE) "):\n"); 57 57 TPRINTF("Expected result: retval=84 buffer=\"Very long text. This text's len\"\n"); 58 58 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); 59 59 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 60 60 61 61 return NULL; 62 62 } -
kernel/test/print/print4.c
r3061bc1 ra35b458 34 34 { 35 35 TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 36 36 37 37 uint8_t group; 38 38 for (group = 1; group < 4; group++) { 39 39 TPRINTF("%#x: ", group << 5); 40 40 41 41 uint8_t index; 42 42 for (index = 0; index < 32; index++) 43 43 TPRINTF("%c", (char) ((group << 5) + index)); 44 44 45 45 TPRINTF(" "); 46 46 for (index = 0; index < 32; index++) 47 47 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 48 48 49 49 TPRINTF("\n"); 50 50 } 51 51 52 52 TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 53 53 54 54 for (group = 4; group < 8; group++) { 55 55 TPRINTF("%#x: ", group << 5); 56 56 57 57 uint8_t index; 58 58 for (index = 0; index < 32; index++) 59 59 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 60 60 61 61 TPRINTF("\n"); 62 62 } 63 63 64 64 TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n"); 65 65 TPRINTF("English: %s\n", "Quick brown fox jumps over the lazy dog"); … … 70 70 TPRINTF("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 71 71 TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 72 72 73 73 TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n"); 74 74 TPRINTF("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); … … 79 79 TPRINTF("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 80 80 TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 81 81 82 82 return NULL; 83 83 } -
kernel/test/print/print5.c
r3061bc1 ra35b458 48 48 TPRINTF("Expected output: \"(NULL)\"\n"); 49 49 TPRINTF("Real output: \"%s\"\n\n", (char *) NULL); 50 50 51 51 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n"); 52 52 TPRINTF("Expected output: [a] [ b] [c ] [ d] [e ]\n"); 53 53 TPRINTF("Real output: [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e'); 54 54 55 55 return NULL; 56 56 }
Note:
See TracChangeset
for help on using the changeset viewer.
