[6.0] debd2c3bd debloat the vtim test
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Oct 31 13:08:26 UTC 2018
commit debd2c3bde369ab01f876e2caa97b640084fe043
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Oct 4 20:24:10 2018 +0200
debloat the vtim test
diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c
index 4bef5e711..a9fbc7cb2 100644
--- a/lib/libvarnish/vtim.c
+++ b/lib/libvarnish/vtim.c
@@ -529,12 +529,26 @@ bench()
e - s, i, 1e9 * (e - s) / i, t);
}
+void
+parse_check(time_t t, const char *s)
+{
+ double tt;
+ char buf[BUFSIZ];
+
+ tt = VTIM_parse(s);
+ if (tt != t) {
+ VTIM_format(tt, buf);
+ printf(" fm: %12jd <%s>\n", (intmax_t)t, s);
+ printf(" to: %12.0f <%s>\n", tt, buf);
+ exit(2);
+ }
+}
+
int
main(int argc, char **argv)
{
time_t t;
struct tm tm;
- double tt;
char buf[BUFSIZ];
char buf1[BUFSIZ];
@@ -553,41 +567,17 @@ main(int argc, char **argv)
buf1, buf, (intmax_t)t);
exit(2);
}
- tt = VTIM_parse(buf1);
- if (tt != t) {
- VTIM_format(tt, buf);
- printf(" fm: %12jd <%s>\n", (intmax_t)t, buf1);
- printf(" to: %12.0f <%s>\n", tt, buf);
- exit(2);
- }
+ parse_check(t, buf1);
strftime(buf1, sizeof buf1, "%a %b %e %T %Y", &tm);
- tt = VTIM_parse(buf1);
- if (tt != t) {
- VTIM_format(tt, buf);
- printf(" fm: %12jd <%s>\n", (intmax_t)t, buf1);
- printf(" to: %12.0f <%s>\n", tt, buf);
- exit(2);
- }
+ parse_check(t, buf1);
strftime(buf1, sizeof buf1, "%Y-%m-%dT%T", &tm);
- tt = VTIM_parse(buf1);
- if (tt != t) {
- VTIM_format(tt, buf);
- printf(" fm: %12jd <%s>\n", (intmax_t)t, buf1);
- printf(" to: %12.0f <%s>\n", tt, buf);
- exit(2);
- }
+ parse_check(t, buf1);
if (tm.tm_year >= 69 && tm.tm_year < 169) {
strftime(buf1, sizeof buf1, "%A, %d-%b-%y %T GMT", &tm);
- tt = VTIM_parse(buf1);
- if (tt != t) {
- VTIM_format(tt, buf);
- printf(" fm: %12jd <%s>\n", (intmax_t)t, buf1);
- printf(" to: %12.0f <%s>\n", tt, buf);
- exit(2);
- }
+ parse_check(t, buf1);
}
}
More information about the varnish-commit
mailing list