1 /*
2 * Copyright (C) 2022 HiHope Open Source Organization .
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 *
14 * limitations under the License.
15 */
16 #ifndef NET_DEMO_COMMON_H
17 #define NET_DEMO_COMMON_H
18
19 void NetDemoTest(unsigned short port, const char* host);
20
21 const char* GetNetDemoName(void);
22
IMPL_GET_NET_DEMO_NAME(testFunc)23 IMPL_GET_NET_DEMO_NAME(testFunc) { \
24 const char* GetNetDemoName() { \
25 static const char* demoName = #testFunc; \
26 return demoName; \
27 }
28 }
29
CLIENT_TEST_DEMO(testFunc)30 CLIENT_TEST_DEMO(testFunc) { \
31 void NetDemoTest(unsigned short port, const char* host) { \
32 (void) host; \
33 printf("%s start\r\n", #testFunc); \
34 printf("I will connect to %s:%d\r\n", host, port); \
35 testFunc(host, port); \
36 printf("%s done!\r\n", #testFunc); \
37 } \
38 }
39 IMPL_GET_NET_DEMO_NAME(testFunc)
40
SERVER_TEST_DEMO(testFunc)41 SERVER_TEST_DEMO(testFunc) { \
42 void NetDemoTest(unsigned short port, const char* host) { \
43 (void) host; \
44 printf("%s start\r\n", #testFunc); \
45 printf("I will listen on :%d\r\n", port); \
46 testFunc(port); \
47 printf("%s done!\r\n", #testFunc); \
48 } \
49 }
50 IMPL_GET_NET_DEMO_NAME(testFunc)
51
52 #endif // NET_DEMO_COMMON_H
53