[PATCH 2/7] ntoskrnl.exe/tests: Make HID driver service name dynamic.

Zebediah Figura (she/her) zfigura at codeweavers.com
Fri Jun 11 14:53:41 CDT 2021


On 6/11/21 10:52 AM, Rémi Bernon wrote:
> On 6/11/21 5:44 PM, Zebediah Figura (she/her) wrote:
>> On 6/11/21 5:43 AM, Rémi Bernon wrote:
>>> Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
>>> ---
>>>    dlls/ntoskrnl.exe/tests/ntoskrnl.c | 14 ++++++++------
>>>    1 file changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
>>> b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
>>> index ff73e8eae18..90d68149c1f 100644
>>> --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
>>> +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
>>> @@ -967,7 +967,7 @@ static const char inf_text[] =
>>>        "CopyFiles=file_section\n"
>>>        "[device_section.NT" EXT ".Services]\n"
>>> -    "AddService=winetest,0x2,svc_section\n"
>>> +    "AddService=%s,0x2,svc_section\n"
>>>        "[file_section]\n"
>>>        "winetest.sys\n"
>>> @@ -982,7 +982,7 @@ static const char inf_text[] =
>>>        "DefaultDestDir=12\n"
>>>        "[svc_section]\n"
>>> -    "ServiceBinary=%12%\\winetest.sys\n"
>>> +    "ServiceBinary=%%12%%\\winetest.sys\n"
>>>        "ServiceType=1\n"
>>>        "StartType=3\n"
>>>        "ErrorControl=1\n"
>>> @@ -1374,6 +1374,7 @@ static void test_pnp_devices(void)
>>>    static void test_pnp_driver(struct testsign_context *ctx)
>>>    {
>>>        static const char hardware_id[] = "test_hardware_id\0";
>>> +    static const char service_name[] = "winetest_pnp";
>>>        char path[MAX_PATH], dest[MAX_PATH], *filepart;
>>>        SP_DEVINFO_DATA device = {sizeof(device)};
>>>        char cwd[MAX_PATH], tempdir[MAX_PATH];
>>> @@ -1395,7 +1396,7 @@ static void test_pnp_driver(struct
>>> testsign_context *ctx)
>>>        f = fopen("winetest.inf", "w");
>>>        ok(!!f, "failed to open winetest.inf: %s\n", strerror(errno));
>>> -    fputs(inf_text, f);
>>> +    fprintf(f, inf_text, service_name);
>>>        fclose(f);
>>>        /* Create the catalog file. */
>>> @@ -1472,7 +1473,7 @@ static void test_pnp_driver(struct
>>> testsign_context *ctx)
>>>        /* Windows stops the service but does not delete it. */
>>>        manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
>>>        ok(!!manager, "failed to open service manager, error %u\n",
>>> GetLastError());
>>> -    service = OpenServiceA(manager, "winetest", SERVICE_STOP | DELETE);
>>> +    service = OpenServiceA(manager, service_name, SERVICE_STOP |
>>> DELETE);
>>>        ok(!!service, "failed to open service, error %u\n",
>>> GetLastError());
>>>        unload_driver(service);
>>>        CloseServiceHandle(manager);
>>> @@ -2031,6 +2032,7 @@ static void test_hid_device(void)
>>>    static void test_hid_driver(struct testsign_context *ctx)
>>>    {
>>>        static const char hardware_id[] = "test_hardware_id\0";
>>> +    static const char service_name[] = "winetest_hid";
>>>        char path[MAX_PATH], dest[MAX_PATH], *filepart;
>>>        SP_DEVINFO_DATA device = {sizeof(device)};
>>>        char cwd[MAX_PATH], tempdir[MAX_PATH];
>>> @@ -2051,7 +2053,7 @@ static void test_hid_driver(struct
>>> testsign_context *ctx)
>>>        f = fopen("winetest.inf", "w");
>>>        ok(!!f, "failed to open winetest.inf: %s\n", strerror(errno));
>>> -    fputs(inf_text, f);
>>> +    fprintf(f, inf_text, service_name);
>>>        fclose(f);
>>>        /* Create the catalog file. */
>>> @@ -2109,7 +2111,7 @@ static void test_hid_driver(struct
>>> testsign_context *ctx)
>>>        /* Windows stops the service but does not delete it. */
>>>        manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
>>>        ok(!!manager, "failed to open service manager, error %u\n",
>>> GetLastError());
>>> -    service = OpenServiceA(manager, "winetest", SERVICE_STOP | DELETE);
>>> +    service = OpenServiceA(manager, service_name, SERVICE_STOP |
>>> DELETE);
>>>        ok(!!service, "failed to open service, error %u\n",
>>> GetLastError());
>>>        unload_driver(service);
>>>        CloseServiceHandle(manager);
>>>
>>
>> What's the motivation for this?
>>
> 
> Be able to pass arguments to the driver somehow. It's used to run the
> driver two times, one without report ids and one with, with very little
> code duplication and with the same tests run in both case.
> 

Okay, I guess that makes sense. It's not the most intuitive way to pass 
that data (I guess that'd be via registry values), and it'd also be nice 
if we could just use a separate TLC instead of having to run the driver 
twice, but of course we don't have support for multiple TLCs yet...



More information about the wine-devel mailing list