I added a new test method, please tell me if I should merge that into an existing one, but as far as I understood, there is no tests for the querying yet.
-- v3: wbemprox: Add property "ExecutablePath" to Win32_Process wbemprox/tests: Add test for Win32_Process querying "ExecutablePath" propery
From: Fabian Maurer dark.shadow4@web.de
--- dlls/wbemprox/tests/query.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index ea108e31e49..d7f0d093531 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -544,11 +544,15 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) static const LONG expected_flavor = WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE | WBEM_FLAVOR_ORIGIN_PROPAGATED; + BSTR wql = SysAllocString( L"wql" ), query; WCHAR full_path[MAX_COMPUTERNAME_LENGTH + ARRAY_SIZE( L"\\%s\ROOT\CIMV2:" )]; BSTR class, method; IWbemClassObject *process, *sig_in, *sig_out, *out, *params; WCHAR cmdlineW[MAX_PATH + 64 + 1]; IWbemQualifierSet *qualifiers; + IEnumWbemClassObject *enum_result; + WCHAR query_buffer[100]; + WCHAR executable_path[255]; VARIANT retval, val; SAFEARRAY *names; LONG bound, i; @@ -765,8 +769,42 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) hr = IWbemQualifierSet_Get( qualifiers, L"ID", 0, &val, &flavor ); ok( hr == WBEM_E_NOT_FOUND, "got %#lx\n", hr );
+ /* Test query and result properties */ + + wsprintfW( query_buffer, L"SELECT * FROM Win32_Process WHERE ProcessId = %lu\n", GetCurrentProcessId() ); + query = SysAllocString( query_buffer); + + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &enum_result ); + ok( hr == S_OK, "got %#lx\n", hr ); + if (hr == S_OK) + { + GetModuleFileNameW( NULL, executable_path, ARRAY_SIZE(executable_path) ); + + hr = IEnumWbemClassObject_Next( enum_result, 10000, 1, &process, &ret ); + ok( hr == S_OK, "got %#lx\n", hr ); + + type = 0xdeadbeef; + VariantInit( &val ); + todo_wine + hr = IWbemClassObject_Get( process, L"ExecutablePath", 0, &val, &type, NULL ); + todo_wine + ok( hr == S_OK, "IWbemClassObject_Get failed with %#lx\n", hr ); + todo_wine + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + todo_wine + ok( type == CIM_STRING, "unexpected type %#lx\n", type ); + todo_wine + ok( !lstrcmpiW( V_BSTR( &val ), executable_path), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&val)), wine_dbgstr_w(executable_path) ); + VariantClear( &val ); + + IWbemClassObject_Release( process ); + IEnumWbemClassObject_Release( enum_result ); + } + IWbemQualifierSet_Release( qualifiers ); IWbemClassObject_Release( out ); + SysFreeString( wql ); + SysFreeString( query ); }
static void test_Win32_ComputerSystem( IWbemServices *services )
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57314 --- dlls/wbemprox/builtin.c | 24 ++++++++++++++++++++++++ dlls/wbemprox/tests/query.c | 5 ----- 2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 80434e5f19f..3fbcf038467 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -323,6 +323,7 @@ static const struct column col_process[] = { L"Caption", CIM_STRING|COL_FLAG_DYNAMIC }, { L"CommandLine", CIM_STRING|COL_FLAG_DYNAMIC }, { L"Description", CIM_STRING|COL_FLAG_DYNAMIC }, + { L"ExecutablePath", CIM_STRING|COL_FLAG_DYNAMIC }, { L"Handle", CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }, { L"Name", CIM_STRING|COL_FLAG_DYNAMIC }, { L"ParentProcessID", CIM_UINT32 }, @@ -815,6 +816,7 @@ struct record_process const WCHAR *caption; const WCHAR *commandline; const WCHAR *description; + const WCHAR *executablepath; const WCHAR *handle; const WCHAR *name; UINT32 pprocess_id; @@ -3360,6 +3362,27 @@ static WCHAR *get_cmdline( DWORD process_id ) return NULL; /* FIXME handle different process case */ }
+static WCHAR *get_executablepath( DWORD process_id ) +{ + DWORD size = MAX_PATH; + HANDLE process = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_id ); + WCHAR *executable_path = calloc(sizeof(WCHAR), size + 1); + if (!process) + { + ERR( "Failed to open process %lu: %lu\n", process_id, GetLastError() ); + return wcsdup( L"" ); + } + + while (!QueryFullProcessImageNameW( process, 0, executable_path, &size ) && GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + size *= 2; + executable_path = realloc(executable_path, (size + 1) * sizeof(WCHAR)); + } + + CloseHandle( process ); + return executable_path; +} + static enum fill_status fill_process( struct table *table, const struct expr *cond ) { WCHAR handle[11]; @@ -3388,6 +3411,7 @@ static enum fill_status fill_process( struct table *table, const struct expr *co rec->caption = wcsdup( entry.szExeFile ); rec->commandline = get_cmdline( entry.th32ProcessID ); rec->description = wcsdup( entry.szExeFile ); + rec->executablepath = get_executablepath( entry.th32ProcessID ); swprintf( handle, ARRAY_SIZE( handle ), L"%u", entry.th32ProcessID ); rec->handle = wcsdup( handle ); rec->name = wcsdup( entry.szExeFile ); diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index d7f0d093531..bc6dee89a53 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -785,15 +785,10 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
type = 0xdeadbeef; VariantInit( &val ); - todo_wine hr = IWbemClassObject_Get( process, L"ExecutablePath", 0, &val, &type, NULL ); - todo_wine ok( hr == S_OK, "IWbemClassObject_Get failed with %#lx\n", hr ); - todo_wine ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); - todo_wine ok( type == CIM_STRING, "unexpected type %#lx\n", type ); - todo_wine ok( !lstrcmpiW( V_BSTR( &val ), executable_path), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&val)), wine_dbgstr_w(executable_path) ); VariantClear( &val );
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=149317
Your paranoid android.
=== debian11b (64 bit WoW report) ===
kernel32: comm.c:1574: Test failed: AbortWaitCts hComPortEvent failed comm.c:1586: Test failed: Unexpected time 1001, expected around 500
On Fri Oct 25 20:02:32 2024 +0000, Fabian Maurer wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/6734/diffs?diff_id=140203&start_sha=c9c987dd8fb405da8d1eff689f5c8ac77741069a#e7d2a960623dc4e9d46a79a72ee8968a4d19cfab_777_772)
Sure, updated
On Fri Oct 25 20:02:33 2024 +0000, Fabian Maurer wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/6734/diffs?diff_id=140203&start_sha=c9c987dd8fb405da8d1eff689f5c8ac77741069a#38386f740b0689e89d38acb18360b6b790541752_3400_3410)
Thanks, updated. Although dynamically is a bit ugly, the only way to get the size is to repeatedly call the function until it doesn't say "buffer too small" anymore.
Hans Leidekker (@hans) commented about dlls/wbemprox/tests/query.c:
hr = IWbemQualifierSet_Get( qualifiers, L"ID", 0, &val, &flavor ); ok( hr == WBEM_E_NOT_FOUND, "got %#lx\n", hr );
- /* Test query and result properties */
- wsprintfW( query_buffer, L"SELECT * FROM Win32_Process WHERE ProcessId = %lu\n", GetCurrentProcessId() );
- query = SysAllocString( query_buffer);
- hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &enum_result );
- ok( hr == S_OK, "got %#lx\n", hr );
You don't need this query, you already have a process object in this test.
Hans Leidekker (@hans) commented about dlls/wbemprox/builtin.c:
return NULL; /* FIXME handle different process case */
}
+static WCHAR *get_executablepath( DWORD process_id ) +{
- DWORD size = MAX_PATH;
- HANDLE process = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_id );
- WCHAR *executable_path = calloc(sizeof(WCHAR), size + 1);
- if (!process)
- {
ERR( "Failed to open process %lu: %lu\n", process_id, GetLastError() );
return wcsdup( L"" );
I don't think this is worth an error message, the process may legitimately disappear before this is called. And returning NULL is fine in that case.
On Fri Oct 25 21:38:35 2024 +0000, Hans Leidekker wrote:
You don't need this query, you already have a process object in this test.
I might be overlooking something, but where do you mean?
On Fri Oct 25 22:38:04 2024 +0000, Fabian Maurer wrote:
I might be overlooking something, but where do you mean?
I see it's a class object rather than an instance object, but you still don't need a query.
On Thu Oct 31 13:42:52 2024 +0000, Hans Leidekker wrote:
I see it's a class object rather than an instance object, but you still don't need a query.
[wbemprox_test.diff](/uploads/b7cf630004b8c4e9b5fd0e35a2fe6230/wbemprox_test.diff) How about this?