2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vppinfra/maplog.h>
18 clib_maplog_main_t maplog_main;
27 process_maplog_records (clib_maplog_header_t * h,
28 test_entry_t * e, u64 records_this_file)
30 static int print_header;
33 if (print_header == 0)
36 fformat (stdout, "%U", format_maplog_header, h, 1 /* verbose */ );
39 while (records_this_file--)
41 fformat (stdout, "%4lld ", e->serial_number);
44 fformat (stdout, "\n");
49 fformat (stdout, "--------------\n");
53 test_maplog_main (unformat_input_t * input)
55 clib_maplog_main_t *mm = &maplog_main;
56 clib_maplog_init_args_t _a, *a = &_a;
61 memset (a, 0, sizeof (*a));
63 a->file_basename = "/tmp/maplog_test";
64 a->file_size_in_bytes = 4096;
65 a->record_size_in_bytes = sizeof (test_entry_t);
66 a->application_id = 1;
67 a->application_major_version = 1;
68 a->application_minor_version = 0;
69 a->application_patch_version = 0;
71 rv = clib_maplog_init (a);
75 clib_warning ("clib_maplog_init returned %d", rv);
79 for (i = 0; i < 64 * 5; i++)
81 t = clib_maplog_get_entry (mm);
85 clib_maplog_close (mm);
87 clib_maplog_process ("/tmp/maplog_test", process_maplog_records);
94 main (int argc, char *argv[])
99 unformat_init_command_line (&i, argv);
100 ret = test_maplog_main (&i);
105 #endif /* CLIB_UNIX */
109 * fd.io coding-style-patch-verification: ON
112 * eval: (c-set-style "gnu")