Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dns_tests.h Source File

dns_tests.h

00001 /*
00002  * Copyright (c) 2018, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef DNS_TESTS_H
00019 #define DNS_TESTS_H
00020 
00021 #ifndef MBED_CONF_APP_DNS_SIMULT_QUERIES
00022 #define MBED_CONF_APP_DNS_SIMULT_QUERIES   5
00023 #endif
00024 
00025 #ifndef MBED_CONF_NSAPI_DNS_CACHE_SIZE
00026 #define MBED_CONF_NSAPI_DNS_CACHE_SIZE     3
00027 #endif
00028 
00029 // Hostnames for testing against
00030 // Both lists must have A and AAAA records
00031 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS
00032 #define MBED_CONF_APP_DNS_TEST_HOSTS {"google.com", "youtube.com", "facebook.com", "wikipedia.org", "yahoo.com", "instagram.com"}
00033 #endif
00034 
00035 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS_SECOND
00036 #define MBED_CONF_APP_DNS_TEST_HOSTS_SECOND {"ipv6ready.org", "wireshark.org", "bbc.co.uk", "cnn.com", "www.flickr.com", "www.mozilla.org"}
00037 #endif
00038 
00039 #ifndef MBED_CONF_APP_DNS_TEST_HOSTS_NUM
00040 #define MBED_CONF_APP_DNS_TEST_HOSTS_NUM 6
00041 #endif
00042 
00043 #define DNS_TEST_HOST_LEN 40
00044 
00045 struct dns_application_data {
00046     rtos::Semaphore *semaphore;
00047     nsapi_error_t result;
00048     SocketAddress addr;
00049     nsapi_error_t req_result;
00050     bool value_set;
00051 };
00052 
00053 extern const char dns_test_hosts[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
00054 extern const char dns_test_hosts_second[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
00055 
00056 /*
00057  * Utility functions
00058  */
00059 NetworkInterface *get_interface();
00060 void hostbyname_cb(void *data, nsapi_error_t result, SocketAddress *address);
00061 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);
00062 
00063 /*
00064  * Test cases
00065  */
00066 void ASYNCHRONOUS_DNS();
00067 void ASYNCHRONOUS_DNS_SIMULTANEOUS();
00068 void ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE();
00069 void ASYNCHRONOUS_DNS_CACHE();
00070 void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC();
00071 void ASYNCHRONOUS_DNS_CANCEL();
00072 void ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE();
00073 void ASYNCHRONOUS_DNS_INVALID_HOST();
00074 void ASYNCHRONOUS_DNS_TIMEOUTS();
00075 void ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT();
00076 
00077 #endif