Changeset e9d600c2 in mainline for uspace/app/tmon/test.c


Ignore:
Timestamp:
2017-12-21T09:03:55Z (6 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ad2a8b1
Parents:
cec130b
Message:

usbdiag: added interrupt endpoint tests, printing tmon device path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tmon/test.c

    rcec130b re9d600c2  
    4444
    4545#define NAME "tmon"
     46#define MAX_PATH_LENGTH 1024
     47
     48#define DEFAULT_CYCLES  1024
     49#define DEFAULT_SIZE    65432
    4650
    4751static int resolve_default_fun(devman_handle_t *fun)
     
    97101}
    98102
    99 static int resolve_and_test(int argc, char *argv[], int (*test)(devman_handle_t)) {
     103static int resolve_and_test(int argc, char *argv[], int (*test)(devman_handle_t, int, size_t)) {
    100104        devman_handle_t fun = -1;
    101105
     
    111115        }
    112116
    113         return test(fun);
    114 }
    115 
    116 static int stress_bulk_in(devman_handle_t fun) {
    117         async_sess_t *sess = usbdiag_connect(fun);
    118         async_exch_t *exch = async_exchange_begin(sess);
    119 
    120         const int cycles = 1024;
    121         const size_t size = 65432;
     117        int rc;
     118        char path[MAX_PATH_LENGTH];
     119        if ((rc = devman_fun_get_path(fun, path, sizeof(path)))) {
     120                printf(NAME ": Error resolving path of device with handle %ld. %s\n", fun, str_error(rc));
     121                return 1;
     122        }
     123
     124        printf("Using device: %s\n", path);
     125
     126        // TODO: Read options here.
     127
     128        return test(fun, DEFAULT_CYCLES, DEFAULT_SIZE);
     129}
     130
     131static int stress_intr_in(devman_handle_t fun, int cycles, size_t size) {
     132        async_sess_t *sess = usbdiag_connect(fun);
     133        async_exch_t *exch = async_exchange_begin(sess);
     134
     135        int rc = usbdiag_stress_intr_in(exch, cycles, size);
     136        int ec = 0;
     137
     138        if (rc) {
     139                printf(NAME ": %s\n", str_error(rc));
     140                ec = 1;
     141        }
     142
     143        async_exchange_end(exch);
     144        usbdiag_disconnect(sess);
     145        return ec;
     146}
     147
     148static int stress_intr_out(devman_handle_t fun, int cycles, size_t size) {
     149        async_sess_t *sess = usbdiag_connect(fun);
     150        async_exch_t *exch = async_exchange_begin(sess);
     151
     152        int rc = usbdiag_stress_intr_out(exch, cycles, size);
     153        int ec = 0;
     154
     155        if (rc) {
     156                printf(NAME ": %s\n", str_error(rc));
     157                ec = 1;
     158        }
     159
     160        async_exchange_end(exch);
     161        usbdiag_disconnect(sess);
     162        return ec;
     163}
     164
     165static int stress_bulk_in(devman_handle_t fun, int cycles, size_t size) {
     166        async_sess_t *sess = usbdiag_connect(fun);
     167        async_exch_t *exch = async_exchange_begin(sess);
     168
    122169        int rc = usbdiag_stress_bulk_in(exch, cycles, size);
    123 
    124         if (rc) {
    125                 printf(NAME ": %s\n", str_error(rc));
    126         }
    127 
    128         async_exchange_end(exch);
    129         usbdiag_disconnect(sess);
    130         return 0;
    131 }
    132 
    133 static int stress_bulk_out(devman_handle_t fun) {
    134         async_sess_t *sess = usbdiag_connect(fun);
    135         async_exch_t *exch = async_exchange_begin(sess);
    136 
    137         const int cycles = 1024;
    138         const size_t size = 65432;
     170        int ec = 0;
     171
     172        if (rc) {
     173                printf(NAME ": %s\n", str_error(rc));
     174                ec = 1;
     175        }
     176
     177        async_exchange_end(exch);
     178        usbdiag_disconnect(sess);
     179        return ec;
     180}
     181
     182static int stress_bulk_out(devman_handle_t fun, int cycles, size_t size) {
     183        async_sess_t *sess = usbdiag_connect(fun);
     184        async_exch_t *exch = async_exchange_begin(sess);
     185
    139186        int rc = usbdiag_stress_bulk_out(exch, cycles, size);
    140 
    141         if (rc) {
    142                 printf(NAME ": %s\n", str_error(rc));
    143         }
    144 
    145         async_exchange_end(exch);
    146         usbdiag_disconnect(sess);
    147         return 0;
     187        int ec = 0;
     188
     189        if (rc) {
     190                printf(NAME ": %s\n", str_error(rc));
     191                ec = 1;
     192        }
     193
     194        async_exchange_end(exch);
     195        usbdiag_disconnect(sess);
     196        return ec;
     197}
     198
     199int tmon_stress_intr_in(int argc, char *argv[])
     200{
     201        return resolve_and_test(argc, argv, stress_intr_in);
     202}
     203
     204int tmon_stress_intr_out(int argc, char *argv[])
     205{
     206        return resolve_and_test(argc, argv, stress_intr_out);
    148207}
    149208
Note: See TracChangeset for help on using the changeset viewer.