From db20f3f1bb8595633a7e16c8900fd401a453a6b5 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Tue, 27 Dec 2016 16:46:08 +0900 Subject: Imported Upstream version 1.0.0.9127 --- .../palsuite/c_runtime/getenv/test1/CMakeLists.txt | 2 +- .../tests/palsuite/c_runtime/getenv/test1/test1.c | 78 ---------------- .../palsuite/c_runtime/getenv/test1/test1.cpp | 78 ++++++++++++++++ .../palsuite/c_runtime/getenv/test2/CMakeLists.txt | 2 +- .../tests/palsuite/c_runtime/getenv/test2/test2.c | 101 --------------------- .../palsuite/c_runtime/getenv/test2/test2.cpp | 101 +++++++++++++++++++++ .../palsuite/c_runtime/getenv/test3/CMakeLists.txt | 2 +- .../tests/palsuite/c_runtime/getenv/test3/test3.c | 75 --------------- .../palsuite/c_runtime/getenv/test3/test3.cpp | 75 +++++++++++++++ 9 files changed, 257 insertions(+), 257 deletions(-) delete mode 100644 src/pal/tests/palsuite/c_runtime/getenv/test1/test1.c create mode 100644 src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/getenv/test2/test2.c create mode 100644 src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/getenv/test3/test3.c create mode 100644 src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp (limited to 'src/pal/tests/palsuite/c_runtime/getenv') diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt index 6243c032ab..9c52c2890e 100644 --- a/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - test1.c + test1.cpp ) add_executable(paltest_getenv_test1 diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.c b/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.c deleted file mode 100644 index 0fb9025c8f..0000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.c +++ /dev/null @@ -1,78 +0,0 @@ -// 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: test1.c -** -** Purpose: Create an environment variable and then use getenv to get -** a pointer to it. Check that the pointer is valid and that the string -** is what we expected. Also check that searching for a non-existent -** variable will cause getenv to return NULL. Also check that function -** passes when the parameter has it's casing changed (e.g upper case) -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - const char* SetVariable = "PalTestingEnvironmentVariable=The value"; - const char* VariableName = "PalTestingEnvironmentVariable"; - const char* VariableValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(SetVariable) == -1) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. - */ - - result = getenv(VariableName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, VariableValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - VariableValue, - result); - } - - /* Try calling getenv on an environment variable which doesn't - exist. - */ - result = getenv("SomeEnvironmentVariableThatReallyDoesNotExist"); - - if(result != NULL) - { - Fail("ERROR: Called getenv on an environment variable which " - "doesn't exist and it returned '%s' instead of NULL.\n",result); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp new file mode 100644 index 0000000000..0fb9025c8f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp @@ -0,0 +1,78 @@ +// 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: test1.c +** +** Purpose: Create an environment variable and then use getenv to get +** a pointer to it. Check that the pointer is valid and that the string +** is what we expected. Also check that searching for a non-existent +** variable will cause getenv to return NULL. Also check that function +** passes when the parameter has it's casing changed (e.g upper case) +** +** +**===================================================================*/ + +#include + +int __cdecl main(int argc, char **argv) +{ + + const char* SetVariable = "PalTestingEnvironmentVariable=The value"; + const char* VariableName = "PalTestingEnvironmentVariable"; + const char* VariableValue = "The value"; + char* result; + + + if (0 != (PAL_Initialize(argc, argv))) + { + return FAIL; + } + + /* Use _putenv to set an environment variable. This ensures that the + variable we're testing on is always present. + */ + + if(_putenv(SetVariable) == -1) + { + Fail("ERROR: _putenv failed to set an environment variable that " + "getenv will be using for testing.\n"); + } + + /* Call getenv -- ensure it doesn't return NULL and the string it returns + is the value we set above. + */ + + result = getenv(VariableName); + if(result == NULL) + { + Fail("ERROR: The result of getenv on a valid Environment Variable " + "was NULL, which indicates the environment varaible was not " + "found.\n"); + } + + if(strcmp(result, VariableValue) != 0) + { + Fail("ERROR: The value obtained by getenv() was not equal to the " + "correct value of the environment variable. The correct " + "value is '%s' and the function returned '%s'.\n", + VariableValue, + result); + } + + /* Try calling getenv on an environment variable which doesn't + exist. + */ + result = getenv("SomeEnvironmentVariableThatReallyDoesNotExist"); + + if(result != NULL) + { + Fail("ERROR: Called getenv on an environment variable which " + "doesn't exist and it returned '%s' instead of NULL.\n",result); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt index 7a301a5ca6..971a836239 100644 --- a/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - test2.c + test2.cpp ) add_executable(paltest_getenv_test2 diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.c b/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.c deleted file mode 100644 index 26f245fcce..0000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.c +++ /dev/null @@ -1,101 +0,0 @@ -// 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: test2.c -** -** Purpose: Create environment variables that differ only in Case, and -** verify that the BSD operating system treats the variables -** differently. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - - return PASS; - -#else - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* SecondVariable = "PALTESTINGEnvironmentVariable=Different value"; - const char* FirstVarName = "PalTestingEnvironmentVariable"; - const char* SecondVarName = "PALTESTINGEnvironmentVariable"; - const char* FirstVarValue = "The value"; - const char* SecondVarValue = "Different value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set the environment variables. This ensures that the - variables we're testing with are always present. - */ - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - if(_putenv(SecondVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, returns it's own value. - */ - - result = getenv(FirstVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - - result = getenv(SecondVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, SecondVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - SecondVarValue, - result); - } - - - PAL_Terminate(); - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp new file mode 100644 index 0000000000..26f245fcce --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp @@ -0,0 +1,101 @@ +// 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: test2.c +** +** Purpose: Create environment variables that differ only in Case, and +** verify that the BSD operating system treats the variables +** differently. +** +** +**===================================================================*/ + +#include + +int __cdecl main(int argc, char **argv) +{ +#if WIN32 + + return PASS; + +#else + + const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; + const char* SecondVariable = "PALTESTINGEnvironmentVariable=Different value"; + const char* FirstVarName = "PalTestingEnvironmentVariable"; + const char* SecondVarName = "PALTESTINGEnvironmentVariable"; + const char* FirstVarValue = "The value"; + const char* SecondVarValue = "Different value"; + char* result; + + + if (0 != (PAL_Initialize(argc, argv))) + { + return FAIL; + } + + /* Use _putenv to set the environment variables. This ensures that the + variables we're testing with are always present. + */ + if(_putenv(FirstVariable) != 0) + { + Fail("ERROR: _putenv failed to set an environment variable that " + "getenv will be using for testing.\n"); + } + + if(_putenv(SecondVariable) != 0) + { + Fail("ERROR: _putenv failed to set an environment variable that " + "getenv will be using for testing.\n"); + } + + + /* Call getenv -- ensure it doesn't return NULL and the string it returns + is the value we set above. Also make sure that each environment variable, + differing only by case, returns it's own value. + */ + + result = getenv(FirstVarName); + if(result == NULL) + { + Fail("ERROR: The result of getenv on a valid Environment Variable " + "was NULL, which indicates the environment varaible was not " + "found.\n"); + } + + if(strcmp(result, FirstVarValue) != 0) + { + Fail("ERROR: The value obtained by getenv() was not equal to the " + "correct value of the environment variable. The correct " + "value is '%s' and the function returned '%s'.\n", + FirstVarValue, + result); + } + + + result = getenv(SecondVarName); + if(result == NULL) + { + Fail("ERROR: The result of getenv on a valid Environment Variable " + "was NULL, which indicates the environment varaible was not " + "found.\n"); + } + + if(strcmp(result, SecondVarValue) != 0) + { + Fail("ERROR: The value obtained by getenv() was not equal to the " + "correct value of the environment variable. The correct " + "value is '%s' and the function returned '%s'.\n", + SecondVarValue, + result); + } + + + PAL_Terminate(); + return PASS; + +#endif +} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt index 2cbe472221..620ccd1003 100644 --- a/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - test3.c + test3.cpp ) add_executable(paltest_getenv_test3 diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.c b/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.c deleted file mode 100644 index 1eefd9d40c..0000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.c +++ /dev/null @@ -1,75 +0,0 @@ -// 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: test3.c -** -** Purpose: Create an environment variable and try to retrieve -** it using the same name but with different case. This -** is to show that the Win32 representation of getenv -** is case insensitive. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* ModifiedName = "PALTESTINGEnvironmentVariable"; - const char* FirstVarValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, doesn't affect the return value. - */ - - result = getenv(ModifiedName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - - PAL_Terminate(); - return PASS; - -#else - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp new file mode 100644 index 0000000000..1eefd9d40c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp @@ -0,0 +1,75 @@ +// 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: test3.c +** +** Purpose: Create an environment variable and try to retrieve +** it using the same name but with different case. This +** is to show that the Win32 representation of getenv +** is case insensitive. +** +** +**===================================================================*/ + +#include + +int __cdecl main(int argc, char **argv) +{ +#if WIN32 + + const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; + const char* ModifiedName = "PALTESTINGEnvironmentVariable"; + const char* FirstVarValue = "The value"; + char* result; + + + if (0 != (PAL_Initialize(argc, argv))) + { + return FAIL; + } + + /* Use _putenv to set an environment variable. This ensures that the + variable we're testing on is always present. + */ + + if(_putenv(FirstVariable) != 0) + { + Fail("ERROR: _putenv failed to set an environment variable that " + "getenv will be using for testing.\n"); + } + + + /* Call getenv -- ensure it doesn't return NULL and the string it returns + is the value we set above. Also make sure that each environment variable, + differing only by case, doesn't affect the return value. + */ + + result = getenv(ModifiedName); + if(result == NULL) + { + Fail("ERROR: The result of getenv on a valid Environment Variable " + "was NULL, which indicates the environment varaible was not " + "found.\n"); + } + + if(strcmp(result, FirstVarValue) != 0) + { + Fail("ERROR: The value obtained by getenv() was not equal to the " + "correct value of the environment variable. The correct " + "value is '%s' and the function returned '%s'.\n", + FirstVarValue, + result); + } + + + PAL_Terminate(); + return PASS; + +#else + return PASS; + +#endif +} -- cgit v1.2.3