pdh: Add tests for opening and closing queries.
[wine] / dlls / pdh / tests / pdh.c
1 /*
2  * Tests for pdh.dll (Performance Data Helper)
3  *
4  * Copyright 2007 Hans Leidekker
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdio.h>
22
23 #include "windows.h"
24
25 #include "pdh.h"
26 #include "pdhmsg.h"
27
28 #include "wine/test.h"
29
30 static void test_open_close_query( void )
31 {
32     PDH_STATUS ret;
33     PDH_HQUERY query;
34
35     ret = PdhOpenQueryA( NULL, 0, NULL );
36     ok(ret == PDH_INVALID_ARGUMENT, "PdhOpenQueryA failed 0x%08x\n", ret);
37
38     ret = PdhOpenQueryA( NULL, 0, &query );
39     ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
40
41     ret = PdhCloseQuery( NULL );
42     ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
43
44     ret = PdhCloseQuery( &query );
45     ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
46
47     ret = PdhCloseQuery( query );
48     ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
49 }
50
51 START_TEST(pdh)
52 {
53     test_open_close_query();
54 }