public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] rpc-tirpc: TI-RPC fixes
@ 2014-03-27 13:56 Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 1/7] rpc-tirpc: introduced a common library Stanislav Kholmanskikh
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Hi!

This series fixes errors in the "bottom level" and "expert level" test binaries.

After applying only these test cases may fail (from runtest/tirpc_tests):
tirpc_authsys_create           FAIL       1    
tirpc_authdes_create           FAIL       1    
tirpc_authdes_seccreate        FAIL       1    

Thanks.


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 1/7] rpc-tirpc: introduced a common library
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 2/7] rpc-tirpc: introduced bound_socket() Stanislav Kholmanskikh
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

This library will contain common functions and etc which may be used
by some of the binaries.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../network/rpc/rpc-tirpc/tests_pack/Makefile      |   16 ++++++++++++
 .../network/rpc/rpc-tirpc/tests_pack/Makefile.inc  |   18 +++++++++++++-
 .../network/rpc/rpc-tirpc/tests_pack/lib/Makefile  |   25 ++++++++++++++++++++
 .../rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c    |   17 +++++++++++++
 .../rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h    |   17 +++++++++++++
 5 files changed, 92 insertions(+), 1 deletions(-)
 create mode 100644 testcases/network/rpc/rpc-tirpc/tests_pack/lib/Makefile
 create mode 100644 testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c
 create mode 100644 testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile
index 6703ebb..d16e1ca 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile
@@ -19,5 +19,21 @@
 top_srcdir		?= ../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
+
+LIBDIR			:= lib
+FILTER_OUT_DIRS		:= $(LIBDIR)
+LIB			:= $(LIBDIR)/librpc-tirpc.a
+
+$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all
+
+trunk-clean:: | lib-clean
+
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
+
 include ./Makefile.inc
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc
index 8513677..636f0d1 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc
@@ -16,5 +16,21 @@
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 
-LDLIBS		+= $(TIRPC_LIBS) -lpthread
+LIBRELDIR	:= testcases/network/rpc/rpc-tirpc/tests_pack/lib
+LIBDIR		:= $(abs_top_builddir)/$(LIBRELDIR)
+LIBSRCDIR	:= $(abs_top_srcdir)/$(LIBRELDIR)
+LIBRPC-TIRPC	:= $(LIBDIR)/librpc-tirpc.a
+
+$(LIBDDIR):
+	mkdir -p "$@"
+
+$(LIBRPC-TIRPC): $(LIBDIR)
+	$(MAKE) -C $^ -f "$(LIBSRCDIR)/Makefile" all
+
+MAKE_DEPS	+= $(LIBRPC-TIRPC)
+
+LDLIBS		+= $(TIRPC_LIBS) -lpthread -lrpc-tirpc
+LDFLAGS		+= -L$(LIBDIR)
+
 CPPFLAGS	+= $(TIRPC_CPPFLAGS)
+CPPFLAGS	+= -I$(LIBSRCDIR)
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/Makefile
new file mode 100644
index 0000000..8afb3da
--- /dev/null
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/Makefile
@@ -0,0 +1,25 @@
+#
+#    Copyright (C) 2014, Oracle and/or its affiliates. All Rights Reserved.
+#
+#    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
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+top_srcdir		?= ../../../../../..
+
+include	$(top_srcdir)/include/mk/env_pre.mk
+
+LIB	:= librpc-tirpc.a
+
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c
new file mode 100644
index 0000000..68abbd8
--- /dev/null
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+ *
+ * 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 the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h
new file mode 100644
index 0000000..68abbd8
--- /dev/null
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+ *
+ * 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 the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 2/7] rpc-tirpc: introduced bound_socket()
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 1/7] rpc-tirpc: introduced a common library Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-04-29 13:15   ` chrubis
  2014-03-27 13:56 ` [LTP] [PATCH 3/7] rpc-tirpc: cleanup of the "bottom level" TI-RPC test binaries Stanislav Kholmanskikh
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

The "bottom level" TI-RPC functions require a bound network socket.

This function is to avoid code duplication.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c    |   52 ++++++++++++++++++++
 .../rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h    |   13 +++++
 2 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c
