[2/2] widl/rpcrt4: Add some tests of the client/server stubs (take
2)
Dan Hipschman
dsh at linux.ucla.edu
Thu Apr 19 16:32:51 CDT 2007
This adds a test case for widl/rpcrt4. I didn't really change anything
since the last attempt. It's just on it's own, now.
---
dlls/rpcrt4/tests/ClientMakefile.in | 15 ++++++++
dlls/rpcrt4/tests/Makefile.in | 5 ++-
dlls/rpcrt4/tests/server.c | 65 +++++++++++++++++++++++++++++++++++
dlls/rpcrt4/tests/server.idl | 34 ++++++++++++++++++
dlls/rpcrt4/tests/server_test.c | 42 ++++++++++++++++++++++
5 files changed, 160 insertions(+), 1 deletions(-)
create mode 100644 dlls/rpcrt4/tests/ClientMakefile.in
create mode 100644 dlls/rpcrt4/tests/server.c
create mode 100644 dlls/rpcrt4/tests/server.idl
create mode 100644 dlls/rpcrt4/tests/server_test.c
diff --git a/dlls/rpcrt4/tests/ClientMakefile.in b/dlls/rpcrt4/tests/ClientMakefile.in
new file mode 100644
index 0000000..69031e9
--- /dev/null
+++ b/dlls/rpcrt4/tests/ClientMakefile.in
@@ -0,0 +1,15 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = rpcrt4.dll
+IMPORTS = rpcrt4 kernel32
+EXTRALIBS = -luuid
+CLIENT = client
+
+CTESTS = server_test.c
+IDL_C_SRCS = server.idl
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/rpcrt4/tests/Makefile.in b/dlls/rpcrt4/tests/Makefile.in
index 036cd21..c4b5be3 100644
--- a/dlls/rpcrt4/tests/Makefile.in
+++ b/dlls/rpcrt4/tests/Makefile.in
@@ -10,7 +10,10 @@ CTESTS = \
cstub.c \
generated.c \
ndr_marshall.c \
- rpc.c
+ rpc.c \
+ server.c
+
+IDL_S_SRCS = server.idl
@MAKE_TEST_RULES@
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
new file mode 100644
index 0000000..8f8bf93
--- /dev/null
+++ b/dlls/rpcrt4/tests/server.c
@@ -0,0 +1,65 @@
+/*
+ * A simple RPC server.
+ *
+ * Copyright (C) Google 2007 (Dan Hipschman)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include "server.h"
+
+int
+Test(void)
+{
+ return TESTCODE;
+}
+
+HANDLE event;
+
+void
+Stop(void)
+{
+ ok(RPC_S_OK == RpcMgmtStopServerListening(NULL),
+ "RpcMgmtStopServerListening failed\n");
+ ok(RPC_S_OK == RpcServerUnregisterIf(NULL, NULL, FALSE),
+ "RpcServerUnregisterIf failed\n");
+ ok(SetEvent(event), "SetEvent failed\n");
+}
+
+START_TEST(server)
+{
+ static unsigned char protseq[] = PROTSEQ;
+ static unsigned char endpoint[] = ENDPOINT;
+
+ ok(RPC_S_OK == RpcServerUseProtseqEp(protseq, 20, endpoint, NULL),
+ "RpcServerUseProtseqEp failed\n");
+ ok(RPC_S_OK == RpcServerRegisterIf(IServer_v0_0_s_ifspec, NULL, NULL),
+ "RpcServerRegisterIf failed\n");
+ ok(RPC_S_OK == RpcServerListen(1, 20, TRUE),
+ "RpcServerListen failed\n");
+
+ event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ ok(event != NULL, "CreateEvent failed\n");
+
+ ok(winetest_run_testclient("server_test"), "client process failed\n");
+
+ ok(WAIT_OBJECT_0 == WaitForSingleObject(event, INFINITE),
+ "WaitForSingleObject failed\n");
+todo_wine {
+ ok(RPC_S_OK == RpcMgmtWaitServerListen(),
+ "RpcMgmtWaitServerListening failed\n");
+}
+}
diff --git a/dlls/rpcrt4/tests/server.idl b/dlls/rpcrt4/tests/server.idl
new file mode 100644
index 0000000..aa63edf
--- /dev/null
+++ b/dlls/rpcrt4/tests/server.idl
@@ -0,0 +1,34 @@
+/*
+ * A simple interface to test the RPC server.
+ *
+ * Copyright (C) Google 2007 (Dan Hipschman)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/* So the server and client are always on the same page. */
+cpp_quote("#define PROTSEQ \"ncacn_ip_tcp\"")
+cpp_quote("#define ENDPOINT \"4114\"")
+cpp_quote("#define TESTCODE 4114")
+
+[
+ uuid(00000000-4114-0704-1701-000000000000),
+ implicit_handle(handle_t IServer_IfHandle)
+]
+interface IServer
+{
+ int Test(void);
+ void Stop(void);
+}
diff --git a/dlls/rpcrt4/tests/server_test.c b/dlls/rpcrt4/tests/server_test.c
new file mode 100644
index 0000000..d5f36c7
--- /dev/null
+++ b/dlls/rpcrt4/tests/server_test.c
@@ -0,0 +1,42 @@
+/*
+ * A simple RPC client.
+ *
+ * Copyright (C) Google 2007 (Dan Hipschman)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include "server.h"
+
+START_TEST(server_test)
+{
+ static unsigned char protseq[] = PROTSEQ;
+ static unsigned char endpoint[] = ENDPOINT;
+ static unsigned char address[] = "127.0.0.1";
+ unsigned char *binding;
+
+ ok(RPC_S_OK == RpcStringBindingCompose(NULL, protseq, address,
+ endpoint, NULL, &binding),
+ "RpcStringBindingCompose failed\n");
+ ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle),
+ "RpcBindingFromStringBinding failed\n");
+
+ ok(Test() == TESTCODE, "RPC `Test' returned the wrong result\n");
+ Stop();
+
+ ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree failed\n");
+ ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree failed\n");
+}
More information about the wine-patches
mailing list