[PATCH] [TESTUSB] Add '-o' option
Felipe Balbi <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <1175539507.4886.49.camel@localhost> |
[PATCH] Add "-o" option to redirect the output of testusb to a file. Signed-off-by: Felipe Balbi <[email protected]> --- --- testusb.c.orig 2007-04-02 13:42:33.000000000 -0400 +++ testusb.c 2007-04-02 14:42:19.000000000 -0400 @@ -37,6 +37,9 @@ #define TEST_CASES 30 +/* File pointer for output */ +FILE *file; + // FIXME make these public somewhere; usbdevfs.h? struct usbtest_param { @@ -261,19 +264,22 @@ snprintf (buf, sizeof buf, "error %d", err); errno = err; } - printf ("%s test %d --> %d (%s)\n", - dev->name, i, errno, buf); - } else - printf ("%s test %d, %4d.%.06d secs\n", dev->name, i, - (int) dev->param.duration.tv_sec, - (int) dev->param.duration.tv_usec); - - fflush (stdout); + fprintf(file, "%s test %d --> %d (%s)\n", + dev->name, i , errno, buf); + } else + fprintf(file, "%s test %d, %4d.%.06d secs\n", + dev->name, i, + (int) dev->param.duration.tv_sec, + (int) dev->param.duration.tv_usec); + } + + fflush (file); } if (dev->forever) goto restart; close (fd); + fclose (file); return arg; } @@ -302,8 +308,9 @@ /* for easy use when hotplugging */ device = getenv ("DEVICE"); + file = stdout; - while ((c = getopt (argc, argv, "D:ac:g:hns:t:v:")) != EOF) + while ((c = getopt (argc, argv, "D:ac:g:hns:t:v:o:")) != EOF) switch (c) { case 'D': /* device, if only one */ device = optarg; @@ -343,13 +350,21 @@ if (param.vary < 0) goto usage; continue; + case 'o': /* output file */ + file = fopen (optarg, "w"); + if (file == NULL) { + printf ("Can't open %s\n", optarg); + goto usage; + } + continue; case '?': case 'h': default: usage: fprintf (stderr, "usage: %s [-an] [-D dev]\n" "\t[-c iterations] [-t testnum]\n" - "\t[-s packetsize] [-g sglen] [-v vary]\n", + "\t[-s packetsize] [-g sglen] [-v vary]\n" + "\t[-o output_file]\n", argv [0]); return 1; } -- Best Regards, Felipe Balbi [email protected] Nokia Institute of Technology - INdT Kernel Developers Team +55 92 2126 1003 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBGEU8zRAONWVkpRGQRAl7YAKCU13V2YMbZ3KEX4DpCt805UNLP1gCfbiwm Xi/3qK9uePyp6KfqG6s7fE8= =XTqv -----END PGP SIGNATURE-----