Skip to content

Commit 940cc46

Browse files
committed
sys/log: Add mixed FCB bmark unittest
- Fix build, address some review comments
1 parent 208c970 commit 940cc46

File tree

13 files changed

+676
-68
lines changed

13 files changed

+676
-68
lines changed

sys/log/full/include/log/log_fcb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ struct log_fcb_bmark *log_fcb_get_bmarks(struct log *log, uint32_t *bmarks_size)
179179
* @return The closest bookmark on success;
180180
* NULL if the log has no applicable bookmarks.
181181
*/
182-
struct log_fcb_bmark *
183-
log_fcb_closest_bmark(struct fcb_log *fcb_log, uint32_t index, int *min_diff);
182+
const struct log_fcb_bmark *
183+
log_fcb_closest_bmark(const struct fcb_log *fcb_log, uint32_t index, int *min_diff);
184184

185185
/**
186186
* Inserts a bookmark into the provided log.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
pkg.name: sys/log/full/selftest/fcb_bookmarks_mixed
19+
pkg.type: unittest
20+
pkg.description: "Log unit tests; flash-alignment=8."
21+
pkg.author: "Apache Mynewt <[email protected]>"
22+
pkg.homepage: "http://mynewt.apache.org/"
23+
pkg.keywords:
24+
25+
pkg.deps:
26+
- "@apache-mynewt-core/sys/console/stub"
27+
- "@apache-mynewt-core/sys/log/full"
28+
- "@apache-mynewt-core/sys/log/full/selftest/util"
29+
- "@apache-mynewt-core/test/testutil"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "os/mynewt.h"
21+
#include "log_test_util/log_test_util.h"
22+
#include "log_test_fcb_bookmarks.h"
23+
24+
TEST_SUITE(log_test_suite_fcb_bookmarks)
25+
{
26+
log_test_case_fcb_bookmarks_s0_l1_b0_p100();
27+
log_test_case_fcb_bookmarks_s0_l1_b5_p100();
28+
log_test_case_fcb_bookmarks_s0_l10_b10_p100();
29+
log_test_case_fcb_bookmarks_s10_l10_b10_p100();
30+
}
31+
32+
int
33+
main(int argc, char **argv)
34+
{
35+
log_test_suite_fcb_bookmarks();
36+
37+
return tu_any_failed;
38+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef H_LOG_TEST_FCB_BOOKMARKS_
21+
#define H_LOG_TEST_FCB_BOOKMARKS_
22+
23+
#include "os/mynewt.h"
24+
#include "testutil/testutil.h"
25+
26+
struct ltfbu_cfg {
27+
int skip_mod;
28+
int body_len;
29+
int bmark_count;
30+
int pop_count;
31+
};
32+
33+
void ltfbu_populate_log(int count);
34+
void ltfbu_verify_log(uint32_t start_idx);
35+
void ltfbu_init(const struct ltfbu_cfg *cfg);
36+
void ltfbu_test_once(const struct ltfbu_cfg *cfg);
37+
38+
TEST_CASE_DECL(log_test_case_fcb_bookmarks_s0_l1_b0_p100);
39+
TEST_CASE_DECL(log_test_case_fcb_bookmarks_s0_l1_b5_p100);
40+
TEST_CASE_DECL(log_test_case_fcb_bookmarks_s0_l10_b10_p100);
41+
TEST_CASE_DECL(log_test_case_fcb_bookmarks_s10_l10_b10_p100);
42+
43+
#endif

0 commit comments

Comments
 (0)