Changeset 8e16454 in mainline for uspace/app/tmon/burst_tests.c
- Timestamp:
- 2017-12-27T16:46:27Z (6 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)
- File:
-
- 1 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 {
Note:
See TracChangeset
for help on using the changeset viewer.