https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d9bd8eaba3ad3a8bc5b0d…
commit d9bd8eaba3ad3a8bc5b0df328fee168eb8712156
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Mon Feb 4 13:11:26 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Mon Feb 4 13:11:26 2019 +0100
[WBEMPROX_WINETEST] Sync with Wine Staging 4.0. CORE-15682
---
modules/rostests/winetests/wbemprox/query.c | 210 +++++++++++++++++++++----
modules/rostests/winetests/wbemprox/services.c | 2 +-
2 files changed, 181 insertions(+), 31 deletions(-)
diff --git a/modules/rostests/winetests/wbemprox/query.c
b/modules/rostests/winetests/wbemprox/query.c
index d95fdd970b..0fa6b5e966 100644
--- a/modules/rostests/winetests/wbemprox/query.c
+++ b/modules/rostests/winetests/wbemprox/query.c
@@ -141,7 +141,7 @@ static void test_select( IWbemServices *services )
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %08x\n", hr );
- for (i = 0; i < sizeof(test)/sizeof(test[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( test ); i++)
{
hr = exec_query( services, test[i], &result );
ok( hr == S_OK, "query %u failed: %08x\n", i, hr );
@@ -168,7 +168,7 @@ static void test_associators( IWbemServices *services )
IEnumWbemClassObject *result;
UINT i;
- for (i = 0; i < sizeof(test)/sizeof(test[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( test ); i++)
{
hr = exec_query( services, test[i], &result );
todo_wine ok( hr == S_OK, "query %u failed: %08x\n", i, hr );
@@ -398,7 +398,7 @@ static void test_Win32_Bios( IWbemServices *services )
SysFreeString( wql );
}
-static void test_Win32_Process( IWbemServices *services )
+static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
{
static const WCHAR returnvalueW[] =
{'R','e','t','u','r','n','V','a','l','u','e',0};
static const WCHAR getownerW[] =
{'G','e','t','O','w','n','e','r',0};
@@ -408,18 +408,33 @@ static void test_Win32_Process( IWbemServices *services )
static const WCHAR idW[] = {'I','D',0};
static const WCHAR fmtW[] =
{'W','i','n','3','2','_','P','r','o','c','e','s','s','.',
'H','a','n','d','l','e','=','"','%','u','"',0};
+ static const WCHAR full_path_fmt[] =
+
{'\\','\\','%','s','\\','R','O','O','T','\\','C','I','M','V','2',':',0};
static const LONG expected_flavor = WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
WBEM_FLAVOR_NOT_OVERRIDABLE |
WBEM_FLAVOR_ORIGIN_PROPAGATED;
+ WCHAR full_path[MAX_COMPUTERNAME_LENGTH + ARRAY_SIZE(full_path_fmt)];
BSTR class, method;
- IWbemClassObject *process, *out;
+ IWbemClassObject *process, *sig_in, *out;
IWbemQualifierSet *qualifiers;
VARIANT user, domain, retval, val;
+ DWORD full_path_len = 0;
LONG flavor;
CIMTYPE type;
HRESULT hr;
- class = SysAllocString( processW );
+ if (use_full_path)
+ {
+ WCHAR server[MAX_COMPUTERNAME_LENGTH+1];
+
+ full_path_len = ARRAY_SIZE(server);
+ ok( GetComputerNameW(server, &full_path_len), "GetComputerName
failed\n" );
+ full_path_len = wsprintfW(full_path, full_path_fmt, server);
+ }
+
+ class = SysAllocStringLen( NULL, full_path_len + ARRAY_SIZE( processW ) );
+ memcpy( class, full_path, full_path_len * sizeof(WCHAR) );
+ memcpy( class + full_path_len, processW, sizeof(processW) );
hr = IWbemServices_GetObject( services, class, 0, NULL, &process, NULL );
SysFreeString( class );
if (hr != S_OK)
@@ -427,14 +442,17 @@ static void test_Win32_Process( IWbemServices *services )
win_skip( "Win32_Process not available\n" );
return;
}
- hr = IWbemClassObject_GetMethod( process, getownerW, 0, NULL, NULL );
+ sig_in = (void*)0xdeadbeef;
+ hr = IWbemClassObject_GetMethod( process, getownerW, 0, &sig_in, NULL );
ok( hr == S_OK, "failed to get GetOwner method %08x\n", hr );
+ ok( !sig_in, "sig_in != NULL\n");
IWbemClassObject_Release( process );
out = NULL;
method = SysAllocString( getownerW );
- class = SysAllocStringLen( NULL, sizeof(fmtW)/sizeof(fmtW[0]) + 10 );
- wsprintfW( class, fmtW, GetCurrentProcessId() );
+ class = SysAllocStringLen( NULL, full_path_len + ARRAY_SIZE( fmtW ) + 10 );
+ memcpy( class, full_path, full_path_len * sizeof(WCHAR) );
+ wsprintfW( class + full_path_len, fmtW, GetCurrentProcessId() );
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL
);
ok( hr == S_OK, "failed to execute method %08x\n", hr );
SysFreeString( method );
@@ -524,13 +542,13 @@ static void test_Win32_ComputerSystem( IWbemServices *services )
WCHAR username[128];
DWORD len, count;
- len = sizeof(compname) / sizeof(compname[0]);
+ len = ARRAY_SIZE( compname );
if (!GetComputerNameW( compname, &len ))
compname[0] = 0;
lstrcpyW( username, compname );
lstrcatW( username, backslashW );
- len = sizeof(username) / sizeof(username[0]) - lstrlenW( username );
+ len = ARRAY_SIZE( username ) - lstrlenW( username );
if (!GetUserNameW( username + lstrlenW( username ), &len ))
username[0] = 0;
@@ -704,6 +722,7 @@ static void test_Win32_SystemEnclosure( IWbemServices *services )
static void test_StdRegProv( IWbemServices *services )
{
+ static const WCHAR createkeyW[] =
{'C','r','e','a','t','e','K','e','y',0};
static const WCHAR enumkeyW[] =
{'E','n','u','m','K','e','y',0};
static const WCHAR enumvaluesW[] =
{'E','n','u','m','V','a','l','u','e','s',0};
static const WCHAR getstringvalueW[] =
{'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
@@ -719,11 +738,14 @@ static void test_StdRegProv( IWbemServices *services )
static const WCHAR windowsW[] =
{'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
- BSTR class = SysAllocString( stdregprovW ), method;
- IWbemClassObject *reg, *sig_in, *in, *out;
+ static const WCHAR regtestW[] =
+
{'S','o','f','t','w','a','r','e','\\','S','t','d','R','e','g','P','r','o','v','T','e','s','t',0};
+ BSTR class = SysAllocString( stdregprovW ), method, name;
+ IWbemClassObject *reg, *sig_in, *sig_out, *in, *out;
VARIANT defkey, subkey, retval, names, types, value, valuename;
CIMTYPE type;
HRESULT hr;
+ LONG res;
hr = IWbemServices_GetObject( services, class, 0, NULL, ®, NULL );
if (hr != S_OK)
@@ -731,6 +753,67 @@ static void test_StdRegProv( IWbemServices *services )
win_skip( "StdRegProv not available\n" );
return;
}
+
+ hr = IWbemClassObject_BeginMethodEnumeration( reg, 0 );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ while (IWbemClassObject_NextMethod( reg, 0, &name, &sig_in, &sig_out ) ==
S_OK)
+ {
+ SysFreeString( name );
+ IWbemClassObject_Release( sig_in );
+ IWbemClassObject_Release( sig_out );
+ }
+
+ hr = IWbemClassObject_EndMethodEnumeration( reg );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = IWbemClassObject_BeginEnumeration( reg, 0 );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ while (IWbemClassObject_Next( reg, 0, &name, NULL, NULL, NULL ) == S_OK)
+ SysFreeString( name );
+
+ hr = IWbemClassObject_EndEnumeration( reg );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = IWbemClassObject_GetMethod( reg, createkeyW, 0, &sig_in, NULL );
+ ok( hr == S_OK, "failed to get CreateKey method %08x\n", hr );
+
+ hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in );
+ ok( hr == S_OK, "failed to spawn instance %08x\n", hr );
+
+ V_VT( &defkey ) = VT_I4;
+ V_I4( &defkey ) = 0x80000001;
+ hr = IWbemClassObject_Put( in, defkeyW, 0, &defkey, 0 );
+ ok( hr == S_OK, "failed to set root %08x\n", hr );
+
+ V_VT( &subkey ) = VT_BSTR;
+ V_BSTR( &subkey ) = SysAllocString( regtestW );
+ hr = IWbemClassObject_Put( in, subkeynameW, 0, &subkey, 0 );
+ ok( hr == S_OK, "failed to set subkey %08x\n", hr );
+
+ out = NULL;
+ method = SysAllocString( createkeyW );
+ hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL
);
+ ok( hr == S_OK, "failed to execute method %08x\n", hr );
+ SysFreeString( method );
+
+ type = 0xdeadbeef;
+ VariantInit( &retval );
+ hr = IWbemClassObject_Get( out, returnvalueW, 0, &retval, &type, NULL );
+ ok( hr == S_OK, "failed to get return value %08x\n", hr );
+ ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT(
&retval ) );
+ ok( !V_I4( &retval ), "unexpected error %u\n", V_UI4( &retval ) );
+ ok( type == CIM_UINT32, "unexpected type 0x%x\n", type );
+
+ res = RegDeleteKeyW( HKEY_CURRENT_USER, regtestW );
+ ok( !res, "got %d\n", res );
+
+ VariantClear( &subkey );
+ IWbemClassObject_Release( in );
+ IWbemClassObject_Release( out );
+ IWbemClassObject_Release( sig_in );
+
hr = IWbemClassObject_GetMethod( reg, enumkeyW, 0, &sig_in, NULL );
ok( hr == S_OK, "failed to get EnumKey method %08x\n", hr );
@@ -1126,6 +1209,14 @@ static void test_Win32_OperatingSystem( IWbemServices *services )
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
ok( hr == S_OK, "IEnumWbemClassObject_Next failed %08x\n", hr );
+ hr = IWbemClassObject_BeginEnumeration( obj, 0 );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ while (IWbemClassObject_Next( obj, 0, NULL, NULL, NULL, NULL ) == S_OK) {}
+
+ hr = IWbemClassObject_EndEnumeration( obj );
+ ok( hr == S_OK, "got %08x\n", hr );
+
type = 0xdeadbeef;
VariantInit( &val );
hr = IWbemClassObject_Get( obj, buildnumberW, 0, &val, &type, NULL );
@@ -1368,25 +1459,28 @@ static void test_Win32_PhysicalMemory( IWbemServices *services )
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 );
+ if (count > 0)
+ {
+ 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 );
+ 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 );
+ IWbemClassObject_Release( obj );
+ }
IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
@@ -1450,6 +1544,7 @@ static void test_Win32_IP4RouteTable( IWbemServices *services )
IWbemClassObject_Release( obj );
}
+ IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
}
@@ -1562,6 +1657,7 @@ static void test_Win32_Processor( IWbemServices *services )
IWbemClassObject_Release( obj );
}
+ IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
}
@@ -1637,6 +1733,7 @@ static void test_Win32_VideoController( IWbemServices *services )
IWbemClassObject_Release( obj );
}
+ IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
}
@@ -1702,10 +1799,61 @@ static void test_Win32_Printer( IWbemServices *services )
IWbemClassObject_Release( obj );
}
+ IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
}
+static void test_Win32_PnPEntity( IWbemServices *services )
+{
+ HRESULT hr;
+ IEnumWbemClassObject *enm;
+ IWbemClassObject *obj;
+ VARIANT val;
+ CIMTYPE type;
+ ULONG count, i;
+ BSTR bstr;
+
+ static WCHAR win32_pnpentityW[] =
{'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0};
+ static const WCHAR deviceidW[] =
{'D','e','v','i','c','e','I','d',0};
+
+ bstr = SysAllocString( win32_pnpentityW );
+
+ hr = IWbemServices_CreateInstanceEnum( services, bstr, 0, NULL, &enm );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ SysFreeString( bstr );
+ bstr = SysAllocString( deviceidW );
+
+ while (1)
+ {
+ hr = IEnumWbemClassObject_Next( enm, 1000, 1, &obj, &count );
+ ok( (count == 1 && (hr == WBEM_S_FALSE || hr == WBEM_S_NO_ERROR)) ||
+ (count == 0 && (hr == WBEM_S_FALSE || hr == WBEM_S_TIMEDOUT)),
+ "got %08x with %u objects returned\n", hr, count );
+
+ if (count == 0)
+ break;
+
+ for (i = 0; i < count; ++i)
+ {
+ hr = IWbemClassObject_Get( obj, bstr, 0, &val, &type, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ if (SUCCEEDED( hr ))
+ {
+ ok( V_VT( &val ) == VT_BSTR, "unexpected variant type
0x%x\n", V_VT( &val ) );
+ ok( type == CIM_STRING, "unexpected type 0x%x\n", type );
+ VariantClear( &val );
+ }
+ }
+ }
+
+ SysFreeString( bstr );
+
+ IEnumWbemClassObject_Release( enm );
+}
+
START_TEST(query)
{
static const WCHAR cimv2W[] =
{'R','O','O','T','\\','C','I','M','V','2',0};
@@ -1734,7 +1882,8 @@ START_TEST(query)
test_select( services );
test_associators( services );
test_Win32_Bios( services );
- test_Win32_Process( services );
+ test_Win32_Process( services, FALSE );
+ test_Win32_Process( services, TRUE );
test_Win32_Service( services );
test_Win32_ComputerSystem( services );
test_Win32_SystemEnclosure( services );
@@ -1750,6 +1899,7 @@ START_TEST(query)
test_Win32_Processor( services );
test_Win32_VideoController( services );
test_Win32_Printer( services );
+ test_Win32_PnPEntity( services );
SysFreeString( path );
IWbemServices_Release( services );
diff --git a/modules/rostests/winetests/wbemprox/services.c
b/modules/rostests/winetests/wbemprox/services.c
index a6774751f3..da10e72fe1 100644
--- a/modules/rostests/winetests/wbemprox/services.c
+++ b/modules/rostests/winetests/wbemprox/services.c
@@ -164,7 +164,7 @@ static void test_IWbemLocator(void)
}
ok( hr == S_OK, "failed to create IWbemLocator interface %08x\n", hr );
- for (i = 0; i < sizeof(test) / sizeof(test[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( test ); i++)
{
resource = SysAllocString( test[i].path );
hr = IWbemLocator_ConnectServer( locator, resource, NULL, NULL, NULL, 0, NULL,
NULL, &services );