Motr  M0
walk.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include "conf/walk.h"
23 #include "conf/ut/common.h" /* m0_conf_ut_cache_from_file */
24 #include "ut/misc.h" /* M0_UT_PATH */
25 #include "ut/ut.h"
26 
27 static int conf_ut_count_nondirs(struct m0_conf_obj *obj, void *args)
28 {
30  ++*(unsigned *)args;
31  return M0_CW_CONTINUE;
32 }
33 
34 static void test_conf_walk(void)
35 {
37  struct m0_conf_obj *root;
38  unsigned n = 0;
39  int rc;
40 
46  M0_UT_ASSERT(rc == 0);
47  M0_UT_ASSERT(n == M0_UT_CONF_NR_OBJS);
49 
50  /* XXX TODO: add more tests */
51 }
52 
54  .ts_name = "conf-walk-ut",
55  .ts_init = m0_conf_ut_cache_init,
56  .ts_fini = m0_conf_ut_cache_fini,
57  .ts_tests = {
58  { "walk", test_conf_walk },
59  { NULL, NULL }
60  }
61 };
const struct m0_conf_obj_type * m0_conf_obj_type(const struct m0_conf_obj *obj)
Definition: obj.c:363
Definition: beck.c:235
struct m0_ut_suite conf_walk_ut
Definition: walk.c:53
M0_INTERNAL int m0_conf_ut_cache_init(void)
Definition: common.c:107
#define NULL
Definition: misc.h:38
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_lookup(const struct m0_conf_cache *cache, const struct m0_fid *id)
Definition: cache.c:106
static void test_conf_walk(void)
Definition: walk.c:34
Definition: ub.c:49
Definition: ut.h:77
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL int m0_conf_walk(int(*fn)(struct m0_conf_obj *obj, void *args), struct m0_conf_obj *origin, void *args)
Definition: walk.c:49
struct m0_conf_cache m0_conf_ut_cache
Definition: common.c:31
struct m0_conf_root * root
Definition: note.c:50
static int conf_ut_count_nondirs(struct m0_conf_obj *obj, void *args)
Definition: walk.c:27
M0_INTERNAL int m0_conf_ut_cache_fini(void)
Definition: common.c:114
const char * ts_name
Definition: ut.h:99
uint64_t n
Definition: fops.h:107
M0_INTERNAL void m0_conf_ut_cache_from_file(struct m0_conf_cache *cache, const char *path)
Definition: common.c:123
const struct m0_fid M0_CONF_ROOT_FID
Definition: root.c:226
#define M0_UT_PATH(name)
Definition: misc.h:41
M0_INTERNAL void m0_conf_cache_lock(struct m0_conf_cache *cache)
Definition: cache.c:50
const struct m0_conf_obj_type M0_CONF_DIR_TYPE
Definition: dir.c:206
int32_t rc
Definition: trigger_fop.h:47
#define M0_UT_ASSERT(a)
Definition: ut.h:46
M0_INTERNAL void m0_conf_cache_unlock(struct m0_conf_cache *cache)
Definition: cache.c:55