summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/_putenv/test4
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/_putenv/test4')
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.c75
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putenv/test4/testinfo.dat14
3 files changed, 108 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt
new file mode 100644
index 0000000000..518282ccc7
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test4.c
+)
+
+add_executable(paltest_putenv_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_putenv_test4 coreclrpal)
+
+target_link_libraries(paltest_putenv_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.c b/src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.c
new file mode 100644
index 0000000000..48d7ba963c
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.c
@@ -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: test4.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 _putenv
+** is case insensitive.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+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/_putenv/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_putenv/test4/testinfo.dat
new file mode 100644
index 0000000000..af1a01c2fc
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_putenv/test4/testinfo.dat
@@ -0,0 +1,14 @@
+# 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 = C Runtime
+Function = _putenv
+Name = Positive test for _putenv
+TYPE = DEFAULT
+EXE1 = test4
+Description
+= Create an environment variable and check
+= that trying to retrieve it using a name with different
+= case, returns the correct value.