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 // Hostnames for testing against
39 // Both lists must have A and AAAA records
40 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS
41 #define MBED_CONF_APP_DNS_TEST_HOSTS {"google.com", "youtube.com", "facebook.com", "wikipedia.org", "yahoo.com", "instagram.com"}
42 #endif
43 
44 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS_SECOND
45 #define MBED_CONF_APP_DNS_TEST_HOSTS_SECOND {"ipv6ready.org", "wireshark.org", "bbc.co.uk", "cnn.com", "www.flickr.com", "www.mozilla.org"}
46 #endif
47 
48 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS_NUM
49 #define MBED_CONF_APP_DNS_TEST_HOSTS_NUM 6
50 #endif
51 
52 #define DNS_TEST_HOST_LEN 40
53 
55  rtos::Semaphore *semaphore;
56  nsapi_error_t result;
57  SocketAddress addr;
58  nsapi_error_t req_result;
59  bool value_set;
60 };
61 
62 extern const char dns_test_hosts[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
63 extern const char dns_test_hosts_second[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
64 
65 /*
66  * Utility functions
67  */
68 NetworkInterface *get_interface();
69 void hostbyname_cb(void *data, nsapi_error_t result, SocketAddress *address);
70 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);
71 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);
72 
73 namespace dns_global {
74 #ifdef MBED_GREENTEA_TEST_DNSSOCKET_TIMEOUT_S
75 static const int TESTS_TIMEOUT = MBED_GREENTEA_TEST_DNSSOCKET_TIMEOUT_S;
76 #else
77 static const int TESTS_TIMEOUT = 14 * 60;
78 #endif
79 }
80 
81 /*
82  * Test cases
83  */
84 void ASYNCHRONOUS_DNS();
85 void ASYNCHRONOUS_DNS_SIMULTANEOUS();
86 void ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE();
87 void ASYNCHRONOUS_DNS_CACHE();
88 void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC();
89 void ASYNCHRONOUS_DNS_CANCEL();
90 void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE();
91 void ASYNCHRONOUS_DNS_INVALID_HOST();
92 void ASYNCHRONOUS_DNS_TIMEOUTS();
93 void ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT();
94 void SYNCHRONOUS_DNS();
95 void SYNCHRONOUS_DNS_MULTIPLE();
96 void SYNCHRONOUS_DNS_CACHE();
97 void SYNCHRONOUS_DNS_INVALID();
98 #endif
The Semaphore class is used to manage and protect access to a set of shared resources.
Definition: Semaphore.h:47
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
SocketAddress class.
Definition: SocketAddress.h:35
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.