Mistake on this page?
Report an issue in GitHub or email us
dns_tests.h
1 /*
2  * Copyright (c) 2018, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * 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, WITHOUT
13  * 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 
18 #ifndef DNS_TESTS_H
19 #define DNS_TESTS_H
20 
21 #include "nsapi_dns.h"
22 #include "mbed_trace.h"
23 
24 #define TRACE_GROUP "GRNT"
25 
26 #ifndef MBED_CONF_APP_DNS_SIMULT_QUERIES
27 #ifdef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
28 #define MBED_CONF_APP_DNS_SIMULT_QUERIES MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
29 #else
30 #define MBED_CONF_APP_DNS_SIMULT_QUERIES 5
31 #endif
32 #endif
33 
34 #ifndef MBED_CONF_NSAPI_DNS_CACHE_SIZE
35 #define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3
36 #endif
37 
38 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS_NUM
39 #define MBED_CONF_APP_DNS_TEST_HOSTS_NUM 6
40 #endif
41 
42 // Hostnames for testing against
43 // Both lists must have A and AAAA records
44 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS
45 #define MBED_CONF_APP_DNS_TEST_HOSTS {"google.com", "youtube.com", "facebook.com", "wikipedia.org", "yahoo.com", "instagram.com"}
46 #endif
47 
48 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS_SECOND
49 #define MBED_CONF_APP_DNS_TEST_HOSTS_SECOND {"ipv6ready.org", "wireshark.org", "bbc.co.uk", "cnn.com", "www.flickr.com", "www.mozilla.org"}
50 #endif
51 
52 #ifndef MBED_CONF_APP_DNS_TEST_MULTI_IP_HOSTS
53 #define MBED_CONF_APP_DNS_TEST_MULTI_IP_HOSTS {"google.com", "www.mozilla.org", "yahoo.com", "instagram.com","www.flickr.com"}
54 #endif
55 
56 #define DNS_TEST_HOST_LEN 40
57 
59  rtos::Semaphore *semaphore;
60  nsapi_error_t result;
61  SocketAddress addr;
62  nsapi_error_t req_result;
63  bool value_set;
64 };
65 
67  rtos::Semaphore *semaphore;
68  nsapi_error_t result;
69  SocketAddress addr[MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT];
70  nsapi_error_t req_result;
71  bool value_set;
72 };
73 
74 extern const char dns_test_hosts[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
75 extern const char dns_test_hosts_second[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
76 
77 #ifndef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
78 extern const char dns_test_hosts_multi_ip[MBED_CONF_APP_DNS_SIMULT_QUERIES][DNS_TEST_HOST_LEN];
79 #endif
80 
81 /*
82  * Utility functions
83  */
84 NetworkInterface *get_interface();
85 void hostbyname_cb(void *data, nsapi_error_t result, SocketAddress *address);
86 void do_asynchronous_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_count, int *exp_ok, int *exp_no_mem, int *exp_dns_failure, int *exp_timeout);
87 void do_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_count, int *exp_ok, int *exp_no_mem, int *exp_dns_failure, int *exp_timeout);
88 
89 namespace dns_global {
90 #ifdef MBED_GREENTEA_TEST_DNSSOCKET_TIMEOUT_S
91 static const int TESTS_TIMEOUT = MBED_GREENTEA_TEST_DNSSOCKET_TIMEOUT_S;
92 #else
93 #define MESH 3
94 #define WISUN 0x2345
95 #if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH && MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN
96 static const int TESTS_TIMEOUT = (25 * 60);
97 #else
98 static const int TESTS_TIMEOUT = (10 * 60);
99 #endif
100 #endif
101 }
102 
103 /*
104  * Test cases
105  */
106 void ASYNCHRONOUS_DNS();
107 void ASYNCHRONOUS_DNS_SIMULTANEOUS();
108 void ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE();
109 void ASYNCHRONOUS_DNS_CACHE();
110 void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC();
111 void ASYNCHRONOUS_DNS_CANCEL();
112 void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE();
113 void ASYNCHRONOUS_DNS_INVALID_HOST();
114 void ASYNCHRONOUS_DNS_TIMEOUTS();
115 void ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT();
116 void SYNCHRONOUS_DNS();
117 void SYNCHRONOUS_DNS_MULTIPLE();
118 void SYNCHRONOUS_DNS_CACHE();
119 void SYNCHRONOUS_DNS_INVALID();
120 void SYNCHRONOUS_DNS_MULTI_IP();
121 void ASYNCHRONOUS_DNS_MULTI_IP();
122 #endif
The Semaphore class is used to manage and protect access to a set of shared resources.
Definition: Semaphore.h:50
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:140
SocketAddress class.
Definition: SocketAddress.h:37
Common interface that is shared between network devices.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.