summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/test_elog.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-04-01 11:07:40 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2017-04-01 17:22:31 +0000
commit903fd513e32a37e55aec0cfb4cf30e000680e0c3 (patch)
treec8e85da35fe9d9107cb3737537ccb4957fddc9e0 /src/vppinfra/test_elog.c
parenta3af337e06a79f7d1dacf42a319f241c907122fc (diff)
Clean up event log merge code
Fix a decade-old ridiculous qsort function bug. Managed to subtract floating-point numbers as if they were integers, leading to manufactured time-paradoxes. That completely confuses g2, leading to the summary disappearance of entire tracks' worth of data at high zoom levels. Add a manual alignment tweak parameter to elog_merge, users can dial-out time paradoxes caused by NTP-grade clock synchronization. The event-logger has a precision of O(100ns), whereas NTP synchronization is O(1ms). Change-Id: I69dedabaa314f69f9df74ec9ee66e21e6c87f703 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/test_elog.c')
-rw-r--r--src/vppinfra/test_elog.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/vppinfra/test_elog.c b/src/vppinfra/test_elog.c
index 89905adb4be..1cf5ba1f75c 100644
--- a/src/vppinfra/test_elog.c
+++ b/src/vppinfra/test_elog.c
@@ -52,6 +52,8 @@ test_elog_main (unformat_input_t * input)
f64 min_sample_time;
char *dump_file, *load_file, *merge_file, **merge_files;
u8 *tag, **tags;
+ f64 align_tweak;
+ f64 *align_tweaks;
n_iter = 100;
max_events = 100000;
@@ -61,6 +63,7 @@ test_elog_main (unformat_input_t * input)
load_file = 0;
merge_files = 0;
tags = 0;
+ align_tweaks = 0;
min_sample_time = 2;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -83,6 +86,8 @@ test_elog_main (unformat_input_t * input)
;
else if (unformat (input, "sample-time %f", &min_sample_time))
;
+ else if (unformat (input, "align-tweak %f", &align_tweak))
+ vec_add1 (align_tweaks, align_tweak);
else
{
error = clib_error_create ("unknown input `%U'\n",
@@ -102,9 +107,15 @@ test_elog_main (unformat_input_t * input)
{
uword i;
elog_main_t *ems;
-
vec_clone (ems, merge_files);
+ /* Supply default tags as needed */
+ if (vec_len (tags) < vec_len (ems))
+ {
+ for (i = vec_len (tags); i < vec_len (ems); i++)
+ vec_add1 (tags, format (0, "F%d%c", i, 0));
+ }
+
elog_init (em, max_events);
for (i = 0; i < vec_len (ems); i++)
{
@@ -113,7 +124,10 @@ test_elog_main (unformat_input_t * input)
goto done;
if (i > 0)
{
- elog_merge (em, tags[0], &ems[i], tags[i]);
+ align_tweak = 0.0;
+ if (i <= vec_len (align_tweaks))
+ align_tweak = align_tweaks[i - 1];
+ elog_merge (em, tags[0], &ems[i], tags[i], align_tweak);
tags[0] = 0;
}
}
@@ -217,7 +231,8 @@ test_elog_main (unformat_input_t * input)
#ifdef CLIB_UNIX
if (dump_file)
{
- if ((error = elog_write_file (em, dump_file)))
+ if ((error =
+ elog_write_file (em, dump_file, 0 /* do not flush ring */ )))
goto done;
}
#endif
@@ -246,6 +261,8 @@ main (int argc, char *argv[])
unformat_input_t i;
int r;
+ clib_mem_init (0, 3ULL << 30);
+
unformat_init_command_line (&i, argv);
r = test_elog_main (&i);
unformat_free (&i);
@@ -253,6 +270,42 @@ main (int argc, char *argv[])
}
#endif
+/**
+ * @brief GDB callable function: vl - Return vector length of vector
+ *
+ * @param *p - void - address of vector
+ *
+ * @return length - u32
+ *
+ */
+u32
+vl (void *p)
+{
+ return vec_len (p);
+}
+
+/**
+ * @brief GDB callable function: pe - call pool_elts - number of elements in a pool
+ *
+ * @param *v - void - address of pool
+ *
+ * @return number - uword
+ *
+ */
+#include <vppinfra/pool.h>
+uword
+pe (void *v)
+{
+ return (pool_elts (v));
+}
+
+#include <vppinfra/hash.h>
+uword
+he (void *v)
+{
+ return (hash_elts (v));
+}
+
/*
* fd.io coding-style-patch-verification: ON
*