Dave Barach | e9d9170 | 2017-11-29 16:59:01 -0500 | [diff] [blame^] | 1 | /* |
| 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: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 14 | */ |
| 15 | |
| 16 | #include <vppinfra/maplog.h> |
| 17 | |
| 18 | clib_maplog_main_t maplog_main; |
| 19 | |
| 20 | typedef struct |
| 21 | { |
| 22 | u64 serial_number; |
| 23 | u64 junk[7]; |
| 24 | } test_entry_t; |
| 25 | |
| 26 | int |
| 27 | test_maplog_main (unformat_input_t * input) |
| 28 | { |
| 29 | clib_maplog_main_t *mm = &maplog_main; |
| 30 | int rv; |
| 31 | int i; |
| 32 | test_entry_t *t; |
| 33 | |
| 34 | rv = clib_maplog_init (mm, "/tmp/maplog_test", 4096, sizeof (test_entry_t)); |
| 35 | |
| 36 | if (rv) |
| 37 | { |
| 38 | clib_warning ("clib_maplog_init returned %d", rv); |
| 39 | exit (1); |
| 40 | } |
| 41 | |
| 42 | for (i = 0; i < 64 * 5; i++) |
| 43 | { |
| 44 | t = clib_maplog_get_entry (mm); |
| 45 | t->serial_number = i; |
| 46 | } |
| 47 | |
| 48 | clib_maplog_close (mm); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | #ifdef CLIB_UNIX |
| 54 | int |
| 55 | main (int argc, char *argv[]) |
| 56 | { |
| 57 | unformat_input_t i; |
| 58 | int ret; |
| 59 | |
| 60 | unformat_init_command_line (&i, argv); |
| 61 | ret = test_maplog_main (&i); |
| 62 | unformat_free (&i); |
| 63 | |
| 64 | return ret; |
| 65 | } |
| 66 | #endif /* CLIB_UNIX */ |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | * fd.io coding-style-patch-verification: ON |
| 71 | * |
| 72 | * Local Variables: |
| 73 | * eval: (c-set-style "gnu") |
| 74 | * End: |
| 75 | */ |