• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #ifndef NET_DEMO_COMMON_H
18 #define NET_DEMO_COMMON_H
19 
20 void NetDemoTest(unsigned short port, const char* host);
21 
22 const char* GetNetDemoName(void);
23 
IMPL_GET_NET_DEMO_NAME(testFunc)24 IMPL_GET_NET_DEMO_NAME(testFunc) { \
25     const char* GetNetDemoName() { \
26         static const char* demoName = #testFunc; \
27         return demoName; \
28     }
29 }
30 
CLIENT_TEST_DEMO(testFunc)31 CLIENT_TEST_DEMO(testFunc) { \
32     void NetDemoTest(unsigned short port, const char* host) { \
33         (void) host; \
34         printf("%s start\r\n", #testFunc); \
35         printf("I will connect to %s:%d\r\n", host, port); \
36         testFunc(host, port); \
37         printf("%s done!\r\n", #testFunc); \
38     } \
39 }
40     IMPL_GET_NET_DEMO_NAME(testFunc)
41 
SERVER_TEST_DEMO(testFunc)42 SERVER_TEST_DEMO(testFunc) { \
43     void NetDemoTest(unsigned short port, const char* host) { \
44         (void) host; \
45         printf("%s start\r\n", #testFunc); \
46         printf("I will listen on :%d\r\n", port); \
47         testFunc(port); \
48         printf("%s done!\r\n", #testFunc); \
49     } \
50 }
51     IMPL_GET_NET_DEMO_NAME(testFunc)
52 
53 #endif // NET_DEMO_COMMON_H
54