summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/file_io/GetFullPathNameA
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/file_io/GetFullPathNameA
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/file_io/GetFullPathNameA')
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.c122
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.c143
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat18
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.c241
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.c203
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat19
13 files changed, 863 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt
new file mode 100644
index 0000000000..a3847f8ca9
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+add_subdirectory(test4)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt
new file mode 100644
index 0000000000..8c10e479fa
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFullPathNameA.c
+)
+
+add_executable(paltest_getfullpathnamea_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamea_test1 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamea_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.c b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.c
new file mode 100644
index 0000000000..de9a266f5a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.c
@@ -0,0 +1,122 @@
+// 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: GetFullPathNameA.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetFullPathNameA function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szFileName = "testing.tmp";
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ char szReturnedPath[_MAX_DIR+1];
+ char szShortBuff[2];
+ LPSTR pPathPtr;
+ HANDLE hFile = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* perform a short buffer test */
+ if (GetFullPathNameA(szFileName, 2, szShortBuff, &pPathPtr) <= 2)
+ {
+ /* this test should have failed but didn't */
+ Fail("GetFullPathNameA: ERROR -> The API was passed a buffer that was"
+ " too small for the path name and yet it apparently passed.\n");
+ }
+
+ memset(szReturnedPath, 0, _MAX_DIR+1);
+ dwRc = GetFullPathNameA(szFileName,
+ _MAX_DIR,
+ szReturnedPath,
+ &pPathPtr);
+
+ if (dwRc == 0)
+ {
+ // this test should have passed but didn't
+ Fail("GetFullPathNameA: ERROR -> Function failed for the "
+ "file \"%s\" with error code: %ld.\n", szFileName, GetLastError());
+ }
+
+ // the returned value should be the current directory with the
+ // file name appended
+ hFile = CreateFileA(szFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("GetFullPathNameA: ERROR -> CreateFileA failed to create "
+ "file \"%s\" with error code: %ld.\n",
+ szFileName,
+ GetLastError());
+ }
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Fail("GetFullPathNameA: ERROR -> CloseHandle failed with error "
+ "code: %ld.\n", GetLastError());
+ }
+
+ // now try to create the file based on the returned value with the
+ // CREATE_NEW option which should fail since the file should
+ // already exist
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ Fail("GetFullPathNameA: ERROR -> CreateFileA was able to "
+ "CREATE_NEW the returned file \"%s\". The returned file "
+ "name is therefore apparently wrong.\n",
+ szReturnedPath);
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Fail("GetFullPathNameA: ERROR -> CloseHandle failed with "
+ "error code: %ld.\n", GetLastError());
+ }
+ if ((DeleteFileA(szReturnedPath) != TRUE) ||
+ (DeleteFileA(szFileName) != TRUE))
+ {
+ Fail("GetFullPathNameA: ERROR -> DeleteFileA failed to "
+ "delete the test files with error code: %ld.\n",
+ GetLastError());
+ }
+ }
+
+ // now make sure the pPathPtr is the same as the file name
+ if (strcmp(pPathPtr, szFileName) != 0)
+ {
+ Fail("GetFullPathNameA: ERROR -> %s != %s\n",
+ pPathPtr, szFileName);
+ }
+ if (DeleteFileA(szFileName) != TRUE)
+ {
+ Fail("GetFullPathNameA: ERROR -> DeleteFileA failed to "
+ "delete \"%s\" with error code: %ld.\n",
+ szFileName,
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat
new file mode 100644
index 0000000000..a4ccc95348
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat
@@ -0,0 +1,15 @@
+# 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 = file_io
+Function = GetFullPathNameA
+Name = Test for GetFullPathNameA (test 1)
+Type = DEFAULT
+EXE1 = getfullpathnamea
+Description
+= Get the full path for a file name and verify the results.
+= Also, attempt to call GetFullPathNameA with a buffer that is
+= too small for the returned path and verify the results.
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt
new file mode 100644
index 0000000000..382b8fa4bd
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test2.c
+)
+
+add_executable(paltest_getfullpathnamea_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamea_test2 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamea_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.c b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.c
new file mode 100644
index 0000000000..95a1497331
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.c
@@ -0,0 +1,143 @@
+// 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: Tests the PAL implementation of the GetFullPathNameA API.
+** GetFullPathA will be passed a directory that contains '..'.
+** To add to this test, we will also call SetCurrentDirectory to
+** ensure this is handled properly.
+** The test will create a file with in the parent directory
+** to verify that the returned directory is valid.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szDotDot = "..\\";
+const char* szFileName = "testing.tmp";
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ char szReturnedPath[_MAX_DIR+1];
+ char szFullFileName[_MAX_DIR+1];
+ LPSTR pPathPtr;
+ HANDLE hFile = NULL;
+
+ /* Initialize the PAL.
+ */
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return (FAIL);
+ }
+
+ /* change the directory */
+ if (!SetCurrentDirectoryA(szDotDot))
+ {
+ Fail("ERROR: SetCurrentDirectoryA failed with error code %u"
+ " when passed \"%s\".\n",
+ GetLastError(),
+ szDotDot);
+ }
+
+ /* Initialize the receiving char buffers.
+ */
+ memset(szReturnedPath, 0, _MAX_DIR+1);
+ memset(szFullFileName, 0, _MAX_DIR+1);
+
+ /* Create Full filename to pass, will include '..\'
+ * as a pre-fix. */
+ strcat(szFullFileName, szDotDot);
+ strcat(szFullFileName, szFileName);
+
+ /* Get the full path to the filename.
+ */
+ dwRc = GetFullPathNameA(szFullFileName,
+ _MAX_DIR,
+ szReturnedPath,
+ &pPathPtr);
+ if (dwRc == 0)
+ {
+ Fail("ERROR :%ld: GetFullPathName failed to "
+ "retrieve the path of \"%s\".\n",
+ GetLastError(),
+ szFileName);
+ }
+
+ /* The returned value should be the parent directory with the
+ * file name appended. */
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR :%ld: CreateFileA failed to create \"%s\".\n",
+ GetLastError(),
+ szReturnedPath);
+ }
+
+ /* Close the handle to the created file.
+ */
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n",
+ GetLastError());
+ goto terminate;
+ }
+
+ /* Verify that the file was created, attempt to create
+ * the file again. */
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if ((hFile != INVALID_HANDLE_VALUE) &&
+ (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ Fail("ERROR :%ld: CreateFileA succeeded to create file "
+ "\"%s\", that already existed.\n",
+ GetLastError(),
+ szFullFileName);
+ }
+
+
+ /* Verify that the returned filename is the same as the supplied.
+ */
+ if (strcmp(pPathPtr, szFileName) != 0)
+ {
+ Trace("ERROR : Returned filename \"%s\" is not equal to "
+ "supplied filename \"%s\".\n",
+ pPathPtr,
+ szFileName);
+ goto terminate;
+ }
+
+terminate:
+ /* Delete the create file.
+ */
+ if (DeleteFileA(szReturnedPath) != TRUE)
+ {
+ Fail("ERROR :%ld: DeleteFileA failed to delete \"%s\".\n",
+ GetLastError(),
+ szFileName);
+ }
+
+ /* Terminate the PAL.*/
+ PAL_Terminate();
+ return PASS;
+}
+
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat
new file mode 100644
index 0000000000..b75f48114b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat
@@ -0,0 +1,18 @@
+# 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 = file_io
+Function = GetFullPathNameA
+Name = Test for GetFullPathNameA
+Type = DEFAULT
+EXE1 = test2
+Description
+= Tests the PAL implementation of the GetFullPathNameA API.
+= GetFullPathA will be passed a directory that contains '..'.
+= To add to this test, we will also call SetCurrentDirectory to
+= ensure this is handled properly.
+= The test will create a file with in the parent directory
+= to verify that the returned directory is valid.
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt
new file mode 100644
index 0000000000..f0f8929b4a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test3.c
+)
+
+add_executable(paltest_getfullpathnamea_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamea_test3 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamea_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.c b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.c
new file mode 100644
index 0000000000..0cc39e7300
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.c
@@ -0,0 +1,241 @@
+// 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: Tests the PAL implementation of the GetFullPathNameA API.
+** GetFullPathA will be passed a directory that contains '..'.
+** Example: test_directory\level1\..\testing.tmp.
+** To add to this test, we will also call SetCurrentDirectory to
+** ensure this is handled properly.
+** The test will create a file with in the parent directory
+** to verify that the returned directory is valid.
+**
+** Depends: SetCurrentDirectory,
+** CreateDirectory,
+** strcat,
+** memset,
+** CreateFile,
+** CloseHandle,
+** strcmp,
+** DeleteFileA,
+** RemoveDirectory.
+**
+
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+#ifdef WIN32
+ const char* szSeperator = "\\";
+#else
+ const char* szSeperator = "//";
+#endif
+
+const char* szDotDot = "..\\";
+const char* szFileName = "testing.tmp";
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ char szReturnedPath[_MAX_DIR+1];
+ char szFullFileName[_MAX_DIR+1];
+ char szDirectory[256];
+ char* szCreatedDir = {"test_directory"};
+ char* szCreatedNextDir = {"level1"};
+ WCHAR *szCreatedDirW;
+ LPSTR pPathPtr;
+ HANDLE hFile = NULL;
+ BOOL bRetVal = FAIL;
+
+ /* Initialize the PAL.
+ */
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return (FAIL);
+ }
+
+ /* Initialize the buffer.
+ */
+ memset(szDirectory, '\0', 256);
+
+ /* Change the current working directory.
+ */
+ if (!SetCurrentDirectoryA(szDotDot))
+ {
+ Fail("ERROR: SetCurrentDirectoryA failed with error code %u"
+ " when passed \"%s\".\n",
+ GetLastError(),
+ szDotDot);
+ }
+
+ /* Create the path to the next level of directory to create.
+ */
+ strcat( szDirectory, szCreatedDir );
+
+
+ /* Create a test directory.
+ */
+ if ( !CreateDirectoryA( szDirectory, NULL ) )
+ {
+ Fail("ERROR:%u: Unable to create directories \"%s\".\n",
+ GetLastError(),
+ szDirectory);
+ }
+
+ /* Create the path to the next level of directory to create.
+ */
+ strcat( szDirectory, szSeperator );
+ strcat( szDirectory, szCreatedNextDir );
+
+ /* Create a test directory.
+ */
+ if ( !CreateDirectoryA( szDirectory, NULL ) )
+ {
+ Trace("ERROR:%u: Unable to create directories \"%s\".\n",
+ GetLastError(),
+ szDirectory);
+ bRetVal = FAIL;
+ goto cleanUpOne;
+ }
+
+ /* Initialize the receiving char buffers.
+ */
+ memset(szReturnedPath, 0, _MAX_DIR+1);
+ memset(szFullFileName, 0, _MAX_DIR+1);
+
+ /* Create Full filename to pass, will include '..\'
+ * in the middle of the path.
+ */
+ strcat(szFullFileName, szCreatedDir);
+ strcat(szFullFileName, szDotDot);
+ strcat(szFullFileName, szFileName);
+
+ /* Get the full path to the filename.
+ */
+ dwRc = GetFullPathNameA(szFullFileName,
+ _MAX_DIR,
+ szReturnedPath,
+ &pPathPtr);
+ if (dwRc == 0)
+ {
+ Trace("ERROR :%ld: GetFullPathName failed to "
+ "retrieve the path of \"%s\".\n",
+ GetLastError(),
+ szFileName);
+ bRetVal = FAIL;
+ goto cleanUpTwo;
+ }
+
+ /* The returned value should be the parent directory with the
+ * file name appended. */
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Trace("ERROR :%ld: CreateFileA failed to create \"%s\".\n",
+ GetLastError(),
+ szReturnedPath);
+ bRetVal = FAIL;
+ goto cleanUpTwo;
+ }
+
+ /* Close the handle to the created file.
+ */
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n",
+ GetLastError());
+ bRetVal = FAIL;
+ goto cleanUpThree;
+ }
+
+ /* Verify that the file was created, attempt to create
+ * the file again. */
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if ((hFile != INVALID_HANDLE_VALUE) &&
+ (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ Trace("ERROR :%ld: CreateFileA succeeded to create file "
+ "\"%s\", that already existed.\n",
+ GetLastError(),
+ szFullFileName);
+ bRetVal = FAIL;
+ goto cleanUpThree;
+ }
+
+ /* Verify that the returned filename is the same as the supplied.
+ */
+ if (strcmp(pPathPtr, szFileName) != 0)
+ {
+ Trace("ERROR : Returned filename \"%s\" is not equal to "
+ "supplied filename \"%s\".\n",
+ pPathPtr,
+ szFileName);
+ bRetVal = FAIL;
+ goto cleanUpThree;
+ }
+
+ /* Successful test.
+ */
+ bRetVal = PASS;
+
+cleanUpThree:
+
+ /* Delete the create file.
+ */
+ if (DeleteFileA(szReturnedPath) != TRUE)
+ {
+ Fail("ERROR :%ld: DeleteFileA failed to delete \"%s\".\n",
+ GetLastError(),
+ szFileName);
+ }
+
+cleanUpTwo:
+
+ /* Remove the empty directory.
+ */
+ szCreatedDirW = convert((LPSTR)szDirectory);
+ if (!RemoveDirectoryW(szCreatedDirW))
+ {
+ free (szCreatedDirW);
+ Fail("ERROR:%u: Unable to remove directory \"%s\".\n",
+ GetLastError(),
+ szCreatedDir);
+ }
+ free (szCreatedDirW);
+
+cleanUpOne:
+
+ /* Remove the empty directory.
+ */
+ szCreatedDirW = convert((LPSTR)szCreatedDir);
+ if (!RemoveDirectoryW(szCreatedDirW))
+ {
+ free (szCreatedDirW);
+ Fail("ERROR:%u: Unable to remove directory \"%s\".\n",
+ GetLastError(),
+ szCreatedDir);
+ }
+ free (szCreatedDirW);
+
+ /* Terminate the PAL.*/
+ PAL_Terminate();
+ return bRetVal;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat
new file mode 100644
index 0000000000..3991744d42
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat
@@ -0,0 +1,19 @@
+# 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 = file_io
+Function = GetFullPathNameA
+Name = Test for GetFullPathNameA
+Type = DEFAULT
+EXE1 = test3
+Description
+= Tests the PAL implementation of the GetFullPathNameA API.
+= GetFullPathA will be passed a directory that contains '..'.
+= Example: test_directory\level1\..\testing.tmp.
+= To add to this test, we will also call SetCurrentDirectory to
+= ensure this is handled properly.
+= The test will create a file with in the parent directory
+= to verify that the returned directory is valid.
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/CMakeLists.txt
new file mode 100644
index 0000000000..cf0d7ff18c
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/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_getfullpathnamea_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamea_test4 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamea_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.c b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.c
new file mode 100644
index 0000000000..fb22c1f07b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.c
@@ -0,0 +1,203 @@
+// 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: Tests the PAL implementation of the GetFullPathNameA API.
+** GetFullPathA will be passed a directory that begins with '..'.
+** Example: ..\test_directory\testing.tmp.
+** To add to this test, we will also call SetCurrentDirectory to
+** ensure this is handled properly.
+** The test will create a file with in the parent directory
+** to verify that the returned directory is valid.
+**
+** Depends: SetCurrentDirectory,
+** CreateDirectory,
+** strcat,
+** memset,
+** CreateFile,
+** CloseHandle,
+** strcmp,
+** DeleteFileA,
+** RemoveDirectory.
+**
+
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+#ifdef WIN32
+ const char* szSeperator = "\\";
+#else
+ const char* szSeperator = "//";
+#endif
+
+const char* szDotDot = "..";
+const char* szFileName = "testing.tmp";
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ char szReturnedPath[_MAX_DIR+1];
+ char szFullFileName[_MAX_DIR+1];
+ char szDirectory[256];
+ char* szCreatedDir = {"test_directory"};
+ WCHAR *szCreatedDirW;
+ LPSTR pPathPtr;
+ HANDLE hFile = NULL;
+ BOOL bRetVal = FAIL;
+
+ /* Initialize the PAL.
+ */
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return (FAIL);
+ }
+
+ /* Initialize the buffer.
+ */
+ memset(szDirectory, '\0', 256);
+
+ /* Create the path to the next level of directory to create.
+ */
+ strcat( szDirectory, szDotDot ); /* .. */
+ strcat( szDirectory, szSeperator ); /* ../ */
+ strcat( szDirectory, szCreatedDir ); /* ../test_directory */
+
+ /* Create a test directory.
+ */
+ if ( !CreateDirectoryA( szDirectory, NULL ) )
+ {
+ Fail("ERROR:%u: Unable to create directories \"%s\".\n",
+ GetLastError(),
+ szDirectory);
+ }
+
+ /* Initialize the receiving char buffers.
+ */
+ memset(szReturnedPath, 0, _MAX_DIR+1);
+ memset(szFullFileName, 0, _MAX_DIR+1);
+
+ /* Create Full filename to pass, will include '..\'
+ * in the middle of the path.
+ */
+ strcat( szFullFileName, szDotDot ); /* .. */
+ strcat( szFullFileName, szSeperator ); /* ../ */
+ strcat( szFullFileName, szCreatedDir ); /* ../test_directory */
+ strcat( szFullFileName, szSeperator ); /* ../test_directory/ */
+ strcat( szFullFileName, szFileName ); /* ../test_directory/testing.tmp */
+
+ /* Get the full path to the filename.
+ */
+ dwRc = GetFullPathNameA(szFullFileName,
+ _MAX_DIR,
+ szReturnedPath,
+ &pPathPtr);
+ if (dwRc == 0)
+ {
+ Trace("ERROR :%ld: GetFullPathName failed to "
+ "retrieve the path of \"%s\".\n",
+ GetLastError(),
+ szFileName);
+ bRetVal = FAIL;
+ goto cleanUpOne;
+ }
+
+ /* The returned value should be the parent directory with the
+ * file name appended. */
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Trace("ERROR :%ld: CreateFileA failed to create \"%s\".\n",
+ GetLastError(),
+ szReturnedPath);
+ bRetVal = FAIL;
+ goto cleanUpOne;
+ }
+
+ /* Close the handle to the created file.
+ */
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n",
+ GetLastError());
+ bRetVal = FAIL;
+ goto cleanUpTwo;
+ }
+
+ /* Verify that the file was created, attempt to create
+ * the file again. */
+ hFile = CreateFileA(szReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if ((hFile != INVALID_HANDLE_VALUE) &&
+ (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ Trace("ERROR :%ld: CreateFileA succeeded to create file "
+ "\"%s\", that already existed.\n",
+ GetLastError(),
+ szFullFileName);
+ bRetVal = FAIL;
+ goto cleanUpTwo;
+ }
+
+ /* Verify that the returned filename is the same as the supplied.
+ */
+ if (strcmp(pPathPtr, szFileName) != 0)
+ {
+ Trace("ERROR : Returned filename \"%s\" is not equal to "
+ "supplied filename \"%s\".\n",
+ pPathPtr,
+ szFileName);
+ bRetVal = FAIL;
+ goto cleanUpTwo;
+ }
+
+ /* Successful test.
+ */
+ bRetVal = PASS;
+
+cleanUpTwo:
+
+ /* Delete the create file.
+ */
+ if (DeleteFileA(szReturnedPath) != TRUE)
+ {
+ Fail("ERROR :%ld: DeleteFileA failed to delete \"%s\".\n",
+ GetLastError(),
+ szFileName);
+ }
+
+cleanUpOne:
+
+ /* Remove the empty directory.
+ */
+ szCreatedDirW = convert((LPSTR)szDirectory);
+ if (!RemoveDirectoryW(szCreatedDirW))
+ {
+ free (szCreatedDirW);
+ Fail("ERROR:%u: Unable to remove directory \"%s\".\n",
+ GetLastError(),
+ szCreatedDir);
+ }
+ free (szCreatedDirW);
+
+ /* Terminate the PAL.*/
+ PAL_Terminate();
+ return bRetVal;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat
new file mode 100644
index 0000000000..8a7b3b35da
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat
@@ -0,0 +1,19 @@
+# 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 = file_io
+Function = GetFullPathNameA
+Name = Test for GetFullPathNameA
+Type = DEFAULT
+EXE1 = test4
+Description
+= Tests the PAL implementation of the GetFullPathNameA API.
+= GetFullPathA will be passed a directory that begins with '..'.
+= Example: ..\test_directory\level1\testing.tmp.
+= To add to this test, we will also call SetCurrentDirectory to
+= ensure this is handled properly.
+= The test will create a file with in the parent directory
+= to verify that the returned directory is valid.
+