index 68abbd8..7bc4e32 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.c
@@ -15,3 +15,55 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/ip.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+int bound_socket(int domain, int type)
+{
+	int sock;
+	struct sockaddr_storage addr;
+	struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
+	struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr;
+	socklen_t slen;
+
+	switch (domain) {
+	case AF_INET:
+		addr4->sin_family = AF_INET;
+		addr4->sin_port = 0;
+		addr4->sin_addr.s_addr = INADDR_ANY;
+		slen = sizeof(*addr4);
+		break;
+
+	case AF_INET6:
+		addr6->sin6_family = AF_INET6;
+		addr6->sin6_port = 0;
+		addr6->sin6_addr = in6addr_any;
+		slen = sizeof(*addr6);
+		break;
+
+	default:
+		errno = EAFNOSUPPORT;
+		return -1;
+	}
+
+	if ((type != SOCK_STREAM) && (type != SOCK_DGRAM)) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	sock = socket(domain, type, 0);
+	if (sock < 0)
+		return -1;
+
+	if (bind(sock, (struct sockaddr *)&addr, slen) < 0) {
+		close(sock);
+		return -1;
+	}
+
+	return sock;
+}
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h
index 68abbd8..1293f2a 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/lib/librpc-tirpc.h
@@ -15,3 +15,16 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#ifndef __LIBRPC_TIRPC_H__
+#define __LIBRPC_TIRPC_H__
+
+/*
+ * Returns a network socket bound to an arbitrary port.
+ * domain - AF_INET or AF_INET6,
+ * type - SOCK_DGRAM, SOCK_STREAM
+ * Returns -1 if failed (with set errno)
+ */
+int bound_socket(int domain, int type);
+
+#endif /* __LIBRPC_TIRPC_H__ */
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 3/7] rpc-tirpc: cleanup of the "bottom level" TI-RPC test binaries
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 1/7] rpc-tirpc: introduced a common library Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 2/7] rpc-tirpc: introduced bound_socket() Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 4/7] rpc-tirpc: the "bottom level" fixes Stanislav Kholmanskikh
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../tirpc_bottomlevel_clnt_call.c                  |   34 +++---------------
 .../tirpc_clnt_dg_create.c                         |   37 +++----------------
 .../tirpc_clnt_vc_create.c                         |   33 +++--------------
 .../tirpc_svc_dg_create.c                          |   15 +-------
 .../tirpc_svc_vc_create.c                          |   15 +-------
 .../rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c |   30 +++-------------
 6 files changed, 27 insertions(+), 137 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
index 98450f3..2498965 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
@@ -33,24 +33,18 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 
-//Standard define
 #define PROCNUM 1
 #define VERSNUM 1
-
-//Sys define
 #define ADDRBUFSIZE 100
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
+	/*
+	 * argc[1] - HostName or Host IP
+	 * argc[2] - Server Program Number
+	 */
 
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	int progNum = atoi(argc[2]);
 	CLIENT *client = NULL;
 	struct netconfig *nconf = NULL;
@@ -61,19 +55,11 @@ int main(int argn, char *argc[])
 	int var_rec = -1;
 	struct timeval tv;
 
-	//Initialization
-	if (run_mode) {
-		printf("Before creation\n");
-		printf("client : %d\n", client);
-		printf("nconf : %d\n", nconf);
-	}
-
 	tv.tv_sec = 0;
 	tv.tv_usec = 100;
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
-		//syslog(LOG_ERR, "getnetconfigent for udp failed");
 		fprintf(stderr, "err nconf\n");
 		printf("5\n");
 		exit(1);
@@ -83,19 +69,11 @@ int main(int argn, char *argc[])
 	svcaddr.maxlen = ADDRBUFSIZE;
 	svcaddr.buf = addrbuf;
 
-	if (svcaddr.buf == NULL) {
-		/* if malloc() failed, print error messages and exit */
-		printf("5\n");
-		exit(1);
-	}
-	//printf("svcaddr reserved (%s)\n", argc[1]);
-
 	if (!rpcb_getaddr(progNum, VERSNUM, nconf, &svcaddr, argc[1])) {
 		fprintf(stderr, "rpcb_getaddr failed!!\n");
 		printf("5\n");
 		exit(1);
 	}
-	//printf("svc get\n");
 
 	client = clnt_dg_create(RPC_ANYFD, &svcaddr,
 				progNum, VERSNUM, 1024, 1024);
@@ -112,8 +90,6 @@ int main(int argn, char *argc[])
 
 	test_status = (cs == RPC_SUCCESS) ? 0 : 1;
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	clnt_destroy(client);
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c
index 6031d9b..88a86f8 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c
@@ -33,41 +33,26 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 
-//Standard define
 #define PROCNUM 1
 #define VERSNUM 1
-
-//Sys define
 #define ADDRBUFSIZE 100
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
+	/*
+	 * argc[1] - HostName or Host IP
+	 * argc[2] - Server Program Number
+	 */
 
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	int progNum = atoi(argc[2]);
 	CLIENT *client = NULL;
 	struct netconfig *nconf = NULL;
 	struct netbuf svcaddr;
 	char addrbuf[ADDRBUFSIZE];
-	bool_t rpcb_rslt;
-
-	//Initialization
-	if (run_mode) {
-		printf("Before creation\n");
-		printf("client : %d\n", client);
-		printf("nconf : %d\n", nconf);
-	}
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
-		//syslog(LOG_ERR, "getnetconfigent for udp failed");
 		fprintf(stderr, "err nconf\n");
 		printf("5\n");
 		exit(1);
