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