diff options
Diffstat (limited to 'src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4')
3 files changed, 98 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/CMakeLists.txt new file mode 100644 index 0000000000..f870bd6b22 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test.c +) + +add_executable(paltest_getenvironmentvariablew_test4 + ${SOURCES} +) + +add_dependencies(paltest_getenvironmentvariablew_test4 coreclrpal) + +target_link_libraries(paltest_getenvironmentvariablew_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/test.c b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/test.c new file mode 100644 index 0000000000..b5894efc6e --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/test.c @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*============================================================ +** +** Source : test.c +** +** Purpose: Test for GetEnvironmentVariable() function +** +** +**=========================================================*/ + +/* Depends on SetEnvironmentVariableW (because we're implmenting the wide + version) and strcmp() */ + +#define UNICODE +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) { + + /* Define some buffers needed for the function */ + WCHAR * pResultBuffer = NULL; + WCHAR SomeEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; + WCHAR TheEnvironmentValue[] = {'T','E','S','T','\0'}; + int size; + + /* + * Initialize the PAL and return FAILURE if this fails + */ + + if(0 != (PAL_Initialize(argc, argv))) + { + return FAIL; + } + + SetEnvironmentVariable(SomeEnvironmentVariable, + TheEnvironmentValue); + + + /* Normal case, PATH should fit into this buffer */ + size = GetEnvironmentVariable(convert("PALTEST"), // Variable Name + pResultBuffer, // Buffer for Value + 0); // Buffer size + + pResultBuffer = malloc(size*sizeof(WCHAR)); + + GetEnvironmentVariable(convert("PALTEST"), + pResultBuffer, + size); + + if(wcsncmp(pResultBuffer,convert("TEST"),wcslen(pResultBuffer) * 2) != 0) + { + Fail("ERROR: The value in the buffer should have been 'TEST' but was " + "really '%s'.",convertC(pResultBuffer)); + } + + free(pResultBuffer); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/testinfo.dat new file mode 100644 index 0000000000..64204fa698 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/testinfo.dat @@ -0,0 +1,16 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = Miscellaneous +Function = GetEnvironmentVariableW +Name = Positive Test for GetEnvironmentVariableW +TYPE = DEFAULT +EXE1 = test +Description += Set an Environment Variable, then use GetEnvironmentVariable += to retrieve it -- ensure that it retrieves properly. + + + |