* [LTP] [PATCH] move gethost from tools to sendfile01
2013-11-11 14:08 ` chrubis
@ 2013-11-12 10:59 ` Simon Xu
2013-11-12 12:38 ` chrubis
0 siblings, 1 reply; 5+ messages in thread
From: Simon Xu @ 2013-11-12 10:59 UTC (permalink / raw)
To: ltp-list
Move tools/gethost.c to
testcases/network/tcp_cmds/sendfile/sendfile01_gethost.c
since sendfile01 is the only test that requires gethost.
Signed-off-by: Simon Xu <xu.simon@oracle.com>
---
testcases/network/tcp_cmds/sendfile/Makefile | 4 +-
testcases/network/tcp_cmds/sendfile/sendfile01 | 4 +-
.../network/tcp_cmds/sendfile/sendfile01_gethost.c | 107 +++++++++++++++++++++
tools/gethost.c | 107 ---------------------
4 files changed, 111 insertions(+), 111 deletions(-)
create mode 100644 testcases/network/tcp_cmds/sendfile/sendfile01_gethost.c
delete mode 100644 tools/gethost.c
diff --git a/testcases/network/tcp_cmds/sendfile/Makefile b/testcases/network/tcp_cmds/sendfile/Makefile
index a8b0736..7ba2d7a 100644
--- a/testcases/network/tcp_cmds/sendfile/Makefile
+++ b/testcases/network/tcp_cmds/sendfile/Makefile
@@ -27,9 +27,9 @@ include $(abs_srcdir)/../Makefile.inc
CPPFLAGS += -I$(abs_srcdir)/../include
-INSTALL_TARGETS := sendfile01 sendfile01_server
+INSTALL_TARGETS := sendfile01 sendfile01_server sendfile01_gethost
-MAKE_TARGETS += testsf_c testsf_s testsf_c6 testsf_s6
+MAKE_TARGETS += testsf_c testsf_s testsf_c6 testsf_s6 sendfile01_gethost
testsf_c6.o testsf_s6.o: CPPFLAGS += -DINET6
diff --git a/testcases/network/tcp_cmds/sendfile/sendfile01 b/testcases/network/tcp_cmds/sendfile/sendfile01
index ba61873..ebeb182 100755
--- a/testcases/network/tcp_cmds/sendfile/sendfile01
+++ b/testcases/network/tcp_cmds/sendfile/sendfile01
@@ -59,9 +59,9 @@ do_setup()
tst_setup
- exists awk diff gethost grep rsh stat
+ exists awk diff sendfile01_gethost grep rsh stat
- if ! IPADDR=$(gethost ${EXEC_SUFFIX:+6} $RHOST | awk 'BEGIN { ec=1 } /addresses:/ {print $2; ec=0 } END { exit ec }'); then
+ if ! IPADDR=$(sendfile01_gethost ${EXEC_SUFFIX:+6} $RHOST | awk 'BEGIN { ec=1 } /addresses:/ {print $2; ec=0 } END { exit ec }'); then
# XXX (garrcoop): || exit 1 is there to prevent the test from hanging in the event of an install error.
end_testcase "Failed to determine the appropriate IP address for the machine." || exit 1
fi
diff --git a/testcases/network/tcp_cmds/sendfile/sendfile01_gethost.c b/testcases/network/tcp_cmds/sendfile/sendfile01_gethost.c
new file mode 100644
index 0000000..5b9a790
--- /dev/null
+++ b/testcases/network/tcp_cmds/sendfile/sendfile01_gethost.c
@@ -0,0 +1,107 @@
+/* host - print information about a host
+ * originally written by Paul Vixie @DEC WRL, January 1989
+ */
+
+/* DECWRL Header: host.c,v 1.1 89/04/05 15:41:12 vixie Locked $ */
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+#include <stdio.h>
+#include <resolv.h>
+#include <netdb.h>
+#include <syslog.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef LOG_PERROR
+#define LOG_PERROR 0
+#endif
+
+int main(argc, argv)
+int argc;
+char **argv;
+{
+ u_char b_addr[IN6ADDRSZ];
+ struct hostent *host;
+ char **ap, **cp, *arg;
+ const char *prog = "amnesia";
+ int af = AF_INET;
+ int size = INADDRSZ;
+ int force = 0;
+
+ if (argc < 1) {
+usage:
+ printf("usage: %s [-d] [-6] [-f] (hostname|ipaddr)\n", prog);
+ exit(1);
+ }
+ prog = *argv++;
+ argc--;
+#ifdef LOG_USER
+ openlog(prog, LOG_PERROR, LOG_USER);
+#else
+ openlog(prog, LOG_PERROR);
+#endif
+ res_init();
+
+ if (argc >= 1 && !strcmp(*argv, "-d")) {
+ _res.options |= RES_DEBUG;
+ argv++, argc--;
+ }
+ if (argc >= 1 && !strcmp(*argv, "-6")) {
+ af = AF_INET6, size = IN6ADDRSZ;
+ _res.options |= RES_USE_INET6;
+ argv++, argc--;
+ }
+ if (argc >= 1 && !strcmp(*argv, "-f")) {
+ force++;
+ argv++, argc--;
+ }
+
+ if (argc < 1)
+ goto usage;
+ arg = *argv++;
+ argc--;
+
+ if (inet_pton(af, arg, b_addr)) {
+ char p[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+
+ printf("[%s]\n", inet_ntop(af, b_addr, p, sizeof p));
+ if (!(host = gethostbyaddr((char *)b_addr, size, af))) {
+ herror("gethostbyaddr");
+ exit(1);
+ }
+ } else {
+ printf("{%s}\n", arg);
+ if (force)
+ host = gethostbyname2(arg, af);
+ else
+ host = gethostbyname(arg);
+ if (!host) {
+ herror("gethostbyname*");
+ exit(1);
+ }
+ }
+ printf("name: %s\n", host->h_name);
+ if (host->h_aliases && *host->h_aliases) {
+ printf("aliases:");
+ for (cp = (char **)host->h_aliases; *cp; cp++)
+ printf(" %s", *cp);
+ printf("\n");
+ }
+ if (host->h_addr_list && *host->h_addr_list) {
+ printf("addresses:");
+ for (ap = host->h_addr_list; *ap; ap++) {
+ char p[sizeof
+ "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+
+ printf(" %s", inet_ntop(host->h_addrtype,
+ *ap, p, sizeof p));
+ }
+ printf("\n");
+ }
+ exit(0);
+}
diff --git a/tools/gethost.c b/tools/gethost.c
deleted file mode 100644
index 5b9a790..0000000
--- a/tools/gethost.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* host - print information about a host
- * originally written by Paul Vixie @DEC WRL, January 1989
- */
-
-/* DECWRL Header: host.c,v 1.1 89/04/05 15:41:12 vixie Locked $ */
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <stdio.h>
-#include <resolv.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef LOG_PERROR
-#define LOG_PERROR 0
-#endif
-
-int main(argc, argv)
-int argc;
-char **argv;
-{
- u_char b_addr[IN6ADDRSZ];
- struct hostent *host;
- char **ap, **cp, *arg;
- const char *prog = "amnesia";
- int af = AF_INET;
- int size = INADDRSZ;
- int force = 0;
-
- if (argc < 1) {
-usage:
- printf("usage: %s [-d] [-6] [-f] (hostname|ipaddr)\n", prog);
- exit(1);
- }
- prog = *argv++;
- argc--;
-#ifdef LOG_USER
- openlog(prog, LOG_PERROR, LOG_USER);
-#else
- openlog(prog, LOG_PERROR);
-#endif
- res_init();
-
- if (argc >= 1 && !strcmp(*argv, "-d")) {
- _res.options |= RES_DEBUG;
- argv++, argc--;
- }
- if (argc >= 1 && !strcmp(*argv, "-6")) {
- af = AF_INET6, size = IN6ADDRSZ;
- _res.options |= RES_USE_INET6;
- argv++, argc--;
- }
- if (argc >= 1 && !strcmp(*argv, "-f")) {
- force++;
- argv++, argc--;
- }
-
- if (argc < 1)
- goto usage;
- arg = *argv++;
- argc--;
-
- if (inet_pton(af, arg, b_addr)) {
- char p[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
-
- printf("[%s]\n", inet_ntop(af, b_addr, p, sizeof p));
- if (!(host = gethostbyaddr((char *)b_addr, size, af))) {
- herror("gethostbyaddr");
- exit(1);
- }
- } else {
- printf("{%s}\n", arg);
- if (force)
- host = gethostbyname2(arg, af);
- else
- host = gethostbyname(arg);
- if (!host) {
- herror("gethostbyname*");
- exit(1);
- }
- }
- printf("name: %s\n", host->h_name);
- if (host->h_aliases && *host->h_aliases) {
- printf("aliases:");
- for (cp = (char **)host->h_aliases; *cp; cp++)
- printf(" %s", *cp);
- printf("\n");
- }
- if (host->h_addr_list && *host->h_addr_list) {
- printf("addresses:");
- for (ap = host->h_addr_list; *ap; ap++) {
- char p[sizeof
- "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
-
- printf(" %s", inet_ntop(host->h_addrtype,
- *ap, p, sizeof p));
- }
- printf("\n");
- }
- exit(0);
-}
--
1.8.4.2
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread