Changeset 119a794 in mainline
- Timestamp:
- 2017-12-22T11:17:25Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab8e0f5
- Parents:
- ff16da5f
- Location:
- uspace/app/tmon
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tmon/main.c
rff16da5f r119a794 91 91 printf(NAME ": benchmark USB diagnostic device\n\n"); 92 92 93 printf("Usage: %s command [ options] [device]\n", app_name);93 printf("Usage: %s command [device] [options]\n", app_name); 94 94 printf("Available commands:\n"); 95 95 for (int i = 0; commands[i].name; ++i) { … … 118 118 } 119 119 120 return cmd->action(argc - 2, argv + 2);120 return cmd->action(argc - 1, argv + 1); 121 121 } 122 122 -
uspace/app/tmon/stress_test.c
rff16da5f r119a794 38 38 #include <errno.h> 39 39 #include <str_error.h> 40 #include <getopt.h> 40 41 #include <usbdiag_iface.h> 41 42 #include "commands.h" … … 46 47 typedef struct tmon_stress_test_params { 47 48 tmon_test_params_t base; /* inheritance */ 48 int cycles;49 uint32_t cycles; 49 50 size_t size; 50 51 } tmon_stress_test_params_t; 51 52 53 static struct option long_options[] = { 54 {"cycles", required_argument, NULL, 'n'}, 55 {"size", required_argument, NULL, 's'}, 56 {0, 0, NULL, 0} 57 }; 58 59 static const char *short_options = "n:s:"; 60 52 61 static int read_params(int argc, char *argv[], tmon_test_params_t **params) 53 62 { 63 int rc; 54 64 tmon_stress_test_params_t *p = (tmon_stress_test_params_t *) malloc(sizeof(tmon_stress_test_params_t)); 55 65 if (!p) … … 57 67 58 68 // Default values. 59 p->cycles = 1024; 60 p->size = 65024; 61 62 // TODO: Parse argc, argv here. 69 p->cycles = 256; 70 p->size = 1024; 71 72 // Parse other than default values. 73 int c; 74 for (c = 0, optreset = 1, optind = 0; c != -1;) { 75 c = getopt_long(argc, argv, short_options, long_options, NULL); 76 switch (c) { 77 case -1: 78 break; 79 case 'n': 80 if (!optarg || str_uint32_t(optarg, NULL, 10, false, &p->cycles) != EOK) { 81 puts(NAME ": Invalid number of cycles.\n"); 82 rc = EINVAL; 83 goto err_malloc; 84 } 85 break; 86 case 's': 87 if (!optarg || str_size_t(optarg, NULL, 10, false, &p->size) != EOK) { 88 puts(NAME ": Invalid data size.\n"); 89 rc = EINVAL; 90 goto err_malloc; 91 } 92 break; 93 } 94 } 63 95 64 96 *params = (tmon_test_params_t *) p; 65 97 return EOK; 98 99 err_malloc: 100 free(p); 101 *params = NULL; 102 return rc; 66 103 } 67 104 … … 70 107 const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params; 71 108 printf("Executing interrupt in stress test.\n" 72 " Packet count: %d\n"73 " Packet size: %ld\n", params->cycles, params->size);109 " Number of cycles: %d\n" 110 " Data size: %ld B\n", params->cycles, params->size); 74 111 75 112 int rc = usbdiag_stress_intr_in(exch, params->cycles, params->size); … … 86 123 const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params; 87 124 printf("Executing interrupt out stress test.\n" 88 " Packet count: %d\n"89 " Packet size: %ld\n", params->cycles, params->size);125 " Number of cycles: %d\n" 126 " Data size: %ld B\n", params->cycles, params->size); 90 127 91 128 int rc = usbdiag_stress_intr_out(exch, params->cycles, params->size); … … 102 139 const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params; 103 140 printf("Executing bulk in stress test.\n" 104 " Packet count: %d\n"105 " Packet size: %ld\n", params->cycles, params->size);141 " Number of cycles: %d\n" 142 " Data size: %ld B\n", params->cycles, params->size); 106 143 107 144 int rc = usbdiag_stress_bulk_in(exch, params->cycles, params->size); … … 118 155 const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params; 119 156 printf("Executing bulk out stress test.\n" 120 " Packet count: %d\n"121 " Packet size: %ld\n", params->cycles, params->size);157 " Number of cycles: %d\n" 158 " Data size: %ld B\n", params->cycles, params->size); 122 159 123 160 int rc = usbdiag_stress_bulk_out(exch, params->cycles, params->size); … … 134 171 const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params; 135 172 printf("Executing isochronous in stress test.\n" 136 " Packet count: %d\n"137 " Packet size: %ld\n", params->cycles, params->size);173 " Number of cycles: %d\n" 174 " Data size: %ld B\n", params->cycles, params->size); 138 175 139 176 int rc = usbdiag_stress_isoch_in(exch, params->cycles, params->size); … … 150 187 const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params; 151 188 printf("Executing isochronous out stress test.\n" 152 " Packet count: %d\n"153 " Packet size: %ld\n", params->cycles, params->size);189 " Number of cycles: %d\n" 190 " Data size: %ld B\n", params->cycles, params->size); 154 191 155 192 int rc = usbdiag_stress_isoch_out(exch, params->cycles, params->size); -
uspace/app/tmon/test.c
rff16da5f r119a794 48 48 devman_handle_t fun = -1; 49 49 50 if (argc == 0) { 50 if (argc >= 2 && *argv[1] != '-') { 51 // Assume that the first argument is device path. 52 if (tmon_resolve_named(argv[1], &fun)) 53 return 1; 54 } else { 55 // The first argument is either an option or not present. 51 56 if (tmon_resolve_default(&fun)) 52 57 return 1; 53 } else if (argc == 1) {54 if (tmon_resolve_named(argv[0], &fun))55 return 1;56 } else {57 printf(NAME ": Too many arguments provided.\n");58 return 1;59 58 } 60 59
Note:
See TracChangeset
for help on using the changeset viewer.