summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/test_maplog.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-12-01 16:20:32 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-02 18:44:07 +0000
commit04fee31f265b1d8b602bf336ef1df6c917cf18b2 (patch)
tree0923dbecc069f4287db84d3946669010f974eec5 /src/vppinfra/test_maplog.c
parente2e9ce5cec3bacaa9445761d86ead2d582b46dca (diff)
maplog headers, offline processing, doxygen tags
Change-Id: I0545018ec02f3706ad6a2da6fc13537db5c31a2d Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/test_maplog.c')
-rw-r--r--src/vppinfra/test_maplog.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/vppinfra/test_maplog.c b/src/vppinfra/test_maplog.c
index fb9fb0cc543..c49ebd6885e 100644
--- a/src/vppinfra/test_maplog.c
+++ b/src/vppinfra/test_maplog.c
@@ -23,15 +23,52 @@ typedef struct
u64 junk[7];
} test_entry_t;
+static void
+process_maplog_records (clib_maplog_header_t * h,
+ test_entry_t * e, u64 records_this_file)
+{
+ static int print_header;
+ int i = 0;
+
+ if (print_header == 0)
+ {
+ print_header = 1;
+ fformat (stdout, "%U", format_maplog_header, h, 1 /* verbose */ );
+ }
+
+ while (records_this_file--)
+ {
+ fformat (stdout, "%4lld ", e->serial_number);
+ if (++i == 8)
+ {
+ fformat (stdout, "\n");
+ i = 0;
+ }
+ e++;
+ }
+ fformat (stdout, "--------------\n");
+}
+
int
test_maplog_main (unformat_input_t * input)
{
clib_maplog_main_t *mm = &maplog_main;
+ clib_maplog_init_args_t _a, *a = &_a;
int rv;
int i;
test_entry_t *t;
- rv = clib_maplog_init (mm, "/tmp/maplog_test", 4096, sizeof (test_entry_t));
+ memset (a, 0, sizeof (*a));
+ a->mm = mm;
+ a->file_basename = "/tmp/maplog_test";
+ a->file_size_in_bytes = 4096;
+ a->record_size_in_bytes = sizeof (test_entry_t);
+ a->application_id = 1;
+ a->application_major_version = 1;
+ a->application_minor_version = 0;
+ a->application_patch_version = 0;
+
+ rv = clib_maplog_init (a);
if (rv)
{
@@ -47,6 +84,8 @@ test_maplog_main (unformat_input_t * input)
clib_maplog_close (mm);
+ clib_maplog_process ("/tmp/maplog_test", process_maplog_records);
+
return 0;
}