Changeset 119a794 in mainline for uspace/app/tmon/stress_test.c
- Timestamp:
- 2017-12-22T11:17:25Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab8e0f5
- Parents:
- ff16da5f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.