[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Powerguru-commit] [SCM] powerguru branch, master, updated. 9751361af69f
From: |
Rob Savoye |
Subject: |
[Powerguru-commit] [SCM] powerguru branch, master, updated. 9751361af69ffa1b55188ba6235ff4d9fb84ca75 |
Date: |
Tue, 11 Dec 2018 21:33:59 -0500 (EST) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "powerguru".
The branch, master has been updated
via 9751361af69ffa1b55188ba6235ff4d9fb84ca75 (commit)
via 6e4e0ee051084ab6483f03e377ae4c43f9fc9830 (commit)
via 0a6cb05bbf82b562d53395bc32ea9c1562b26ac8 (commit)
via 56204654eda257f0710a478b220449d05ddbcb63 (commit)
from c1cc82e9d17c55fcd90118a52c6fdfcf0d04d3c5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=9751361af69ffa1b55188ba6235ff4d9fb84ca75
commit 9751361af69ffa1b55188ba6235ff4d9fb84ca75
Author: Rob Savoye <address@hidden>
Date: Tue Dec 11 19:33:39 2018 -0700
Make tcpip/tcputil tests work again.
diff --git a/testsuite/libtests/childtcpip.cc b/testsuite/libtests/childtcpip.cc
index 5bd4fad..534c969 100644
--- a/testsuite/libtests/childtcpip.cc
+++ b/testsuite/libtests/childtcpip.cc
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2005,2006-2018 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -33,18 +33,17 @@
#include <sys/types.h>
#include <cstdio>
#include <iostream>
+#include <vector>
#include "dejagnu.h"
#include "tcpip.h"
-using namespace std;
-
int verbosity;
static void usage (void);
bool waitforgdb = false;
-int proc_tests (string procname);
-int start_proc (string procname);
+int proc_tests (const std::string &procname);
+int start_proc (const std::string &procname);
TestState runtest;
@@ -53,120 +52,48 @@ main(int argc, char *argv[])
{
int c;
bool dump = false;
- string filespec;
- string procname, memname;
+ std::string filespec;
- while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
+ while ((c = getopt (argc, argv, "hdvs:")) != -1) {
switch (c) {
case 'h':
usage ();
break;
-
case 'd':
dump = true;
break;
-
case 's':
waitforgdb = true;
break;
-
case 'v':
verbosity++;
break;
-
- case 'm':
- memname = optarg;
- cerr << "Open " << memname << endl;
- break;
-
default:
usage ();
break;
}
}
- // get the file name from the command line
- if (optind < argc) {
- filespec = argv[optind];
- cout << "Will use \"" << filespec << "\" for test " << endl;
- }
-
-
Tcpip tcpip;
- const struct hostent *host;
- const struct servent *service;
- const struct in_addr *addr;
+ retcode_t ts = tcpip.createNetClient(DEFAULTPORT);
- char hostname[MAXHOSTNAMELEN];
- gethostname(hostname, MAXHOSTNAMELEN);
-
- // See if we can do host lookups
- host = tcpip.hostDataGet();
- addr = (struct in_addr *)host->h_addr_list[0];
+ tcpip.writeNet("foo");
- if (strcmp(host->h_name, hostname) == 0)
- runtest.pass ("Tcpip::hostDataGet()");
- else
- runtest.fail ("Tcpip::hostDataGet()");
+ std::vector<unsigned char> data;
+ tcpip.readNet(data);
+ if (data.size() > 0) {
+ std::cout << "Child read " << data.size() <<" bytes from parent:" <<
std::endl;
+ }
- if (host->h_name == tcpip.hostNameGet())
- runtest.pass ("Tcpip::hostNameGet()");
- else
- runtest.fail ("Tcpip::hostNameGet()");
-
- if ((in_addr_t *)host->h_addr_list[0] == tcpip.hostIPGet())
- runtest.pass ("Tcpip::hostIPGet()");
- else
- runtest.fail ("Tcpip::hostIPGet()");
-
-#if 0
-// cerr << "Name is " << host->h_name << " IP is "
-// << inet_ntoa(*(struct in_addr *)host->h_addr_list[0]) << endl;
-
- cerr << "childtcpip: Name is " << tcpip.hostNameGet() << " IP is " <<
- tcpip.hostIPNameGet() << endl;
-#endif
-
- // See if we can do service lookups
- service = tcpip.lookupService("powerguru", "tcp");
- if (strcmp(service->s_name, "powerguru") == 0 &&
- strcmp(service->s_proto, "tcp") == 0 &&
- ntohs(service->s_port) == 7654)
- runtest.pass ("Tcpip::lookupService()");
- else
- runtest.fail ("Tcpip::lookupService()");
-
- retcode_t ts = tcpip.createNetClient(7654);
- // retcode_t ts = tcpip.createNetClient("powerguru");
-
- char *buffer;
-
- buffer = (char *)new char[300];
- memset(buffer, 0, 300);
-
-// cerr << "Dump from child" << endl;
-// ts->dump();
-
- //ts->writeNet("Hello World!\n");
-
-#if 1
- int bytes;// = ts->readNet(buffer, 300);
-
- if (bytes > 0)
- {
- cout << "Child read from parent:" << endl << buffer << endl;
- }
-#endif
-
sleep(2);
}
static void
usage (void)
{
- cerr << "This program tests the Global memory system." << endl;
- cerr << "Usage: tglobal [h] filename" << endl;
- cerr << "-h\tHelp" << endl;
- cerr << "-d\tDump parsed data" << endl;
+ std::cerr << "This program tests the Global memory system." << std::endl;
+ std::cerr << "Usage: tglobal [h] filename" << std::endl;
+ std::cerr << "-h\tHelp" << std::endl;
+ std::cerr << "-d\tDump parsed data" << std::endl;
exit (-1);
}
diff --git a/testsuite/libtests/tcpip-test.cc b/testsuite/libtests/tcpip-test.cc
index 7d005d5..7d39362 100644
--- a/testsuite/libtests/tcpip-test.cc
+++ b/testsuite/libtests/tcpip-test.cc
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006-2018 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -38,8 +38,6 @@
#include "dejagnu.h"
#include "tcpip.h"
-using namespace std;
-
int verbosity;
static void usage (void);
bool waitforgdb = false;
@@ -47,20 +45,109 @@ static void cntrlc_handler (int);
static void alarm_handler (int);
static bool loop = true;
-int proc_tests (string procname);
-int start_proc (string procname);
+int
+start_proc (const std::string &procname);
TestState runtest;
+class Test : public Tcpip
+{
+public:
+ Test(void) {
+ // Get some system information needed to test the classes.
+ std::memset(_thost, 0, MAXHOSTNAMELEN);
+ if (gethostname(_thost, MAXHOSTNAMELEN) != 0) {
+ std::cerr << "ERROR: gethostname() failed!" << std::endl;
+ exit(-1);
+ }
+ if (_thost == 0) {
+ std::cerr << "ERROR: gethostbyname() failed!" << std::endl;
+ exit(-1);
+ }
+ _tservice = getservbyname("git", NULL);
+ if (_tservice == 0) {
+ std::cerr << "ERROR: getservbyname() failed!" << std::endl;
+ exit(-1);
+ }
+ };
+
+ ~Test(void) {
+ };
+
+ int test(void) {
+ // See if we can do service lookups
+ _tservice = lookupService("powerguru", "tcp");
+ if (_tservice != 0) {
+ if (strcmp(_tservice->s_name, "powerguru") == 0 &&
+ strcmp(_tservice->s_proto, "tcp") == 0 &&
+ _tservice->s_port == htons(7654))
+ runtest.pass ("lookupService(powerguru)");
+ else
+ runtest.fail ("lookupService(powerguru)");
+ } else {
+ runtest.fail ("lookupService(powerguru)");
+ }
+
+ createNetServer(7654);
+ int pid = start_proc("./childtcpip");
+
+ // sleep so the child process has time to run, and we have time
+ // to debug it. We setup a handler for ^C, so we can get out of
+ // this sleep when we're done.
+ if (waitforgdb) {
+ struct sigaction act2;
+ act2.sa_handler = cntrlc_handler;
+ sigaction (SIGINT, &act2, NULL);
+ sleep(300);
+ } else {
+ sleep(1);
+ }
+
+ int retries = 3;
+ while (retries-- > 0) {
+ retcode_t ts = newNetConnection(true);
+ if (ts) {
+ break;
+ } else {
+ // Under purify, things are very slow, so wait before retries
+ sleep(10);
+ }
+ }
+ struct sigaction act;
+ act.sa_handler = alarm_handler;
+ sigaction (SIGALRM, &act, NULL);
+ alarm(5);
+ std::cout << std::endl
+ << "Waiting 5 seconds for input from the child process..." <<
std::endl;
+
+ // Read data from the child process
+ std::vector<unsigned char> data;
+ readNet(data);
+
+ if (data.size() > 0) {
+ runtest.pass("Established netork connection");
+ } else {
+ runtest.fail("Established netork connection");
+ }
+
+ sleep(1);
+ closeNet();
+ };
+
+protected:
+ char _thost[MAXHOSTNAMELEN];
+ const struct servent *_tservice;
+ const struct protoent *_tproto;
+ const in_addr_t *_taddr;
+};
int
main(int argc, char *argv[])
{
int c;
bool dump = false;
- string filespec;
- string procname, memname;
+ std::string filespec;
+ std::string procname, memname;
char buffer[300];
- int retries = 3;
memset(buffer, 0, 300);
@@ -84,7 +171,7 @@ main(int argc, char *argv[])
case 'm':
memname = optarg;
- cerr << "Open " << memname << endl;
+ std::cerr << "Open " << memname << std::endl;
break;
default:
@@ -96,140 +183,55 @@ main(int argc, char *argv[])
// get the file name from the command line
if (optind < argc) {
filespec = argv[optind];
- cout << "Will use \"" << filespec << "\" for test " << endl;
- }
-
-
- Tcpip tcpip;
- const struct hostent *host;
-// struct protoent *proto;
- const struct servent *service;
- const struct protoent *proto;
- const struct in_addr *addr;
-
- char hostname[MAXHOSTNAMELEN];
- gethostname(hostname, MAXHOSTNAMELEN);
-
- // See if we can do host lookups
- host = tcpip.hostDataGet();
- if (host == 0)
- {
- runtest.fail ("Tcpip::hostDataGet()");
- cerr << "ERROR: no hostname! Tests can't continue" << endl;
- exit(1);
+ std::cout << "Will use \"" << filespec << "\" for test " << std::endl;
}
-
- addr = (struct in_addr *)host->h_addr_list[0];
-
-#if 1
-// cerr << "Name is " << host->h_name << " IP is "
-// << inet_ntoa(*(struct in_addr *)host->h_addr_list[0]) << endl;
-
- cerr << "tcpip: Name is " << tcpip.hostNameGet() << " IP is " <<
- tcpip.hostIPNameGet() << endl;
-#endif
-
- if (strcmp(host->h_name, hostname) == 0)
- runtest.pass ("Tcpip::hostDataGet()");
- else
- runtest.fail ("Tcpip::hostDataGet()");
-
- if (host->h_name == tcpip.hostNameGet())
- runtest.pass ("Tcpip::hostNameGet()");
- else
- runtest.fail ("Tcpip::hostNameGet()");
- if ((in_addr_t *)host->h_addr_list[0] == tcpip.hostIPGet())
- runtest.pass ("Tcpip::hostIPGet()");
- else
- runtest.fail ("Tcpip::hostIPGet()");
+ Test test;
+ test.test();
+#if 0
// See if we can do service lookups
service = tcpip.lookupService("powerguru", "tcp");
- if (strcmp(service->s_name, "powerguru") == 0 &&
- strcmp(service->s_proto, "tcp") == 0 &&
- service->s_port == htons(7654))
- runtest.pass ("Tcpip::lookupService(powerguru)");
- else
+ if (service != 0) {
+ if (strcmp(service->s_name, "powerguru") == 0 &&
+ strcmp(service->s_proto, "tcp") == 0 &&
+ service->s_port == htons(7654))
+ runtest.pass ("Tcpip::lookupService(powerguru)");
+ else
+ runtest.fail ("Tcpip::lookupService(powerguru)");
+ } else {
runtest.fail ("Tcpip::lookupService(powerguru)");
-
-// tcpip.toggleDebug(true);
+ }
+// tcpip.toggleDebug(true);
// See if we can do protocol lookups
proto = tcpip.protoDataGet();
- if (strcmp(proto->p_name, "tcp") == 0 &&
- proto->p_proto == 6)
- runtest.pass ("Tcpip::protoDataGet()");
- else
- runtest.fail ("Tcpip::protoDataGet()");
-
- if (tcpip.protoNameGet() == "tcp")
+ if (proto != 0) {
+ if (strcmp(proto->p_name, "tcp") == 0 &&
+ proto->p_proto == 6) {
+ runtest.pass ("Tcpip::protoDataGet()");
+ } else {
+ runtest.fail ("Tcpip::protoDataGet()");
+ }
+ } else {
+ runtest.fail ("Tcpip::protoDataGet()");
+ }
+ if (tcpip.protoNameGet() == "tcp") {
runtest.pass ("Tcpip::protoNameGet()");
- else
+ } else {
runtest.fail ("Tcpip::protoNameGet()");
-
- if (tcpip.protoNumGet() == 6)
+ }
+ if (tcpip.protoNumGet() == 6) {
runtest.pass ("Tcpip::protoNumGet()");
- else
- runtest.fail ("Tcpip::protoNumGet()");
-
- tcpip.createNetServer(7654);
- // tcpip.createNetServer("powerguru");
-
-#if 1
- int pid;
- // Run the memory tests between two processes
- if (procname.size() == 0)
- pid = start_proc("./childtcpip");
- else
- pid = proc_tests (procname);
-
- // sleep so the child process has time to run, and we have time to debug
it. We setup a
- // handler for ^C, so we can get out of this sleep when we're done.
- if (waitforgdb) {
- struct sigaction act2;
- act2.sa_handler = cntrlc_handler;
- sigaction (SIGINT, &act2, NULL);
- sleep(300);
} else {
- sleep(1);
+ runtest.fail ("Tcpip::protoNumGet()");
}
#endif
- while (retries-- > 0)
- {
- retcode_t ts = tcpip.newNetConnection(true);
- if (ts)
- break;
- else
- // Under purify, things are very slow, so wait before retries
- sleep(10);
- }
-
- struct sigaction act;
-
- act.sa_handler = alarm_handler;
- sigaction (SIGALRM, &act, NULL);
-
- alarm(5);
-
- cout << endl
- << "Waiting 5 seconds for input from the child process..." << endl;
-
- // int bytes = ts->readNet((char *)&buffer, 300);
- int bytes;
-
- if (bytes > 0)
- {
- cout << "Parent read from child" << endl << buffer << endl;
- }
- //ts->writeNet("FoobyDo!");
- sleep(1);
- tcpip.closeNet();
}
// Run the tests between two processes
int
-start_proc (string procname)
+start_proc (const std::string &procname)
{
struct stat procstats;
char *cmd_line[5];
@@ -238,7 +240,7 @@ start_proc (string procname)
// See if the file actually exists, otherwise we can't spawn it
if (stat(procname.c_str(), &procstats) == -1) {
- cerr << "Invalid filename \"" << procname << "\"" <<endl;
+ std::cerr << "Invalid filename \"" << procname << "\"" << std::endl;
perror(procname.c_str());
return -1;
}
@@ -258,13 +260,12 @@ start_proc (string procname)
// childpid is a positive integer, if we are the parent, and fork() worked
if (childpid > 0) {
- cerr << "Forked sucessfully, child process PID is " << childpid <<
endl;
+ std::cerr << "Forked sucessfully, child process PID is " << childpid
<< std::endl;
return childpid;
}
// childpid is -1, if the fork failed, so print out an error message
if (childpid == -1) {
- /* fork() failed */
perror(procname.c_str());
return -1;
}
@@ -272,41 +273,34 @@ start_proc (string procname)
// If we are the child, exec the new process, then go away
if (childpid == 0) {
// Start the desired executable
- cout << "Starting " << procname << " with " << cmd_line[0] << endl;
+ std::cout << "Starting " << procname << " with " << cmd_line[0] <<
std::endl;
ret = execv(procname.c_str(), cmd_line);
perror(procname.c_str());
exit(0);
}
return 0;
}
-
-// Run the memory tests between two processes
-int
-proc_tests (string procname)
-{
- return start_proc(procname);
-}
void
cntrlc_handler (int sig)
{
- cerr << "Got a ^C !" << endl;
+ std::cerr << "Got a ^C !" << std::endl;
}
void
alarm_handler (int sig)
{
- cerr << "Got an alarm signal !" << endl;
- cerr << "This is OK, we use it to end this test case." << endl;
+ std::cerr << "Got an alarm signal !" << std::endl;
+ std::cerr << "This is OK, we use it to end this test case." << std::endl;
loop = false;
}
static void
usage (void)
{
- cerr << "This program tests the Global memory system." << endl;
- cerr << "Usage: tglobal [h] filename" << endl;
- cerr << "-h\tHelp" << endl;
- cerr << "-d\tDump parsed data" << endl;
+ std::cerr << "This program tests the Global memory system." << std::endl;
+ std::cerr << "Usage: tglobal [h] filename" << std::endl;
+ std::cerr << "-h\tHelp" << std::endl;
+ std::cerr << "-d\tDump parsed data" << std::endl;
exit (-1);
}
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=6e4e0ee051084ab6483f03e377ae4c43f9fc9830
commit 6e4e0ee051084ab6483f03e377ae4c43f9fc9830
Author: Rob Savoye <address@hidden>
Date: Tue Dec 11 19:28:27 2018 -0700
Add all executables to be tested
diff --git a/testsuite/libtests/Makefile.am b/testsuite/libtests/Makefile.am
index ae38d94..2fd7804 100644
--- a/testsuite/libtests/Makefile.am
+++ b/testsuite/libtests/Makefile.am
@@ -1,5 +1,6 @@
#
-# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
Inc.
+# Copyright (C) 2005, 2006-2018
+# Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,27 +22,30 @@ AUTOMAKE_OPTIONS = dejagnu subdir-objects
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib $(LIBXML_CPPFLAGS)
$(PQ_CPPFLAGS) -DSRCDIR=\"$(srcdir)\"
-noinst_PROGRAMS = tcpip tutil childtcpip
+check_PROGRAMS = tcpip tutil childtcpip
+TESTS = $(check_PROGRAMS)
if BUILD_LIBXML
-noinst_PROGRAMS += xml-test
+check_PROGRAMS += xml-test cmd-test
endif
LOG = ../../lib/log.lo
if BUILD_LIBXML
+cmd_test_SOURCES = cmd-test.cc ../../lib/commands.cc ../../lib/xml.cc
+cmd_test_LDADD = $(LIBXML_LIBS) $(LOG)
xml_test_SOURCES = xml-test.cc ../../lib/xml.cc
xml_test_LDADD = $(LIBXML_LIBS) $(LOG)
endif
tcpip_SOURCES = tcpip-test.cc
-tcpip_LDADD = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) #
../../lib/libpguru.la
-tcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) #
../../lib/libpguru.la
+tcpip_LDADD = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG)
+tcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG)
tutil_SOURCES = tcputil-test.cc
-tutil_LDADD = ../../lib/tcputil.lo $(LOG) # ../../lib/libpguru.la
-tutil_DEPENDENCIES = ../../lib/tcputil.lo $(LOG) # ../../lib/libpguru.la
+tutil_LDADD = ../../lib/tcputil.lo $(LOG)
+tutil_DEPENDENCIES = ../../lib/tcputil.lo $(LOG)
childtcpip_SOURCES = childtcpip.cc
-childtcpip_LDADD = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) #
../../lib/libpguru.la
-childtcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) #
../../lib/libpguru.la
+childtcpip_LDADD = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG)
+childtcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG)
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=0a6cb05bbf82b562d53395bc32ea9c1562b26ac8
commit 0a6cb05bbf82b562d53395bc32ea9c1562b26ac8
Author: Rob Savoye <address@hidden>
Date: Tue Dec 11 18:33:03 2018 -0700
Initialize _addrinfo pointer too
diff --git a/lib/tcputil.cc b/lib/tcputil.cc
index 35654c9..43426eb 100644
--- a/lib/tcputil.cc
+++ b/lib/tcputil.cc
@@ -44,7 +44,8 @@ extern LogFile dbglogfile;
Tcputil::Tcputil(void)
: _service(0),
- _proto(0)
+ _proto(0),
+ _addrinfo(0)
{
// Get the hostname of this machine
char hostname[MAXHOSTNAMELEN];
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=56204654eda257f0710a478b220449d05ddbcb63
commit 56204654eda257f0710a478b220449d05ddbcb63
Author: Rob Savoye <address@hidden>
Date: Tue Dec 11 18:32:21 2018 -0700
Make new class that inherits from Tcputil we we can exaime protected
variables.
diff --git a/testsuite/libtests/tcputil-test.cc
b/testsuite/libtests/tcputil-test.cc
index ad716f1..c198be3 100644
--- a/testsuite/libtests/tcputil-test.cc
+++ b/testsuite/libtests/tcputil-test.cc
@@ -1,5 +1,6 @@
//
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006-2018
+// Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -33,6 +34,7 @@
#include <sys/types.h>
#include <cstdio>
#include <iostream>
+#include <netdb.h>
#include <sys/utsname.h>
#include "dejagnu.h"
@@ -46,6 +48,72 @@ int verbosity;
static void usage (void);
TestState runtest;
+const short DEFAULTPORT = 7654;
+
+class Test : public Tcputil
+{
+public:
+ Test(void) {
+ // Get some system information needed to test the classes.
+ std::memset(_thost, 0, MAXHOSTNAMELEN);
+ if (gethostname(_thost, MAXHOSTNAMELEN) != 0) {
+ std::cerr << "ERROR: gethostname() failed!" << std::endl;
+ exit(-1);
+ }
+
+ if (_thost == 0) {
+ std::cerr << "ERROR: gethostbyname() failed!" << std::endl;
+ exit(-1);
+ }
+
+ _tservice = getservbyname("git", NULL);
+ if (_tservice == 0) {
+ std::cerr << "ERROR: getservbyname() failed!" << std::endl;
+ exit(-1);
+ }
+ };
+
+ int test(void) {
+ if (numberOfInterfaces() >= 2) {
+ runtest.pass ("Tcputil::numberOfInterfaces()");
+ } else {
+ runtest.fail ("Tcputil::numberOfInterfaces()");
+ }
+
+ // Check the defaults
+ if (_hostname == _thost) {
+ runtest.pass ("Hostname is correct");
+ } else {
+ runtest.fail ("Hostname is not correct");
+ }
+
+ if (_service == 0) {
+ runtest.pass ("Service is correctly empty");
+ } else {
+ runtest.unresolved ("Service is not correctly empty");
+ }
+
+ // See if we can do service lookups
+ struct servent *serv = lookupService("ftp", "tcp");
+
+ if (strcmp(serv->s_name, "ftp") == 0 &&
+ strcmp(serv->s_proto, "tcp") == 0 &&
+ serv->s_port == ntohs(21)) {
+ runtest.pass ("Tcputil::lookupService(ftp)");
+ } else {
+ runtest.fail ("Tcputil::lookupService(ftp)");
+ }
+ };
+
+ ~Test(void) {
+ };
+
+protected:
+ char _thost[MAXHOSTNAMELEN];
+ const struct servent *_tservice;
+ const struct protoent *_tproto;
+ const in_addr_t *_taddr;
+};
int
main(int argc, char *argv[])
@@ -81,111 +149,8 @@ main(int argc, char *argv[])
cout << "Will use \"" << filespec << "\" for test " << endl;
}
- Tcputil tcputil;
- const struct hostent *host;
- const struct servent *service;
- const struct protoent *proto;
- const in_addr_t *addr;
-
- char hostname[MAXHOSTNAMELEN];
- gethostname(hostname, MAXHOSTNAMELEN);
-
-
- tcputil.toggleDebug(true);
-
- if (tcputil.numberOfInterfaces() >= 2)
- runtest.pass ("Tcputil::numberOfInterfaces()");
- else
- runtest.fail ("Tcputil::numberOfInterfaces()");
-
- // See if we can do host lookups
- host = tcputil.hostDataGet();
- addr = (in_addr_t *)host->h_addr_list[0];
-
-#if 0
-// cerr << "Name is " << host->h_name << " IP is "
-// << inet_ntoa(*(struct in_addr *)host->h_addr_list[0]) << endl;
-
- cerr << "tcputil: Name is " << tcputil.hostNameGet() << " IP is " <<
- tcputil.hostIPNameGet() << endl;
-#endif
-
- if (strcmp(host->h_name, hostname) == 0)
- runtest.pass ("Tcputil::hostDataGet()");
- else
- runtest.fail ("Tcputil::hostData(Get)");
-
- if (host->h_name == tcputil.hostNameGet())
- runtest.pass ("Tcputil::hostNameGet()");
- else
- runtest.fail ("Tcputil::hostNameGet()");
-
- if ((in_addr_t *)host->h_addr_list[0] == tcputil.hostIPGet())
- runtest.pass ("Tcputil::hostIPGet()");
- else
- runtest.fail ("Tcputil::hostIPGet()");
-
-
- // See if we can do service lookups
- service = tcputil.lookupService("ftp", "tcp");
-
- if (strcmp(service->s_name, "ftp") == 0 &&
- strcmp(service->s_proto, "tcp") == 0 &&
- service->s_port == ntohs(21))
- runtest.pass ("Tcputil::lookupService(ftp)");
- else
- runtest.fail ("Tcputil::lookupService(ftp)");
-
- // See if we can do protocol lookups
- proto = tcputil.protoDataGet();
- if (strcmp(proto->p_name, "tcp") == 0 &&
- proto->p_proto == 6)
- runtest.pass ("Tcputil::protoDataGet()");
- else
- runtest.fail ("Tcputil::protoDataGet()");
-
- if (tcputil.protoNameGet() == "tcp")
- runtest.pass ("Tcputil::protoNameGet()");
- else
- runtest.fail ("Tcputil::protoNameGet()");
-
- if (tcputil.protoNumGet() == 6)
- runtest.pass ("Tcputil::protoNumGet()");
- else
- runtest.fail ("Tcputil::protoNumGet()");
-
- if (tcputil.hostByAddrGet() == tcputil.hostNameGet())
- runtest.pass ("Tcputil::hostByAddrGet()");
- else
- runtest.fail ("Tcputil::hostByAddrGet()");
-
- // If we are using IP aliasing, test them all
- if (tcputil.numberOfInterfaces() > 2) {
- // Get the IP number, increment it, and then get the new name
- in_addr_t nodeaddr, netaddr;
- struct in_addr newaddr;
- nodeaddr = inet_lnaof(*(struct in_addr *)tcputil.hostIPGet());
- netaddr = inet_netof(*(struct in_addr *)tcputil.hostIPGet());
- nodeaddr++;
- newaddr = inet_makeaddr(netaddr, nodeaddr);
- string newname = inet_ntoa(newaddr);
-
- // Get the node name part of the default hostname and add a 1 to it.
- char *ptr = strchr(hostname, '.');
- *ptr++ = '1';
- *ptr++ = 0;
-
- // Get the new name, and strip off the domain part
- string nodename = tcputil.hostByAddrGet(newname).substr(0,
strlen(hostname));
-
- // the new node name should match the construct one. except on
- // machines in the ATC lab, which don't have multiple IP number
- // aliases.
- if ((nodename == hostname) || (nodename.substr(0, 3) == "atc"))
- runtest.pass ("Tcputil::hostByAddrGet(std::string)");
- else
- runtest.unresolved ("Tcputil::hostByAddrGet(std::string)");
- }
+ Test test;
+ test.test();
}
static void
-----------------------------------------------------------------------
Summary of changes:
lib/tcputil.cc | 3 +-
testsuite/libtests/Makefile.am | 22 +--
testsuite/libtests/childtcpip.cc | 107 +++-----------
testsuite/libtests/tcpip-test.cc | 278 ++++++++++++++++++-------------------
testsuite/libtests/tcputil-test.cc | 177 ++++++++++-------------
5 files changed, 239 insertions(+), 348 deletions(-)
hooks/post-receive
--
powerguru
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Powerguru-commit] [SCM] powerguru branch, master, updated. 9751361af69ffa1b55188ba6235ff4d9fb84ca75,
Rob Savoye <=