Motr  M0
cookie.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2019-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
29 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT
30 #include "lib/trace.h"
31 
32 #include "ha/cookie.h"
33 #include "ut/ut.h"
34 
35 #include "lib/memory.h" /* M0_ALLOC_PTR */
36 
37 
38 void m0_ha_ut_cookie(void)
39 {
40  struct m0_ha_cookie_xc *hc_xc;
41  struct m0_ha_cookie *a;
42  struct m0_ha_cookie *b;
43 
44  M0_ALLOC_PTR(a);
45  M0_UT_ASSERT(a != NULL);
51  m0_free(a);
52 
53  M0_ALLOC_PTR(hc_xc);
54  M0_UT_ASSERT(hc_xc != NULL);
55  M0_ALLOC_PTR(a);
56  M0_UT_ASSERT(a != NULL);
57  M0_ALLOC_PTR(b);
58  M0_UT_ASSERT(b != NULL);
59 
62 
64  m0_ha_cookie_to_xc(a, hc_xc);
67  m0_ha_cookie_from_xc(a, hc_xc);
69  m0_ha_cookie_from_xc(b, hc_xc);
75  m0_ha_cookie_from_xc(a, hc_xc);
77  m0_ha_cookie_from_xc(b, hc_xc);
83  m0_ha_cookie_to_xc(a, hc_xc);
84  m0_ha_cookie_from_xc(b, hc_xc);
90 
93 
94  m0_free(b);
95  m0_free(a);
96  m0_free(hc_xc);
97 }
98 
99 #undef M0_TRACE_SUBSYSTEM
100 
103 /*
104  * Local variables:
105  * c-indentation-style: "K&R"
106  * c-basic-offset: 8
107  * tab-width: 8
108  * fill-column: 80
109  * scroll-step: 1
110  * End:
111  */
112 /*
113  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
114  */
void m0_ha_ut_cookie(void)
Definition: cookie.c:38
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_ha_cookie_to_xc(const struct m0_ha_cookie *hc, struct m0_ha_cookie_xc *hc_xc)
Definition: cookie.c:101
M0_INTERNAL void m0_ha_cookie_init(struct m0_ha_cookie *hc)
Definition: cookie.c:55
M0_INTERNAL void m0_ha_cookie_fini(struct m0_ha_cookie *hc)
Definition: cookie.c:62
M0_INTERNAL bool m0_ha_cookie_is_eq(const struct m0_ha_cookie *a, const struct m0_ha_cookie *b)
Definition: cookie.c:79
const struct m0_ha_cookie m0_ha_cookie_no_record
Definition: cookie.c:40
M0_INTERNAL void m0_ha_cookie_record(struct m0_ha_cookie *hc)
Definition: cookie.c:67
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_ha_cookie_from_xc(struct m0_ha_cookie *hc, const struct m0_ha_cookie_xc *hc_xc)
Definition: cookie.c:90
void m0_free(void *data)
Definition: memory.c:146
#define M0_UT_ASSERT(a)
Definition: ut.h:46