Changeset 2d11a7d8 in mainline
- Timestamp:
- 2009-06-30T15:54:14Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9c40f883
- Parents:
- db24058
- Location:
- uspace/app/tester
- Files:
-
- 3 added
- 9 deleted
- 17 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/Makefile
rdb24058 r2d11a7d8 46 46 thread/thread1.c \ 47 47 print/print1.c \ 48 print/print2.c \ 49 print/print3.c \ 48 50 print/print4.c \ 49 fault/fault1.c \50 fault/fault2.c \51 ipc/register.c \52 ipc/connect.c \53 ipc/send_async.c \54 ipc/send_sync.c \55 ipc/answer.c \56 ipc/hangup.c \57 ipc/ping_pong.c \58 loop/loop1.c \59 devmap/devmap1.c \60 51 console/console1.c \ 61 52 stdio/stdio1.c \ 62 53 stdio/stdio2.c \ 63 vfs/vfs1.c 54 fault/fault1.c \ 55 fault/fault2.c \ 56 vfs/vfs1.c \ 57 ipc/ping_pong.c \ 58 ipc/register.c \ 59 ipc/connect.c \ 60 loop/loop1.c \ 61 mm/malloc1.c 64 62 65 63 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) -
uspace/app/tester/console/console1.c
rdb24058 r2d11a7d8 47 47 }; 48 48 49 char * test_console1(bool quiet)49 char *test_console1(void) 50 50 { 51 int i, j; 52 53 printf("Style test: "); 54 fflush(stdout); 55 console_set_style(fphone(stdout), STYLE_NORMAL); 56 printf("normal "); 57 fflush(stdout); 58 console_set_style(fphone(stdout), STYLE_EMPHASIS); 59 printf("emphasized"); 60 fflush(stdout); 61 console_set_style(fphone(stdout), STYLE_NORMAL); 62 printf(".\n"); 63 64 printf("Foreground color test:\n"); 65 for (j = 0; j < 2; j++) { 66 for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { 51 if (!test_quiet) { 52 printf("Style test: "); 53 fflush(stdout); 54 console_set_style(fphone(stdout), STYLE_NORMAL); 55 printf("normal "); 56 fflush(stdout); 57 console_set_style(fphone(stdout), STYLE_EMPHASIS); 58 printf("emphasized"); 59 fflush(stdout); 60 console_set_style(fphone(stdout), STYLE_NORMAL); 61 printf(".\n"); 62 63 unsigned int i; 64 unsigned int j; 65 66 printf("\nForeground color test:\n"); 67 for (j = 0; j < 2; j++) { 68 for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { 69 fflush(stdout); 70 console_set_color(fphone(stdout), i, COLOR_WHITE, 71 j ? CATTR_BRIGHT : 0); 72 printf(" %s ", color_name[i]); 73 } 67 74 fflush(stdout); 68 console_set_color(fphone(stdout), i, COLOR_WHITE, 69 j ? CATTR_BRIGHT : 0); 70 printf(" %s ", color_name[i]); 75 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 76 putchar('\n'); 77 } 78 79 printf("\nBackground color test:\n"); 80 for (j = 0; j < 2; j++) { 81 for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { 82 fflush(stdout); 83 console_set_color(fphone(stdout), COLOR_WHITE, i, 84 j ? CATTR_BRIGHT : 0); 85 printf(" %s ", color_name[i]); 86 } 87 fflush(stdout); 88 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 89 putchar('\n'); 90 } 91 92 printf("\nRGB colors test:\n"); 93 94 for (i = 0; i < 255; i += 16) { 95 fflush(stdout); 96 console_set_rgb_color(fphone(stdout), 0xffffff, i << 16); 97 putchar('X'); 98 } 99 fflush(stdout); 100 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 101 putchar('\n'); 102 103 for (i = 0; i < 255; i += 16) { 104 fflush(stdout); 105 console_set_rgb_color(fphone(stdout), 0xffffff, i << 8); 106 putchar('X'); 107 } 108 fflush(stdout); 109 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 110 putchar('\n'); 111 112 for (i = 0; i < 255; i += 16) { 113 fflush(stdout); 114 console_set_rgb_color(fphone(stdout), 0xffffff, i); 115 putchar('X'); 71 116 } 72 117 fflush(stdout); … … 74 119 putchar('\n'); 75 120 } 76 77 printf("Background color test:\n"); 78 for (j = 0; j < 2; j++) { 79 for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { 80 fflush(stdout); 81 console_set_color(fphone(stdout), COLOR_WHITE, i, 82 j ? CATTR_BRIGHT : 0); 83 printf(" %s ", color_name[i]); 84 } 85 fflush(stdout); 86 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 87 putchar('\n'); 88 } 89 90 printf("Now let's test RGB colors:\n"); 91 92 for (i = 0; i < 255; i += 16) { 93 fflush(stdout); 94 console_set_rgb_color(fphone(stdout), 0xffffff, i << 16); 95 putchar('X'); 96 } 97 fflush(stdout); 98 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 99 putchar('\n'); 100 101 for (i = 0; i < 255; i += 16) { 102 fflush(stdout); 103 console_set_rgb_color(fphone(stdout), 0xffffff, i << 8); 104 putchar('X'); 105 } 106 fflush(stdout); 107 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 108 putchar('\n'); 109 110 for (i = 0; i < 255; i += 16) { 111 fflush(stdout); 112 console_set_rgb_color(fphone(stdout), 0xffffff, i); 113 putchar('X'); 114 } 115 fflush(stdout); 116 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 117 putchar('\n'); 118 119 printf("[press a key]\n"); 120 getchar(); 121 121 122 122 return NULL; 123 123 } -
uspace/app/tester/fault/fault1.c
rdb24058 r2d11a7d8 30 30 #include "../tester.h" 31 31 32 char * test_fault1(bool quiet)32 char *test_fault1(void) 33 33 { 34 34 ((int *)(0))[1] = 0; -
uspace/app/tester/fault/fault2.c
rdb24058 r2d11a7d8 30 30 #include "../tester.h" 31 31 32 char * test_fault2(bool quiet)32 char *test_fault2(void) 33 33 { 34 34 volatile long long var; -
uspace/app/tester/ipc/connect.c
rdb24058 r2d11a7d8 29 29 #include <stdio.h> 30 30 #include <unistd.h> 31 #include <atomic.h> 31 32 #include "../tester.h" 32 33 33 char * test_connect(bool quiet) 34 static atomic_t finish; 35 36 static void callback(void *priv, int retval, ipc_call_t *data) 34 37 { 35 char c; 36 int svc; 37 int phid; 38 atomic_set(&finish, 1); 39 } 38 40 39 printf("Choose one service: 0:10000....9:10009 (q to skip)\n"); 40 do { 41 c = getchar(); 42 if ((c == 'Q') || (c == 'q')) 43 return TEST_SKIPPED; 44 } while (c < '0' || c > '9'); 41 char *test_connect(void) 42 { 43 TPRINTF("Connecting to %u...", IPC_TEST_SERVICE); 44 int phone = ipc_connect_me_to(PHONE_NS, IPC_TEST_SERVICE, 0, 0); 45 if (phone > 0) { 46 TPRINTF("phoneid %d\n", phone); 47 } else { 48 TPRINTF("\n"); 49 return "ipc_connect_me_to() failed"; 50 } 45 51 46 svc = IPC_TEST_START + c - '0';47 i f (svc == myservice)48 return "Currently cannot connect to myself, update test";52 printf("Sending synchronous message...\n"); 53 int retval = ipc_call_sync_0_0(phone, IPC_TEST_METHOD); 54 TPRINTF("Received response to synchronous message\n"); 49 55 50 printf("Connecting to %d..", svc); 51 phid = ipc_connect_me_to(PHONE_NS, svc, 0, 0); 52 if (phid > 0) { 53 printf("phoneid: %d\n", phid); 54 phones[phid] = 1; 55 } else 56 return "Error"; 56 TPRINTF("Sending asynchronous message...\n"); 57 atomic_set(&finish, 0); 58 ipc_call_async_0(phone, IPC_TEST_METHOD, NULL, callback, 1); 59 while (atomic_get(&finish) != 1) 60 TPRINTF("."); 61 TPRINTF("Received response to asynchronous message\n"); 62 63 TPRINTF("Hanging up..."); 64 retval = ipc_hangup(phone); 65 if (retval == 0) { 66 TPRINTF("OK\n"); 67 } else { 68 TPRINTF("\n"); 69 return "ipc_hangup() failed"; 70 } 57 71 58 72 return NULL; -
uspace/app/tester/ipc/ping_pong.c
rdb24058 r2d11a7d8 38 38 #define COUNT_GRANULARITY 100 39 39 40 char *test_ping_pong( bool quiet)40 char *test_ping_pong(void) 41 41 { 42 printf("Pinging ns server for %d seconds...\n", DURATION_SECS);42 TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS); 43 43 44 44 struct timeval start; 45 if (gettimeofday(&start, NULL) != 0) 46 return "Failed getting the time."; 45 if (gettimeofday(&start, NULL) != 0) { 46 TPRINTF("\n"); 47 return "Failed getting the time"; 48 } 47 49 48 50 uint64_t count = 0; 49 50 51 while (true) { 51 52 struct timeval now; 52 if (gettimeofday(&now, NULL) != 0) 53 return "Failed getting the time."; 53 if (gettimeofday(&now, NULL) != 0) { 54 TPRINTF("\n"); 55 return "Failed getting the time"; 56 } 54 57 55 58 if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) … … 60 63 int retval = async_req_0_0(PHONE_NS, NS_PING); 61 64 62 if (retval != EOK) 63 return "Failed to send ping message."; 65 if (retval != EOK) { 66 TPRINTF("\n"); 67 return "Failed to send ping message"; 68 } 64 69 } 65 70 … … 67 72 } 68 73 69 printf("Completed %lu round trips in %u seconds, %lu RT/s.\n",74 TPRINTF("OK\nCompleted %llu round trips in %u seconds, %llu rt/s.\n", 70 75 count, DURATION_SECS, count / DURATION_SECS); 71 76 -
uspace/app/tester/ipc/register.c
rdb24058 r2d11a7d8 33 33 #include "../tester.h" 34 34 35 #define MAX_CONNECTIONS 50 36 37 static int connections[MAX_CONNECTIONS]; 38 35 39 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 36 40 { 37 ipc_callid_t callid; 38 ipc_call_t call; 39 ipcarg_t phonehash = icall->in_phone_hash; 40 int retval; 41 int i; 42 43 printf("Connected phone: %P, accepting\n", icall->in_phone_hash); 41 unsigned int i; 42 43 TPRINTF("Connected phone %#x accepting\n", icall->in_phone_hash); 44 44 ipc_answer_0(iid, EOK); 45 for (i = 0; i < 1024; i++)45 for (i = 0; i < MAX_CONNECTIONS; i++) { 46 46 if (!connections[i]) { 47 connections[i] = phonehash;47 connections[i] = icall->in_phone_hash; 48 48 break; 49 49 } 50 } 50 51 51 while (1) { 52 callid = async_get_call(&call); 52 while (true) { 53 ipc_call_t call; 54 ipc_callid_t callid = async_get_call(&call); 55 int retval; 56 53 57 switch (IPC_GET_METHOD(call)) { 54 58 case IPC_M_PHONE_HUNGUP: 55 printf("Phone (%P) hung up.\n", phonehash);59 TPRINTF("Phone %#x hung up\n", icall->in_phone_hash); 56 60 retval = 0; 57 61 break; 62 case IPC_TEST_METHOD: 63 TPRINTF("Received well known message from %#x: %#x\n", 64 icall->in_phone_hash, callid); 65 ipc_answer_0(callid, EOK); 66 break; 58 67 default: 59 printf("Received message from %P: %X\n", phonehash, 60 callid); 61 for (i = 0; i < 1024; i++) 62 if (!callids[i]) { 63 callids[i] = callid; 64 break; 65 } 66 continue; 68 TPRINTF("Received unknown message from %#x: %#x\n", 69 icall->in_phone_hash, callid); 70 ipc_answer_0(callid, ENOENT); 71 break; 67 72 } 68 ipc_answer_0(callid, retval);69 73 } 70 74 } 71 75 72 char * test_register(bool quiet)76 char *test_register(void) 73 77 { 74 int i;78 async_set_client_connection(client_connection); 75 79 76 async_set_client_connection(client_connection); 77 78 for (i = IPC_TEST_START; i < IPC_TEST_START + 10; i++) { 79 ipcarg_t phonead; 80 int res = ipc_connect_to_me(PHONE_NS, i, 0, 0, &phonead); 81 if (!res) 82 break; 83 printf("Failed registering as %d..:%d\n", i, res); 84 } 85 printf("Registered as service: %d\n", i); 86 myservice = i; 80 ipcarg_t phonead; 81 int res = ipc_connect_to_me(PHONE_NS, IPC_TEST_SERVICE, 0, 0, &phonead); 82 if (res != 0) 83 return "Failed registering IPC service"; 84 85 TPRINTF("Registered as service %u, accepting connections\n", IPC_TEST_SERVICE); 86 async_manager(); 87 87 88 88 return NULL; -
uspace/app/tester/loop/loop1.c
rdb24058 r2d11a7d8 31 31 #include "../tester.h" 32 32 33 char *test_loop1( bool quiet)33 char *test_loop1(void) 34 34 { 35 printf("Looping...\n");36 while ( 1);37 printf("Survived endless loop?!!\n");38 39 return NULL;35 TPRINTF("Looping..."); 36 while (true); 37 TPRINTF("\n"); 38 39 return "Survived endless loop"; 40 40 } 41 -
uspace/app/tester/print/print1.c
rdb24058 r2d11a7d8 31 31 #include "../tester.h" 32 32 33 #define BUFFER_SIZE 32 34 35 char * test_print1(bool quiet) 33 char *test_print1(void) 36 34 { 37 if (!quiet) { 38 int retval; 39 unsigned int nat = 0x12345678u; 40 41 char buffer[BUFFER_SIZE]; 42 43 printf(" text 10.8s %*.*s \n", 5, 3, "text"); 44 printf(" very long text 10.8s %10.8s \n", "very long text"); 45 printf(" text 8.10s %8.10s \n", "text"); 46 printf(" very long text 8.10s %8.10s \n", "very long text"); 47 48 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' ); 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(" -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 ); 51 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 ); 52 53 printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" ); 54 55 printf(" Print to NULL '%s'\n", NULL); 56 57 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); 58 printf("Result is: '%s', retval = %d\n", buffer, retval); 59 60 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); 61 printf("Result is: '%s', retval = %d\n", buffer, retval); 62 63 printf("Print short text to %d char long buffer via snprintf.\n", BUFFER_SIZE); 64 retval = snprintf(buffer, BUFFER_SIZE, "Short %s", "text"); 65 printf("Result is: '%s', retval = %d\n", buffer, retval); 66 67 printf("Print long text to %d char long buffer via snprintf.\n", BUFFER_SIZE); 68 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); 69 printf("Result is: '%s', retval = %d\n", buffer, retval); 70 } 35 TPRINTF("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n"); 36 TPRINTF("Expected output: \" tex\"\n"); 37 TPRINTF("Real output: \"%*.*s\"\n\n", 5, 3, "text"); 38 39 TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n"); 40 TPRINTF("Expected output: \" very lon\"\n"); 41 TPRINTF("Real output: \"%10.8s\"\n\n", "very long text"); 42 43 TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n"); 44 TPRINTF("Expected output: \"text\"\n"); 45 TPRINTF("Real output: \"%8.10s\"\n\n", "text"); 46 47 TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n"); 48 TPRINTF("Expected output: \"very long \"\n"); 49 TPRINTF("Real output: \"%8.10s\"\n\n", "very long text"); 50 51 TPRINTF("Testing printf(\"%%s\", NULL):\n"); 52 TPRINTF("Expected output: \"(NULL)\"\n"); 53 TPRINTF("Real output: \"%s\"\n\n", NULL); 71 54 72 55 return NULL; -
uspace/app/tester/print/print1.def
rdb24058 r2d11a7d8 1 1 { 2 2 "print1", 3 " Printf test",3 "String printf test", 4 4 &test_print1, 5 5 true -
uspace/app/tester/print/print2.c
rdb24058 r2d11a7d8 1 1 /* 2 * Copyright (c) 200 6 Ondrej Palkovsky2 * Copyright (c) 2005 Josef Cejka 3 3 * All rights reserved. 4 4 * … … 29 29 #include <stdio.h> 30 30 #include <unistd.h> 31 #include <errno.h>32 31 #include "../tester.h" 33 32 34 char * test_hangup(bool quiet)33 char *test_print2(void) 35 34 { 36 char c; 37 int res; 38 int phoneid; 39 40 printf("Select phoneid to hangup: 2-9 (q to skip)\n"); 41 do { 42 c = getchar(); 43 if ((c == 'Q') || (c == 'q')) 44 return TEST_SKIPPED; 45 } while (c < '2' || c > '9'); 46 phoneid = c - '0'; 35 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n"); 36 TPRINTF("Expected output: [a] [ b] [c ] [ d] [e ]\n"); 37 TPRINTF("Real output: [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e'); 47 38 48 printf("Hanging up..."); 49 res = ipc_hangup(phoneid); 50 printf("done: %d\n", phoneid); 39 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n"); 40 TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n"); 41 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5); 42 43 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n"); 44 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 45 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5); 46 47 TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n"); 48 TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n"); 49 TPRINTF("Real output: [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21); 51 50 52 51 return NULL; -
uspace/app/tester/print/print4.c
rdb24058 r2d11a7d8 31 31 #include "../tester.h" 32 32 33 #define PRIx8 "x" 34 35 char *test_print4(bool quiet) 33 char *test_print4(void) 36 34 { 37 if (!quiet) { 38 printf("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 35 TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 36 37 uint8_t group; 38 for (group = 1; group < 4; group++) { 39 TPRINTF("%#x: ", group << 5); 39 40 40 uint8_t group; 41 for (group = 1; group < 4; group++) { 42 printf("%#" PRIx8 ": ", group << 5); 43 44 uint8_t index; 45 for (index = 0; index < 32; index++) 46 printf("%c", (char) ((group << 5) + index)); 47 48 printf(" "); 49 for (index = 0; index < 32; index++) 50 printf("%lc", (wchar_t) ((group << 5) + index)); 51 52 printf("\n"); 53 } 41 uint8_t index; 42 for (index = 0; index < 32; index++) 43 TPRINTF("%c", (char) ((group << 5) + index)); 54 44 55 printf("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 45 TPRINTF(" "); 46 for (index = 0; index < 32; index++) 47 TPRINTF("%lc", (wchar_t) ((group << 5) + index)); 56 48 57 for (group = 4; group < 8; group++) { 58 printf("%#" PRIx8 ": ", group << 5); 59 60 uint8_t index; 61 for (index = 0; index < 32; index++) 62 printf("%lc", (wchar_t) ((group << 5) + index)); 63 64 printf("\n"); 65 } 49 TPRINTF("\n"); 50 } 51 52 TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 53 54 for (group = 4; group < 8; group++) { 55 TPRINTF("%#x: ", group << 5); 66 56 67 printf("\nUTF-8 strings using printf(\"%%s\"):\n"); 68 printf("English: %s\n", "Quick brown fox jumps over the lazy dog"); 69 printf("Czech: %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy"); 70 printf("Greek: %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 71 printf("Hebrew: %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה"); 72 printf("Arabic: %s\n", "التوزيع الجغرافي للحمل العنقودي"); 73 printf("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 74 printf("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 57 uint8_t index; 58 for (index = 0; index < 32; index++) 59 TPRINTF("%lc", (wchar_t) ((group << 5) + index)); 75 60 76 printf("\nUTF-32 strings using printf(\"%%ls\"):\n"); 77 printf("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); 78 printf("Czech: %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy"); 79 printf("Greek: %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 80 printf("Hebrew: %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה"); 81 printf("Arabic: %ls\n", L"التوزيع الجغرافي للحمل العنقودي"); 82 printf("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 83 printf("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 84 85 printf("Test: [%d] '%lc'\n", L'\x0161', L'\x0161'); 61 TPRINTF("\n"); 86 62 } 87 88 printf("[Press a key]\n"); 89 getchar(); 63 64 TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n"); 65 TPRINTF("English: %s\n", "Quick brown fox jumps over the lazy dog"); 66 TPRINTF("Czech: %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy"); 67 TPRINTF("Greek: %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 68 TPRINTF("Hebrew: %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה"); 69 TPRINTF("Arabic: %s\n", "التوزيع الجغرافي للحمل العنقودي"); 70 TPRINTF("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 71 TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 72 73 TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n"); 74 TPRINTF("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); 75 TPRINTF("Czech: %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy"); 76 TPRINTF("Greek: %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε"); 77 TPRINTF("Hebrew: %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה"); 78 TPRINTF("Arabic: %ls\n", L"التوزيع الجغرافي للحمل العنقودي"); 79 TPRINTF("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 80 TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 90 81 91 82 return NULL; -
uspace/app/tester/stdio/stdio1.c
rdb24058 r2d11a7d8 32 32 #include "../tester.h" 33 33 34 #define BUF_SIZE 32 34 #define BUF_SIZE 32 35 35 36 static char buf[BUF_SIZE + 1]; 36 37 37 char * test_stdio1(bool quiet)38 char *test_stdio1(void) 38 39 { 39 FILE *f ;40 FILE *file; 40 41 char *file_name = "/readme"; 41 size_t n; 42 int c; 43 44 printf("Open file '%s'\n", file_name); 42 43 TPRINTF("Open file \"%s\"...", file_name); 45 44 errno = 0; 46 f = fopen(file_name, "rt"); 47 48 if (f == NULL) printf("errno = %d\n", errno); 49 50 if (f == NULL) 51 return "Failed opening file."; 52 53 n = fread(buf, 1, BUF_SIZE, f); 54 if (ferror(f)) { 55 fclose(f); 56 return "Failed reading file."; 45 file = fopen(file_name, "rt"); 46 if (file == NULL) { 47 TPRINTF("errno = %d\n", errno); 48 return "Failed opening file"; 49 } else 50 TPRINTF("OK\n"); 51 52 TPRINTF("Read file..."); 53 size_t cnt = fread(buf, 1, BUF_SIZE, file); 54 if (ferror(file)) { 55 TPRINTF("errno = %d\n", errno); 56 fclose(file); 57 return "Failed reading file"; 58 } else 59 TPRINTF("OK\n"); 60 61 buf[cnt] = '\0'; 62 TPRINTF("Read %u bytes, string \"%s\"\n", cnt, buf); 63 64 TPRINTF("Seek to beginning..."); 65 if (fseek(file, 0, SEEK_SET) != 0) { 66 TPRINTF("errno = %d\n", errno); 67 fclose(file); 68 return "Failed seeking in file"; 69 } else 70 TPRINTF("OK\n"); 71 72 TPRINTF("Read using fgetc()..."); 73 while (true) { 74 int c = fgetc(file); 75 if (c == EOF) 76 break; 77 78 TPRINTF("."); 57 79 } 58 59 printf("Read %d bytes.\n", n); 60 61 buf[n] = '\0'; 62 printf("Read string '%s'.\n", buf); 63 64 printf("Seek to beginning.\n"); 65 if (fseek(f, 0, SEEK_SET) != 0) { 66 fclose(f); 67 return "Failed seeking."; 68 } 69 70 printf("Read using fgetc().\n"); 71 while (true) { 72 c = fgetc(f); 73 if (c == EOF) break; 74 75 printf("'%c'", c); 76 } 77 78 printf("[EOF]\n"); 79 printf("Closing.\n"); 80 81 if (fclose(f) != 0) 82 return "Failed closing."; 83 80 TPRINTF("[EOF]\n"); 81 82 TPRINTF("Close..."); 83 if (fclose(file) != 0) { 84 TPRINTF("errno = %d\n", errno); 85 return "Failed closing file"; 86 } else 87 TPRINTF("OK\n"); 88 84 89 return NULL; 85 90 } -
uspace/app/tester/stdio/stdio2.c
rdb24058 r2d11a7d8 32 32 #include "../tester.h" 33 33 34 char * test_stdio2(bool quiet)34 char *test_stdio2(void) 35 35 { 36 FILE *f ;36 FILE *file; 37 37 char *file_name = "/test"; 38 int c; 39 40 printf("Open file '%s' for writing\n", file_name); 38 39 TPRINTF("Open file \"%s\" for writing...", file_name); 41 40 errno = 0; 42 f = fopen(file_name, "wt"); 43 44 if (f == NULL) 45 return "Failed opening file."; 46 47 fprintf(f, "Integer: %d, string: '%s'\n", 42, "Hello!"); 48 if (fclose(f) != 0) 49 return "Failed closing file."; 50 51 printf("Open file '%s' for reading\n", file_name); 52 53 f = fopen(file_name, "rt"); 54 if (f == NULL) 55 return "Failed opening file."; 56 57 printf("File contains:\n"); 41 file = fopen(file_name, "wt"); 42 if (file == NULL) { 43 TPRINTF("errno = %d\n", errno); 44 return "Failed opening file"; 45 } else 46 TPRINTF("OK\n"); 47 48 TPRINTF("Write to file..."); 49 fprintf(file, "integer: %u, string: \"%s\"", 42, "Hello!"); 50 TPRINTF("OK\n"); 51 52 TPRINTF("Close..."); 53 if (fclose(file) != 0) { 54 TPRINTF("errno = %d\n", errno); 55 return "Failed closing file"; 56 } else 57 TPRINTF("OK\n"); 58 59 TPRINTF("Open file \"%s\" for reading...", file_name); 60 file = fopen(file_name, "rt"); 61 if (file == NULL) { 62 TPRINTF("errno = %d\n", errno); 63 return "Failed opening file"; 64 } else 65 TPRINTF("OK\n"); 66 67 TPRINTF("File contains:\n"); 58 68 while (true) { 59 c = fgetc(f); 60 if (c == EOF) break; 61 putchar(c); 69 int c = fgetc(file); 70 if (c == EOF) 71 break; 72 TPRINTF("%c", c); 62 73 } 63 64 if (fclose(f) != 0) 65 return "Failed closing file."; 66 74 75 TPRINTF("\nClose..."); 76 if (fclose(file) != 0) { 77 TPRINTF("errno = %d\n", errno); 78 return "Failed closing file"; 79 } else 80 TPRINTF("OK\n"); 81 67 82 return NULL; 68 83 } -
uspace/app/tester/tester.c
rdb24058 r2d11a7d8 28 28 */ 29 29 30 /** @addtogroup tester User space Tester31 * @brief 30 /** @addtogroup tester User space tester 31 * @brief User space testing infrastructure. 32 32 * @{ 33 */ 33 */ 34 34 /** 35 35 * @file … … 38 38 #include <unistd.h> 39 39 #include <stdio.h> 40 #include <string.h> 40 41 #include "tester.h" 41 42 42 int myservice = 0; 43 int phones[MAX_PHONES]; 44 int connections[MAX_CONNECTIONS]; 45 ipc_callid_t callids[MAX_CONNECTIONS]; 43 bool test_quiet; 44 int test_argc; 45 char **test_argv; 46 46 47 47 test_t tests[] = { 48 48 #include "thread/thread1.def" 49 49 #include "print/print1.def" 50 #include "print/print2.def" 51 #include "print/print3.def" 50 52 #include "print/print4.def" 51 #include "fault/fault1.def"52 #include "fault/fault2.def"53 #include "ipc/register.def"54 #include "ipc/connect.def"55 #include "ipc/send_async.def"56 #include "ipc/send_sync.def"57 #include "ipc/answer.def"58 #include "ipc/hangup.def"59 #include "ipc/ping_pong.def"60 #include "devmap/devmap1.def"61 #include "loop/loop1.def"62 #include "vfs/vfs1.def"63 53 #include "console/console1.def" 64 54 #include "stdio/stdio1.def" 65 55 #include "stdio/stdio2.def" 66 {NULL, NULL, NULL} 56 #include "fault/fault1.def" 57 #include "fault/fault2.def" 58 #include "vfs/vfs1.def" 59 #include "ipc/ping_pong.def" 60 #include "ipc/register.def" 61 #include "ipc/connect.def" 62 #include "loop/loop1.def" 63 #include "mm/malloc1.def" 64 {NULL, NULL, NULL, false} 67 65 }; 68 66 69 67 static bool run_test(test_t *test) 70 68 { 71 printf("%s\t\t%s\n", test->name, test->desc);72 73 69 /* Execute the test */ 74 char * ret = test->entry(false);70 char *ret = test->entry(); 75 71 76 72 if (ret == NULL) { 77 printf(" Test passed\n\n");73 printf("\nTest passed\n"); 78 74 return true; 79 75 } 80 81 printf(" %s\n\n", ret);76 77 printf("\n%s\n", ret); 82 78 return false; 83 79 } … … 88 84 unsigned int i = 0; 89 85 unsigned int n = 0; 90 86 91 87 printf("\n*** Running all safe tests ***\n\n"); 92 88 93 89 for (test = tests; test->name != NULL; test++) { 94 90 if (test->safe) { 91 printf("%s (%s)\n", test->name, test->desc); 95 92 if (run_test(test)) 96 93 i++; … … 99 96 } 100 97 } 101 102 printf("\n Safe tests completed, %u tests run, %u passed.\n\n", i + n, i);98 99 printf("\nCompleted, %u tests run, %u passed.\n", i + n, i); 103 100 } 104 101 105 102 static void list_tests(void) 106 103 { 104 size_t len = 0; 107 105 test_t *test; 108 char c = 'a'; 106 for (test = tests; test->name != NULL; test++) { 107 if (str_length(test->name) > len) 108 len = str_length(test->name); 109 } 109 110 110 for (test = tests; test->name != NULL; test++ , c++)111 printf("% c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)"));111 for (test = tests; test->name != NULL; test++) 112 printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); 112 113 113 printf(" *\t\t\tRun all safe tests\n");114 printf("%-*s Run all safe tests\n", len, "*"); 114 115 } 115 116 116 int main(int argc, char * *argv)117 int main(int argc, char *argv[]) 117 118 { 118 printf("Number of arguments: %d\n", argc); 119 if (argv) { 120 printf("Arguments:"); 121 while (*argv) { 122 printf(" '%s'", *argv++); 119 if (argc < 2) { 120 printf("Usage:\n\n"); 121 printf("%s <test> [args ...]\n\n", argv[0]); 122 list_tests(); 123 return 0; 124 } 125 126 test_quiet = false; 127 test_argc = argc - 2; 128 test_argv = argv + 2; 129 130 if (str_cmp(argv[1], "*") == 0) { 131 run_safe_tests(); 132 return 0; 133 } 134 135 test_t *test; 136 for (test = tests; test->name != NULL; test++) { 137 if (str_cmp(argv[1], test->name) == 0) { 138 return (run_test(test) ? 0 : -1); 123 139 } 124 printf("\n");125 140 } 126 127 while (1) { 128 char c; 129 test_t *test; 130 131 list_tests(); 132 printf("> "); 133 fflush(stdout); 134 135 c = getchar(); 136 printf("%c\n", c); 137 138 if ((c >= 'a') && (c <= 'z')) { 139 for (test = tests; test->name != NULL; test++, c--) 140 if (c == 'a') 141 break; 142 143 if (test->name == NULL) 144 printf("Unknown test\n\n"); 145 else 146 run_test(test); 147 } else if (c == '*') { 148 run_safe_tests(); 149 } else if (c < 0) { 150 /* got EOF */ 151 break; 152 } else { 153 printf("Invalid test\n\n"); 154 } 155 156 } 157 158 return 0; 141 142 printf("Unknown test \"%s\"\n", argv[1]); 143 return -2; 159 144 } 160 145 -
uspace/app/tester/tester.h
rdb24058 r2d11a7d8 40 40 #include <ipc/ipc.h> 41 41 42 #define IPC_TEST_START 10000 43 #define MAX_PHONES 20 44 #define MAX_CONNECTIONS 50 45 #define TEST_SKIPPED "Test Skipped" 42 #define IPC_TEST_SERVICE 10240 43 #define IPC_TEST_METHOD 2000 46 44 47 extern int myservice; 48 extern int phones[MAX_PHONES]; 49 extern int connections[MAX_CONNECTIONS]; 50 extern ipc_callid_t callids[MAX_CONNECTIONS]; 45 extern bool test_quiet; 46 extern int test_argc; 47 extern char **test_argv; 51 48 52 typedef char * (* test_entry_t)(bool); 49 #define TPRINTF(format, ...) \ 50 { \ 51 if (!test_quiet) { \ 52 fprintf(stderr, format, ##__VA_ARGS__); \ 53 } \ 54 } 55 56 typedef char *(*test_entry_t)(void); 53 57 54 58 typedef struct { 55 char * 56 char * 59 char *name; 60 char *desc; 57 61 test_entry_t entry; 58 62 bool safe; 59 63 } test_t; 60 64 61 extern char * test_thread1(bool quiet); 62 extern char * test_print1(bool quiet); 63 extern char * test_print4(bool quiet); 64 extern char * test_fault1(bool quiet); 65 extern char * test_fault2(bool quiet); 66 extern char * test_register(bool quiet); 67 extern char * test_connect(bool quiet); 68 extern char * test_send_async(bool quiet); 69 extern char * test_send_sync(bool quiet); 70 extern char * test_answer(bool quiet); 71 extern char * test_hangup(bool quiet); 72 extern char * test_ping_pong(bool quiet); 73 extern char * test_devmap1(bool quiet); 74 extern char * test_loop1(bool quiet); 75 extern char * test_vfs1(bool quiet); 76 extern char * test_console1(bool quiet); 77 extern char * test_stdio1(bool quiet); 78 extern char * test_stdio2(bool quiet); 65 extern char *test_thread1(void); 66 extern char *test_print1(void); 67 extern char *test_print2(void); 68 extern char *test_print3(void); 69 extern char *test_print4(void); 70 extern char *test_console1(void); 71 extern char *test_stdio1(void); 72 extern char *test_stdio2(void); 73 extern char *test_fault1(void); 74 extern char *test_fault2(void); 75 extern char *test_vfs1(void); 76 extern char *test_ping_pong(void); 77 extern char *test_register(void); 78 extern char *test_connect(void); 79 extern char *test_loop1(void); 80 extern char *test_malloc1(void); 79 81 80 82 extern test_t tests[]; -
uspace/app/tester/thread/thread1.c
rdb24058 r2d11a7d8 28 28 */ 29 29 30 #define THREADS 5 30 #define THREADS 20 31 #define DELAY 10 31 32 32 33 #include <atomic.h> … … 43 44 { 44 45 thread_detach(thread_get_id()); 45 46 while (atomic_get(&finish)) { 47 if (!sh_quiet) 48 printf("%llu ", thread_get_id()); 46 47 while (atomic_get(&finish)) 49 48 usleep(100000); 50 }49 51 50 atomic_inc(&threads_finished); 52 51 } 53 52 54 char * test_thread1(bool quiet)53 char *test_thread1(void) 55 54 { 56 unsigned int i , total = 0;57 sh_quiet = quiet;55 unsigned int i; 56 unsigned int total = 0; 58 57 59 58 atomic_set(&finish, 1); 60 59 atomic_set(&threads_finished, 0); 61 62 for (i = 0; i < THREADS; i++) { 60 61 TPRINTF("Creating threads"); 62 for (i = 0; i < THREADS; i++) { 63 63 if (thread_create(threadtest, NULL, "threadtest", NULL) < 0) { 64 if (!quiet) 65 printf("Could not create thread %d\n", i); 64 TPRINTF("\nCould not create thread %u\n", i); 66 65 break; 67 66 } 67 TPRINTF("."); 68 68 total++; 69 69 } 70 70 71 if (!quiet)72 printf("Running threads for 10 seconds...\n");73 sleep(10);71 TPRINTF("\nRunning threads for %u seconds...", DELAY); 72 sleep(DELAY); 73 TPRINTF("\n"); 74 74 75 75 atomic_set(&finish, 0); 76 76 while (atomic_get(&threads_finished) < total) { 77 if (!quiet) 78 printf("Threads left: %d\n", total - atomic_get(&threads_finished)); 77 TPRINTF("Threads left: %u\n", total - atomic_get(&threads_finished)); 79 78 sleep(1); 80 79 } -
uspace/app/tester/vfs/vfs1.c
rdb24058 r2d11a7d8 35 35 #include <fcntl.h> 36 36 #include <dirent.h> 37 #include <devmap.h> 37 38 #include <sys/types.h> 38 39 #include <sys/stat.h> 39 40 #include "../tester.h" 40 41 41 char text[] = "O xein', angellein Lakedaimoniois hoti teide " 42 "keimetha tois keinon rhemasi peithomenoi."; 42 #define FS_TYPE "tmpfs" 43 #define MOUNT_POINT "/tmp" 44 #define OPTIONS "" 45 #define FLAGS 0 43 46 44 char *test_vfs1(bool quiet) 47 #define TEST_DIRECTORY MOUNT_POINT "/testdir" 48 #define TEST_FILE TEST_DIRECTORY "/testfile" 49 #define TEST_FILE2 TEST_DIRECTORY "/nextfile" 50 51 #define MAX_DEVICE_NAME 32 52 #define BUF_SIZE 16 53 54 static char text[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; 55 56 static char *read_root(void) 45 57 { 46 int rc; 47 48 rc = mount("tmpfs", "/", "nulldev0", "", 0); 49 switch (rc) { 50 case EOK: 51 if (!quiet) 52 printf("mounted tmpfs on /\n"); 53 break; 54 case EBUSY: 55 if (!quiet) 56 printf("(INFO) something is already mounted on /\n"); 57 break; 58 default: 59 if (!quiet) 60 printf("(INFO) IPC returned errno %d\n", rc); 61 return "mount() failed."; 62 } 63 64 if (mkdir("/mydir", 0) != 0) 65 return "mkdir() failed.\n"; 66 if (!quiet) 67 printf("created directory /mydir\n"); 58 TPRINTF("Opening the root directory..."); 68 59 69 int fd0 = open("/mydir/myfile", O_CREAT); 70 if (fd0 < 0) 71 return "open() failed.\n"; 72 if (!quiet) 73 printf("created file /mydir/myfile, fd=%d\n", fd0); 74 75 ssize_t cnt; 76 size_t size = sizeof(text); 77 cnt = write(fd0, text, size); 78 if (cnt < 0) 79 return "write() failed.\n"; 80 if (!quiet) 81 printf("written %d bytes, fd=%d\n", cnt, fd0); 82 if (lseek(fd0, 0, SEEK_SET) != 0) 83 return "lseek() failed.\n"; 84 if (!quiet) 85 printf("sought to position 0, fd=%d\n", fd0); 86 87 char buf[10]; 88 89 while ((cnt = read(fd0, buf, sizeof(buf)))) { 90 if (cnt < 0) 91 return "read() failed.\n"; 92 if (!quiet) 93 printf("read %d bytes: \"%.*s\", fd=%d\n", cnt, cnt, 94 buf, fd0); 95 } 96 97 close(fd0); 98 99 DIR *dirp; 60 DIR *dirp = opendir("/"); 61 if (!dirp) { 62 TPRINTF("\n"); 63 return "opendir() failed"; 64 } else 65 TPRINTF("OK\n"); 66 100 67 struct dirent *dp; 101 102 if (!quiet)103 printf("scanning the root directory...\n");104 105 dirp = opendir("/");106 if (!dirp)107 return "opendir() failed\n";108 68 while ((dp = readdir(dirp))) 109 printf("discovered node %s in /\n", dp->d_name);69 TPRINTF(" node \"%s\"\n", dp->d_name); 110 70 closedir(dirp); 111 112 if (rename("/mydir/myfile", "/mydir/yourfile"))113 return "rename() failed.\n";114 115 if (!quiet)116 printf("renamed /mydir/myfile to /mydir/yourfile\n");117 118 if (unlink("/mydir/yourfile"))119 return "unlink() failed.\n";120 71 121 if (!quiet)122 printf("unlinked file /mydir/yourfile\n");123 124 if (rmdir("/mydir"))125 return "rmdir() failed.\n";126 127 if (!quiet)128 printf("removed directory /mydir\n");129 130 if (!quiet)131 printf("scanning the root directory...\n");132 133 dirp = opendir("/");134 if (!dirp)135 return "opendir() failed\n";136 while ((dp = readdir(dirp)))137 printf("discovered node %s in /\n", dp->d_name);138 closedir(dirp);139 140 72 return NULL; 141 73 } 142 74 75 char *test_vfs1(void) 76 { 77 if (mkdir(MOUNT_POINT, 0) != 0) 78 return "mkdir() failed"; 79 TPRINTF("Created directory %s\n", MOUNT_POINT); 80 81 char null[MAX_DEVICE_NAME]; 82 int null_id = devmap_null_create(); 83 84 if (null_id == -1) 85 return "Unable to create null device"; 86 87 snprintf(null, MAX_DEVICE_NAME, "null%d", null_id); 88 int rc = mount(FS_TYPE, MOUNT_POINT, null, OPTIONS, FLAGS); 89 switch (rc) { 90 case EOK: 91 TPRINTF("Mounted /dev/%s as %s on %s\n", null, FS_TYPE, MOUNT_POINT); 92 break; 93 case EBUSY: 94 TPRINTF("(INFO) Filesystem already mounted on %s\n", MOUNT_POINT); 95 break; 96 default: 97 TPRINTF("(ERR) IPC returned errno %d (is tmpfs loaded?)\n", rc); 98 return "mount() failed"; 99 } 100 101 if (mkdir(TEST_DIRECTORY, 0) != 0) 102 return "mkdir() failed"; 103 TPRINTF("Created directory %s\n", TEST_DIRECTORY); 104 105 int fd0 = open(TEST_FILE, O_CREAT); 106 if (fd0 < 0) 107 return "open() failed"; 108 TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0); 109 110 size_t size = sizeof(text); 111 ssize_t cnt = write(fd0, text, size); 112 if (cnt < 0) 113 return "write() failed"; 114 TPRINTF("Written %d bytes\n", cnt); 115 116 if (lseek(fd0, 0, SEEK_SET) != 0) 117 return "lseek() failed"; 118 TPRINTF("Sought to position 0\n"); 119 120 char buf[BUF_SIZE]; 121 while ((cnt = read(fd0, buf, BUF_SIZE))) { 122 if (cnt < 0) 123 return "read() failed"; 124 125 TPRINTF("Read %d bytes: \".*s\"\n", cnt, cnt, buf); 126 } 127 128 close(fd0); 129 130 char *rv = read_root(); 131 if (rv != NULL) 132 return rv; 133 134 if (rename(TEST_FILE, TEST_FILE2)) 135 return "rename() failed"; 136 TPRINTF("Renamed %s to %s\n", TEST_FILE, TEST_FILE2); 137 138 if (unlink(TEST_FILE2)) 139 return "unlink() failed"; 140 TPRINTF("Unlinked %s\n", TEST_FILE2); 141 142 if (rmdir(TEST_DIRECTORY)) 143 return "rmdir() failed"; 144 TPRINTF("Removed directory %s\n", TEST_DIRECTORY); 145 146 rv = read_root(); 147 if (rv != NULL) 148 return rv; 149 150 return NULL; 151 }
Note:
See TracChangeset
for help on using the changeset viewer.