]> git.karo-electronics.de Git - linux-beck.git/commitdiff
greybus: loopback_test: make output to csv file a parameter option
authorAxel Haslam <ahaslam@baylibre.com>
Tue, 26 Jan 2016 20:26:02 +0000 (21:26 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 27 Jan 2016 01:07:27 +0000 (17:07 -0800)
Its useful to get a CSV output on stdout for test frameworks to read
and parse the results. However, a csv file is not always needed.

Add the -z option to  create/append a csv file only when the user
asks for it.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/tools/loopback_test.c

index 27c733d1c82e2882a412be8e7246e1d058bb5bb9..e8d35bd95cc7084807dffcaba52e6b3832b66e7e 100644 (file)
@@ -92,6 +92,7 @@ struct loopback_test {
        int async_timeout;
        int async_outstanding_operations;
        int us_wait;
+       int file_output;
        char test_name[MAX_STR_LEN];
        char sysfs_prefix[MAX_SYSFS_PATH];
        char debugfs_prefix[MAX_SYSFS_PATH];
@@ -202,6 +203,7 @@ void usage(void)
        "   -o     Async Timeout - Timeout in uSec for async operations\n"
        "   -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"
        "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"
@@ -527,7 +529,7 @@ static int log_results(struct loopback_test *t)
        * append to the same CSV with datestamp - representing each test
        * dataset.
        */
-       if (!t->porcelain) {
+       if (t->file_output && !t->porcelain) {
                snprintf(file_name, sizeof(file_name), "%s_%d_%d.csv",
                        t->test_name, t->size, t->iteration_max);
 
@@ -545,7 +547,7 @@ static int log_results(struct loopback_test *t)
                len = format_output(t, &t->devices[i].results,
                                        t->devices[i].name,
                                        data, sizeof(data), &tm);
-               if (!t->porcelain) {
+               if (t->file_output && !t->porcelain) {
                        ret = write(fd, data, len);
                        if (ret == -1)
                                fprintf(stderr, "unable to write %d bytes to csv.\n", len);
@@ -557,14 +559,14 @@ static int log_results(struct loopback_test *t)
        if (t->aggregate_output) {
                len = format_output(t, &t->aggregate_results, "aggregate",
                                        data, sizeof(data), &tm);
-               if (!t->porcelain) {
+               if (t->file_output && !t->porcelain) {
                        ret = write(fd, data, len);
                        if (ret == -1)
                                fprintf(stderr, "unable to write %d bytes to csv.\n", len);
                }
        }
 
-       if (!t->porcelain)
+       if (t->file_output && !t->porcelain)
                close(fd);
 
        return 0;
@@ -923,6 +925,8 @@ int main(int argc, char *argv[])
                case 'w':
                        t.us_wait = atoi(optarg);
                        break;
+               case 'z':
+                       t.file_output = 1;
                default:
                        usage();
                        return -EINVAL;