[ofw] [RFC] [PATCH 12/12] winverbs: expand test framework to all WV interfaces

Sean Hefty sean.hefty at intel.com
Fri Mar 14 23:13:57 PDT 2008


Expand test framework to include all WinVerb interfaces.  The tests are
currently limited to creating and destroying the WinVerb interface objects,
but a few placeholders are added to give an idea of the types of tests
that the winverb test will eventually perform.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: tests/wvtests/user/getopt.cpp
===================================================================
--- tests/wvtests/user/getopt.cpp	(revision 972)
+++ tests/wvtests/user/getopt.cpp	(working copy)
@@ -37,21 +37,24 @@
 	static int index = 1;
 	char *opt;
 
-	if (index >= argc)
+	if (index >= argc) {
 		return -1;
+	}
 
 	optarg = NULL;
-	if (argv[index][0] != '-' || strlen(argv[index]) != 2)
+	if (argv[index][0] != '-' || strlen(argv[index]) != 2) {
 		goto err;
+	}
 
 	opt = strchr(opts, argv[index][1]);
-	if (!opt)
+	if (opt == NULL) {
 		goto err;
+	}
 
-	if (opt[1] == ':')
-	{
-		if (++index >= argc)
+	if (opt[1] == ':') {
+		if (++index >= argc) {
 			goto err;
+		}
 		optarg = argv[index];
 	}
 
Index: tests/wvtests/user/SOURCES
===================================================================
--- tests/wvtests/user/SOURCES	(revision 982)
+++ tests/wvtests/user/SOURCES	(working copy)
@@ -9,6 +9,13 @@
 SOURCES=\
 	wv_main.cpp		\
 	wv_device.cpp	\
+	wv_listen.cpp	\
+	wv_connect.cpp	\
+	wv_datagram.cpp	\
+	wv_pd.cpp		\
+	wv_cq.cpp		\
+	wv_srq.cpp		\
+	wv_qp.cpp		\
 	getopt.cpp
 	
 INCLUDES=..\..\..\inc;..\..\..\inc\user;
Index: tests/wvtests/user/wv_connect.cpp
===================================================================
--- tests/wvtests/user/wv_connect.cpp	(revision 0)
+++ tests/wvtests/user/wv_connect.cpp	(revision 0)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2008 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <iostream>
+using namespace std;
+
+#include "wv_main.h"
+#include "getopt.h"
+#include <rdma\winverbs.h>
+
+static IWVConnectEndpoint	*ep;
+
+static void ShowOptions()
+{
+	cout << "usage: winverb connect [options]" << endl;
+	cout << "connect options" << endl;
+	cout << "\t" << "-b ip-address      bind to IP address" << endl;
+	cout << "\t" << "-c connections     number of connections to server" << endl;
+	cout << "\t" << "-s server-address  set server address" << endl;
+	cout << "\t" << "-?                 display this message" << endl;
+}
+
+HRESULT ConnectTest(int argc, char *argv[])
+{
+	HRESULT hr;
+	ULONG ref;
+	int op;
+
+	while ((op = getopt(argc, argv, "b:c:s:?")) != -1) {
+		switch (op) {
+		case 'b':
+			break;
+		case 'c':
+			break;
+		case 's':
+			break;
+		default:
+			ShowOptions();
+			return 1;
+		}
+	}
+
+	cout << "Validating IWVConnectEndpoint interface" << endl;
+
+	hr = OpenProvider();
+	if (FAILED(hr)) {
+		goto out;
+	}
+
+	hr = prov->CreateConnectEndpoint(&ep);
+	if (FAILED(hr)) {
+		cout << "Error CreateConnectEndpoint: 0x" << hex << hr << endl;
+		goto out;
+	}
+
+	ep->Release();
+	prov->Release();
+out:
+	return hr;
+}
Index: tests/wvtests/user/wv_datagram.cpp
===================================================================
--- tests/wvtests/user/wv_datagram.cpp	(revision 0)
+++ tests/wvtests/user/wv_datagram.cpp	(revision 0)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2008 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <iostream>
+using namespace std;
+
+#include "wv_main.h"
+#include "getopt.h"
+#include <rdma\winverbs.h>
+
+static IWVDatagramEndpoint	*ep;
+
+static void ShowOptions()
+{
+	cout << "usage: winverb datagram [options]" << endl;
+	cout << "datagram options" << endl;
+	cout << "\t" << "-b ip-address      bind to IP address" << endl;
+	cout << "\t" << "-c communications  number of 'connections' to server" << endl;
+	cout << "\t" << "-s server-address  set server address" << endl;
+	cout << "\t" << "-?                 display this message" << endl;
+}
+
+HRESULT DatagramTest(int argc, char *argv[])
+{
+	HRESULT hr;
+	ULONG ref;
+	int op;
+
+	while ((op = getopt(argc, argv, "b:c:s:?")) != -1) {
+		switch (op) {
+		case 'b':
+			break;
+		case 'c':
+			break;
+		case 's':
+			break;
+		default:
+			ShowOptions();
+			return 1;
+		}
+	}
+
+	cout << "Validating IWVDatagramEndpoint interface" << endl;
+
+	hr = OpenProvider();
+	if (FAILED(hr)) {
+		goto out;
+	}
+
+	hr = prov->CreateDatagramEndpoint(&ep);
+	if (FAILED(hr)) {
+		cout << "Error CreateDatagramEndpoint: 0x" << hex << hr << endl;
+		goto out;
+	}
+
+	ep->Release();
+	prov->Release();
+out:
+	return hr;
+}
Index: tests/wvtests/user/wv_device.cpp
===================================================================
--- tests/wvtests/user/wv_device.cpp	(revision 982)
+++ tests/wvtests/user/wv_device.cpp	(working copy)
@@ -34,14 +34,14 @@
 #include "getopt.h"
 #include <rdma\winverbs.h>
 
-static IWVProvider	*prov;
-static IWVDevice	*dev;
+IWVDevice *dev;
 
 static void ShowOptions()
 {
 	cout << "usage: winverb device [options]" << endl;
 	cout << "device options" << endl;
-	cout << "\t" << "-?" << "\t" << "display this message" << endl;
+	cout << "\t" << "-d index    index of device to open" << endl;
+	cout << "\t" << "-?          display this message" << endl;
 }
 
 static int GetGuid(int index)
@@ -49,6 +49,30 @@
 	return 0;
 }
 
