Motr  M0
misc.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 "net/net.h" /* m0_net_endpoint_is_valid */
23 #include "ut/ut.h"
24 
25 static void test_endpoint_is_valid(void)
26 {
27  const char *good[] = {
28  "0@lo:12345:34:1",
29  "172.18.1.1@tcp:12345:40:401",
30  "255.0.0.0@tcp:12345:1:1",
31  "172.18.50.40@o2ib:12345:34:1",
32  "172.18.50.40@o2ib1:12345:34:1",
33  };
34  const char *bad[] = {
35  "",
36  " 172.18.1.1@tcp:12345:40:401",
37  "172.18.1.1@tcp:12345:40:401 ",
38  "1@lo:12345:34:1",
39  "172.16.64.1:12345:45:41",
40  "256.0.0.0@tcp:12345:1:1",
41  "172.18.50.40@o2ib:54321:34:1",
42  };
43 
45  m0_net_endpoint_is_valid(good[i])));
47  !m0_net_endpoint_is_valid(bad[i])));
48 }
49 
51  .ts_name = "net-misc-ut",
52  .ts_tests = {
53  { "endpoint-is-valid", test_endpoint_is_valid },
54  { NULL, NULL }
55  }
56 };
M0_INTERNAL bool m0_net_endpoint_is_valid(const char *endpoint)
Definition: net.c:99
#define NULL
Definition: misc.h:38
Definition: ut.h:77
int i
Definition: dir.c:1033
#define m0_forall(var, nr,...)
Definition: misc.h:112
const char * ts_name
Definition: ut.h:99
struct m0_ut_suite m0_net_misc_ut
Definition: misc.c:50
static void test_endpoint_is_valid(void)
Definition: misc.c:25
#define ARRAY_SIZE(a)
Definition: misc.h:45
#define M0_UT_ASSERT(a)
Definition: ut.h:46