]> git.karo-electronics.de Git - linux-beck.git/commitdiff
greybus: loopback_test: Add -f argument to cancel all tests
authorRyan Lim <limryan@google.com>
Wed, 20 Jul 2016 15:14:04 +0000 (08:14 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 20 Jul 2016 18:23:03 +0000 (11:23 -0700)
To make sure tests on all devices, enabled or not, are cancelled,
specify -f when starting new loopback test.

Signed-off-by: Ryan Lim <limryan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/tools/loopback_test.c

index 412e6dca0d0801551833771732c46c56370c823c..f7f4cd6fb55b3ddbc9865588f4ca659a7f53d412 100644 (file)
@@ -91,6 +91,7 @@ struct loopback_test {
        int async_outstanding_operations;
        int us_wait;
        int file_output;
+       int stop_all;
        int poll_count;
        char test_name[MAX_STR_LEN];
        char sysfs_prefix[MAX_SYSFS_PATH];
@@ -207,6 +208,7 @@ void usage(void)
        "   -c     Max number of outstanding operations for async operations\n"
        "   -w     Wait in uSec between operations\n"
        "   -z     Enable output to a CSV file (incompatible with -p)\n"
+       "   -f     When starting new loopback test, stop currently running tests on all devices\n"
        "Examples:\n"
        "  Send 10000 transfers with a packet size of 128 bytes to all active connections\n"
        "  loopback_test -t transfer -s 128 -i 10000 -S /sys/bus/greybus/devices/ -D /sys/kernel/debug/gb_loopback/\n"
@@ -778,9 +780,11 @@ static void prepare_devices(struct loopback_test *t)
 {
        int i;
 
-       /* Cancel any running tests */
+       /* Cancel any running tests on enabled devices. If
+        * stop_all option is given, stop test on all devices.
+        */
        for (i = 0; i < t->device_count; i++)
-               if (device_enabled(t, i))
+               if (t->stop_all || device_enabled(t, i))
                        write_sysfs_val(t->devices[i].sysfs_entry, "type", 0);
 
 
@@ -901,7 +905,7 @@ int main(int argc, char *argv[])
        memset(&t, 0, sizeof(t));
 
        while ((o = getopt(argc, argv,
-                          "t:s:i:S:D:m:v::d::r::p::a::l::x::o:O:c:w:z::")) != -1) {
+                          "t:s:i:S:D:m:v::d::r::p::a::l::x::o:O:c:w:z::f::")) != -1) {
                switch (o) {
                case 't':
                        snprintf(t.test_name, MAX_STR_LEN, "%s", optarg);
@@ -957,6 +961,9 @@ int main(int argc, char *argv[])
                case 'z':
                        t.file_output = 1;
                        break;
+               case 'f':
+                       t.stop_all = 1;
+                       break;
                default:
                        usage();
                        return -EINVAL;