1 /* Unit test suite for *Information* Registry API functions
3 * Copyright 2005 Paul Vriens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "ntdll_test.h"
23 static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
25 static HMODULE hntdll = 0;
27 #define NTDLL_GET_PROC(func) \
28 p ## func = (void*)GetProcAddress(hntdll, #func); \
30 trace("GetProcAddress(%s) failed\n", #func); \
31 FreeLibrary(hntdll); \
35 static BOOL InitFunctionPtrs(void)
37 hntdll = LoadLibraryA("ntdll.dll");
39 trace("Could not load ntdll.dll\n");
44 NTDLL_GET_PROC(NtQuerySystemInformation)
49 static void test_basic()
54 SYSTEM_BASIC_INFORMATION* sbi = HeapAlloc(GetProcessHeap(), 0, sizeof(*sbi));
56 /* This test also covers some basic parameter testing that should be the same for
57 * every information class
60 /* Use a nonexistent info class */
61 trace("Check nonexistent info class\n");
62 status = pNtQuerySystemInformation(-1, NULL, 0, NULL);
63 ok( status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got %08lx\n", status);
65 /* Use an existing class but with a zero-length buffer */
66 trace("Check zero-length buffer\n");
67 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, 0, NULL);
68 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
70 /* Use an existing class, correct length but no SystemInformation buffer */
71 trace("Check no SystemInformation buffer\n");
72 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, sizeof(*sbi), NULL);
73 ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
75 /* Use a existing class, correct length, a pointer to a buffer but no ReturnLength pointer */
76 trace("Check no ReturnLength pointer\n");
77 status = pNtQuerySystemInformation(SystemBasicInformation, sbi, sizeof(*sbi), NULL);
78 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
80 /* Finally some correct calls */
81 trace("Check with correct parameters\n");
82 status = pNtQuerySystemInformation(SystemBasicInformation, sbi, sizeof(*sbi), &ReturnLength);
83 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
84 ok( sizeof(*sbi) == ReturnLength, "Inconsistent length (%08x) <-> (%ld)\n", sizeof(*sbi), ReturnLength);
86 /* Check if we have some return values */
87 trace("Number of Processors : %d\n", sbi->NumberOfProcessors);
88 ok( sbi->NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n", sbi->NumberOfProcessors);
90 HeapFree(GetProcessHeap(), 0, sbi);
95 if(!InitFunctionPtrs())
98 /* 0 SystemBasicInformation */
99 trace("Starting test_basic()\n");