@@ -77,26 +62,16 @@ int main(int argn, char *argc[])
 	svcaddr.maxlen = ADDRBUFSIZE;
 	svcaddr.buf = addrbuf;
 
-	if (svcaddr.buf == NULL) {
-		/* if malloc() failed, print error messages and exit */
-		printf("5\n");
-		return 1;
-	}
-	//printf("svcaddr reserved (%s)\n", argc[1]);
-
 	if (!rpcb_getaddr(progNum, VERSNUM, nconf, &svcaddr, argc[1])) {
 		fprintf(stderr, "rpcb_getaddr failed!!\n");
 		printf("5\n");
 		exit(1);
 	}
-	//printf("svc get\n");
 
 	client = clnt_dg_create(RPC_ANYFD, &svcaddr,
 				progNum, VERSNUM, 1024, 1024);
-	/**/ test_status = ((CLIENT *) client != NULL) ? 0 : 1;
+	test_status = ((CLIENT *) client != NULL) ? 0 : 1;
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c
index 855359a..e547f1f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c
@@ -42,32 +42,20 @@
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
+	/*
+	 * argc[1] - HostName or Host IP
+	 * argc[2] - Server Program Number
+	 */
 
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	int progNum = atoi(argc[2]);
 	CLIENT *client = NULL;
 	struct netconfig *nconf = NULL;
 	struct netbuf svcaddr;
 	char addrbuf[ADDRBUFSIZE];
-	bool_t rpcb_rslt;
-
-	//Initialization
-	if (run_mode) {
-		printf("Before creation\n");
-		printf("client : %d\n", client);
-		printf("nconf : %d\n", nconf);
-	}
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
-		//syslog(LOG_ERR, "getnetconfigent for udp failed");
 		printf("err nconf\n");
 		exit(1);
 	}
@@ -76,24 +64,15 @@ int main(int argn, char *argc[])
 	svcaddr.maxlen = ADDRBUFSIZE;
 	svcaddr.buf = addrbuf;
 
-	if (svcaddr.buf == NULL) {
-		/* if malloc() failed, print error messages and exit */
-		return 1;
-	}
-	//printf("svcaddr reserved (%s)\n", argc[1]);
-
 	if (!rpcb_getaddr(progNum, VERSNUM, nconf, &svcaddr, argc[1])) {
 		fprintf(stderr, "rpcb_getaddr failed!!\n");
 		exit(1);
 	}
-	//printf("svc get\n");
 
 	client = clnt_vc_create(RPC_ANYFD, &svcaddr,
 				progNum, VERSNUM, 1024, 1024);
-	/**/ test_status = ((CLIENT *) client != NULL) ? 0 : 1;
+	test_status = ((CLIENT *) client != NULL) ? 0 : 1;
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c
index 4ac17de..8f1953e 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c
@@ -33,28 +33,17 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 
-//Standard define
 #define PROCNUM 1
 #define VERSNUM 1
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
-
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	SVCXPRT *transp = NULL;
 
 	transp = svc_dg_create(RPC_ANYFD, 0, 0);
-	/**/ test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;
+	test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c
index ae83ee1..4245586 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c
@@ -33,28 +33,17 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 
-//Standard define
 #define PROCNUM 1
 #define VERSNUM 1
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
-
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	SVCXPRT *transp = NULL;
 
 	transp = svc_vc_create(RPC_ANYFD, 0, 0);
-	/**/ test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;
+	test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c
index cfab9b2..d75e2eb 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c
@@ -35,27 +35,17 @@
 #include <errno.h>
 #include <netinet/in.h>
 
-//Standard define
 #define VERSNUM 1
 #define PROCSIMPLEPING	1
 
-static void exm_proc();
+static void exm_proc(struct svc_req *rqstp, SVCXPRT *transp);
 
