1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*============================================================ |
6 | ** |
7 | ** Source : test.c |
8 | ** |
9 | ** Purpose: Test for GetEnvironmentVariable() function |
10 | ** Pass a small buffer to GetEnvironmentVariableA to ensure |
11 | ** it returns the size it requires. |
12 | ** |
13 | ** |
14 | **=========================================================*/ |
15 | |
16 | #include <palsuite.h> |
17 | |
18 | #define SMALL_BUFFER_SIZE 1 |
19 | |
20 | int __cdecl main(int argc, char *argv[]) { |
21 | |
22 | /* A place to stash the returned values */ |
23 | int ReturnValueForSmallBuffer = 0; |
24 | |
25 | char pSmallBuffer[SMALL_BUFFER_SIZE]; |
26 | |
27 | /* |
28 | * Initialize the PAL and return FAILURE if this fails |
29 | */ |
30 | |
31 | if(0 != (PAL_Initialize(argc, argv))) |
32 | { |
33 | return FAIL; |
34 | } |
35 | |
36 | /* PATH won't fit in this buffer, it should return how many |
37 | characters it needs |
38 | */ |
39 | |
40 | ReturnValueForSmallBuffer = GetEnvironmentVariable("PATH" , |
41 | pSmallBuffer, |
42 | SMALL_BUFFER_SIZE); |
43 | if(ReturnValueForSmallBuffer <= 0) |
44 | { |
45 | Fail("The return value was %d when it should have been greater " |
46 | "than 0. " |
47 | "This should return the number of characters needed to contained " |
48 | "the contents of PATH in a buffer.\n" ,ReturnValueForSmallBuffer); |
49 | } |
50 | |
51 | PAL_Terminate(); |
52 | return PASS; |
53 | } |
54 | |
55 | |
56 | |
57 | |