This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[APPROVE?] DNS test fixes


The DNS tests use hard coded addresses that can't work anywhere outside of the now dismantled Red Hat test farm. This is annoying for people using the config tool to test.

So where possible we should use the info from BOOTP. This patch does that, with an option of falling back to a hard-coded address which will likely fail (arguably a good thing in that case).

This still isn't brilliant though as we lose the test for the FQDN being correct, but I think it'll have to do.

We could probably do this better if there was some well known public DNS server we could use that _didn't_ require recursion support in the client. This is what most ISPs do, but those aren't public :-|. The root servers are public but require recursion support. We could implement recursion support but it would take a little while, and we'd probably want it to be a config option anyway.

So I'll apply to trunk for sure... and is this okay for branch?

Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine
Index: tests/dns1.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ns/dns/current/tests/dns1.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 dns1.c
--- tests/dns1.c	10 Jan 2003 14:58:25 -0000	1.3
+++ tests/dns1.c	3 Mar 2003 17:26:35 -0000
@@ -66,43 +66,51 @@ static cyg_thread thread_data;
 static cyg_handle_t thread_handle;
 
 #define __string(_x) #_x
 #define __xstring(_x) __string(_x)
 
-#define _DNS_IP            __xstring(172.16.19.254) // farmnet dns0 address
-#define _LOOKUP_FQDN       __xstring(dell-paw-2.cambridge.redhat.com.)
-#define _LOOKUP_DOMAINNAME __xstring(cambridge.redhat.com)
-#define _LOOKUP_HOSTNAME   __xstring(dell-paw-2)
-#define _LOOKUP_IP         __xstring(195.224.55.226)
+// Change the following if you aren't using BOOTP! It's almost certainly not right for you.
+#define _DNS_IP            __xstring(172.16.1.254) // test farm host addr
+#define _LOOKUP_FQDN       __xstring(b.root-servers.net.) // should stay the same?
+#define _LOOKUP_DOMAINNAME __xstring(root-servers.net.)
+#define _LOOKUP_HOSTNAME   __xstring(b)
+#define _LOOKUP_IP         __xstring(128.9.0.107) // must be same as _LOOKUP_FQDN
 #define _LOOKUP_IP_BAD     __xstring(10.0.0.0)
 
 void
 dns_test(cyg_addrword_t p)
 {
     struct in_addr addr;
     struct hostent *hent;
     char dn[256];
+    int i;
 
     CYG_TEST_INIT();
 
     init_all_network_interfaces();
 
-    CYG_TEST_INFO("Connecting to DNS at " _DNS_IP);
-    inet_aton(_DNS_IP, &addr);
-    CYG_TEST_CHECK(cyg_dns_res_init(&addr) == 0, "Failed to initialize resolver");
+    CYG_TEST_INFO("Starting dns1 test");
+
     setdomainname(NULL,0);
     
-    /* Expect _LOOKUP_IP as the answer. This is a CNAME lookup */
-    inet_aton(_LOOKUP_IP, &addr);
-    hent = gethostbyname(_LOOKUP_FQDN);
-    if (hent != NULL) {
-        diag_printf("PASS:<%s is %s>\n", hent->h_name, inet_ntoa(*(struct in_addr *)hent->h_addr));
-        if (0 != memcmp((void*)&addr, (void*)(hent->h_addr), sizeof(struct in_addr))) {
-          diag_printf("FAIL:<expected " _LOOKUP_FQDN " to be " _LOOKUP_IP ">\n");
+    for (i=0; i<2; i++) {
+        /* Expect _LOOKUP_IP as the answer. This is a CNAME lookup */
+        inet_aton(_LOOKUP_IP, &addr);
+        hent = gethostbyname(_LOOKUP_FQDN);
+        if (hent != NULL) {
+            diag_printf("PASS:<%s is %s>\n", hent->h_name, inet_ntoa(*(struct in_addr *)hent->h_addr));
+            if (0 != memcmp((void*)&addr, (void*)(hent->h_addr), sizeof(struct in_addr))) {
+                diag_printf("FAIL:<expected " _LOOKUP_FQDN " to be " _LOOKUP_IP ">\n");
+            }
+            break;
+        } else {
+            diag_printf("FAIL:<Asked for " _LOOKUP_FQDN ". No answer: %s>\n", hstrerror(h_errno));
+            CYG_TEST_INFO("Retrying with explicit DNS server");
+            CYG_TEST_INFO("Connecting to DNS at " _DNS_IP);
+            inet_aton(_DNS_IP, &addr);
+            CYG_TEST_CHECK(cyg_dns_res_init(&addr) == 0, "Failed to initialize resolver");
         }
-    } else {
-        diag_printf("FAIL:<Asked for " _LOOKUP_FQDN ". No answer: %s>\n", hstrerror(h_errno));
     }
 
     /* Reverse lookup the _LOOKUP_IP addres, expect _LOOKUP_FQDN
        as the answer. */
     hent = gethostbyaddr((char *)&addr, sizeof(struct in_addr), AF_INET);
Index: tests/dns2.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ns/dns/current/tests/dns2.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 dns2.c
--- tests/dns2.c	18 Jan 2003 03:47:03 -0000	1.3
+++ tests/dns2.c	3 Mar 2003 17:26:35 -0000
@@ -66,15 +66,18 @@ static cyg_thread thread_data;
 static cyg_handle_t thread_handle;
 
 #define __string(_x) #_x
 #define __xstring(_x) __string(_x)
 
-#define _DNS_IP            __xstring(172.16.19.254) // farmnet dns0 address
-#define _LOOKUP_FQDN       __xstring(dell-paw-2.cambridge.redhat.com.)
-#define _LOOKUP_DOMAINNAME __xstring(cambridge.redhat.com)
-#define _LOOKUP_HOSTNAME   __xstring(dell-paw-2)
-#define _LOOKUP_IP         __xstring(195.224.55.226)
+#define USE_HARDCODED_DOMAIN 1
+
+// Change the following if you aren't using BOOTP! It's almost certainly not right for you.
+#define _DNS_IP            __xstring(172.16.1.254) // test farm host addr
+#define _LOOKUP_FQDN       __xstring(b.root-servers.net.) // should stay the same?
+#define _LOOKUP_DOMAINNAME __xstring(root-servers.net.)
+#define _LOOKUP_HOSTNAME   __xstring(b)
+#define _LOOKUP_IP         __xstring(128.9.0.107) // must be same as _LOOKUP_FQDN
 #define _LOOKUP_IP_BAD     __xstring(10.0.0.0)
 
 void
 dns_test(cyg_addrword_t p)
 {
@@ -84,14 +87,19 @@ dns_test(cyg_addrword_t p)
 
     CYG_TEST_INIT();
 
     init_all_network_interfaces();
 
+    CYG_TEST_INFO("Starting dns2 test");
+
     getdomainname(dn,sizeof(dn));
     diag_printf("INFO:<DHCP said domain name is %s>\n",dn);
+#ifndef USE_HARDCODED_DOMAIN
+    // If not hard-coded we can't tell what it's _meant_ to be
     CYG_TEST_CHECK(!strncmp(dn,_LOOKUP_DOMAINNAME,sizeof(_LOOKUP_DOMAINNAME)),
                    "DHCP got the wrong domainname");
+#endif //ifdef _LOOKUP_DOMAINNAME
     
     /* Expect _LOOKUP_IP as the answer. This is a CNAME lookup */
     inet_aton(_LOOKUP_IP, &addr);
     hent = gethostbyname(_LOOKUP_FQDN);
     if (hent != NULL) {
@@ -102,10 +110,14 @@ dns_test(cyg_addrword_t p)
     } else {
         diag_printf("FAIL:<Asked for " _LOOKUP_FQDN ". No answer: %s>\n", hstrerror(h_errno));
     }
 
     /* Now just the hostname */
+#ifdef USE_HARDCODED_DOMAIN
+    // set the domain by hand if required.
+    setdomainname(_LOOKUP_DOMAINNAME, sizeof(_LOOKUP_DOMAINNAME));
+#endif //ifdef _LOOKUP_DOMAINNAME
     hent = gethostbyname(_LOOKUP_HOSTNAME);
     if (hent != NULL) {
         diag_printf("PASS:<%s is %s>\n", _LOOKUP_HOSTNAME, inet_ntoa(*(struct in_addr *)hent->h_addr));
     } else {
         diag_printf("FAIL:<Asked for " _LOOKUP_HOSTNAME ". No answer: %s>\n", hstrerror(h_errno));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]