-//****************************************//
-//***           Main Function          ***//
-//****************************************//
 int main(int argn, char *argc[])
 {
-	//Server parameter is : argc[1] : Server Program Number
-	//                                          others arguments depend on server program
-	int run_mode = 0;
 	int progNum = atoi(argc[1]);
-	bool_t rslt;
 	SVCXPRT *transp = NULL;
 	struct netconfig *nconf;
-	struct netbuf svcaddr;
 
-	//Initialization
 	svc_unreg(progNum, VERSNUM);
 
 	if ((nconf = getnetconfigent("udp")) == NULL) {
@@ -83,37 +73,29 @@ int main(int argn, char *argc[])
 	return 1;
 }
 
-//****************************************//
-//***        Remotes Procedures        ***//
-//****************************************//
+/* Remote Procedures */
 char *simplePing(char *in)
 {
-	//printf("*** in Ping Func.\n");
-	//Simple function, returns what received
 	static int result = 0;
 	result = *in;
 	return (char *)&result;
 }
 
-//****************************************//
-//***       Dispatch Function          ***//
-//****************************************//
-static void exm_proc(struct svc_req *rqstp, SVCXPRT * transp)
+/* Dispatch Function */
+static void exm_proc(struct svc_req *rqstp, SVCXPRT *transp)
 {
-	//printf("* in Dispatch Func.\n");
 	union {
 		int varIn;
 	} argument;
 
 	char *result;
-	xdrproc_t xdr_argument;
-	xdrproc_t xdr_result;
+	xdrproc_t xdr_argument = NULL;
+	xdrproc_t xdr_result = NULL;
 	char *(*proc) (char *);
 
 	switch (rqstp->rq_proc) {
 	case PROCSIMPLEPING:
 		{
-			//printf("** in PROCPONG dispatch Func.\n");
 			xdr_argument = (xdrproc_t) xdr_int;
 			xdr_result = (xdrproc_t) xdr_int;
 			proc = (char *(*)(char *))simplePing;
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 4/7] rpc-tirpc: the "bottom level" fixes
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
                   ` (2 preceding siblings ...)
  2014-03-27 13:56 ` [LTP] [PATCH 3/7] rpc-tirpc: cleanup of the "bottom level" TI-RPC test binaries Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-04-29 13:19   ` chrubis
  2014-03-27 13:56 ` [LTP] [PATCH 5/7] rpc-tirpc: tirpc_svc_5 fixes Stanislav Kholmanskikh
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

The functions from the "bottom level" TI-RPC API:
 * svc_dg_create
 * svc_vc_create
 * clnt_dg_create
 * clnt_vc_create
do not accept RPC_ANYFD parameter. This parameter is for the "expert level" API.

These functions should be passed with a bound socket.

Implemented it using bound_socket() function.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../tirpc_bottomlevel_clnt_call.c                  |   18 ++++++++++++++--
 .../tirpc_clnt_dg_create.c                         |   16 ++++++++++++++-
 .../tirpc_clnt_vc_create.c                         |   18 +++++++++++++++-
 .../tirpc_svc_dg_create.c                          |   16 ++++++++++++++-
 .../tirpc_svc_vc_create.c                          |   21 +++++++++++++++++++-
 5 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
index 2498965..28d14ff 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
@@ -32,6 +32,8 @@
 #include <netinet/in.h>
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
+#include <unistd.h>
+#include "librpc-tirpc.h"
 
 #define PROCNUM 1
 #define VERSNUM 1
@@ -54,9 +56,10 @@ int main(int argn, char *argc[])
 	int var_snd = 10;
 	int var_rec = -1;
 	struct timeval tv;
+	int sock;
 
-	tv.tv_sec = 0;
-	tv.tv_usec = 100;
+	tv.tv_sec = 1;
+	tv.tv_usec = 0;
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
@@ -75,12 +78,19 @@ int main(int argn, char *argc[])
 		exit(1);
 	}
 
-	client = clnt_dg_create(RPC_ANYFD, &svcaddr,
+	sock = bound_socket(AF_INET, SOCK_DGRAM);
+	if (sock < 0) {
+		perror("bound_socket() failed");
+		exit(1);
+	}
+
+	client = clnt_dg_create(sock, &svcaddr,
 				progNum, VERSNUM, 1024, 1024);
 
 	if (client == NULL) {
 		clnt_pcreateerror("ERR");
 		printf("5\n");
+		close(sock);
 		exit(1);
 	}
 
@@ -94,5 +104,7 @@ int main(int argn, char *argc[])
 
 	clnt_destroy(client);
 
+	close(sock);
+
 	return test_status;
 }
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c
index 88a86f8..b38bc9e 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_dg_create/tirpc_clnt_dg_create.c
@@ -32,6 +32,8 @@
 #include <netinet/in.h>
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
+#include <unistd.h>
+#include "librpc-tirpc.h"
 
 #define PROCNUM 1
 #define VERSNUM 1
@@ -50,6 +52,7 @@ int main(int argn, char *argc[])
 	struct netconfig *nconf = NULL;
 	struct netbuf svcaddr;
 	char addrbuf[ADDRBUFSIZE];
+	int sock;
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
@@ -68,10 +71,21 @@ int main(int argn, char *argc[])
 		exit(1);
 	}
 
-	client = clnt_dg_create(RPC_ANYFD, &svcaddr,
+	sock = bound_socket(AF_INET, SOCK_DGRAM);
+	if (sock < 0) {
+		perror("bound_socket() failed");
+		exit(1);
+	}
+
+	client = clnt_dg_create(sock, &svcaddr,
 				progNum, VERSNUM, 1024, 1024);
 	test_status = ((CLIENT *) client != NULL) ? 0 : 1;
 
+	if (client != NULL)
+		clnt_destroy(client);
+
+	close(sock);
+
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c
index e547f1f..acbb55f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_vc_create/tirpc_clnt_vc_create.c
@@ -32,6 +32,8 @@
 #include <netinet/in.h>
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
+#include <unistd.h>
+#include "librpc-tirpc.h"
 
 //Standard define
 #define PROCNUM 1
@@ -53,8 +55,9 @@ int main(int argn, char *argc[])
 	struct netconfig *nconf = NULL;
 	struct netbuf svcaddr;
 	char addrbuf[ADDRBUFSIZE];
+	int sock;
 
-	nconf = getnetconfigent("udp");
+	nconf = getnetconfigent("tcp");
 	if (nconf == (struct netconfig *)NULL) {
 		printf("err nconf\n");
 		exit(1);
@@ -69,10 +72,21 @@ int main(int argn, char *argc[])
 		exit(1);
 	}
 
-	client = clnt_vc_create(RPC_ANYFD, &svcaddr,
+	sock = bound_socket(AF_INET, SOCK_DGRAM);
+	if (sock < 0) {
+		perror("bound_socket() failed");
+		exit(1);
+	}
+
+	client = clnt_vc_create(sock, &svcaddr,
 				progNum, VERSNUM, 1024, 1024);
 	test_status = ((CLIENT *) client != NULL) ? 0 : 1;
 
+	if (client != NULL)
+		clnt_destroy(client);
+
+	close(sock);
+
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c
index 8f1953e..b93e4d6 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_dg_create/tirpc_svc_dg_create.c
@@ -32,6 +32,8 @@
 #include <netinet/in.h>
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
+#include <unistd.h>
+#include "librpc-tirpc.h"
 
 #define PROCNUM 1
 #define VERSNUM 1
@@ -40,10 +42,22 @@ int main(int argn, char *argc[])
 {
 	int test_status = 1;
 	SVCXPRT *transp = NULL;
+	int sock;
 
-	transp = svc_dg_create(RPC_ANYFD, 0, 0);
+	sock = bound_socket(AF_INET, SOCK_DGRAM);
+	if (sock < 0) {
+		perror("bound_socket() failed");
+		return 1;
+	}
+
+	transp = svc_dg_create(sock, 0, 0);
 	test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;
 
+	if (transp != NULL)
+		svc_destroy(transp);
+
+	close(sock);
+
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c
index 4245586..491ac82 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_svc_vc_create/tirpc_svc_vc_create.c
@@ -32,6 +32,8 @@
 #include <netinet/in.h>
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
+#include <unistd.h>
+#include "librpc-tirpc.h"
 
 #define PROCNUM 1
 #define VERSNUM 1
@@ -40,10 +42,27 @@ int main(int argn, char *argc[])
 {
 	int test_status = 1;
 	SVCXPRT *transp = NULL;
+	int sock;
 
-	transp = svc_vc_create(RPC_ANYFD, 0, 0);
+	sock = bound_socket(AF_INET, SOCK_STREAM);
+	if (sock < 0) {
+		perror("bound_socket() failed");
+		return 1;
+	}
+
+	if (listen(sock, 10) < 0) {
+		perror("listen() failed");
+		return 1;
+	}
+
+	transp = svc_vc_create(sock, 0, 0);
 	test_status = ((SVCXPRT *) transp != NULL) ? 0 : 1;
 
+	if (transp != NULL)
+		svc_destroy(transp);
+
+	close(sock);
+
 	printf("%d\n", test_status);
 
 	return test_status;
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 5/7] rpc-tirpc: tirpc_svc_5 fixes
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
                   ` (3 preceding siblings ...)
  2014-03-27 13:56 ` [LTP] [PATCH 4/7] rpc-tirpc: the "bottom level" fixes Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 6/7] rpc-tirpc: tirpc_rpcb_set and tirpc_rpcb_unset cleanup Stanislav Kholmanskikh
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

This server binary has the following problems:
 * uses the "bottom level" API with RPC_ANYFD parameter (it violates the API)
 * the clients of tirpc_svc_5 use not only the UDP protocol, but TCP too. But the
   server does not listen a TCP port.

Fixed them.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c |   80 ++++++++++++++++----
 1 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c
index d75e2eb..c899d0f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/tirpc_svc_5.c
@@ -1,5 +1,6 @@
 /*
 * Copyright (c) Bull S.A.  2007 All Rights Reserved.
+* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
@@ -34,42 +35,93 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 #include <netinet/in.h>
+#include <unistd.h>
+#include "librpc-tirpc.h"
 
 #define VERSNUM 1
 #define PROCSIMPLEPING	1
 
+struct server_def_t {
+	SVCXPRT *transp;
+	struct netconfig *nconf;
+	char netid[4];
+	int domain;
+	int type;
+	int sock;
+	SVCXPRT *(*svc_func)(const int, const u_int, const u_int);
+};
+
+static struct server_def_t server_defs[] = {
+	{ NULL, NULL, "tcp", AF_INET, SOCK_STREAM, -1, svc_vc_create },
+	{ NULL, NULL, "udp", AF_INET, SOCK_DGRAM, -1, svc_dg_create },
+};
+
+static int server_instances = sizeof(server_defs) / sizeof(*server_defs);
+
 static void exm_proc(struct svc_req *rqstp, SVCXPRT *transp);
 
 int main(int argn, char *argc[])
 {
 	int progNum = atoi(argc[1]);
-	SVCXPRT *transp = NULL;
-	struct netconfig *nconf;
+	int i;
+	struct server_def_t *this;
 
 	svc_unreg(progNum, VERSNUM);
 
-	if ((nconf = getnetconfigent("udp")) == NULL) {
-		fprintf(stderr, "Cannot get netconfig entry for UDP\n");
-		exit(1);
-	}
+	for (i = 0; i < server_instances; i++) {
+		this = &(server_defs[i]);
 
-	transp = svc_vc_create(RPC_ANYFD, 1024, 1024);
+		this->nconf = getnetconfigent(this->netid);
+		if (this->nconf == NULL) {
+			fprintf(stderr, "Cannot get a netconfig entry for %s",
+				this->netid);
+			goto cleanup;
+		}
 
-	if (transp == NULL) {
-		fprintf(stderr, "Cannot create service.\n");
-		exit(1);
-	}
+		this->sock = bound_socket(this->domain, this->type);
+		if (this->sock < 0) {
+			perror("bound_socket() failed");
+			goto cleanup;
+		}
 
-	if (!svc_reg(transp, progNum, VERSNUM, exm_proc, nconf)) {
-		fprintf(stderr, "svc_reg failed!!\n");
-		exit(1);
+		if (this->type == SOCK_STREAM) {
+			if (listen(this->sock, 10) < 0) {
+				perror("listen() failed");
+				goto cleanup;
+			}
+		}
+
+		this->transp = this->svc_func(this->sock, 1024, 1024);
+		if (this->transp == NULL) {
+			fprintf(stderr, "Cannot create service.\n");
+			goto cleanup;
+		}
+
+		if (!svc_reg(this->transp, progNum, VERSNUM,
+				exm_proc, this->nconf)) {
+			fprintf(stderr, "svc_reg failed!!\n");
+			goto cleanup;
+		}
 	}
 
+
 	svc_run();
 
 	fprintf(stderr, "svc_run() returned.  ERROR has occurred.\n");
+
+cleanup:
 	svc_unreg(progNum, VERSNUM);
 
+	for (i = 0; i < server_instances; i++) {
+		this = &(server_defs[i]);
+
+		if (this->transp != NULL)
+			svc_destroy(this->transp);
+
+		if (this->sock >= 0)
+			close(this->sock);
+	}
+
 	return 1;
 }
 
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 6/7] rpc-tirpc: tirpc_rpcb_set and tirpc_rpcb_unset cleanup
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
                   ` (4 preceding siblings ...)
  2014-03-27 13:56 ` [LTP] [PATCH 5/7] rpc-tirpc: tirpc_svc_5 fixes Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-03-27 13:56 ` [LTP] [PATCH 7/7] rpc-tirpc: fix arguments to rpcb_set and rpcb_unset test cases Stanislav Kholmanskikh
  2014-04-29 13:27 ` [LTP] rpc-tirpc: TI-RPC fixes chrubis
  7 siblings, 0 replies; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c    |   22 ++++--------------
 .../tirpc_rpcb_unset.c                             |   23 ++++---------------
 2 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c
index 4b60586..eb42618 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c
@@ -33,35 +33,25 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 
-//Standard define
 #define PROCNUM 1
 #define VERSNUM 1
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
+	/*
+	 * argc[1] - HostName or Host IP
+	 * argc[2] - Server Program Number
+	 */
 
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	int progNum = atoi(argc[2]);
 	SVCXPRT *transp = NULL;
 	struct netconfig *nconf = NULL;
 	struct netbuf svcaddr;
 
-	//Initialization
-	if (run_mode) {
-		printf("Before creation\n");
-		printf("nconf : %d\n", nconf);
-	}
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
-		//syslog(LOG_ERR, "getnetconfigent for udp failed");
 		printf("err nconf\n");
 		exit(1);
 	}
@@ -70,8 +60,6 @@ int main(int argn, char *argc[])
 
 	test_status = !rpcb_set(progNum, VERSNUM, nconf, &svcaddr);
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	return test_status;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c
index 75155cf..adb951f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c
@@ -33,35 +33,24 @@
 #include <tirpc/rpc/svc.h>
 #include <errno.h>
 
-//Standard define
 #define PROCNUM 1
 #define VERSNUM 1
 
 int main(int argn, char *argc[])
 {
-	//Program parameters : argc[1] : HostName or Host IP
-	//                                         argc[2] : Server Program Number
-	//                                         other arguments depend on test case
+	/*
+	 * argc[1] - HostName or Host IP
+	 * argc[2] - Server Program Number
+	 */
 
-	//run_mode can switch into stand alone program or program launch by shell script
-	//1 : stand alone, debug mode, more screen information
-	//0 : launch by shell script as test case, only one printf -> result status
-	int run_mode = 0;
-	int test_status = 1;	//Default test result set to FAILED
+	int test_status = 1;
 	int progNum = atoi(argc[2]);
 	SVCXPRT *transp = NULL;
 	struct netconfig *nconf = NULL;
 	struct netbuf svcaddr;
 
-	//Initialization
-	if (run_mode) {
-		printf("Before creation\n");
-		printf("nconf : %d\n", nconf);
-	}
-
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
-		//syslog(LOG_ERR, "getnetconfigent for udp failed");
 		printf("err nconf\n");
 		exit(1);
 	}
@@ -72,8 +61,6 @@ int main(int argn, char *argc[])
 
 	test_status = !rpcb_unset(progNum, VERSNUM, nconf);
 
-	//This last printf gives the result status to the tests suite
-	//normally should be 0: test has passed or 1: test has failed
 	printf("%d\n", test_status);
 
 	return test_status;
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 7/7] rpc-tirpc: fix arguments to rpcb_set and rpcb_unset test cases
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
                   ` (5 preceding siblings ...)
  2014-03-27 13:56 ` [LTP] [PATCH 6/7] rpc-tirpc: tirpc_rpcb_set and tirpc_rpcb_unset cleanup Stanislav Kholmanskikh
@ 2014-03-27 13:56 ` Stanislav Kholmanskikh
  2014-04-29 13:27 ` [LTP] rpc-tirpc: TI-RPC fixes chrubis
  7 siblings, 0 replies; 11+ messages in thread
From: Stanislav Kholmanskikh @ 2014-03-27 13:56 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Both testcases utilise an unset variable - svcaddr.
It's incorrect.

Also added some simple checks of the transport creation.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c    |   13 ++++++++++---
 .../tirpc_rpcb_unset.c                             |   10 ++++++++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c
index eb42618..f68b045 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_set/tirpc_rpcb_set.c
@@ -47,8 +47,6 @@ int main(int argn, char *argc[])
 	int progNum = atoi(argc[2]);
 	SVCXPRT *transp = NULL;
 	struct netconfig *nconf = NULL;
-	struct netbuf svcaddr;
-
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
@@ -57,8 +55,17 @@ int main(int argn, char *argc[])
 	}
 
 	transp = svc_tli_create(RPC_ANYFD, nconf, (struct t_bind *)NULL, 0, 0);
