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