push b0b97fcd59eff07f047585692fa36859b459324f
[wine/hacks.git] / dlls / kernel32 / tests / environ.c
blobad3734f26ba73700f668d6c5940a43ae5c532f6b
1 /*
2 * Unit test suite for environment functions.
4 * Copyright 2002 Dmitry Timoshkov
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.
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.
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
21 #include <stdarg.h>
23 #include "wine/test.h"
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "winnls.h"
29 static CHAR string[MAX_PATH];
30 #define ok_w(res, format, szString) \
32 WideCharToMultiByte(CP_ACP, 0, szString, -1, string, MAX_PATH, NULL, NULL); \
33 ok(res, format, string);
35 static BOOL (WINAPI *pGetComputerNameExA)(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
36 static BOOL (WINAPI *pGetComputerNameExW)(COMPUTER_NAME_FORMAT,LPWSTR,LPDWORD);
38 static void init_functionpointers(void)
40 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
42 pGetComputerNameExA = (void *)GetProcAddress(hkernel32, "GetComputerNameExA");
43 pGetComputerNameExW = (void *)GetProcAddress(hkernel32, "GetComputerNameExW");
46 static void test_GetSetEnvironmentVariableA(void)
48 char buf[256];
49 BOOL ret;
50 DWORD ret_size;
51 static const char name[] = "SomeWildName";
52 static const char name_cased[] = "sOMEwILDnAME";
53 static const char value[] = "SomeWildValue";
55 ret = SetEnvironmentVariableA(name, value);
56 ok(ret == TRUE,
57 "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
58 GetLastError());
60 /* Try to retrieve the environment variable we just set */
61 ret_size = GetEnvironmentVariableA(name, NULL, 0);
62 ok(ret_size == strlen(value) + 1,
63 "should return length with terminating 0 ret_size=%d\n", ret_size);
65 lstrcpyA(buf, "foo");
66 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value));
67 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
68 ok(ret_size == strlen(value) + 1,
69 "should return length with terminating 0 ret_size=%d\n", ret_size);
71 lstrcpyA(buf, "foo");
72 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
73 ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
74 ok(ret_size == strlen(value),
75 "should return length without terminating 0 ret_size=%d\n", ret_size);
77 lstrcpyA(buf, "foo");
78 ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
79 ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
80 ok(ret_size == strlen(value),
81 "should return length without terminating 0 ret_size=%d\n", ret_size);
83 /* Remove that environment variable */
84 ret = SetEnvironmentVariableA(name_cased, NULL);
85 ok(ret == TRUE, "should erase existing variable\n");
87 lstrcpyA(buf, "foo");
88 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
89 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
90 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
91 "should not find variable but ret_size=%d GetLastError=%d\n",
92 ret_size, GetLastError());
94 /* Check behavior of SetEnvironmentVariableA(name, "") */
95 ret = SetEnvironmentVariableA(name, value);
96 ok(ret == TRUE,
97 "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
98 GetLastError());
100 lstrcpyA(buf, "foo");
101 ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
102 ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
103 ok(ret_size == strlen(value),
104 "should return length without terminating 0 ret_size=%d\n", ret_size);
106 ret = SetEnvironmentVariableA(name_cased, "");
107 ok(ret == TRUE,
108 "should not fail with empty value but GetLastError=%d\n", GetLastError());
110 lstrcpyA(buf, "foo");
111 SetLastError(0);
112 ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
113 ok(ret_size == 0 &&
114 ((GetLastError() == 0 && lstrcmpA(buf, "") == 0) ||
115 (GetLastError() == ERROR_ENVVAR_NOT_FOUND)),
116 "%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%d GetLastError=%d and buf=%s\n",
117 name, ret_size, GetLastError(), buf);
119 /* Test the limits */
120 ret_size = GetEnvironmentVariableA(NULL, NULL, 0);
121 ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
122 "should not find variable but ret_size=%d GetLastError=%d\n",
123 ret_size, GetLastError());
125 ret_size = GetEnvironmentVariableA(NULL, buf, lstrlenA(value) + 1);
126 ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
127 "should not find variable but ret_size=%d GetLastError=%d\n",
128 ret_size, GetLastError());
130 ret_size = GetEnvironmentVariableA("", buf, lstrlenA(value) + 1);
131 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
132 "should not find variable but ret_size=%d GetLastError=%d\n",
133 ret_size, GetLastError());
136 static void test_GetSetEnvironmentVariableW(void)
138 WCHAR buf[256];
139 BOOL ret;
140 DWORD ret_size;
141 static const WCHAR name[] = {'S','o','m','e','W','i','l','d','N','a','m','e',0};
142 static const WCHAR value[] = {'S','o','m','e','W','i','l','d','V','a','l','u','e',0};
143 static const WCHAR name_cased[] = {'s','O','M','E','w','I','L','D','n','A','M','E',0};
144 static const WCHAR empty_strW[] = { 0 };
145 static const WCHAR fooW[] = {'f','o','o',0};
147 ret = SetEnvironmentVariableW(name, value);
148 if (ret == FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
150 /* Must be Win9x which doesn't support the Unicode functions */
151 skip("SetEnvironmentVariableW is not implemented\n");
152 return;
154 ok(ret == TRUE,
155 "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
156 GetLastError());
158 /* Try to retrieve the environment variable we just set */
159 ret_size = GetEnvironmentVariableW(name, NULL, 0);
160 ok(ret_size == lstrlenW(value) + 1,
161 "should return length with terminating 0 ret_size=%d\n",
162 ret_size);
164 lstrcpyW(buf, fooW);
165 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value));
166 ok_w(lstrcmpW(buf, fooW) == 0, "should not touch the buffer: %s\n", buf);
168 ok(ret_size == lstrlenW(value) + 1,
169 "should return length with terminating 0 ret_size=%d\n", ret_size);
171 lstrcpyW(buf, fooW);
172 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
173 ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
174 ok(ret_size == lstrlenW(value),
175 "should return length without terminating 0 ret_size=%d\n", ret_size);
177 lstrcpyW(buf, fooW);
178 ret_size = GetEnvironmentVariableW(name_cased, buf, lstrlenW(value) + 1);
179 ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
180 ok(ret_size == lstrlenW(value),
181 "should return length without terminating 0 ret_size=%d\n", ret_size);
183 /* Remove that environment variable */
184 ret = SetEnvironmentVariableW(name_cased, NULL);
185 ok(ret == TRUE, "should erase existing variable\n");
187 lstrcpyW(buf, fooW);
188 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
189 ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
190 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
191 "should not find variable but ret_size=%d GetLastError=%d\n",
192 ret_size, GetLastError());
194 /* Check behavior of SetEnvironmentVariableW(name, "") */
195 ret = SetEnvironmentVariableW(name, value);
196 ok(ret == TRUE,
197 "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
198 GetLastError());
200 lstrcpyW(buf, fooW);
201 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
202 ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
203 ok(ret_size == lstrlenW(value),
204 "should return length without terminating 0 ret_size=%d\n", ret_size);
206 ret = SetEnvironmentVariableW(name_cased, empty_strW);
207 ok(ret == TRUE, "should not fail with empty value but GetLastError=%d\n", GetLastError());
209 lstrcpyW(buf, fooW);
210 ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
211 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
212 "should not find variable but ret_size=%d GetLastError=%d\n",
213 ret_size, GetLastError());
214 ok(lstrcmpW(buf, empty_strW) == 0, "should copy an empty string\n");
216 /* Test the limits */
217 ret_size = GetEnvironmentVariableW(NULL, NULL, 0);
218 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
219 "should not find variable but ret_size=%d GetLastError=%d\n",
220 ret_size, GetLastError());
222 if (0) /* Both tests crash on Vista */
224 ret_size = GetEnvironmentVariableW(NULL, buf, lstrlenW(value) + 1);
225 ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
226 "should not find variable but ret_size=%d GetLastError=%d\n",
227 ret_size, GetLastError());
229 ret = SetEnvironmentVariableW(NULL, NULL);
230 ok(ret == FALSE && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
231 "should fail with NULL, NULL but ret=%d and GetLastError=%d\n",
232 ret, GetLastError());
236 static void test_ExpandEnvironmentStringsA(void)
238 const char* value="Long long value";
239 const char* not_an_env_var="%NotAnEnvVar%";
240 char buf[256], buf1[256], buf2[0x8000];
241 DWORD ret_size, ret_size1;
243 SetEnvironmentVariableA("EnvVar", value);
245 ret_size = ExpandEnvironmentStringsA(NULL, buf1, sizeof(buf1));
246 ok(ret_size == 1 || ret_size == 0 /* Win9x */,
247 "ExpandEnvironmentStrings returned %d\n", ret_size);
249 /* Try to get the required buffer size 'the natural way' */
250 strcpy(buf, "%EnvVar%");
251 ret_size = ExpandEnvironmentStringsA(buf, NULL, 0);
252 ok(ret_size == strlen(value)+1 || /* win98 */
253 ret_size == strlen(value)+2 || /* win2k, XP, win2k3 */
254 ret_size == 0 /* Win95 */,
255 "ExpandEnvironmentStrings returned %d instead of %d, %d or %d\n",
256 ret_size, lstrlenA(value)+1, lstrlenA(value)+2, 0);
258 /* Again, side-stepping the Win95 bug */
259 ret_size = ExpandEnvironmentStringsA(buf, buf1, 0);
260 /* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
261 ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2,
262 "ExpandEnvironmentStrings returned %d instead of %d\n",
263 ret_size, lstrlenA(value)+1);
265 /* Try with a buffer that's too small */
266 ret_size = ExpandEnvironmentStringsA(buf, buf1, 12);
267 /* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
268 ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2,
269 "ExpandEnvironmentStrings returned %d instead of %d\n",
270 ret_size, lstrlenA(value)+1);
272 /* Try with a buffer of just the right size */
273 /* v5.1.2600.2945 (XP SP2) needs and returns len + 2 here! */
274 ret_size = ExpandEnvironmentStringsA(buf, buf1, ret_size);
275 ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2,
276 "ExpandEnvironmentStrings returned %d instead of %d\n",
277 ret_size, lstrlenA(value)+1);
278 ok(!strcmp(buf1, value), "ExpandEnvironmentStrings returned [%s]\n", buf1);
280 /* Try with an unset environment variable */
281 strcpy(buf, not_an_env_var);
282 ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
283 ok(ret_size == strlen(not_an_env_var)+1, "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlenA(value)+1);
284 ok(!strcmp(buf1, not_an_env_var), "ExpandEnvironmentStrings returned [%s]\n", buf1);
286 /* test a large destination size */
287 strcpy(buf, "12345");
288 ret_size = ExpandEnvironmentStringsA(buf, buf2, sizeof(buf2));
289 ok(!strcmp(buf, buf2), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n", buf, buf2, ret_size);
291 ret_size1 = GetWindowsDirectoryA(buf1,256);
292 ok ((ret_size1 >0) && (ret_size1<256), "GetWindowsDirectory Failed\n");
293 ret_size = ExpandEnvironmentStringsA("%SystemRoot%",buf,sizeof(buf));
294 if (ERROR_ENVVAR_NOT_FOUND != GetLastError())
296 ok(!strcmp(buf, buf1), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n", buf, buf1, ret_size);
299 /* Try with a variable that references another */
300 SetEnvironmentVariableA("IndirectVar", "Foo%EnvVar%Bar");
301 strcpy(buf, "Indirect-%IndirectVar%-Indirect");
302 strcpy(buf2, "Indirect-Foo%EnvVar%Bar-Indirect");
303 ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
304 ok(ret_size == strlen(buf2)+1, "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlen(buf2)+1);
305 ok(!strcmp(buf1, buf2), "ExpandEnvironmentStrings returned [%s]\n", buf1);
306 SetEnvironmentVariableA("IndirectVar", NULL);
308 SetEnvironmentVariableA("EnvVar", NULL);
311 static void test_GetComputerName(void)
313 DWORD size;
314 BOOL ret;
315 LPSTR name;
316 LPWSTR nameW;
317 DWORD error;
318 int name_len;
320 size = 0;
321 ret = GetComputerNameA((LPSTR)0xdeadbeef, &size);
322 error = GetLastError();
323 todo_wine
324 ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error);
326 /* Only Vista returns the computer name length as documented in the MSDN */
327 if (size != 0)
329 size++; /* nul terminating character */
330 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
331 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
332 ret = GetComputerNameA(name, &size);
333 ok(ret, "GetComputerNameA failed with error %d\n", GetLastError());
334 HeapFree(GetProcessHeap(), 0, name);
337 size = MAX_COMPUTERNAME_LENGTH + 1;
338 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
339 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
340 ret = GetComputerNameA(name, &size);
341 ok(ret, "GetComputerNameA failed with error %d\n", GetLastError());
342 trace("computer name is \"%s\"\n", name);
343 name_len = strlen(name);
344 ok(size == name_len, "size should be same as length, name_len=%d, size=%d\n", name_len, size);
345 HeapFree(GetProcessHeap(), 0, name);
347 size = 0;
348 SetLastError(0xdeadbeef);
349 ret = GetComputerNameW((LPWSTR)0xdeadbeef, &size);
350 error = GetLastError();
351 if (error == ERROR_CALL_NOT_IMPLEMENTED)
352 skip("GetComputerNameW is not implemented\n");
353 else
355 todo_wine
356 ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error);
357 size++; /* nul terminating character */
358 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
359 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
360 ret = GetComputerNameW(nameW, &size);
361 ok(ret, "GetComputerNameW failed with error %d\n", GetLastError());
362 HeapFree(GetProcessHeap(), 0, nameW);
366 static void test_GetComputerNameExA(void)
368 DWORD size;
369 BOOL ret;
370 LPSTR name;
371 DWORD error;
373 static const int MAX_COMP_NAME = 32767;
375 if (!pGetComputerNameExA)
377 skip("GetComputerNameExA function not implemented\n");
378 return;
381 size = 0;
382 ret = pGetComputerNameExA(ComputerNameDnsDomain, (LPSTR)0xdeadbeef, &size);
383 error = GetLastError();
384 ok(ret == 0, "Expected 0, got %d\n", ret);
385 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
387 /* size is not set in win2k */
388 size = MAX_COMP_NAME;
389 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
390 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
391 ret = pGetComputerNameExA(ComputerNameDnsDomain, name, &size);
392 ok(ret, "GetComputerNameExA(ComputerNameDnsDomain) failed with error %d\n", GetLastError());
393 trace("domain name is \"%s\"\n", name);
394 HeapFree(GetProcessHeap(), 0, name);
396 size = 0;
397 ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, (LPSTR)0xdeadbeef, &size);
398 error = GetLastError();
399 ok(ret == 0, "Expected 0, got %d\n", ret);
400 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
402 /* size is not set in win2k */
403 size = MAX_COMP_NAME;
404 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
405 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
406 ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, name, &size);
407 ok(ret, "GetComputerNameExA(ComputerNameDnsFullyQualified) failed with error %d\n", GetLastError());
408 trace("fully qualified hostname is \"%s\"\n", name);
409 HeapFree(GetProcessHeap(), 0, name);
411 size = 0;
412 ret = pGetComputerNameExA(ComputerNameDnsHostname, (LPSTR)0xdeadbeef, &size);
413 error = GetLastError();
414 ok(ret == 0, "Expected 0, got %d\n", ret);
415 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
417 /* size is not set in win2k */
418 size = MAX_COMP_NAME;
419 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
420 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
421 ret = pGetComputerNameExA(ComputerNameDnsHostname, name, &size);
422 ok(ret, "GetComputerNameExA(ComputerNameDnsHostname) failed with error %d\n", GetLastError());
423 trace("hostname is \"%s\"\n", name);
424 HeapFree(GetProcessHeap(), 0, name);
426 size = 0;
427 ret = pGetComputerNameExA(ComputerNameNetBIOS, (LPSTR)0xdeadbeef, &size);
428 error = GetLastError();
429 ok(ret == 0, "Expected 0, got %d\n", ret);
430 ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
432 /* size is not set in win2k */
433 size = MAX_COMP_NAME;
434 name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
435 ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
436 ret = pGetComputerNameExA(ComputerNameNetBIOS, name, &size);
437 ok(ret, "GetComputerNameExA(ComputerNameNetBIOS) failed with error %d\n", GetLastError());
438 trace("NetBIOS name is \"%s\"\n", name);
439 HeapFree(GetProcessHeap(), 0, name);
442 static void test_GetComputerNameExW(void)
444 DWORD size;
445 BOOL ret;
446 LPWSTR nameW;
447 DWORD error;
449 if (!pGetComputerNameExW)
451 skip("GetComputerNameExW function not implemented\n");
452 return;
455 size = 0;
456 ret = pGetComputerNameExW(ComputerNameDnsDomain, (LPWSTR)0xdeadbeef, &size);
457 error = GetLastError();
458 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
459 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
460 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
461 ret = pGetComputerNameExW(ComputerNameDnsDomain, nameW, &size);
462 ok(ret, "GetComputerNameExW(ComputerNameDnsDomain) failed with error %d\n", GetLastError());
463 HeapFree(GetProcessHeap(), 0, nameW);
465 size = 0;
466 ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, (LPWSTR)0xdeadbeef, &size);
467 error = GetLastError();
468 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
469 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
470 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
471 ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, nameW, &size);
472 ok(ret, "GetComputerNameExW(ComputerNameDnsFullyQualified) failed with error %d\n", GetLastError());
473 HeapFree(GetProcessHeap(), 0, nameW);
475 size = 0;
476 ret = pGetComputerNameExW(ComputerNameDnsHostname, (LPWSTR)0xdeadbeef, &size);
477 error = GetLastError();
478 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
479 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
480 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
481 ret = pGetComputerNameExW(ComputerNameDnsHostname, nameW, &size);
482 ok(ret, "GetComputerNameExW(ComputerNameDnsHostname) failed with error %d\n", GetLastError());
483 HeapFree(GetProcessHeap(), 0, nameW);
485 size = 0;
486 ret = pGetComputerNameExW(ComputerNameNetBIOS, (LPWSTR)0xdeadbeef, &size);
487 error = GetLastError();
488 ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
489 nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
490 ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
491 ret = pGetComputerNameExW(ComputerNameNetBIOS, nameW, &size);
492 ok(ret, "GetComputerNameExW(ComputerNameNetBIOS) failed with error %d\n", GetLastError());
493 HeapFree(GetProcessHeap(), 0, nameW);
496 START_TEST(environ)
498 init_functionpointers();
500 test_GetSetEnvironmentVariableA();
501 test_GetSetEnvironmentVariableW();
502 test_ExpandEnvironmentStringsA();
503 test_GetComputerName();
504 test_GetComputerNameExA();
505 test_GetComputerNameExW();