+	if (transp == NULL) {
+		printf("svc_tli_create() failed\n");
+		exit(1);
+	}
 
-	test_status = !rpcb_set(progNum, VERSNUM, nconf, &svcaddr);
+	test_status = !rpcb_set(progNum, VERSNUM, nconf, &(transp->xp_ltaddr));
+
+	if (!rpcb_unset(progNum, VERSNUM, nconf)) {
+		printf("rpcb_unset() failed\n");
+		exit(1);
+	}
 
 	printf("%d\n", test_status);
 
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c
index adb951f..9e3d67f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_expertlevel_rpcb_unset/tirpc_rpcb_unset.c
@@ -47,7 +47,6 @@ int main(int argn, char *argc[])
 	int progNum = atoi(argc[2]);
 	SVCXPRT *transp = NULL;
 	struct netconfig *nconf = NULL;
-	struct netbuf svcaddr;
 
 	nconf = getnetconfigent("udp");
 	if (nconf == (struct netconfig *)NULL) {
@@ -56,8 +55,15 @@ int main(int argn, char *argc[])
 	}
 
 	transp = svc_tli_create(RPC_ANYFD, nconf, (struct t_bind *)NULL, 0, 0);
+	if (transp == NULL) {
+		printf("svc_tli_create() failed\n");
+		exit(1);
+	}
 
