Changeset 8e16454 in mainline
- Timestamp:
- 2017-12-27T16:46:27Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4b83cc
- Parents:
- 59958992
- git-author:
- Petr Manek <petr.manek@…> (2017-12-27 16:43:34)
- git-committer:
- Petr Manek <petr.manek@…> (2017-12-27 16:46:27)
- Location:
- uspace/app/tmon
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tmon/burst_tests.c
r59958992 r8e16454 47 47 #define INDENT " " 48 48 49 /** Generic burst test parameters. */ 49 50 typedef struct tmon_burst_test_params { 50 tmon_test_params_t base; /* inheritance */ 51 /** Inherited base. */ 52 tmon_test_params_t base; 53 /** The count of reads/writes to perform. */ 51 54 uint32_t cycles; 55 /** Size of single read/write. */ 52 56 size_t size; 53 57 } tmon_burst_test_params_t; 54 58 59 /** Static array of long options, from which test parameters are parsed. */ 55 60 static struct option long_options[] = { 56 61 {"cycles", required_argument, NULL, 'n'}, … … 59 64 }; 60 65 66 /** String of short options, from which test parameters are parsed. */ 61 67 static const char *short_options = "n:s:"; 62 68 69 /** Common option parser for all burst tests. 70 * @param[in] argc Number of arguments. 71 * @param[in] argv Argument values. Must point to exactly `argc` strings. 72 * @param[out] params Parsed test parameters (if successful). 73 * 74 * @return EOK if successful (in such case caller becomes the owner of `params`). 75 */ 63 76 static int read_params(int argc, char *argv[], tmon_test_params_t **params) 64 77 { … … 105 118 } 106 119 120 /** Unit of quantity used for pretty formatting. */ 107 121 typedef struct tmon_unit { 122 /** Prefix letter, which is printed before the actual unit. */ 108 123 char prefix; 124 /** Factor of the unit. */ 109 125 uint64_t factor; 110 126 } tmon_unit_t; 111 127 128 /** Static array of units with decreasing factors. */ 112 129 static const tmon_unit_t units[] = { 113 130 { .prefix = 'E', .factor = 1ul << 60 }, … … 119 136 }; 120 137 138 /** Format size in bytes for human reading. 139 * @param[in] size The size to format. 140 * @param[in] fmt Format string. Must include one double and char. 141 * 142 * @return Heap-allocated string if successful (caller becomes its owner), NULL otherwise. 143 */ 121 144 static char * format_size(double size, const char *fmt) 122 145 { 146 // Figure out the "tightest" unit. 123 147 unsigned i; 124 148 for (i = 0; i < ARRAY_SIZE(units); ++i) { … … 135 159 } 136 160 161 // Format the size. 137 162 const double div_size = size / factor; 138 163 char *out = NULL; … … 142 167 } 143 168 169 /** Print burst test parameters. 170 * @param[in] params Test parameters to print. 171 */ 144 172 static void print_params(const tmon_burst_test_params_t *params) 145 173 { … … 151 179 } 152 180 181 /** Print burst test results. 182 * @param[in] params Test parameters. 183 * @param[in] duration Duration of the burst test. 184 */ 153 185 static void print_results(const tmon_burst_test_params_t *params, usbdiag_dur_t duration) 154 186 { … … 169 201 } 170 202 203 /** Run "interrupt in" burst test. 204 * @param[in] exch Open async exchange with the diagnostic device. 205 * @param[in] generic_params Test parameters. Must point to 'tmon_burst_test_params_t'. 206 * 207 * @return Exit code 208 */ 171 209 static int run_intr_in(async_exch_t *exch, const tmon_test_params_t *generic_params) 172 210 { … … 187 225 } 188 226 227 /** Run "interrupt out" burst test. 228 * @param[in] exch Open async exchange with the diagnostic device. 229 * @param[in] generic_params Test parameters. Must point to 'tmon_burst_test_params_t'. 230 * 231 * @return Exit code 232 */ 189 233 static int run_intr_out(async_exch_t *exch, const tmon_test_params_t *generic_params) 190 234 { … … 205 249 } 206 250 251 /** Run "bulk in" burst test. 252 * @param[in] exch Open async exchange with the diagnostic device. 253 * @param[in] generic_params Test parameters. Must point to 'tmon_burst_test_params_t'. 254 * 255 * @return Exit code 256 */ 207 257 static int run_bulk_in(async_exch_t *exch, const tmon_test_params_t *generic_params) 208 258 { … … 223 273 } 224 274 275 /** Run "bulk out" burst test. 276 * @param[in] exch Open async exchange with the diagnostic device. 277 * @param[in] generic_params Test parameters. Must point to 'tmon_burst_test_params_t'. 278 * 279 * @return Exit code 280 */ 225 281 static int run_bulk_out(async_exch_t *exch, const tmon_test_params_t *generic_params) 226 282 { … … 241 297 } 242 298 299 /** Run "isochronous in" burst test. 300 * @param[in] exch Open async exchange with the diagnostic device. 301 * @param[in] generic_params Test parameters. Must point to 'tmon_burst_test_params_t'. 302 * 303 * @return Exit code 304 */ 243 305 static int run_isoch_in(async_exch_t *exch, const tmon_test_params_t *generic_params) 244 306 { … … 259 321 } 260 322 323 /** Run "isochronous out" burst test. 324 * @param[in] exch Open async exchange with the diagnostic device. 325 * @param[in] generic_params Test parameters. Must point to 'tmon_burst_test_params_t'. 326 * 327 * @return Exit code 328 */ 261 329 static int run_isoch_out(async_exch_t *exch, const tmon_test_params_t *generic_params) 262 330 { … … 277 345 } 278 346 347 /** Interrupt in burst test command handler. 348 * @param[in] argc Number of arguments. 349 * @param[in] argv Argument values. Must point to exactly `argc` strings. 350 * 351 * @return Exit code 352 */ 279 353 int tmon_burst_intr_in(int argc, char *argv[]) 280 354 { … … 287 361 } 288 362 363 /** Interrupt out burst test command handler. 364 * @param[in] argc Number of arguments. 365 * @param[in] argv Argument values. Must point to exactly `argc` strings. 366 * 367 * @return Exit code 368 */ 289 369 int tmon_burst_intr_out(int argc, char *argv[]) 290 370 { … … 297 377 } 298 378 379 /** Interrupt bulk burst test command handler. 380 * @param[in] argc Number of arguments. 381 * @param[in] argv Argument values. Must point to exactly `argc` strings. 382 * 383 * @return Exit code 384 */ 299 385 int tmon_burst_bulk_in(int argc, char *argv[]) 300 386 { … … 307 393 } 308 394 395 /** Bulk out burst test command handler. 396 * @param[in] argc Number of arguments. 397 * @param[in] argv Argument values. Must point to exactly `argc` strings. 398 * 399 * @return Exit code 400 */ 309 401 int tmon_burst_bulk_out(int argc, char *argv[]) 310 402 { … … 317 409 } 318 410 411 /** Isochronous in burst test command handler. 412 * @param[in] argc Number of arguments. 413 * @param[in] argv Argument values. Must point to exactly `argc` strings. 414 * 415 * @return Exit code 416 */ 319 417 int tmon_burst_isoch_in(int argc, char *argv[]) 320 418 { … … 327 425 } 328 426 427 /** Isochronous out burst test command handler. 428 * @param[in] argc Number of arguments. 429 * @param[in] argv Argument values. Must point to exactly `argc` strings. 430 * 431 * @return Exit code 432 */ 329 433 int tmon_burst_isoch_out(int argc, char *argv[]) 330 434 { -
uspace/app/tmon/commands.h
r59958992 r8e16454 37 37 #define TMON_COMMANDS_H_ 38 38 39 /* All commands are just versions of int main(int, char **). */ 40 41 /* List command just prints compatible devices. */ 39 42 int tmon_list(int, char **); 40 43 -
uspace/app/tmon/list.c
r59958992 r8e16454 44 44 #define MAX_PATH_LENGTH 1024 45 45 46 /** Print a single item of the device list. 47 * @param[in] svc Service ID of the devman function. 48 */ 46 49 static void print_list_item(service_id_t svc) 47 50 { … … 63 66 } 64 67 68 /** List command handler. 69 * @param[in] argc Number of arguments. 70 * @param[in] argv Argument values. Must point to exactly `argc` strings. 71 * 72 * @return Exit code 73 */ 65 74 int tmon_list(int argc, char *argv[]) 66 75 { -
uspace/app/tmon/main.c
r59958992 r8e16454 42 42 #define INDENT " " 43 43 44 /** Command which is executed by tmon. */ 44 45 typedef struct tmon_cmd { 46 /** Unique name, by which the command is executed. */ 45 47 const char *name; 48 /** Description of the command, which is displayed in the usage string. */ 46 49 const char *description; 50 /** Function, which executes the command. Same as int main(int, char**). */ 47 51 int (*action)(int, char **); 48 52 } tmon_cmd_t; 49 53 54 /** Static array of commands supported by tmon. */ 50 55 static tmon_cmd_t commands[] = { 51 56 { … … 86 91 }; 87 92 93 /** Option shown in the usage string. */ 88 94 typedef struct tmon_opt { 95 /** Long name of the option without "--" prefix. */ 89 96 const char *long_name; 97 /** Short name of the option without "-" prefix. */ 90 98 char short_name; 99 /** Description of the option displayed in the usage string. */ 91 100 const char *description; 92 101 } tmon_opt_t; 93 102 103 /** Static array of options displayed in the tmon usage string. */ 94 104 static tmon_opt_t options[] = { 95 105 { … … 105 115 }; 106 116 117 /** Print usage string. 118 * @param[in] app_name Name to print in the invocation example. 119 */ 107 120 static void print_usage(char *app_name) 108 121 { … … 122 135 } 123 136 137 /** Main tmon entry point. 138 * @param[in] argc Number of arguments. 139 * @param[in] argv Argument values. Must point to exactly `argc` strings. 140 * 141 * @return Exit code 142 */ 124 143 int main(int argc, char *argv[]) 125 144 { -
uspace/app/tmon/resolve.c
r59958992 r8e16454 44 44 #define NAME "tmon" 45 45 46 /** Resolve a single function by its class (fail if there is more/less than 1). 47 * @param[out] fun Resolved function handle (if found). 48 * 49 * @return EOK if the function was resolved successfully. 50 */ 46 51 int tmon_resolve_default(devman_handle_t *fun) 47 52 { … … 79 84 } 80 85 86 /** Resolve a function by its name or device path. 87 * @param[in] dev_path Name or device path (see `devman_fun_get_handle` for possible values). 88 * @param[out] fun Resolved function handle (if found). 89 * 90 * @return EOK if the function was resolved successfully. 91 */ 81 92 int tmon_resolve_named(const char *dev_path, devman_handle_t *fun) 82 93 { -
uspace/app/tmon/tf.c
r59958992 r8e16454 45 45 #define MAX_PATH_LENGTH 1024 46 46 47 int tmon_test_main(int argc, char *argv[], const tmon_test_ops_t *ops) { 47 /** Common command handler for all test commands. 48 * @param[in] argc Number of arguments. 49 * @param[in] argv Argument values. Must point to exactly `argc` strings. 50 * 51 * @return Exit code 52 */ 53 int tmon_test_main(int argc, char *argv[], const tmon_test_ops_t *ops) 54 { 55 // Resolve device function. 48 56 devman_handle_t fun = -1; 49 57 … … 67 75 printf("Using device: %s\n", path); 68 76 77 // Read test parameters from options. 69 78 tmon_test_params_t *params = NULL; 70 79 if ((rc = ops->read_params(argc, argv, ¶ms))) { … … 73 82 } 74 83 84 // Run the test body. 75 85 async_sess_t *sess = usbdiag_connect(fun); 76 86 if (!sess) { -
uspace/app/tmon/tf.h
r59958992 r8e16454 41 41 /** Parameters common for all tests. */ 42 42 typedef struct tmon_test_params { 43 /* Nothing here. */ 43 44 } tmon_test_params_t; 44 45
Note:
See TracChangeset
for help on using the changeset viewer.