summaryrefslogtreecommitdiff
path: root/tools/test
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2004-03-10 20:30:19 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2004-03-10 20:30:19 +0000
commit724e52cd0dd6494889b65466e9350632f4d6eaa8 (patch)
tree2d9286a294f38799a5433186e7516ca872f20afc /tools/test
parentcbde2013a67e98499ad0d79e0c16ee3e0edd9f5e (diff)
downloadsrc-test2-724e52cd0dd6494889b65466e9350632f4d6eaa8.tar.gz
src-test2-724e52cd0dd6494889b65466e9350632f4d6eaa8.zip
Notes
Diffstat (limited to 'tools/test')
-rw-r--r--tools/test/ppsapi/ppsapitest.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/test/ppsapi/ppsapitest.c b/tools/test/ppsapi/ppsapitest.c
index b80c853dbab5..78e73825e16c 100644
--- a/tools/test/ppsapi/ppsapitest.c
+++ b/tools/test/ppsapi/ppsapitest.c
@@ -31,14 +31,17 @@ int
main(int argc, char **argv)
{
int fd;
+ FILE *fdo;
pps_info_t pi;
pps_params_t pp;
pps_handle_t ph;
int i, mode;
u_int olda, oldc;
struct timespec to;
+ char const *ofn;
- while ((i = getopt(argc, argv, "aAbBcCeuv")) != -1) {
+ ofn = NULL;
+ while ((i = getopt(argc, argv, "aAbBcCeo:uv")) != -1) {
switch (i) {
case 'a': aflag = 1; break;
case 'A': Aflag = 1; break;
@@ -47,6 +50,7 @@ main(int argc, char **argv)
case 'c': cflag = 1; break;
case 'C': Cflag = 1; break;
case 'e': eflag = 1; break;
+ case 'o': ofn = optarg; break;
case 'u': uflag = 1; break;
case 'v': vflag = 1; break;
case '?':
@@ -56,6 +60,13 @@ main(int argc, char **argv)
exit (1);
}
}
+ if (ofn != NULL) {
+ fdo = fopen(ofn, "w");
+ if (fdo == NULL)
+ err(1, "Cannot open %s", ofn);
+ } else {
+ fdo = NULL;
+ }
argc -= optind;
argv += optind;
if (argc > 0) {
@@ -163,6 +174,12 @@ main(int argc, char **argv)
usleep(10000);
continue;
}
+ if (fdo != NULL) {
+ if (fwrite(&pi, sizeof pi, 1, fdo) != 1)
+ err(1, "Write error on %s", ofn);
+ if (uflag)
+ fflush(fdo);
+ }
Chew(&pi.assert_timestamp, &pi.clear_timestamp,
pi.assert_sequence, pi.clear_sequence);
olda = pi.assert_sequence;