+HRESULT OpenDevice(int Index)
+{
+	HRESULT hr;
+
+	hr = OpenProvider();
+	if (FAILED(hr)) {
+		return hr;
+	}
+
+	hr = prov->OpenDevice(GetGuid(Index), &dev);
+	if (FAILED(hr)) {
+		cout << "Error OpenDevice: 0x" << hex << hr << endl;
+		prov->Release();
+	}
+
+	return hr;
+}
+
+void ReleaseDevice(void)
+{
+	dev->Release();
+	prov->Release();
+}
+
 HRESULT DeviceTest(int argc, char *argv[])
 {
 	HRESULT hr;
@@ -56,38 +80,21 @@
 	int op;
 	int index = 0;
 
-	while ((op = getopt(argc, argv, "d:?")) != -1)
-	{
-		switch (op)
-		{
+	while ((op = getopt(argc, argv, "d:?")) != -1) {
+		switch (op) {
 		case 'd':
 			index = atoi(optarg);
 			break;
 		default:
 			ShowOptions();
-			return WV_INVALID_PARAMETER;
+			return 1;
 		}
 	}
 
-	cout << "Validating IWVDevice interface" << endl;
-
-	hr = WvGetObject(IID_IWVProvider, (LPVOID*) &prov);
-	if (hr != WV_SUCCESS)
-	{
-		cout << "Error WvGetObject: 0x" << hex << hr << endl;
-		return hr;
+	hr = OpenDevice(index);
+	if (SUCCEEDED(hr)) {
+		ReleaseDevice();
 	}
 
-	hr = prov->OpenDevice(GetGuid(0), &dev);
-	if (hr != WV_SUCCESS)
-	{
-		cout << "Error OpenDevice: 0x" << hex << hr << endl;
-		return hr;
-	}
-
-	dev->Release();
-	prov->Release();
-
-	cout << "Success" << endl;
 	return hr;
 }
Index: tests/wvtests/user/wv_listen.cpp
===================================================================
--- tests/wvtests/user/wv_listen.cpp	(revision 0)
+++ tests/wvtests/user/wv_listen.cpp	(revision 0)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2008 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <iostream>
+using namespace std;
+
+#include "wv_main.h"
+#include "getopt.h"
+#include <rdma\winverbs.h>
+
+static IWVListen	*listener;
+
+static void ShowOptions()
+{
+	cout << "usage: winverb listen [options]" << endl;
+	cout << "listen options" << endl;
+	cout << "\t" << "-b ip-address  bind to IP address" << endl;
+	cout << "\t" << "-c connections number of connections from clients" << endl;
+	cout << "\t" << "-p port        set port (default 0x7174)" << endl;
+	cout << "\t" << "-?             display this message" << endl;
+}
+
+HRESULT ListenTest(int argc, char *argv[])
+{
+	HRESULT hr;
+	ULONG ref;
+	int op;
+	struct sockaddr_in address;	// TODO: verify defaults and set
+
+	while ((op = getopt(argc, argv, "b:c:p:?")) != -1) {
+		switch (op) {
+		case 'b':
+			break;
+		case 'c':
+			break;
+		case 'p':
+			break;
+		default:
+			ShowOptions();
+			return 1;
+		}
+	}
+
+	cout << "Validating IWVListen interface" << endl;
+
+	hr = OpenProvider();
+	if (FAILED(hr)) {
+		goto out;
+	}
+
+	hr = prov->CreateListen((struct sockaddr *) &address, 128, &listener);
+	if (FAILED(hr)) {
+		cout << "Error CreateListen: 0x" << hex << hr << endl;
+		goto out;
+	}
+
+	listener->Release();
+	prov->Release();
+out:
+	return hr;
+}
Index: tests/wvtests/user/wv_main.cpp
===================================================================
--- tests/wvtests/user/wv_main.cpp	(revision 982)
+++ tests/wvtests/user/wv_main.cpp	(working copy)
@@ -34,43 +34,50 @@
 #include "getopt.h"
 #include <rdma\winverbs.h>
 
+IWVProvider *prov;
+
 static void ShowOptions()
 {
 	cout << "usage: winverb provider [options]" << endl;
 	cout << "provider options" << endl;
-	cout << "\t" << "-?" << "\t" << "display this message" << endl;
+	cout << "\t" << "-?          display this message" << endl;
 }
 
+HRESULT OpenProvider(void)
+{
+	HRESULT hr;
+
+	hr = WvGetObject(IID_IWVProvider, (LPVOID*) &prov);
+	if (FAILED(hr)) {
+		cout << "Error WvGetObject: 0x" << hex << hr << endl;
+	}	
+	return hr;
+}
+
 static HRESULT ProviderTest(int argc, char *argv[])
 {
-	IWVProvider *prov;
 	HRESULT hr;
 	ULONG ref;
 	int op;
 
-	if ((op = getopt(argc, argv, "?")) != -1)
-	{
+	if ((op = getopt(argc, argv, "?")) != -1) {
 		ShowOptions();
-		return WV_INVALID_PARAMETER;
+		return 1;
 	}
 
-	cout << "Validating IWVProvider interface" << endl;
-
-	hr = WvGetObject(IID_IWVProvider, (LPVOID*) &prov);
-	if (hr != WV_SUCCESS)
-	{
-		cout << "Error WvGetObject: 0x" << hex << hr << endl;
-		return hr;
+	hr = OpenProvider();
+	if (FAILED(hr)) {
+		goto out;
 	}
 
 	ref = prov->AddRef();
-	if (ref != 2)
+	if (ref != 2) {
 		cout << "Error AddRef: " << ref << endl;
+	}
 
 	prov->Release();
 	prov->Release();
-
-	cout << "Success" << endl;
+out:
 	return hr;
 }
 
@@ -80,19 +87,49 @@
 	cout << "<interface> is one of the following:" << endl;
 	cout << "\t" << "provider" << endl;
 	cout << "\t" << "device" << endl;
+	cout << "\t" << "listen" << endl;
+	cout << "\t" << "connect" << endl;
+	cout << "\t" << "datagram" << endl;
+	cout << "\t" << "pd" << endl;
+	cout << "\t" << "cq" << endl;
+	cout << "\t" << "srq" << endl;
+	cout << "\t" << "qp" << endl;
 	cout << endl;
 	cout << "Type 'winverb <interface> -?' for option details" << endl;
 }
 
 int __cdecl main(int argc, char *argv[])
 {
-	if (argc < 2)
+	HRESULT hr;
+
+	if (argc < 2) {
 		goto err;
+	} else if (strcmp("provider", argv[1]) == 0) {
+		hr = ProviderTest(argc - 1, &argv[1]);
+	} else if (strcmp("device", argv[1]) == 0) {
+		hr = DeviceTest(argc - 1, &argv[1]);
+	} else if (strcmp("listen", argv[1]) == 0) {
+		hr = ListenTest(argc - 1, &argv[1]);
+	} else if (strcmp("connect", argv[1]) == 0) {
+		hr = ConnectTest(argc - 1, &argv[1]);
+	} else if (strcmp("datagram", argv[1]) == 0) {
+		hr = DatagramTest(argc - 1, &argv[1]);
+	} else if (strcmp("pd", argv[1]) == 0) {
+		hr = PdTest(argc - 1, &argv[1]);
+	} else if (strcmp("cq", argv[1]) == 0) {
+		hr = CqTest(argc - 1, &argv[1]);
+	} else if (strcmp("srq", argv[1]) == 0) {
+		hr = SrqTest(argc - 1, &argv[1]);
+	} else if (strcmp("qp", argv[1]) == 0) {
+		hr = QpTest(argc - 1, &argv[1]);
+	} else {
+		goto err;
+	}
 
-	if (!strcmp("provider", argv[1]))
-		return ProviderTest(argc - 1, &argv[1]);
-	else if (!strcmp("device", argv[1]))
-		return DeviceTest(argc - 1, &argv[1]);
+	if (hr != 1) {
+		cout << ((hr == WV_SUCCESS) ? "success" : "*** failure ***") << endl;
+	}
+	return hr;
 
 err:
 	ShowUsage();
Index: tests/wvtests/user/wv_main.h
===================================================================
--- tests/wvtests/user/wv_main.h	(revision 982)
+++ tests/wvtests/user/wv_main.h	(working copy)
@@ -34,6 +34,23 @@
 
 #include <rdma\winverbs.h>
 
+extern IWVProvider			*prov;
+extern IWVDevice			*dev;
+extern IWVProtectionDomain	*pd;
+
+HRESULT OpenProvider();
+HRESULT OpenDevice(int Index);
+HRESULT AllocatePd(int DevIndex);
+void ReleaseDevice();
+void ReleasePd();
+
 HRESULT DeviceTest(int argc, char *argv[]);
+HRESULT ListenTest(int argc, char *argv[]);
+HRESULT ConnectTest(int argc, char *argv[]);
+HRESULT DatagramTest(int argc, char *argv[]);
+HRESULT PdTest(int argc, char *argv[]);
+HRESULT CqTest(int argc, char *argv[]);
+HRESULT SrqTest(int argc, char *argv[]);
+HRESULT QpTest(int argc, char *argv[]);
 
 #endif // _WV_MAIN_H_





More information about the ofw mailing list