Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/tests/lib/libutil Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/69f9ad617838
branches:  netbsd-7
changeset: 798418:69f9ad617838
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Oct 11 16:52:56 2014 +0000

description:
Pull up following revision(s) (requested by apb in ticket #135.10):
        tests/lib/libutil/t_parsedate.c: revision 1.12
When tests fail, print all args, notjust the date string.

diffstat:

 tests/lib/libutil/t_parsedate.c |  52 +++++++++++++++++++++++++++++-----------
 1 files changed, 37 insertions(+), 15 deletions(-)

diffs (91 lines):

diff -r ba5a7ce9a7fc -r 69f9ad617838 tests/lib/libutil/t_parsedate.c
--- a/tests/lib/libutil/t_parsedate.c   Sat Oct 11 16:52:07 2014 +0000
+++ b/tests/lib/libutil/t_parsedate.c   Sat Oct 11 16:52:56 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_parsedate.c,v 1.7.8.4 2014/10/11 16:47:00 snj Exp $ */
+/* $NetBSD: t_parsedate.c,v 1.7.8.5 2014/10/11 16:52:56 snj Exp $ */
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,10 +29,11 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_parsedate.c,v 1.7.8.4 2014/10/11 16:47:00 snj Exp $");
+__RCSID("$NetBSD: t_parsedate.c,v 1.7.8.5 2014/10/11 16:52:56 snj Exp $");
 
 #include <atf-c.h>
 #include <errno.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <util.h>
@@ -59,34 +60,55 @@
 {
        time_t t;
        struct tm tm;
+       char argstr[128];
+
+       /*
+        * printable version of the args.
+        *
+        * Note that printf("%.*d", 0, 0)) prints nothing at all,
+        * while printf("%.*d", 1, val) prints the value as usual.
+        */
+       snprintf(argstr, sizeof(argstr), "%s%s%s, %s%.*jd, %s%.*d",
+               /* NULL or \"<datestr>\" */
+               (datestr ? "\"" : ""),
+               (datestr ? datestr : "NULL"),
+               (datestr ? "\"" : ""),
+               /* NULL or *reftime */
+               (reftime ? "" : "NULL"),
+               (reftime ? 1 : 0), 
+               (reftime ? (intmax_t)*reftime : (intmax_t)0), 
+               /* NULL or *zoff */
+               (zoff ? "" : "NULL"),
+               (zoff ? 1 : 0), 
+               (zoff ? *zoff : 0));
 
        ATF_CHECK_MSG((t = parsedate(datestr, reftime, zoff)) != -1,
-           "parsedate(\"%s\",,) returned -1\n", datestr);
+           "parsedate(%s) returned -1\n", argstr);
        ATF_CHECK(time_to_tm(&t, &tm) != NULL);
        if (year != ANY)
                ATF_CHECK_MSG(tm.tm_year + 1900 == year,
-                   "parsedate(\"%s\",,) expected year %d got %d (+1900)\n",
-                   datestr, year, (int)tm.tm_year);
+                   "parsedate(%s) expected year %d got %d (+1900)\n",
+                   argstr, year, (int)tm.tm_year);
        if (month != ANY)
                ATF_CHECK_MSG(tm.tm_mon + 1 == month,
-                   "parsedate(\"%s\",,) expected month %d got %d (+1)\n",
-                   datestr, month, (int)tm.tm_mon);
+                   "parsedate(%s) expected month %d got %d (+1)\n",
+                   argstr, month, (int)tm.tm_mon);
        if (day != ANY)
                ATF_CHECK_MSG(tm.tm_mday == day,
-                   "parsedate(\"%s\",,) expected day %d got %d\n",
-                   datestr, day, (int)tm.tm_mday);
+                   "parsedate(%s) expected day %d got %d\n",
+                   argstr, day, (int)tm.tm_mday);
        if (hour != ANY)
                ATF_CHECK_MSG(tm.tm_hour == hour,
-                   "parsedate(\"%s\",,) expected hour %d got %d\n",
-                   datestr, hour, (int)tm.tm_hour);
+                   "parsedate(%s) expected hour %d got %d\n",
+                   argstr, hour, (int)tm.tm_hour);
        if (minute != ANY)
                ATF_CHECK_MSG(tm.tm_min == minute,
-                   "parsedate(\"%s\",,) expected minute %d got %d\n",
-                   datestr, minute, (int)tm.tm_min);
+                   "parsedate(%s) expected minute %d got %d\n",
+                   argstr, minute, (int)tm.tm_min);
        if (second != ANY)
                ATF_CHECK_MSG(tm.tm_sec == second,
-                   "parsedate(\"%s\",,) expected second %d got %d\n",
-                   datestr, second, (int)tm.tm_sec);
+                   "parsedate(%s) expected second %d got %d\n",
+                   argstr, second, (int)tm.tm_sec);
 }
 
 ATF_TC(dates);



Home | Main Index | Thread Index | Old Index