-	rpcb_set(progNum, VERSNUM, nconf, &svcaddr);
+	if (!rpcb_set(progNum, VERSNUM, nconf, &(transp->xp_ltaddr))) {
+		printf("rpcb_set() failed\n");
+		exit(1);
+	}
 
 	test_status = !rpcb_unset(progNum, VERSNUM, nconf);
 
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 2/7] rpc-tirpc: introduced bound_socket()
  2014-03-27 13:56 ` [LTP] [PATCH 2/7] rpc-tirpc: introduced bound_socket() Stanislav Kholmanskikh
@ 2014-04-29 13:15   ` chrubis
  0 siblings, 0 replies; 11+ messages in thread
From: chrubis @ 2014-04-29 13:15 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> The "bottom level" TI-RPC functions require a bound network socket.
> 
> This function is to avoid code duplication.

I would personaly merge this patch with the previous one. It does not
make much sense to create empty library :)

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 4/7] rpc-tirpc: the "bottom level" fixes
  2014-03-27 13:56 ` [LTP] [PATCH 4/7] rpc-tirpc: the "bottom level" fixes Stanislav Kholmanskikh
@ 2014-04-29 13:19   ` chrubis
  0 siblings, 0 replies; 11+ messages in thread
From: chrubis @ 2014-04-29 13:19 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> The functions from the "bottom level" TI-RPC API:
>  * svc_dg_create
>  * svc_vc_create
>  * clnt_dg_create
>  * clnt_vc_create
> do not accept RPC_ANYFD parameter. This parameter is for the "expert level" API.
> 
> These functions should be passed with a bound socket.
> 
> Implemented it using bound_socket() function.
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
>  .../tirpc_bottomlevel_clnt_call.c                  |   18 ++++++++++++++--
>  .../tirpc_clnt_dg_create.c                         |   16 ++++++++++++++-
>  .../tirpc_clnt_vc_create.c                         |   18 +++++++++++++++-
>  .../tirpc_svc_dg_create.c                          |   16 ++++++++++++++-
>  .../tirpc_svc_vc_create.c                          |   21 +++++++++++++++++++-
>  5 files changed, 81 insertions(+), 8 deletions(-)
> 
> diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
> index 2498965..28d14ff 100644
> --- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
> +++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_bottomlevel_clnt_call/tirpc_bottomlevel_clnt_call.c
> @@ -32,6 +32,8 @@
>  #include <netinet/in.h>
>  #include <tirpc/rpc/svc.h>
>  #include <errno.h>
> +#include <unistd.h>
> +#include "librpc-tirpc.h"
>  
>  #define PROCNUM 1
>  #define VERSNUM 1
> @@ -54,9 +56,10 @@ int main(int argn, char *argc[])
>  	int var_snd = 10;
>  	int var_rec = -1;
>  	struct timeval tv;
> +	int sock;
>  
> -	tv.tv_sec = 0;
> -	tv.tv_usec = 100;
> +	tv.tv_sec = 1;
> +	tv.tv_usec = 0;

