Changeset dd36558 in mainline


Ignore:
Timestamp:
2017-12-21T10:26:47Z (7 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5302493
Parents:
d0d8e59
git-author:
Petr Mánek <petr.manek@…> (2017-12-21 10:26:43)
git-committer:
Petr Mánek <petr.manek@…> (2017-12-21 10:26:47)
Message:

tmon: refactoring

Tests now live as descendants of a common interface, which allows them to read generic parameters and be executed on diagnostic devices. All tests have a common main function, which calls this interface, and poses as a command to the main function of the tmon utility. Stress tests have therefore been moved to a separate file.

Location:
uspace/app/tmon
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tmon/Makefile

    rd0d8e59 rdd36558  
    3636        list.c\
    3737        test.c\
     38        stress_test.c\
    3839        resolve.c
    3940
  • uspace/app/tmon/test.c

    rd0d8e59 rdd36558  
    3232/**
    3333 * @file
    34  * USB transfer debugging.
     34 * Testing framework.
    3535 */
    3636
     
    3939#include <str_error.h>
    4040#include <usbdiag_iface.h>
    41 #include "commands.h"
    4241#include "resolve.h"
     42#include "test.h"
    4343
    4444#define NAME "tmon"
    4545#define MAX_PATH_LENGTH 1024
    4646
    47 #define DEFAULT_CYCLES  1024
    48 #define DEFAULT_SIZE    65432
    49 
    50 static int resolve_and_test(int argc, char *argv[], int (*test)(async_exch_t *, int, size_t)) {
     47int tmon_test_main(int argc, char *argv[], const tmon_test_ops_t *ops) {
    5148        devman_handle_t fun = -1;
    5249
     
    7168        printf("Using device: %s\n", path);
    7269
    73         // TODO: Read options here.
     70        tmon_test_params_t *params = NULL;
     71        if ((rc = ops->read_params(argc, argv, &params))) {
     72                printf(NAME ": Reading test parameters failed.\n");
     73                return 1;
     74        }
    7475
    7576        async_sess_t *sess = usbdiag_connect(fun);
     
    8687        }
    8788
    88         ec = test(exch, DEFAULT_CYCLES, DEFAULT_SIZE);
     89        ec = ops->run(exch, params);
    8990        async_exchange_end(exch);
    9091
    9192err_sess:
    9293        usbdiag_disconnect(sess);
     94        free(params);
    9395        return ec;
    94 }
    95 
    96 static int stress_intr_in(async_exch_t *exch, int cycles, size_t size)
    97 {
    98         printf("Executing interrupt in stress test.\n"
    99             "      Packet count: %d\n"
    100             "      Packet size: %ld\n", cycles, size);
    101 
    102         int rc = usbdiag_stress_intr_in(exch, cycles, size);
    103         if (rc) {
    104                 printf(NAME ": %s\n", str_error(rc));
    105                 return 1;
    106         }
    107 
    108         return 0;
    109 }
    110 
    111 static int stress_intr_out(async_exch_t *exch, int cycles, size_t size)
    112 {
    113         printf("Executing interrupt out stress test.\n"
    114             "      Packet count: %d\n"
    115             "      Packet size: %ld\n", cycles, size);
    116 
    117         int rc = usbdiag_stress_intr_out(exch, cycles, size);
    118         if (rc) {
    119                 printf(NAME ": %s\n", str_error(rc));
    120                 return 1;
    121         }
    122 
    123         return 0;
    124 }
    125 
    126 static int stress_bulk_in(async_exch_t *exch, int cycles, size_t size)
    127 {
    128         printf("Executing bulk in stress test.\n"
    129             "      Packet count: %d\n"
    130             "      Packet size: %ld\n", cycles, size);
    131 
    132         int rc = usbdiag_stress_bulk_in(exch, cycles, size);
    133         if (rc) {
    134                 printf(NAME ": %s\n", str_error(rc));
    135                 return 1;
    136         }
    137 
    138         return 0;
    139 }
    140 
    141 static int stress_bulk_out(async_exch_t *exch, int cycles, size_t size)
    142 {
    143         printf("Executing bulk out stress test.\n"
    144             "      Packet count: %d\n"
    145             "      Packet size: %ld\n", cycles, size);
    146 
    147         int rc = usbdiag_stress_bulk_out(exch, cycles, size);
    148         if (rc) {
    149                 printf(NAME ": %s\n", str_error(rc));
    150                 return 1;
    151         }
    152 
    153         return 0;
    154 }
    155 
    156 int tmon_stress_intr_in(int argc, char *argv[])
    157 {
    158         return resolve_and_test(argc, argv, stress_intr_in);
    159 }
    160 
    161 int tmon_stress_intr_out(int argc, char *argv[])
    162 {
    163         return resolve_and_test(argc, argv, stress_intr_out);
    164 }
    165 
    166 int tmon_stress_bulk_in(int argc, char *argv[])
    167 {
    168         return resolve_and_test(argc, argv, stress_bulk_in);
    169 }
    170 
    171 int tmon_stress_bulk_out(int argc, char *argv[])
    172 {
    173         return resolve_and_test(argc, argv, stress_bulk_out);
    17496}
    17597
Note: See TracChangeset for help on using the changeset viewer.