Hans Leidekker : wbemprox: Implement Win32_PhysicalMemory.MemoryType.

Alexandre Julliard julliard at winehq.org
Wed Nov 16 17:39:18 CST 2016


Module: wine
Branch: master
Commit: b05928aae0faebb6d7de92392a85abddcc7c65d8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b05928aae0faebb6d7de92392a85abddcc7c65d8

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Nov 16 10:02:07 2016 -0600

wbemprox: Implement Win32_PhysicalMemory.MemoryType.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wbemprox/builtin.c     |  9 ++++--
 dlls/wbemprox/tests/query.c | 75 ++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 7513347..718b818 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -252,6 +252,8 @@ static const WCHAR prop_mediatypeW[] =
     {'M','e','d','i','a','T','y','p','e',0};
 static const WCHAR prop_memberW[] =
     {'M','e','m','b','e','r',0};
+static const WCHAR prop_memorytypeW[] =
+    {'M','e','m','o','r','y','T','y','p','e',0};
 static const WCHAR prop_methodW[] =
     {'M','e','t','h','o','d',0};
 static const WCHAR prop_modelW[] =
@@ -540,7 +542,8 @@ static const struct column col_physicalmedia[] =
 };
 static const struct column col_physicalmemory[] =
 {
-    { prop_capacityW,   CIM_UINT64 }
+    { prop_capacityW,   CIM_UINT64 },
+    { prop_memorytypeW, CIM_UINT16, VT_I4 }
 };
 static const struct column col_printer[] =
 {
@@ -924,6 +927,7 @@ struct record_physicalmedia
 struct record_physicalmemory
 {
     UINT64 capacity;
+    UINT16 memorytype;
 };
 struct record_printer
 {
@@ -2303,7 +2307,8 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e
     if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
 
     rec = (struct record_physicalmemory *)table->data;
-    rec->capacity = get_total_physical_memory();
+    rec->capacity   = get_total_physical_memory();
+    rec->memorytype = 9; /* RAM */
     if (!match_row( table, row, cond, &status )) free_row_values( table, row );
     else row++;
 
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index 5529fe0..1aeb7e5 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -482,9 +482,11 @@ static void test_Win32_Process( IWbemServices *services )
 
 static void test_Win32_ComputerSystem( IWbemServices *services )
 {
+    static const WCHAR backslashW[] = {'\\',0};
+    static const WCHAR memorytypeW[] = {'M','e','m','o','r','y','T','y','p','e',0};
+    static const WCHAR modelW[] = {'M','o','d','e','l',0};
     static const WCHAR nameW[] = {'N','a','m','e',0};
     static const WCHAR usernameW[] = {'U','s','e','r','N','a','m','e',0};
-    static const WCHAR backslashW[] = {'\\',0};
     static const WCHAR queryW[] =
         {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
          'C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
@@ -526,6 +528,20 @@ static void test_Win32_ComputerSystem( IWbemServices *services )
 
     type = 0xdeadbeef;
     VariantInit( &value );
+    hr = IWbemClassObject_Get( service, memorytypeW, 0, &value, &type, NULL );
+    ok( hr == WBEM_E_NOT_FOUND, "got %08x\n", hr );
+
+    type = 0xdeadbeef;
+    VariantInit( &value );
+    hr = IWbemClassObject_Get( service, modelW, 0, &value, &type, NULL );
+    ok( hr == S_OK, "failed to get model %08x\n", hr );
+    ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
+    ok( type == CIM_STRING, "unexpected type 0x%x\n", type );
+    trace( "model: %s\n", wine_dbgstr_w(V_BSTR( &value )) );
+    VariantClear( &value );
+
+    type = 0xdeadbeef;
+    VariantInit( &value );
     hr = IWbemClassObject_Get( service, nameW, 0, &value, &type, NULL );
     ok( hr == S_OK, "failed to get computer name %08x\n", hr );
     ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
@@ -1206,7 +1222,7 @@ static void test_ComputerSystemProduct( IWbemServices *services )
          'C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
     BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW );
     IEnumWbemClassObject *result;
-    IWbemClassObject *service;
+    IWbemClassObject *obj;
     VARIANT value;
     CIMTYPE type;
     HRESULT hr;
@@ -1219,24 +1235,72 @@ static void test_ComputerSystemProduct( IWbemServices *services )
         return;
     }
 
-    hr = IEnumWbemClassObject_Next( result, 10000, 1, &service, &count );
+    hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
     ok( hr == S_OK, "got %08x\n", hr );
 
     type = 0xdeadbeef;
     VariantInit( &value );
-    hr = IWbemClassObject_Get( service, uuidW, 0, &value, &type, NULL );
+    hr = IWbemClassObject_Get( obj, uuidW, 0, &value, &type, NULL );
     ok( hr == S_OK, "failed to get computer name %08x\n", hr );
     ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
     ok( type == CIM_STRING, "unexpected type 0x%x\n", type );
     trace( "uuid %s\n", wine_dbgstr_w(V_BSTR(&value)) );
     VariantClear( &value );
 
-    IWbemClassObject_Release( service );
+    IWbemClassObject_Release( obj );
     IEnumWbemClassObject_Release( result );
     SysFreeString( query );
     SysFreeString( wql );
 }
 
+static void test_PhysicalMemory( IWbemServices *services )
+{
+    static const WCHAR capacityW[] = {'C','a','p','a','c','i','t','y',0};
+    static const WCHAR memorytypeW[] = {'M','e','m','o','r','y','T','y','p','e',0};
+    static const WCHAR queryW[] =
+        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
+         'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
+    BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW );
+    IEnumWbemClassObject *result;
+    IWbemClassObject *obj;
+    VARIANT val;
+    CIMTYPE type;
+    HRESULT hr;
+    DWORD count;
+
+    hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
+    if (hr != S_OK)
+    {
+        win_skip( "Win32_PhysicalMemory not available\n" );
+        return;
+    }
+
+    hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    type = 0xdeadbeef;
+    VariantInit( &val );
+    hr = IWbemClassObject_Get( obj, capacityW, 0, &val, &type, NULL );
+    ok( hr == S_OK, "failed to get capacity %08x\n", hr );
+    ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) );
+    ok( type == CIM_UINT64, "unexpected type 0x%x\n", type );
+    trace( "capacity %s\n", wine_dbgstr_w(V_BSTR( &val )) );
+    VariantClear( &val );
+
+    type = 0xdeadbeef;
+    VariantInit( &val );
+    hr = IWbemClassObject_Get( obj, memorytypeW, 0, &val, &type, NULL );
+    ok( hr == S_OK, "failed to get memory type %08x\n", hr );
+    ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) );
+    ok( type == CIM_UINT16, "unexpected type 0x%x\n", type );
+    trace( "memorytype %u\n", V_I4( &val ) );
+    VariantClear( &val );
+
+    IWbemClassObject_Release( obj );
+    SysFreeString( query );
+    SysFreeString( wql );
+}
+
 START_TEST(query)
 {
     static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0};
@@ -1276,6 +1340,7 @@ START_TEST(query)
     test_SystemSecurity( services );
     test_OperatingSystem( services );
     test_ComputerSystemProduct( services );
+    test_PhysicalMemory( services );
 
     SysFreeString( path );
     IWbemServices_Release( services );




More information about the wine-cvs mailing list