Changeset 79ae36dd in mainline for uspace/app/tester
- Timestamp:
- 2011-06-08T19:01:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/app/tester
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/console/console1.c
r764d71e r79ae36dd 50 50 { 51 51 if (!test_quiet) { 52 console_ctrl_t *console = console_init(stdin, stdout); 53 52 54 printf("Style test: "); 53 fflush(stdout);54 console_set_style( fphone(stdout), STYLE_NORMAL);55 console_flush(console); 56 console_set_style(console, STYLE_NORMAL); 55 57 printf(" normal "); 56 fflush(stdout);57 console_set_style( fphone(stdout), STYLE_EMPHASIS);58 console_flush(console); 59 console_set_style(console, STYLE_EMPHASIS); 58 60 printf(" emphasized "); 59 fflush(stdout);60 console_set_style( fphone(stdout), STYLE_INVERTED);61 console_flush(console); 62 console_set_style(console, STYLE_INVERTED); 61 63 printf(" inverted "); 62 fflush(stdout);63 console_set_style( fphone(stdout), STYLE_SELECTED);64 console_flush(console); 65 console_set_style(console, STYLE_SELECTED); 64 66 printf(" selected "); 65 fflush(stdout);66 console_set_style( fphone(stdout), STYLE_NORMAL);67 console_flush(console); 68 console_set_style(console, STYLE_NORMAL); 67 69 printf("\n"); 68 70 … … 73 75 for (j = 0; j < 2; j++) { 74 76 for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { 75 fflush(stdout);76 console_set_color( fphone(stdout), i, COLOR_WHITE,77 console_flush(console); 78 console_set_color(console, i, COLOR_WHITE, 77 79 j ? CATTR_BRIGHT : 0); 78 80 printf(" %s ", color_name[i]); 79 81 } 80 fflush(stdout);81 console_set_style( fphone(stdout), STYLE_NORMAL);82 console_flush(console); 83 console_set_style(console, STYLE_NORMAL); 82 84 putchar('\n'); 83 85 } … … 86 88 for (j = 0; j < 2; j++) { 87 89 for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { 88 fflush(stdout);89 console_set_color( fphone(stdout), COLOR_WHITE, i,90 console_flush(console); 91 console_set_color(console, COLOR_WHITE, i, 90 92 j ? CATTR_BRIGHT : 0); 91 93 printf(" %s ", color_name[i]); 92 94 } 93 fflush(stdout);94 console_set_style( fphone(stdout), STYLE_NORMAL);95 console_flush(console); 96 console_set_style(console, STYLE_NORMAL); 95 97 putchar('\n'); 96 98 } … … 99 101 100 102 for (i = 0; i < 255; i += 16) { 101 fflush(stdout);102 console_set_rgb_color( fphone(stdout), (255 - i) << 16, i << 16);103 console_flush(console); 104 console_set_rgb_color(console, (255 - i) << 16, i << 16); 103 105 putchar('X'); 104 106 } 105 fflush(stdout);106 console_set_color( fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);107 console_flush(console); 108 console_set_color(console, COLOR_BLACK, COLOR_WHITE, 0); 107 109 putchar('\n'); 108 110 109 111 for (i = 0; i < 255; i += 16) { 110 fflush(stdout);111 console_set_rgb_color( fphone(stdout), (255 - i) << 8, i << 8);112 console_flush(console); 113 console_set_rgb_color(console, (255 - i) << 8, i << 8); 112 114 putchar('X'); 113 115 } 114 fflush(stdout);115 console_set_color( fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);116 console_flush(console); 117 console_set_color(console, COLOR_BLACK, COLOR_WHITE, 0); 116 118 putchar('\n'); 117 119 118 120 for (i = 0; i < 255; i += 16) { 119 fflush(stdout);120 console_set_rgb_color( fphone(stdout), 255 - i, i);121 console_flush(console); 122 console_set_rgb_color(console, 255 - i, i); 121 123 putchar('X'); 122 124 } 123 fflush(stdout);124 console_set_style( fphone(stdout), STYLE_NORMAL);125 console_flush(console); 126 console_set_style(console, STYLE_NORMAL); 125 127 putchar('\n'); 126 128 } -
uspace/app/tester/devs/devman2.c
r764d71e r79ae36dd 42 42 #include <devman.h> 43 43 #include <str.h> 44 #include <async.h> 44 45 #include <vfs/vfs.h> 46 #include <vfs/vfs_sess.h> 45 47 #include <sys/stat.h> 46 48 #include <fcntl.h> … … 68 70 continue; 69 71 } 70 int phone = fd_phone(fd);72 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 71 73 close(fd); 72 if ( phone < 0) {73 TPRINTF("Failed opening phone: %s.\n", str_error( phone));74 rc = phone;74 if (sess == NULL) { 75 TPRINTF("Failed opening phone: %s.\n", str_error(errno)); 76 rc = errno; 75 77 err_msg = "Failed opening file descriptor phone"; 76 78 continue; 77 79 } 78 async_hangup( phone);80 async_hangup(sess); 79 81 TPRINTF("Path `%s' okay.\n", path); 80 82 free(path); … … 83 85 } 84 86 85 if (path != NULL) {87 if (path != NULL) 86 88 free(path); 87 } 88 89 89 90 return err_msg; 90 91 } -
uspace/app/tester/hw/misc/virtchar1.c
r764d71e r79ae36dd 43 43 #include <str.h> 44 44 #include <vfs/vfs.h> 45 #include <vfs/vfs_sess.h> 45 46 #include <sys/stat.h> 46 47 #include <fcntl.h> … … 66 67 TPRINTF(" ...file handle %d\n", fd); 67 68 68 TPRINTF(" Asking for phone...\n");69 int phone = fd_phone(fd);70 if ( phone < 0) {69 TPRINTF(" Asking for session...\n"); 70 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 71 if (!sess) { 71 72 close(fd); 72 TPRINTF(" ...error: %s\n", str_error( phone));73 return "Failed to get phoneto device";73 TPRINTF(" ...error: %s\n", str_error(errno)); 74 return "Failed to get session to device"; 74 75 } 75 TPRINTF(" ... phone is %d\n", phone);76 TPRINTF(" ...session is %p\n", sess); 76 77 77 78 TPRINTF(" Will try to read...\n"); 78 79 size_t i; 79 80 char buffer[BUFFER_SIZE]; 80 char_dev_read( phone, buffer, BUFFER_SIZE);81 char_dev_read(sess, buffer, BUFFER_SIZE); 81 82 TPRINTF(" ...verifying that we read zeroes only...\n"); 82 83 for (i = 0; i < BUFFER_SIZE; i++) { … … 88 89 89 90 /* Clean-up. */ 90 TPRINTF(" Closing phones and file descriptors\n");91 async_hangup( phone);91 TPRINTF(" Closing session and file descriptor\n"); 92 async_hangup(sess); 92 93 close(fd); 93 94 -
uspace/app/tester/hw/serial/serial1.c
r764d71e r79ae36dd 71 71 } 72 72 73 int res = devman_get_phone(DEVMAN_CLIENT, IPC_FLAG_BLOCKING);74 75 73 devman_handle_t handle; 76 res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,74 int res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle, 77 75 IPC_FLAG_BLOCKING); 78 76 if (res != EOK) 79 77 return "Could not get serial device handle"; 80 78 81 int phone = devman_device_connect(handle, IPC_FLAG_BLOCKING);82 if (phone < 0) {83 devman_hangup_phone(DEVMAN_CLIENT);79 async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle, 80 IPC_FLAG_BLOCKING); 81 if (!sess) 84 82 return "Unable to connect to serial device"; 85 }86 83 87 84 char *buf = (char *) malloc(cnt + 1); 88 85 if (buf == NULL) { 89 async_hangup(phone); 90 devman_hangup_phone(DEVMAN_CLIENT); 86 async_hangup(sess); 91 87 return "Failed to allocate input buffer"; 92 88 } … … 97 93 sysarg_t old_word_size; 98 94 99 res = async_req_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud, 95 async_exch_t *exch = async_exchange_begin(sess); 96 res = async_req_0_4(exch, SERIAL_GET_COM_PROPS, &old_baud, 100 97 &old_par, &old_word_size, &old_stop); 98 async_exchange_end(exch); 99 101 100 if (res != EOK) { 102 101 free(buf); 103 async_hangup(phone); 104 devman_hangup_phone(DEVMAN_CLIENT); 102 async_hangup(sess); 105 103 return "Failed to get old serial communication parameters"; 106 104 } 107 105 108 res = async_req_4_0(phone, SERIAL_SET_COM_PROPS, 1200, 106 exch = async_exchange_begin(sess); 107 res = async_req_4_0(exch, SERIAL_SET_COM_PROPS, 1200, 109 108 SERIAL_NO_PARITY, 8, 1); 109 async_exchange_end(exch); 110 110 111 if (EOK != res) { 111 112 free(buf); 112 async_hangup(phone); 113 devman_hangup_phone(DEVMAN_CLIENT); 113 async_hangup(sess); 114 114 return "Failed to set serial communication parameters"; 115 115 } … … 120 120 size_t total = 0; 121 121 while (total < cnt) { 122 ssize_t read = char_dev_read( phone, buf, cnt - total);122 ssize_t read = char_dev_read(sess, buf, cnt - total); 123 123 124 124 if (read < 0) { 125 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 125 exch = async_exchange_begin(sess); 126 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 126 127 old_par, old_word_size, old_stop); 128 async_exchange_end(exch); 129 127 130 free(buf); 128 async_hangup(phone); 129 devman_hangup_phone(DEVMAN_CLIENT); 131 async_hangup(sess); 130 132 return "Failed read from serial device"; 131 133 } 132 134 133 135 if ((size_t) read > cnt - total) { 134 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 136 exch = async_exchange_begin(sess); 137 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 135 138 old_par, old_word_size, old_stop); 139 async_exchange_end(exch); 140 136 141 free(buf); 137 async_hangup(phone); 138 devman_hangup_phone(DEVMAN_CLIENT); 142 async_hangup(sess); 139 143 return "Read more data than expected"; 140 144 } … … 151 155 * direction of data transfer. 152 156 */ 153 ssize_t written = char_dev_write( phone, buf, read);157 ssize_t written = char_dev_write(sess, buf, read); 154 158 155 159 if (written < 0) { 156 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 160 exch = async_exchange_begin(sess); 161 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 157 162 old_par, old_word_size, old_stop); 163 async_exchange_end(exch); 164 158 165 free(buf); 159 async_hangup(phone); 160 devman_hangup_phone(DEVMAN_CLIENT); 166 async_hangup(sess); 161 167 return "Failed write to serial device"; 162 168 } 163 169 164 170 if (written != read) { 165 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 171 exch = async_exchange_begin(sess); 172 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 166 173 old_par, old_word_size, old_stop); 174 async_exchange_end(exch); 175 167 176 free(buf); 168 async_hangup(phone); 169 devman_hangup_phone(DEVMAN_CLIENT); 177 async_hangup(sess); 170 178 return "Written less data than read from serial device"; 171 179 } … … 180 188 181 189 size_t eot_size = str_size(EOT); 182 ssize_t written = char_dev_write(phone, (void *) EOT, eot_size); 183 184 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 190 ssize_t written = char_dev_write(sess, (void *) EOT, eot_size); 191 192 exch = async_exchange_begin(sess); 193 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 185 194 old_par, old_word_size, old_stop); 195 async_exchange_end(exch); 196 186 197 free(buf); 187 async_hangup(phone); 188 devman_hangup_phone(DEVMAN_CLIENT); 198 async_hangup(sess); 189 199 190 200 if (written < 0) -
uspace/app/tester/ipc/ping_pong.c
r764d71e r79ae36dd 30 30 #include <stdlib.h> 31 31 #include <sys/time.h> 32 #include < ipc/ns.h>32 #include <ns.h> 33 33 #include <async.h> 34 34 #include <errno.h> … … 61 61 size_t i; 62 62 for (i = 0; i < COUNT_GRANULARITY; i++) { 63 int retval = async_req_0_0(PHONE_NS, NS_PING);63 int retval = ns_ping(); 64 64 65 65 if (retval != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.