From 796a53f9c7ed1e962650d7bfa2333aa9053f805f Mon Sep 17 00:00:00 2001 From: shefty Date: Tue, 4 Mar 2008 07:32:38 +0000 Subject: [PATCH] Add winverbs test application framework. Test acquires and releases IWVProvider interface. Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@968 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- branches/winverbs/tests/dirs | 5 +- branches/winverbs/tests/wvtests/dirs | 2 + branches/winverbs/tests/wvtests/user/SOURCES | 26 +++++ branches/winverbs/tests/wvtests/user/makefile | 7 ++ .../winverbs/tests/wvtests/user/wv_main.cpp | 101 ++++++++++++++++++ 5 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 branches/winverbs/tests/wvtests/dirs create mode 100644 branches/winverbs/tests/wvtests/user/SOURCES create mode 100644 branches/winverbs/tests/wvtests/user/makefile create mode 100644 branches/winverbs/tests/wvtests/user/wv_main.cpp diff --git a/branches/winverbs/tests/dirs b/branches/winverbs/tests/dirs index fc792b6c..31cd5c20 100644 --- a/branches/winverbs/tests/dirs +++ b/branches/winverbs/tests/dirs @@ -1,6 +1,7 @@ DIRS=\ alts \ cmtest \ - wsd \ + wsd \ ibat \ - limits + limits \ + wvtests diff --git a/branches/winverbs/tests/wvtests/dirs b/branches/winverbs/tests/wvtests/dirs new file mode 100644 index 00000000..389156fd --- /dev/null +++ b/branches/winverbs/tests/wvtests/dirs @@ -0,0 +1,2 @@ +DIRS=\ + user diff --git a/branches/winverbs/tests/wvtests/user/SOURCES b/branches/winverbs/tests/wvtests/user/SOURCES new file mode 100644 index 00000000..5eedd231 --- /dev/null +++ b/branches/winverbs/tests/wvtests/user/SOURCES @@ -0,0 +1,26 @@ +TARGETNAME=winverb +TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR) +TARGETTYPE=PROGRAM +UMTYPE=console +UMENTRY=main +USE_MSVCRT=1 +USE_STL=1 + +SOURCES=\ + wv_main.cpp + +INCLUDES=..\..\..\inc;..\..\..\inc\user; + +TARGETLIBS= \ + $(SDK_LIB_PATH)\kernel32.lib \ + $(SDK_LIB_PATH)\advapi32.lib \ + $(SDK_LIB_PATH)\user32.lib \ + $(SDK_LIB_PATH)\ole32.lib \ +!if $(FREEBUILD) + $(TARGETPATH)\*\winverbs.lib +!else + $(TARGETPATH)\*\winverbsd.lib +!endif + +USER_C_FLAGS=$(USER_C_FLAGS) /EHsc +MSC_WARNING_LEVEL= /W3 diff --git a/branches/winverbs/tests/wvtests/user/makefile b/branches/winverbs/tests/wvtests/user/makefile new file mode 100644 index 00000000..bffacaa7 --- /dev/null +++ b/branches/winverbs/tests/wvtests/user/makefile @@ -0,0 +1,7 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the driver components of the OpenIB Windows project. +# + +!INCLUDE ..\..\..\inc\openib.def diff --git a/branches/winverbs/tests/wvtests/user/wv_main.cpp b/branches/winverbs/tests/wvtests/user/wv_main.cpp new file mode 100644 index 00000000..de84d961 --- /dev/null +++ b/branches/winverbs/tests/wvtests/user/wv_main.cpp @@ -0,0 +1,101 @@ +/* + * 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 + +#include + +static void ShowProviderOptions() +{ + std::cout << "provider options" << std::endl; + std::cout << "\t" << "--help" << std::endl; + std::cout << "\t\t" << "display this message" << std::endl; +} + +static int ProviderTest(int argc, char *argv[]) +{ + IWVProvider *prov; + HRESULT hr; + ULONG ref; + + if (argc > 2) + { + ShowProviderOptions(); + return 0; + } + + std::cout << "Validating IWVProvider interface" << std::endl; + + hr = WvGetObject(IID_IWVProvider, (LPVOID*) &prov); + if (hr != NOERROR) + { + std::cout << "Error WvGetObject: " << hr << std::endl; + return hr; + } + + ref = prov->AddRef(); + if (ref != 2) + std::cout << "Error AddRef: " << ref << std::endl; + + prov->Release(); + prov->Release(); + + std::cout << "Success" << std::endl; + return hr; +} + +static void ShowUsage() +{ + std::cout << "winverb [options]" << std::endl; + std::cout << " is one of the following:" << std::endl; + std::cout << "\t" << "provider" << std::endl; + std::cout << std::endl; + std::cout << "Type 'winverb --help' for option details" << std::endl; +} + +int __cdecl main(int argc, char *argv[]) +{ + if (argc < 2) + { + ShowUsage(); + return E_INVALIDARG; + } + + if (!strcmp("provider", argv[1])) + { + return ProviderTest(argc, argv); + } + else + { + ShowUsage(); + return E_INVALIDARG; + } + + return 0; +} -- 2.41.0