You also modify timeout here, this should be mentioned in the commit
message as well.

>  	if (nconf == (struct netconfig *)NULL) {

I would also remove this useless casts (in a cleanup patch).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] rpc-tirpc: TI-RPC fixes
  2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
                   ` (6 preceding siblings ...)
  2014-03-27 13:56 ` [LTP] [PATCH 7/7] rpc-tirpc: fix arguments to rpcb_set and rpcb_unset test cases Stanislav Kholmanskikh
@ 2014-04-29 13:27 ` chrubis
  7 siblings, 0 replies; 11+ messages in thread
From: chrubis @ 2014-04-29 13:27 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
Looks good to me (minus missing timeout modification in log).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-04-29 13:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27 13:56 [LTP] rpc-tirpc: TI-RPC fixes Stanislav Kholmanskikh
2014-03-27 13:56 ` [LTP] [PATCH 1/7] rpc-tirpc: introduced a common library Stanislav Kholmanskikh
2014-03-27 13:56 ` [LTP] [PATCH 2/7] rpc-tirpc: introduced bound_socket() Stanislav Kholmanskikh
2014-04-29 13:15   ` chrubis
2014-03-27 13:56 ` [LTP] [PATCH 3/7] rpc-tirpc: cleanup of the "bottom level" TI-RPC test binaries Stanislav Kholmanskikh
2014-03-27 13:56 ` [LTP] [PATCH 4/7] rpc-tirpc: the "bottom level" fixes Stanislav Kholmanskikh
2014-04-29 13:19   ` chrubis
2014-03-27 13:56 ` [LTP] [PATCH 5/7] rpc-tirpc: tirpc_svc_5 fixes Stanislav Kholmanskikh
2014-03-27 13:56 ` [LTP] [PATCH 6/7] rpc-tirpc: tirpc_rpcb_set and tirpc_rpcb_unset cleanup Stanislav Kholmanskikh
2014-03-27 13:56 ` [LTP] [PATCH 7/7] rpc-tirpc: fix arguments to rpcb_set and rpcb_unset test cases Stanislav Kholmanskikh
2014-04-29 13:27 ` [LTP] rpc-tirpc: TI-RPC fixes chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox