[Git][NTPsec/ntpsec][master] Replay checkpoint: cope with random number of calls in measre_tick_fuzz
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Dec 13 17:07:22 UTC 2015
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
fda68b3c by Eric S. Raymond at 2015-12-13T12:05:50Z
Replay checkpoint: cope with random number of calls in measre_tick_fuzz
- - - - -
2 changed files:
- ntpd/ntp_intercept.c
- ntpd/ntp_proto.c
Changes:
=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -110,6 +110,7 @@ static intercept_mode mode = none;
static char linebuf[256];
static int lineno;
+static double saved_drift;
intercept_mode intercept_get_mode(void)
{
@@ -140,8 +141,8 @@ static void get_operation(const char *expect)
}
if (expect != NULL && strncmp(linebuf, expect, strlen(expect)) != 0) {
- fprintf(stderr, "ntpd: replay failed, expected %s but saw %*s\n",
- expect, (int)strlen(expect), linebuf);
+ fprintf(stderr, "ntpd: replay failed on line %d, expected %s but saw %*s",
+ lineno, expect, (int)strlen(expect), linebuf);
exit(1);
}
@@ -251,8 +252,15 @@ void intercept_getconfig(const char *configfile)
/* this can be null if the default config doesn't exist */
configfile = getconfig(configfile);
- if (configfile != NULL && mode != none)
+ if (configfile != NULL && mode == capture)
pump(configfile, "startconfig\n", "endconfig\n", stdout);
+ /*
+ * Has to be done here because intercept_drift_read() is called from
+ * inside the config parser - otherwise, things get emitted in the
+ * wrong order.
+ */
+ if (mode == capture)
+ printf("drift-read %.3f\n", saved_drift);
}
}
@@ -337,7 +345,7 @@ bool intercept_drift_read(const char *drift_file, double *drift)
{
if (mode == replay) {
float df;
- get_operation("drift_read ");
+ get_operation("drift-read ");
if (strstr(linebuf, "false") != NULL)
return false;
/*
@@ -372,8 +380,8 @@ bool intercept_drift_read(const char *drift_file, double *drift)
}
fclose(fp);
- if (mode == capture)
- printf("drift-read %.3f\n", *drift);
+ /* capture write has to be done in the config intercwept */
+ saved_drift = *drift;
}
return true;
=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -4029,7 +4029,11 @@ measure_tick_fuzz(void)
DTOLFP(MINSTEP, &minstep);
intercept_get_systime(__func__, &last);
for (i = 0; i < MAXLOOPS && changes < MINCHANGES; i++) {
- intercept_get_systime(__func__, &val);
+ /*
+ * Not intercepted because it's called a variable
+ * number of times, which screws up replay.
+ */
+ get_systime(&val);
ldiff = val;
L_SUB(&ldiff, &last);
last = val;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/fda68b3c875068e083759eb3ce44c09e45988ac7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151213/a163b818/attachment.html>
More information about the vc
mailing list