From 524e3caf8ca17ef5b85547114882c38fda2fc424 Mon Sep 17 00:00:00 2001 From: shefty Date: Fri, 20 Jun 2008 04:27:54 +0000 Subject: [PATCH] winverb/test: add test to query device attributes Basic functionality test, only display port count for now. Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@1290 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- .../winverbs/tests/wvtests/user/wv_device.cpp | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/branches/winverbs/tests/wvtests/user/wv_device.cpp b/branches/winverbs/tests/wvtests/user/wv_device.cpp index be33af9f..62280e08 100644 --- a/branches/winverbs/tests/wvtests/user/wv_device.cpp +++ b/branches/winverbs/tests/wvtests/user/wv_device.cpp @@ -34,19 +34,34 @@ using namespace std; #include "getopt.h" #include -IWVDevice *dev; +#define WV_TEST_SHOW_ATTRIBUTES 0x00000001 + +IWVDevice *dev; +DWORD flags; static void ShowOptions() { cout << "usage: winverb device [options]" << endl; cout << "device options" << endl; cout << "\t" << "-d index index of device to open" << endl; + cout << "\t" << "-a show device attributes" << endl; cout << "\t" << "-? display this message" << endl; } -static int GetGuid(int index) +static UINT64 GetGuid(int index) { - return 0; + UINT64 guids[16]; + SIZE_T size; + HRESULT hr; + + size = sizeof guids; + hr = prov->QueryDeviceList(guids, &size); + if (FAILED(hr)){ + cout << "Error QueryDeviceList: 0x" << hex << hr << endl; + return 0; + } + + return guids[index]; } HRESULT OpenDevice(int Index) @@ -73,6 +88,20 @@ void ReleaseDevice(void) prov->Release(); } +void ShowAttributes(void) +{ + WV_DEVICE_ATTRIBUTES attr; + HRESULT hr; + + hr = dev->Query(&attr); + if (FAILED(hr)) { + cout << "Error querying for attributes: 0x" << hex << hr << endl; + return; + } + + printf("PhysPortCount : %d\n", attr.PhysPortCount); +} + HRESULT DeviceTest(int argc, char *argv[]) { HRESULT hr; @@ -80,11 +109,14 @@ HRESULT DeviceTest(int argc, char *argv[]) int op; int index = 0; - while ((op = getopt(argc, argv, "d:?")) != -1) { + while ((op = getopt(argc, argv, "d:a?")) != -1) { switch (op) { case 'd': index = atoi(optarg); break; + case 'a': + flags |= WV_TEST_SHOW_ATTRIBUTES; + break; default: ShowOptions(); return 1; @@ -92,9 +124,14 @@ HRESULT DeviceTest(int argc, char *argv[]) } hr = OpenDevice(index); - if (SUCCEEDED(hr)) { - ReleaseDevice(); + if (FAILED(hr)) { + return hr; + } + + if ((flags & WV_TEST_SHOW_ATTRIBUTES) != 0) { + ShowAttributes(); } + ReleaseDevice(); return hr; } -- 2.46.0