summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/file_io
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 10:09:09 (GMT)
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 10:09:09 (GMT)
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/file_io
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/file_io')
-rw-r--r--src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.c40
-rw-r--r--src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CMakeLists.txt61
-rw-r--r--src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.c68
-rw-r--r--src/pal/tests/palsuite/file_io/CompareFileTime/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c159
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.c120
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test2/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.c141
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test3/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.c180
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileA/test4/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt6
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.c155
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.c124
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test2/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.c196
-rw-r--r--src/pal/tests/palsuite/file_io/CopyFileW/test3/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.c296
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.c335
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.c347
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.c345
-rw-r--r--src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.c145
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput1
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.c152
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput1
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp182
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.c164
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.c83
-rw-r--r--src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.c116
-rw-r--r--src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.c275
-rw-r--r--src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.c206
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.c212
-rw-r--r--src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.c243
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.c107
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileA/test2/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.c249
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.c107
-rw-r--r--src/pal/tests/palsuite/file_io/FindNextFileW/test2/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.c130
-rw-r--r--src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.c35
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleCP/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.c35
-rw-r--r--src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.c97
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.c106
-rw-r--r--src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.c94
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.c65
-rw-r--r--src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt26
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.c340
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat20
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt23
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.c227
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.c170
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt26
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.c345
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme1
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat20
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.c173
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.c173
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/CMakeLists.txt10
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.c180
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.c195
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test2/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.c142
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test3/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.c98
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test4/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.c224
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test5/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.c281
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test6/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test7/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.c279
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileTime/test7/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt6
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.c76
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.c95
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.c72
-rw-r--r--src/pal/tests/palsuite/file_io/GetFileType/test3/testinfo.dat13
-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
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.c157
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.c159
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.c240
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/testinfo.dat19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.c201
-rw-r--r--src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/testinfo.dat19
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.c280
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/getlongpathnamew.c266
-rw-r--r--src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.c132
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/test2/GetStdHandle.c79
-rw-r--r--src/pal/tests/palsuite/file_io/GetStdHandle/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.c124
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.c86
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/CMakeLists.txt6
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.c125
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/GetTempFileNameA.c80
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/gettempfilenamea.c159
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/CMakeLists.txt6
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.c129
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/GetTempFileNameW.c84
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/gettempfilenamew.c161
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempPathW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempPathW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.c103
-rw-r--r--src/pal/tests/palsuite/file_io/GetTempPathW/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileA/test1/ExpectedResults.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileA/test1/MoveFileA.c469
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExA/test1/ExpectedResults.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExA/test1/MoveFileExA.c360
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExW/test1/ExpectedResults.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExW/test1/MoveFileExW.c431
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileExW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileW/test1/ExpectedResults.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileW/test1/MoveFileW.c478
-rw-r--r--src/pal/tests/palsuite/file_io/MoveFileW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.c82
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.c198
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.c184
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.c147
-rw-r--r--src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/RemoveDirectoryA.cpp315
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/RemoveDirectoryW.c282
-rw-r--r--src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathA/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathA/test1/SearchPathA.c144
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathA/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.c198
-rw-r--r--src/pal/tests/palsuite/file_io/SearchPathW/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/CMakeLists.txt6
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/SetCurrentDirectoryA.c215
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/setcurrentdirectorya.c142
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/setcurrentdirectorya.c56
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/CMakeLists.txt6
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/SetCurrentDirectoryW.c178
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/setcurrentdirectoryw.c147
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.c64
-rw-r--r--src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/CMakeLists.txt8
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test1/SetEndOfFile.c85
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test2/SetEndOfFile.c154
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test2/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test3/SetEndOfFile.c109
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test3/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test4/setendoffile.c138
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test4/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test5/test5.c183
-rw-r--r--src/pal/tests/palsuite/file_io/SetEndOfFile/test5/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/SetFileAttributesA.c168
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/test_file1
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/SetFileAttributesA.c114
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/test_file1
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/SetFileAttributesA.c48
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/SetFileAttributesA.c128
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/test_file1
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/SetFileAttributesW.c167
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/test_file1
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/SetFileAttributesW.c121
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/test_file1
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/SetFileAttributesW.c57
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/SetFileAttributesW.c133
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/test_file1
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/CMakeLists.txt10
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test1/SetFilePointer.c123
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test2/SetFilePointer.c356
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test3/SetFilePointer.c350
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test4/SetFilePointer.c242
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test4/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test5/SetFilePointer.c182
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test5/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test6/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test6/SetFilePointer.c213
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test6/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test7/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test7/SetFilePointer.c213
-rw-r--r--src/pal/tests/palsuite/file_io/SetFilePointer/test7/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test1/SetFileTime.c129
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test2/SetFileTime.c101
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test2/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test3/SetFileTime.c66
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test3/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test4/SetFileTime.c108
-rw-r--r--src/pal/tests/palsuite/file_io/SetFileTime/test4/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/CMakeLists.txt8
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test1/WriteFile.c114
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test2/Results.txt1
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test2/WriteFile.c109
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test3/WriteFile.c136
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test4/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test4/writefile.c155
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test5/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/file_io/WriteFile/test5/writefile.c117
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test1/test1.c783
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test1/testinfo.dat31
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.c785
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat34
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test3/test3.c244
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test3/testinfo.dat30
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test4/test4.c351
-rw-r--r--src/pal/tests/palsuite/file_io/errorpathnotfound/test4/testinfo.dat34
-rw-r--r--src/pal/tests/palsuite/file_io/gettemppatha/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/file_io/gettemppatha/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/gettemppatha/test1/gettemppatha.c103
-rw-r--r--src/pal/tests/palsuite/file_io/gettemppatha/test1/testinfo.dat15
484 files changed, 26909 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt b/src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.c b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.c
new file mode 100644
index 0000000..ec61f0c
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.c
@@ -0,0 +1,40 @@
+// 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: AreFileApisANSI.c
+**
+** Purpose: Tests the PAL implementation of the AreFileApisANSI function.
+** The only possible return is TRUE.
+**
+**
+**===================================================================*/
+
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ BOOL bRc = FALSE;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ bRc = AreFileApisANSI();
+
+
+ if (bRc == FALSE)
+ {
+ Fail("AreFileApisANSI: ERROR: Function returned FALSE whereas only TRUE "
+ "is acceptable.\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt
new file mode 100644
index 0000000..4f50127
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ AreFileApisANSI.c
+)
+
+add_executable(paltest_arefileapisansi_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_arefileapisansi_test1 coreclrpal)
+
+target_link_libraries(paltest_arefileapisansi_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/testinfo.dat
new file mode 100644
index 0000000..5e6b422
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = AreFileApisANSI
+Name = Positive Test for AreFileApisANSI
+Type = DEFAULT
+EXE1 = arefileapisansi
+Description
+=Ensure the return is TRUE because FALSE is not an option in FreeBSD
+
diff --git a/src/pal/tests/palsuite/file_io/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CMakeLists.txt
new file mode 100644
index 0000000..3d6eff1
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CMakeLists.txt
@@ -0,0 +1,61 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(AreFileApisANSI)
+add_subdirectory(CompareFileTime)
+add_subdirectory(CopyFileA)
+add_subdirectory(CopyFileW)
+add_subdirectory(CreateDirectoryA)
+add_subdirectory(CreateDirectoryW)
+add_subdirectory(CreateFileA)
+add_subdirectory(CreateFileW)
+add_subdirectory(DeleteFileA)
+add_subdirectory(DeleteFileW)
+add_subdirectory(errorpathnotfound)
+add_subdirectory(FILECanonicalizePath)
+add_subdirectory(FileTimeToDosDateTime)
+add_subdirectory(FindClose)
+add_subdirectory(FindFirstFileA)
+add_subdirectory(FindFirstFileW)
+add_subdirectory(FindNextFileA)
+add_subdirectory(FindNextFileW)
+add_subdirectory(FlushFileBuffers)
+add_subdirectory(GetConsoleCP)
+add_subdirectory(GetConsoleOutputCP)
+add_subdirectory(GetCurrentDirectoryA)
+add_subdirectory(GetCurrentDirectoryW)
+add_subdirectory(GetDiskFreeSpaceW)
+add_subdirectory(GetFileAttributesA)
+add_subdirectory(GetFileAttributesExW)
+add_subdirectory(GetFileAttributesW)
+add_subdirectory(GetFileSize)
+add_subdirectory(GetFileSizeEx)
+add_subdirectory(GetFileTime)
+add_subdirectory(GetFileType)
+add_subdirectory(GetFullPathNameA)
+add_subdirectory(GetFullPathNameW)
+add_subdirectory(GetLongPathNameW)
+add_subdirectory(GetStdHandle)
+add_subdirectory(GetSystemTime)
+add_subdirectory(GetSystemTimeAsFileTime)
+add_subdirectory(GetTempFileNameA)
+add_subdirectory(GetTempFileNameW)
+add_subdirectory(gettemppatha)
+add_subdirectory(GetTempPathW)
+add_subdirectory(MoveFileA)
+add_subdirectory(MoveFileExA)
+add_subdirectory(MoveFileExW)
+add_subdirectory(MoveFileW)
+add_subdirectory(ReadFile)
+add_subdirectory(RemoveDirectoryA)
+add_subdirectory(RemoveDirectoryW)
+add_subdirectory(SearchPathA)
+add_subdirectory(SearchPathW)
+add_subdirectory(SetCurrentDirectoryA)
+add_subdirectory(SetCurrentDirectoryW)
+add_subdirectory(SetEndOfFile)
+add_subdirectory(SetFileAttributesA)
+add_subdirectory(SetFileAttributesW)
+add_subdirectory(SetFilePointer)
+add_subdirectory(SetFileTime)
+add_subdirectory(WriteFile)
+
diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt
new file mode 100644
index 0000000..fdcb655
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CompareFileTime.c
+)
+
+add_executable(paltest_comparefiletime_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_comparefiletime_test1 coreclrpal)
+
+target_link_libraries(paltest_comparefiletime_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.c b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.c
new file mode 100644
index 0000000..3758f7e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.c
@@ -0,0 +1,68 @@
+// 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: CompareFileTime.c
+**
+** Purpose: Tests the PAL implementation of the CompareFileTime function.
+** Defines a large and small file time, and compares them in all fashions
+** to ensure proper return values.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ FILETIME SmallTime, BigTime;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Set a Big and Small time. These were generated using
+ GetFileTime on a file, with a recent creation time and an old
+ modify time, to get a bigger and smaller value.
+ */
+
+ BigTime.dwLowDateTime = -755748832;
+ BigTime.dwHighDateTime = 29436941;
+
+ SmallTime.dwLowDateTime = -459754240;
+ SmallTime.dwHighDateTime = 29436314;
+
+ /* Check to see that SmallTime is less than Big Time */
+
+ if(CompareFileTime(&SmallTime,&BigTime) != -1)
+ {
+ Fail("ERROR: The first time is less than the second time, so "
+ "-1 should have been returned to indicate this.");
+ }
+
+ /* Check that BigTime is greater than SmallTime */
+
+ if(CompareFileTime(&BigTime,&SmallTime) != 1)
+ {
+ Fail("ERROR: The first time is greater than the second time, so "
+ "1 should have been returned to indicate this.");
+ }
+
+ /* Check that BigTime is equal to BigTime */
+
+ if(CompareFileTime(&BigTime,&BigTime) != 0)
+ {
+ Fail("ERROR: The first time is equal to the second time, so "
+ "0 should have been returned to indicate this.");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/testinfo.dat
new file mode 100644
index 0000000..4ff1b4c
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/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 = file_io
+Function = CompareFileTime
+Name = Positive Test for CompareFileTime
+TYPE = DEFAULT
+EXE1 = comparefiletime
+Description
+= Test the CompareFileTime function.
+= Defines a large and small file time, and compares them in all fashions
+= to ensure proper return values.
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/CMakeLists.txt
new file mode 100644
index 0000000..a3847f8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/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/CopyFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt
new file mode 100644
index 0000000..b52e507
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CopyFileA.c
+)
+
+add_executable(paltest_copyfilea_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilea_test1 coreclrpal)
+
+target_link_libraries(paltest_copyfilea_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c
new file mode 100644
index 0000000..bfea85b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c
@@ -0,0 +1,159 @@
+// 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: CopyFileA.c
+**
+** Purpose: Tests the PAL implementation of the CopyFileA function
+**
+**
+**===================================================================*/
+
+/*
+ 1. copy an existing file to existing with overwrite true
+ 2. copy an existing file to existing with overwrite false
+ 3. copy an existing file to non-existant with overwrite true
+ 4. copy an existing file to non-existant with overwrite false
+ 5. copy non-existant file to existing with overwrite true
+ 6. copy non-existant file to existing with overwrite false
+ 7. copy non-existant file to non-existant with overwrite true
+ 8. copy non-existant file to non-existant with overwrite false
+*/
+
+#include <palsuite.h>
+
+struct TESTS{
+ char* lpSource;
+ char* lpDestination;
+ BOOL bFailIfExists;
+ int nResult;
+ };
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ char szSrcExisting[] = {"src_existing.tmp"};
+ char szSrcNonExistant[] = {"src_non-existant.tmp"};
+ char szDstExisting[] = {"dst_existing.tmp"};
+ char szDstNonExistant[] = {"dst_non-existant.tmp"};
+ BOOL bRc = TRUE;
+ BOOL bSuccess = TRUE;
+ FILE* tempFile = NULL;
+ int i;
+ struct TESTS testCase[] =
+ {
+ {szSrcExisting, szDstExisting, FALSE, 1},
+ {szSrcExisting, szDstExisting, TRUE, 0},
+ {szSrcExisting, szDstNonExistant, FALSE, 1},
+ {szSrcExisting, szDstNonExistant, TRUE, 1},
+ {szSrcNonExistant, szDstExisting, FALSE, 0},
+ {szSrcNonExistant, szDstExisting, TRUE, 0},
+ {szSrcNonExistant, szDstNonExistant, FALSE, 0},
+ {szSrcNonExistant, szDstNonExistant, TRUE, 0}
+ };
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* create the src_existing file */
+ tempFile = fopen(szSrcExisting, "w");
+ if (tempFile != NULL)
+ {
+ fprintf(tempFile, "CopyFileA test file: src_existing.tmp\n");
+ fclose(tempFile);
+ }
+ else
+ {
+ Fail("CopyFileA: ERROR-> Couldn't create \"src_existing.tmp\" with "
+ "error %ld\n",
+ GetLastError());
+ }
+
+ /* create the dst_existing file */
+ tempFile = fopen(szDstExisting, "w");
+ if (tempFile != NULL)
+ {
+ fprintf(tempFile, "CopyFileA test file: dst_existing.tmp\n");
+ fclose(tempFile);
+ }
+ else
+ {
+ Fail("CopyFileA: ERROR-> Couldn't create \"dst_existing.tmp\" with "
+ "error %ld\n",
+ GetLastError());
+ }
+
+
+
+ for (i = 0; i < (sizeof(testCase) / sizeof(struct TESTS)); i++)
+ {
+ bRc = CopyFileA(testCase[i].lpSource,
+ testCase[i].lpDestination,
+ testCase[i].bFailIfExists);
+ if (!bRc)
+ {
+ if (testCase[i].nResult == 1)
+ {
+ Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d "
+ "with error %ld\n",
+ testCase[i].lpSource,
+ testCase[i].lpDestination,
+ testCase[i].bFailIfExists,
+ GetLastError());
+ bSuccess = FALSE;
+ }
+ }
+ else
+ {
+ if (testCase[i].nResult == 0)
+ {
+ Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d\n",
+ testCase[i].lpSource,
+ testCase[i].lpDestination,
+ testCase[i].bFailIfExists);
+ bSuccess = FALSE;
+ }
+ else
+ {
+ /* verify the file was moved */
+ if (GetFileAttributesA(testCase[i].lpDestination) == -1)
+ {
+ Trace("CopyFileA: GetFileAttributes of destination file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ bSuccess = FALSE;
+ }
+ else if (GetFileAttributesA(testCase[i].lpSource) == -1)
+ {
+ Trace("CopyFileA: GetFileAttributes of source file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ bSuccess = FALSE;
+ }
+ else
+ {
+ /* verify attributes of destination file to source file*/
+ if(GetFileAttributes(testCase[i].lpSource) !=
+ GetFileAttributes(testCase[i].lpDestination))
+ {
+ Trace("CopyFileA : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file.\n");
+ bSuccess = FALSE;
+ }
+ }
+ }
+ }
+ /* delete file file but don't worry if it fails */
+ DeleteFileA(szDstNonExistant);
+ }
+
+ int exitCode = bSuccess ? PASS : FAIL;
+ PAL_TerminateEx(exitCode);
+ return exitCode;
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat
new file mode 100644
index 0000000..88b9c73
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat
@@ -0,0 +1,12 @@
+# 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 = CopyFileA
+Name = Test for CopyFileA (test 1)
+Type = DEFAULT
+EXE1 = copyfilea
+Description
+= Test the CopyFileA function
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test2/CMakeLists.txt
new file mode 100644
index 0000000..7454f32
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/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_copyfilea_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilea_test2 coreclrpal)
+
+target_link_libraries(paltest_copyfilea_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.c b/src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.c
new file mode 100644
index 0000000..56618d0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.c
@@ -0,0 +1,120 @@
+// 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 CopyFileA function
+** to see if a file can be copied to itself
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ BOOL bRc = TRUE;
+ char* szSrcExisting = "src_existing.tmp";
+ FILE* tempFile = NULL;
+ DWORD temp;
+ int retCode;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* create the src_existing file */
+ tempFile = fopen(szSrcExisting, "w");
+ if (tempFile != NULL)
+ {
+ retCode = fputs("CopyFileA test file: src_existing.tmp ", tempFile);
+ if(retCode < 0)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't write to %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+ retCode = fclose(tempFile);
+ if(retCode != 0)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't close file: %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+
+ }
+ else
+ {
+ Fail("CopyFileA: ERROR-> Couldn't create %s with "
+ "error %ld\n",szSrcExisting,GetLastError());
+ }
+
+ /* Get file attributes of source */
+ temp = GetFileAttributes(szSrcExisting);
+ if (temp == -1)
+ {
+ Fail("CopyFileA: GetFileAttributes of source file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+
+ /* make sure a file can't copy to itself
+ first testing with IfFileExists flag set to true */
+ bRc = CopyFileA(szSrcExisting,szSrcExisting,TRUE);
+ if(bRc)
+ {
+ Fail("ERROR: Cannot copy a file to itself, %u",GetLastError());
+ }
+
+ /* try to get file attributes of desitnation */
+ if (GetFileAttributesA(szSrcExisting) == -1)
+ {
+ Fail("CopyFileA: GetFileAttributes of destination file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+ else
+ {
+ /* verify attributes of destination file to source file*/
+
+ if(temp != GetFileAttributes(szSrcExisting))
+ {
+ Fail("CopyFileA : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file.\n");
+ }
+ }
+
+ /* testing with IfFileExists flags set to false
+ should fail in Windows and pass in UNIX */
+ bRc = CopyFileA(szSrcExisting,szSrcExisting,FALSE);
+ if(bRc && (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ Fail("ERROR: Cannot copy a file to itself, %u",GetLastError());
+ }
+
+ if (GetFileAttributesA(szSrcExisting) == -1)
+ {
+ Fail("CopyFileA: GetFileAttributes of destination file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+ else
+ {
+ /* verify attributes of destination file to source file*/
+
+ if(temp != GetFileAttributes(szSrcExisting))
+ {
+ Fail("CopyFileA : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file.\n");
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test2/testinfo.dat
new file mode 100644
index 0000000..3114384
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test2/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 = file_io
+Function = CopyFileA
+Name = CopyFileA - checking copying to itself (test2)
+Type = DEFAULT
+EXE1 = test2
+Description
+= Test the CopyFileA function's behaviour
+= for copying a file to itself.
+
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test3/CMakeLists.txt
new file mode 100644
index 0000000..986be9f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/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_copyfilea_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilea_test3 coreclrpal)
+
+target_link_libraries(paltest_copyfilea_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.c b/src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.c
new file mode 100644
index 0000000..18c8ce8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.c
@@ -0,0 +1,141 @@
+// 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 CopyFileA function
+** to see if a file can be copied to itself
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ BOOL bRc = TRUE;
+ char* szSrcExisting = "src_existing.tmp";
+ char* szDest = "src_dest.tmp";
+ FILE* tempFile = NULL;
+ int retCode;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* create the src_existing file */
+ tempFile = fopen(szSrcExisting, "w");
+ if (tempFile != NULL)
+ {
+ retCode = fputs("CopyFileA test file: src_existing.tmp ", tempFile);
+ if(retCode < 0)
+ {
+ retCode = fclose(tempFile);
+ if(retCode != 0)
+ {
+ Trace("CopyFileA: ERROR-> Couldn't close file: %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+
+ Fail("CopyFileA: ERROR-> Couldn't write to %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+ retCode = fclose(tempFile);
+ if(retCode != 0)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't close file: %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+
+ }
+ else
+ {
+ Fail("CopyFileA: ERROR-> Couldn't create %s with "
+ "error %ld\n",szSrcExisting,GetLastError());
+ }
+
+ /* set the file attributes of the source file to readonly */
+ bRc = SetFileAttributes(szSrcExisting, FILE_ATTRIBUTE_READONLY);
+ if(!bRc)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't set file attributes for "
+ "file %s with error %u\n", szSrcExisting, GetLastError());
+ }
+
+ // Check the file attributes to make sure SetFileAttributes() above actually succeeded
+ DWORD fileAttributes = GetFileAttributesA(szSrcExisting);
+ if (fileAttributes == INVALID_FILE_ATTRIBUTES)
+ {
+ Fail("CopyFileA: Failed to get file attributes for source file, %u\n", GetLastError());
+ }
+ if ((fileAttributes & FILE_ATTRIBUTE_READONLY) == 0)
+ {
+ Fail("CopyFileA: SetFileAttributes(read-only) on source file returned success but did not make it read-only.\n");
+ }
+
+ /* copy the file */
+ bRc = CopyFileA(szSrcExisting,szDest,TRUE);
+ if(!bRc)
+ {
+ Fail("CopyFileA: Cannot copy a file with error, %u",GetLastError());
+ }
+
+
+ /* try to get file attributes of destination file */
+ fileAttributes = GetFileAttributesA(szDest);
+ if (fileAttributes == INVALID_FILE_ATTRIBUTES)
+ {
+ Fail("CopyFileA: GetFileAttributes of destination file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+
+ /* verify attributes of destination file to source file*/
+ if((fileAttributes & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY)
+ {
+ Fail("CopyFileA : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file.\n");
+ }
+
+ /* set the attributes of the destination file to normal again */
+ bRc = SetFileAttributesA(szDest, FILE_ATTRIBUTE_NORMAL);
+ if(!bRc)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't set file attributes for "
+ "file %s with error %u\n", szDest, GetLastError());
+ }
+
+ /* delete the newly copied file */
+ bRc = DeleteFile(szDest);
+ if(!bRc)
+ {
+ Fail("CopyFileA: DeleteFile failed to delete the"
+ "file correctly with error,%u.\n",GetLastError());
+ }
+
+ /* set the attributes of the source file to normal again */
+ bRc = SetFileAttributesA(szSrcExisting, FILE_ATTRIBUTE_NORMAL);
+ if(!bRc)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't set file attributes for "
+ "file %s with error %u\n", szSrcExisting, GetLastError());
+ }
+
+ /* delete the original file */
+ bRc = DeleteFile(szSrcExisting);
+ if(!bRc)
+ {
+ Fail("CopyFileA: DeleteFile failed to delete the"
+ "file correctly with error,%u.\n",GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test3/testinfo.dat
new file mode 100644
index 0000000..5a9775d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test3/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 = file_io
+Function = CopyFileA
+Name = CopyFileA - checking file attributes maintained (test2)
+Type = DEFAULT
+EXE1 = test3
+Description
+= Test the CopyFileA function's behaviour
+= for copying a file and verifying that
+= the copied file has the same file attributes
+= as the original.
+
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test4/CMakeLists.txt
new file mode 100644
index 0000000..fb48c83
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/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_copyfilea_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilea_test4 coreclrpal)
+
+target_link_libraries(paltest_copyfilea_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.c b/src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.c
new file mode 100644
index 0000000..1ae69f5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.c
@@ -0,0 +1,180 @@
+// 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 CopyFileA function
+** to see if a file can through different users belonging to
+** different groups.
+**
+
+=====================================================================*/
+
+/* USECASE
+ Copy a file from a different user, belonging to a different group to
+ the the current user, who is a member of the current group. Then check
+ to see that the current user has the basic access rights to the copied
+ file.
+
+ Thie original file used is the passwd file in the etc directory of a
+ BSD machine. This file should exist on all machines.
+*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+#if WIN32
+ return PASS;
+
+#else
+
+ BOOL bRc = TRUE;
+ char* szSrcExisting = "/etc/passwd";
+ char* szDest = "temp.tmp";
+ char* szStringTest = "Marry had a little lamb";
+ char szStringRead[30]; /* large enough for string szStringTest */
+
+ HANDLE hFile = NULL;
+ DWORD dwBytesWritten=0;
+ DWORD dwBytesRead=0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* copy the file */
+ bRc = CopyFileA(szSrcExisting,szDest,TRUE);
+ if(!bRc)
+ {
+ Fail("CopyFileA: Cannot copy a file with error, %u",GetLastError());
+ }
+
+ /* try to get file attributes of destination file */
+ if (GetFileAttributesA(szDest) == -1)
+ {
+ Fail("CopyFileA: GetFileAttributes of destination file "
+ "failed with error code %u. \n",
+ GetLastError());
+ }
+
+ /* set the attributes of the destination file to normal again */
+ bRc = SetFileAttributes(szDest, FILE_ATTRIBUTE_NORMAL);
+ if(!bRc)
+ {
+ Fail("CopyFileA: ERROR-> Couldn't set file attributes for "
+ "file %s with error %u\n", szDest, GetLastError());
+ }
+
+ /* open the file for write purposes */
+ hFile = CreateFile(szDest,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("CopyFileA: ERROR -> Unable to create file \"%s\".\n",
+ szDest);
+ }
+
+ /* Attempt to write to the file */
+ bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), &dwBytesWritten, NULL);
+ if (!bRc)
+ {
+ Trace("CopyFileA: ERROR -> Unable to write to copied file with error "
+ "%u.\n", GetLastError());
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with "
+ "error %u.\n",szDest, GetLastError());
+ }
+ Fail("");
+
+ }
+
+ /* Close the file handle */
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with error %u "
+ ".\n",szDest,GetLastError());
+ }
+
+
+ /* open the file for read purposes */
+ hFile = CreateFile(szDest,
+ GENERIC_READ,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("CopyFileA: ERROR -> Unable to create file \"%s\".\n",
+ szDest);
+ }
+
+ /* Attempt to read from the file */
+ bRc = ReadFile(hFile, szStringRead, strlen(szStringTest), &dwBytesRead, NULL);
+ if (!bRc)
+ {
+ Trace("CopyFileA: ERROR -> Unable to read from copied file with "
+ "error %u.\n",GetLastError());
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with "
+ "error %u.\n",szDest, GetLastError());
+ }
+ Fail("");
+
+ }
+
+ if(strncmp(szStringTest,szStringRead, strlen(szStringTest)) != 0)
+ {
+ Trace("CopyFileA: ERROR -> The string which was written '%s' does not "
+ "match the string '%s' which was read from the copied file.\n",
+ szStringTest,szStringRead);
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with "
+ "error %u.\n",szDest, GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Close the file handle */
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with error %u "
+ ".\n",szDest,GetLastError());
+ }
+
+ /* Remove the temporary file */
+ bRc = DeleteFile(szDest);
+ if(!bRc)
+ {
+ Fail("CopyFileA: Could not remove copied file with error %u\n",
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+
+#endif
+
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test4/testinfo.dat
new file mode 100644
index 0000000..42187b7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileA/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 = file_io
+Function = CopyFileA
+Name = CopyFileA - checking file attributes maintained (test4)
+Type = DEFAULT
+EXE1 = test4
+Description
+= Copy a file from a different user, belonging to a different group to
+= the the current user, who is a member of the current group. Then check
+= to see that the current user has the basic access rights to the copied
+= file.
+
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt
new file mode 100644
index 0000000..1962ade
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt
new file mode 100644
index 0000000..766b120
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CopyFileW.c
+)
+
+add_executable(paltest_copyfilew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilew_test1 coreclrpal)
+
+target_link_libraries(paltest_copyfilew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.c b/src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.c
new file mode 100644
index 0000000..6127cc2
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.c
@@ -0,0 +1,155 @@
+// 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: CopyFileW.c
+**
+** Purpose: Tests the PAL implementation of the CopyFileW function
+**
+**
+**===================================================================*/
+
+/*
+1. copy an existing file to non-existant with overwrite true
+2. copy an existing file to non-existant with overwrite false
+3. copy an existing file to existing with overwrite true
+4. copy an existing file to existing with overwrite false
+5. copy non-existant file to non-existant with overwrite true
+6. copy non-existant file to non-existant with overwrite false
+7. copy non-existant file to existing with overwrite true
+8. copy non-existant file to existing with overwrite false
+*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ LPSTR lpSource[2] = {"src_existing.tmp", "src_non-existant.tmp"};
+ LPSTR lpDestination[2] = {"dst_existing.tmp", "dst_non-existant.tmp"};
+ WCHAR* wcSource;
+ WCHAR* wcDest;
+ BOOL bFailIfExists[3] = {FALSE, TRUE};
+ BOOL bRc = TRUE;
+ BOOL bSuccess = TRUE;
+ char results[20];
+ FILE* resultsFile = NULL;
+ FILE* tempFile = NULL;
+ int nCounter = 0;
+ int i, j, k;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* load the expected results */
+ resultsFile = fopen("expectedresults.txt", "r");
+ memset (results, 0, 20);
+ fgets(results, 20, resultsFile);
+ fclose(resultsFile);
+
+ nCounter = 0;
+
+ /* create the src_existing file */
+ tempFile = fopen(lpSource[0], "w");
+ if (tempFile != NULL)
+ {
+ fprintf(tempFile, "CopyFileW test file: src_existing.tmp\n");
+ fclose(tempFile);
+ }
+ else
+ {
+ Fail("CopyFileW: ERROR-> Couldn't create \"src_existing.tmp\"\n");
+ }
+
+ /* create the dst_existing file */
+ tempFile = fopen(lpDestination[0], "w");
+ if (tempFile != NULL)
+ {
+ fprintf(tempFile, "CopyFileW test file: dst_existing.tmp\n");
+ fclose(tempFile);
+ }
+ else
+ {
+ Fail("CopyFileW: ERROR-> Couldn't create \"dst_existing.tmp\"\n");
+ }
+
+
+ /* lpSource loop */
+ for (i = 0; i < 2; i++)
+ {
+ /* lpDestination loop */
+ for (j = 0; j < 2; j++)
+ {
+ /* bFailIfExists loop */
+ for (k = 0; k < 2; k++)
+ {
+ wcSource = convert(lpSource[i]);
+ wcDest = convert(lpDestination[j]);
+ bRc = CopyFileW(wcSource,
+ wcDest,
+ bFailIfExists[k]);
+ free(wcSource);
+ free(wcDest);
+ if (!bRc)
+ {
+ if (results[nCounter] == '1')
+ {
+ Trace("CopyFileW: FAILED: test[%d][%d][%d]\n", i, j, k);
+ bSuccess = FALSE;
+ }
+ }
+ else
+ {
+ if (results[nCounter] == '0')
+ {
+ Trace("CopyFileW: FAILED: test[%d][%d][%d]\n", i, j, k);
+ bSuccess = FALSE;
+ }
+ else
+ {
+ /* verify the file was moved */
+ if (GetFileAttributesA(lpDestination[j]) == -1)
+ {
+ Trace("CopyFileW: GetFileAttributes of destination"
+ "file failed on test[%d][%d][%d] with error "
+ "code %ld. \n",i,j,k,GetLastError());
+ bSuccess = FALSE;
+ }
+ else if (GetFileAttributesA(lpSource[i]) == -1)
+ {
+ Trace("CopyFileW: GetFileAttributes of source file "
+ "file failed on test[%d][%d][%d] with error "
+ "code %ld. \n",i,j,k,GetLastError());
+ bSuccess = FALSE;
+ }
+ else
+ {
+ /* verify attributes of destination file to
+ source file*/
+ if(GetFileAttributes(lpSource[i]) !=
+ GetFileAttributes(lpDestination[j]))
+ {
+ Trace("CopyFileW : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file on test "
+ "[%d][%d][%d].\n",i,j,k);
+ bSuccess = FALSE;
+ }
+ }
+ }
+
+ }
+ nCounter++;
+ /* delete file file but don't worry if it fails */
+ DeleteFileA(lpDestination[1]);
+ }
+ }
+ }
+
+ int exitCode = bSuccess ? PASS : FAIL;
+ PAL_TerminateEx(exitCode);
+ return exitCode;
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt
new file mode 100644
index 0000000..535a89f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt
@@ -0,0 +1 @@
+10110000 \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat
new file mode 100644
index 0000000..b7ff6de
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = CopyFileW
+Name = Tests CopyFileW functionality.
+Type = DEFAULT
+EXE1 = copyfilew
+Description
+= Test the CopyFileW function
+
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test2/CMakeLists.txt
new file mode 100644
index 0000000..5c0030b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/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_copyfilew_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilew_test2 coreclrpal)
+
+target_link_libraries(paltest_copyfilew_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.c b/src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.c
new file mode 100644
index 0000000..5380a18
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.c
@@ -0,0 +1,124 @@
+// 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 CopyFileW function
+** Attempt to copy a file to itself
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ LPSTR szSrcExisting = "src_existing.tmp";
+ WCHAR* wcSource;
+ BOOL bRc = TRUE;
+ FILE* tempFile = NULL;
+ DWORD temp;
+ int retCode;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* create the src_existing file */
+ tempFile = fopen(szSrcExisting, "w");
+ if (tempFile != NULL)
+ {
+ retCode = fputs("CopyFileA test file: src_existing.tmp ", tempFile);
+ if(retCode < 0)
+ {
+ Fail("CopyFileW: ERROR-> Couldn't write to %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+ retCode = fclose(tempFile);
+ if(retCode != 0)
+ {
+ Fail("CopyFileW: ERROR-> Couldn't close file: %s with error "
+ "%u.\n", szSrcExisting, GetLastError());
+ }
+ }
+ else
+ {
+ Fail("CopyFileW: ERROR-> Couldn't create %s.\n", szSrcExisting);
+ }
+
+ /* convert source string to wide character */
+ wcSource = convert(szSrcExisting);
+
+ /* Get file attributes of source */
+ temp = GetFileAttributes(szSrcExisting);
+ if (temp == -1)
+ {
+ free(wcSource);
+ Fail("CopyFileW: GetFileAttributes of source file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+
+ /* make sure a file can't copy to itself
+ first testing with IfFileExists flag set to true */
+ bRc = CopyFileW(wcSource,wcSource,TRUE);
+ if(bRc)
+ {
+ free(wcSource);
+ Fail("ERROR: Cannot copy a file to itself, %u",GetLastError());
+ }
+
+ /* try to get file attributes of desitnation */
+ if (GetFileAttributesA(szSrcExisting) == -1)
+ {
+ free(wcSource);
+ Fail("CopyFileW: GetFileAttributes of destination file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+ else
+ {
+ /* verify attributes of destination file to source file*/
+ if(temp != GetFileAttributes(szSrcExisting))
+ {
+ free(wcSource);
+ Fail("CopyFileW : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file.\n");
+ }
+ }
+
+ /* testing with IfFileExists flags set to false
+ should fail in Windows and pass in UNIX */
+ bRc = CopyFileW(wcSource,wcSource,FALSE);
+ free(wcSource);
+ if(bRc && (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ Fail("ERROR: Cannot copy a file to itself, %u",GetLastError());
+ }
+
+ if (GetFileAttributesA(szSrcExisting) == -1)
+ {
+ Fail("CopyFileW: GetFileAttributes of destination file "
+ "failed with error code %ld. \n",
+ GetLastError());
+ }
+ else
+ {
+ /* verify attributes of destination file to source file*/
+
+ if(temp != GetFileAttributes(szSrcExisting))
+ {
+ Fail("CopyFileW : The file attributes of the "
+ "destination file do not match the file "
+ "attributes of the source file.\n");
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileW/test2/testinfo.dat
new file mode 100644
index 0000000..7e1591d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test2/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 = CopyFileW
+Name = Tests CopyFileW to check if file can be copied to itself. (test2)
+Type = DEFAULT
+EXE1 = test2
+Description
+= Test the CopyFileW function
+= to see the effect of copying a
+= file to itself.
+
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test3/CMakeLists.txt
new file mode 100644
index 0000000..52d9aad
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/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_copyfilew_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_copyfilew_test3 coreclrpal)
+
+target_link_libraries(paltest_copyfilew_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.c b/src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.c
new file mode 100644
index 0000000..a2eb04c
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.c
@@ -0,0 +1,196 @@
+// 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 CopyFileW function
+** to see if a file can through different users belonging to
+** different groups.
+**
+
+=====================================================================*/
+
+/* USECASE
+ Copy a file from a different user, belonging to a different group to
+ the the current user, who is a member of the current group. Then check
+ to see that the current user has the basic access rights to the copied
+ file.
+
+ Thie original file used is the passwd file in the etc directory of a
+ BSD machine. This file should exist on all machines.
+*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+#if WIN32
+ return PASS;
+
+#else
+
+ BOOL bRc = TRUE;
+ WCHAR szSrcExisting[] = {'/','e','t','c','/','p','a','s','s','w','d','\0'};
+ WCHAR szDest[] = {'t','e','m','p','.','t','m','p','\0'};
+ WCHAR szStringTest[] = {'M','a','r','r','y',' ','h','a','d',' ','a',' ',
+ 'l','i','t','t','l','e',' ','l','a','m','b','\0'};
+ WCHAR szStringRead[30]; /* large enough for string szStringTest */
+
+ HANDLE hFile = NULL;
+ DWORD dwBytesWritten=0;
+ DWORD dwBytesRead=0;
+ int size=0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* copy the file */
+ bRc = CopyFileW(szSrcExisting,szDest,TRUE);
+ if(!bRc)
+ {
+ Fail("CopyFileW: Cannot copy a file with error, %u",GetLastError());
+ }
+
+ /* try to get file attributes of destination file */
+ if (GetFileAttributesW(szDest) == -1)
+ {
+ Fail("CopyFileW: GetFileAttributes of destination file "
+ "failed with error code %u. \n",
+ GetLastError());
+ }
+
+ /* set the attributes of the destination file to normal again */
+ bRc = SetFileAttributesW(szDest, FILE_ATTRIBUTE_NORMAL);
+ if(!bRc)
+ {
+ Fail("CopyFileW: ERROR-> Couldn't set file attributes for "
+ "file %S with error %u\n", szDest, GetLastError());
+ }
+
+ /* open the file for write purposes */
+ hFile = CreateFileW((WCHAR *)szDest,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("CopyFileW: ERROR -> Unable to create file \"%S\".\n",
+ szDest);
+ }
+
+ /* To account for the size of a WCHAR is twice that of a char */
+ size = wcslen(szStringTest);
+ size = size*sizeof(WCHAR);
+
+ /* Attempt to write to the file */
+ bRc = WriteFile(hFile,
+ szStringTest,
+ size,
+ &dwBytesWritten,
+ NULL);
+
+ if (!bRc)
+ {
+ Trace("CopyFileW: ERROR -> Unable to write to copied file with error "
+ "%u.\n", GetLastError());
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with "
+ "error %u.\n",szDest, GetLastError());
+ }
+ Fail("");
+
+ }
+
+ /* Close the file handle */
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with error %u "
+ ".\n",szDest,GetLastError());
+ }
+
+
+ /* open the file for read purposes */
+ hFile = CreateFileW((WCHAR *)szDest,
+ GENERIC_READ,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("CopyFileW: ERROR -> Unable to create file \"%S\".\n",
+ szDest);
+ }
+
+ /* Attempt to read from the file */
+ bRc = ReadFile(hFile,
+ szStringRead,
+ size,
+ &dwBytesRead,
+ NULL);
+
+ if (!bRc)
+ {
+ Trace("CopyFileW: ERROR -> Unable to read from copied file with "
+ "error %u.\n",GetLastError());
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with "
+ "error %u.\n",szDest, GetLastError());
+ }
+ Fail("");
+
+ }
+
+ if(wcsncmp(szStringTest,szStringRead, wcslen(szStringTest)) != 0)
+ {
+ Trace("CopyFileW: ERROR -> The string which was written '%S' does not "
+ "match the string '%S' which was read from the copied file.\n",
+ szStringTest,szStringRead);
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with "
+ "error %u.\n",szDest, GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Close the file handle */
+ bRc = CloseHandle(hFile);
+ if (!bRc)
+ {
+ Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with error %u "
+ ".\n",szDest,GetLastError());
+ }
+
+ /* Remove the temporary file */
+ bRc = DeleteFileW(szDest);
+ if(!bRc)
+ {
+ Fail("CopyFileW: Could not remove copied file with error %u.\n",
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+
+#endif
+
+}
diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileW/test3/testinfo.dat
new file mode 100644
index 0000000..9fd185d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CopyFileW/test3/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 = file_io
+Function = CopyFileW
+Name = CopyFileW - checking file attributes maintained (test3)
+Type = DEFAULT
+EXE1 = test3
+Description
+= Copy a file from a different user, belonging to a different group to
+= the the current user, who is a member of the current group. Then check
+= to see that the current user has the basic access rights to the copied
+= file.
+
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt
new file mode 100644
index 0000000..f8cdf19
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CreateDirectoryA.c
+)
+
+add_executable(paltest_createdirectorya_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_createdirectorya_test1 coreclrpal)
+
+target_link_libraries(paltest_createdirectorya_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.c b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.c
new file mode 100644
index 0000000..2bb441e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.c
@@ -0,0 +1,296 @@
+// 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: CreateDirectoryA.c
+**
+** Purpose: Tests the PAL implementation of the CreateDirectoryA function.
+**
+** Depends on:
+** RemoveDirectoryW (since RemoveDirectoryA is unavailable)
+** GetCurrentDirectoryA
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+/* apparently, under WIN32 the max path size is 248 but under
+ BSD it is _MAX_PATH */
+#if WIN32
+#define CREATE_MAX_PATH_SIZE 248
+#else
+#define CREATE_MAX_PATH_SIZE _MAX_PATH
+#endif
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ const char* szTestDir = {"test_directory"};
+ const char* szDotDir = {".dotDirectory"};
+ BOOL bRc = FALSE;
+ BOOL bSuccess = FALSE;
+ const int buf_size = CREATE_MAX_PATH_SIZE + 10;
+ char szDirName[CREATE_MAX_PATH_SIZE + 10];
+ char buffer[CREATE_MAX_PATH_SIZE + 10];
+ WCHAR* pTemp = NULL;
+ DWORD curDirLen;
+ DWORD curDirectory = 1024;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+
+ /* directory does not exist */
+ bRc = CreateDirectoryA(szTestDir, NULL);
+ if (bRc == FALSE)
+ {
+ Fail("CreateDirectoryA: Failed to create \"%s\" with error code %ld\n",
+ szTestDir,
+ GetLastError());
+ }
+
+
+ /* directory exists should fail */
+ bRc = CreateDirectoryA(szTestDir, NULL);
+ if (bRc == TRUE)
+ {
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ Fail("CreateDirectoryA: Succeeded creating the directory"
+ "\"%s\" when it exists already.\n",
+ szTestDir);
+ }
+ else
+ {
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ }
+
+
+ /* long directory names (CREATE_MAX_PATH_SIZE - 1, CREATE_MAX_PATH_SIZE
+ and CREATE_MAX_PATH_SIZE + 1 characters
+ including terminating null char) */
+
+ curDirLen = GetCurrentDirectoryA(0, NULL);
+
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 2 - curDirLen);
+ bRc = CreateDirectoryA(szDirName, NULL);
+ if (bRc == FALSE)
+ {
+ Fail("CreateDirectoryA: Failed to create a directory"
+ " name %d chars long with the error code %ld\n",
+ strlen(szDirName),
+ GetLastError());
+ }
+ else
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ }
+
+ /* Set directory back to initial directory */
+ SetCurrentDirectoryA(buffer);
+
+ pTemp = convert((LPSTR)szDirName);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szDirName,
+ GetLastError());
+ }
+ }
+
+
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 1 - curDirLen);
+ bRc = CreateDirectoryA(szDirName, NULL);
+ if (bRc == FALSE)
+ {
+ Fail("CreateDirectoryA: Failed to create a directory"
+ " name %d chars long with error code %ld\n",
+ strlen(szDirName),
+ GetLastError());
+ }
+ else
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ }
+
+ /* Set Directroy back to initial directory */
+ SetCurrentDirectoryA(buffer);
+
+ pTemp = convert(szDirName);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szDirName,
+ GetLastError());
+ }
+ }
+
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - curDirLen);
+ bRc = CreateDirectoryA(szDirName, NULL);
+ if (bRc != FALSE)
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ }
+
+ /* set directory back to initial directory */
+ SetCurrentDirectoryA(buffer);
+
+ pTemp = convert(szDirName);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szDirName,
+ GetLastError());
+ }
+ if (strlen(szDirName) > CREATE_MAX_PATH_SIZE)
+ {
+ Fail("CreateDirectoryA: Failed because it created a directory"
+ " name 1 character longer (%d chars) than the max dir size "
+ "allowed\n",
+ strlen(szDirName));
+ }
+ }
+
+
+ /* long directory name CREATE_MAX_PATH_SIZE + 3 chars including "..\"
+ (real path length <= CREATE_MAX_PATH_SIZE) */
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE + 3 - 1 - curDirLen);
+ szDirName[0] = '.';
+ szDirName[1] = '.';
+ szDirName[2] = '\\';
+ bRc = CreateDirectoryA(szDirName, NULL);
+ if (bRc == FALSE)
+ {
+ Fail("CreateDirectoryA: Failed to create a directory name more "
+ "than %d chars long and its real path name is less "
+ "than %d chars, error %u\n",
+ CREATE_MAX_PATH_SIZE,
+ CREATE_MAX_PATH_SIZE, GetLastError());
+ }
+ else
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ }
+
+ /* set directory back to initial directory */
+ SetCurrentDirectoryA(buffer);
+
+ pTemp = convert(szDirName);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ " \"%s\" with the error code %ld.\n",
+ szDirName,
+ GetLastError());
+ }
+ }
+
+
+ /* directories with dots */
+ memset(szDirName, 0, buf_size);
+ sprintf(szDirName, szDotDir);
+ bRc = CreateDirectoryA(szDirName, NULL);
+ if (bRc == FALSE)
+ {
+ Fail("CreateDirectoryA: Failed to create \"%s\" with error code %ld\n",
+ szDotDir,
+ GetLastError());
+ }
+ else
+ {
+
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ }
+
+ /* set directory back to initial directory */
+ SetCurrentDirectoryA(buffer);
+
+ pTemp = convert((LPSTR)szDotDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ " \"%s\" with the error code %ld.\n",
+ szDotDir,
+ GetLastError());
+ }
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat
new file mode 100644
index 0000000..562d76d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = CreateDirectoryA
+Name = Test for CreateDirectoryA
+Type = DEFAULT
+EXE1 = createdirectorya
+Description
+= Create a directory that exists (should fail) and create
+= a directory that doesn't exist and verify results.
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt
new file mode 100644
index 0000000..a50a986
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ createdirectorya.c
+)
+
+add_executable(paltest_createdirectorya_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_createdirectorya_test2 coreclrpal)
+
+target_link_libraries(paltest_createdirectorya_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.c b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.c
new file mode 100644
index 0000000..fc1bc96
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.c
@@ -0,0 +1,335 @@
+// 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: createdirectorya.c
+**
+** Purpose: Tests the PAL implementation of the CreateDirectoryA function.
+** Test creating a directory in a directory path that does not exist.
+** Test creating directory with trailing slashes.
+**
+** Depends on:
+** RemoveDirectoryW (since RemoveDirectoryA is unavailable)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+
+int main(int argc, char *argv[])
+{
+
+#if WIN32
+ const char* szTestRootDir = {"/at_root_directory_PALTEST"};
+#endif
+
+ const char* szTestDir = {"test_ directory"};
+ const char* szTestSubDir =
+ {".\\./././../test2/./../../////////createdirectorya"
+ "\\\\/test2/test_ directory\\sub"};
+ const char* szTest2SubDir = {"test_ directory/sub\\sub_sub"};
+ const char* szTest2SubDirWinSlash =
+ {"test_ directory/sub\\sub_sub\\"};
+ const char* szTest2SubDirUnixSlash =
+ {"test_ directory/sub\\sub_sub/////"};
+ BOOL bRc = FALSE;
+ BOOL clean = TRUE;
+ WCHAR* pTemp = NULL;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* platform dependent cases */
+ /* test for WIN32, create directory at the root."
+ * using '/directory_name ' format */
+#if WIN32
+
+ bRc = CreateDirectoryA(szTestRootDir, NULL);
+
+ if (bRc != TRUE)
+ {
+ Fail("CreateDirectoryA: Failed creating the directory "
+ "\"%s\" with the error code %ld.\n",
+ szTestRootDir,GetLastError());
+ }
+
+ /* clean szTestRootDir */
+ pTemp = convert((LPSTR) szTestRootDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+
+ if (! bRc)
+ {
+ clean=bRc;
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestRootDir,
+ GetLastError());
+ }
+
+#endif
+
+
+ /*
+ * create subdirectory "test_directory//sub//sub_sub"
+ * while parent directory does not exist.
+ */
+ bRc = CreateDirectoryA(szTest2SubDir, NULL);
+ if (bRc == TRUE)
+ {
+ pTemp = convert((LPSTR)szTest2SubDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDir,
+ GetLastError());
+ }
+ Fail("CreateDirectoryA: Succeeded creating the directory\"%s\" while"
+ " its parent directory does not exists. It should fail.\n",
+ szTest2SubDir);
+
+ }
+
+
+ /* create directory tree one by one
+ * first create "test_dir"
+ */
+ bRc = CreateDirectoryA(szTestDir, NULL);
+
+ if (bRc != TRUE)/*failed creating the path*/
+ {
+ Fail("CreateDirectoryA: Failed creating the directory "
+ "\"%s\" with the error code %ld.\n", szTestDir,GetLastError());
+ }
+
+ /* create the sub directory test_directory//sub */
+ bRc = CreateDirectoryA(szTestSubDir, NULL);
+
+ if (bRc != TRUE)/*failed creating the path*/
+ {
+ Trace("CreateDirectoryA: Failed creating the directory "
+ "\"%s\" with the error code %ld.\n",
+ szTestSubDir , GetLastError());
+
+ /* cleaning... remove parent directory */
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with an error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /*
+ * the director structure is test_directory//sub
+ * test creating directory " test_directory//sub//sub_sub"
+ */
+ bRc = CreateDirectoryA(szTest2SubDir, NULL);
+ if (bRc != TRUE)
+ {
+ Trace("CreateDirectoryA: Failed creating the directory "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDir , GetLastError());
+
+ /* remove parent directory test_directory//sub */
+ pTemp = convert((LPSTR)szTestSubDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (!bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /* remove parent directory test_directory */
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ Fail("");
+
+ }
+
+ /* RemoveDirectiryW szTest2SubDir */
+ pTemp = convert((LPSTR)szTest2SubDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+
+ if (! bRc)
+ {
+ clean=bRc;
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDir,
+ GetLastError());
+ }
+
+
+ /*
+ * the director structure is test_directory//sub
+ * test creating directory " test_directory//sub//sub_sub\\"
+ */
+ bRc = CreateDirectoryA(szTest2SubDirWinSlash, NULL);
+ if (bRc != TRUE)
+ {
+ Trace("CreateDirectoryA: Failed creating the directory "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDirWinSlash , GetLastError());
+
+ /* remove parent directory test_directory//sub */
+ pTemp = convert((LPSTR)szTestSubDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /* remove parent directory test_directory */
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ Fail("");
+
+ }
+
+ /* RemoveDirectiryW szTest2SubDirWinSlash */
+ pTemp = convert((LPSTR)szTest2SubDirWinSlash);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+
+ if (! bRc)
+ {
+ clean=bRc;
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDirWinSlash,
+ GetLastError());
+ }
+
+ /*
+ * the director structure is test_directory//sub
+ * test creating directory " test_directory//sub//sub_sub/////"
+ */
+ bRc = CreateDirectoryA(szTest2SubDirUnixSlash, NULL);
+ if (bRc != TRUE)
+ {
+ Trace("CreateDirectoryA: Failed creating the directory "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDirUnixSlash , GetLastError());
+
+ /* remove parent directory test_directory//sub */
+ pTemp = convert((LPSTR)szTestSubDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /* remove parent directory test_directory */
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ Fail("");
+
+ }
+
+ /* RemoveDirectiryW will return false if directory does not exist.
+ * if it returns true then test is completed and the directory path
+ * is clean for running the test again.
+ */
+ pTemp = convert((LPSTR)szTest2SubDirUnixSlash);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+
+ if (! bRc)
+ {
+ clean=bRc;
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTest2SubDirUnixSlash,
+ GetLastError());
+ }
+
+
+
+
+ /*clean parent szTestSubDir */
+ pTemp = convert((LPSTR)szTestSubDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /*clean parent szTestDir */
+ pTemp = convert((LPSTR)szTestDir);
+ bRc = RemoveDirectoryW(pTemp);
+ free(pTemp);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
+ "\"%s\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+
+ if(! clean)
+ {
+ Fail("");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat
new file mode 100644
index 0000000..1e2ae77
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = CreateDirectoryA
+Name = Test for CreateDirectoryA
+Type = DEFAULT
+EXE1 = createdirectorya
+Description
+= Call CreateDirectoryA with a path in which more than just
+= the last component doesn't exist.
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt
new file mode 100644
index 0000000..1981e37
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CreateDirectoryW.c
+)
+
+add_executable(paltest_createdirectoryw_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_createdirectoryw_test1 coreclrpal)
+
+target_link_libraries(paltest_createdirectoryw_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.c b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.c
new file mode 100644
index 0000000..9b020cc
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.c
@@ -0,0 +1,347 @@
+// 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: CreateDirectoryW.c
+**
+** Purpose: Tests the PAL implementation of the CreateDirectoryW function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+/* apparently, under WIN32 the max path size is 248 but under
+ BSD it is _MAX_PATH */
+#if WIN32
+#define CREATE_MAX_PATH_SIZE 248
+#else
+#define CREATE_MAX_PATH_SIZE _MAX_PATH
+#endif
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ BOOL bRc = FALSE;
+ BOOL bSuccess = FALSE;
+ const int buf_size = CREATE_MAX_PATH_SIZE + 10;
+ char szDirName[CREATE_MAX_PATH_SIZE + 10];
+ char buffer[CREATE_MAX_PATH_SIZE + 10];
+ WCHAR* pTemp = NULL;
+ DWORD curDirLen;
+ DWORD curDirectory = 1024;
+
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* directory does not exist */
+ pTemp = convert("test_directory");
+ bRc = CreateDirectoryW(pTemp, NULL);
+ free(pTemp);
+ if (bRc == FALSE)
+ {
+ Fail("CreateDirectoryW: Failed to create \"test_directory\"\n");
+ }
+
+ /* directory exists */
+ pTemp = convert("test_directory");
+ bRc = CreateDirectoryW(pTemp, NULL);
+ if (bRc == TRUE)
+ {
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ Fail("CreateDirectoryW: Succeeded creating the directory"
+ " \"test_directory\" when it exists already.\n");
+ }
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+
+ /* long directory names (CREATE_MAX_PATH_SIZE - 1, CREATE_MAX_PATH_SIZE
+ and CREATE_MAX_PATH_SIZE + 1 characters
+ including terminating null char) */
+
+ curDirLen = GetCurrentDirectoryA(0, NULL);
+
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 2 - curDirLen);
+ pTemp = convert((LPSTR)szDirName);
+ bRc = CreateDirectoryW(pTemp, NULL);
+ if (bRc == FALSE)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: Failed to create a directory"
+ " name (%d) chars long with the error code %ld\n",
+ CREATE_MAX_PATH_SIZE - 1,
+ GetLastError());
+ }
+ else
+ {
+
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Trace("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ Fail("");
+
+ }
+
+ /* Set directory back to initial directory */
+ bRc = SetCurrentDirectoryA(buffer);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "change the directory with error %u.\n",
+ GetLastError());
+ }
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ }
+
+
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 1 - curDirLen);
+ pTemp = convert(szDirName);
+ bRc = CreateDirectoryW(pTemp, NULL);
+ if (bRc == FALSE)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: Failed to create a directory"
+ " name %d chars long with error code %ld\n",
+ strlen(szDirName),
+ GetLastError());
+ }
+ else
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Trace("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ Fail("");
+ }
+
+ /* Set directory back to initial directory */
+ bRc = SetCurrentDirectoryA(buffer);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "change the directory with error %u.\n",
+ GetLastError());
+ }
+
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ }
+
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - curDirLen);
+ pTemp = convert(szDirName);
+ bRc = CreateDirectoryW(pTemp, NULL);
+
+ if (bRc != FALSE)
+ {
+ RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ if (strlen(szDirName) > CREATE_MAX_PATH_SIZE)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: Failed because it created a directory"
+ " name 1 character longer (%d chars) than the max dir size"
+ " allowed\n",
+ strlen(szDirName));
+ }
+ }
+
+ free(pTemp);
+
+ /* long directory name CREATE_MAX_PATH_SIZE + 3 chars including "..\"
+ (real path length <= CREATE_MAX_PATH_SIZE) */
+ memset(szDirName, 0, buf_size);
+ memset(szDirName, 'a', CREATE_MAX_PATH_SIZE + 3 - 1 - curDirLen);
+ szDirName[0] = '.';
+ szDirName[1] = '.';
+ szDirName[2] = '\\';
+ pTemp = convert(szDirName);
+ bRc = CreateDirectoryW(pTemp, NULL);
+ if (bRc == FALSE)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: Failed to create a directory name more "
+ "than %d chars long and its real path name is less "
+ "than %d chars\n",
+ CREATE_MAX_PATH_SIZE,
+ CREATE_MAX_PATH_SIZE);
+ }
+ else
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Trace("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ Fail("");
+ }
+
+ /* Set directory back to initial directory */
+ bRc = SetCurrentDirectoryA(buffer);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "change the directory with error %u.\n",
+ GetLastError());
+ }
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ }
+
+ /* directories with dots */
+ memset(szDirName, 0, 252);
+ sprintf(szDirName, ".dotDirectory");
+ pTemp = convert(szDirName);
+ bRc = CreateDirectoryW(pTemp, NULL);
+ if (bRc == FALSE)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: Failed to create a dot directory\n");
+ }
+ else
+ {
+ /* Check to see if it's possible to navigate to directory */
+ GetCurrentDirectoryA(curDirectory, buffer);
+ bSuccess = SetCurrentDirectoryA(szDirName);
+ if(!bSuccess)
+ {
+ Trace("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "navigate to the newly created directory with error "
+ "code %u.\n", GetLastError());
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ Fail("");
+ }
+
+ /* Set directory back to initial directory */
+ bRc = SetCurrentDirectoryA(buffer);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: SetCurrentDirectoryA failed to "
+ "change the directory with error %u.\n",
+ GetLastError());
+ }
+
+ bRc = RemoveDirectoryW(pTemp);
+ if(!bRc)
+ {
+ free(pTemp);
+ Fail("CreateDirectoryW: RemoveDirectoryW failed to "
+ "delete the directory with error %u.\n",
+ GetLastError());
+ }
+ free(pTemp);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat
new file mode 100644
index 0000000..bc66489
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat
@@ -0,0 +1,12 @@
+# 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 = CreateDirectoryW
+Name = Positive Test for CreateDirectoryW
+Type = DEFAULT
+EXE1 = createdirectoryw
+Description
+= Test the CreateDirctoryW function
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt
new file mode 100644
index 0000000..aae4e7d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ createdirectoryw.c
+)
+
+add_executable(paltest_createdirectoryw_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_createdirectoryw_test2 coreclrpal)
+
+target_link_libraries(paltest_createdirectoryw_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.c b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.c
new file mode 100644
index 0000000..20fac5a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.c
@@ -0,0 +1,345 @@
+// 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: createdirectoryw.c
+**
+** Purpose: Tests the PAL implementation of the CreateDirectoryW function.
+** Test creating a directory in a directory path that does not exist.
+** Test creating directory with trailing slashes.
+**
+** Depends on:
+** RemoveDirectoryW.
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+#if WIN32
+WCHAR* szTestRootDir = NULL;
+#endif
+
+WCHAR* szTestDir = NULL;
+WCHAR* szTestSubDir = NULL;
+WCHAR* szTest2SubDir = NULL;
+WCHAR* szTest2SubDirWinSlash = NULL;
+WCHAR* szTest2SubDirUnixSlash = NULL;
+
+
+/* Free the memory allocated by convert(...) function*/
+static void CleanMemory(){
+
+#if WIN32
+ free(szTestRootDir);
+#endif
+
+ free( szTestDir);
+ free( szTestSubDir);
+ free( szTest2SubDir);
+ free( szTest2SubDirWinSlash);
+ free( szTest2SubDirUnixSlash);
+
+}
+
+
+int main(int argc, char *argv[])
+{
+ BOOL bRc = FALSE;
+ BOOL clean = TRUE;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* initialize strings */
+
+#if WIN32
+ szTestRootDir = convert("/at_root_directory_PALTEST");
+#endif
+
+ szTestDir = convert("test_ directory");
+ szTestSubDir = convert(
+ ".\\./././../test2/./../../////////createdirectoryw"
+ "\\\\/test2/test_ directory\\sub");
+ szTest2SubDir = convert("test_ directory/sub\\sub_sub");
+ szTest2SubDirWinSlash = convert("test_ directory/sub\\sub_sub\\\\");
+ szTest2SubDirUnixSlash = convert("test_ directory/sub\\sub_sub///");
+
+
+ /* Platform dependent cases:-
+ * test for WIN32, create directory at the root.
+ * using /directory_name format
+ */
+#if WIN32
+
+ bRc = CreateDirectoryW(szTestRootDir, NULL);
+
+ if (bRc != TRUE)
+ {
+
+ Trace("CreateDirectoryW: Failed creating the directory "
+ "\"%S\" with the error code %ld.\n",
+ szTestRootDir,GetLastError());
+ CleanMemory();
+ Fail("");
+ }
+
+ /*clean szTestRootDir */
+ bRc = RemoveDirectoryW(szTestRootDir);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestRootDir,
+ GetLastError());
+ }
+
+#endif
+
+
+ /*
+ * create subdirectory "test_directory//sub//sub_sub"
+ * while parent directory does not exist.
+ */
+ bRc = CreateDirectoryW(szTest2SubDir, NULL);
+ if (bRc == TRUE)
+ {
+ bRc = RemoveDirectoryW(szTest2SubDir);
+
+ if (! bRc )
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDir,
+ GetLastError());
+ }
+
+ Trace("CreateDirectoryW: Succeeded creating the directory\"%S\" while"
+ " its parent directory does not exists. It should fail.\n",
+ szTest2SubDir);
+ CleanMemory();
+ Fail("");
+
+ }
+
+
+ /* create directory tree one by one
+ * first create "test_dir"
+ */
+ bRc = CreateDirectoryW(szTestDir, NULL);
+
+
+ if (bRc != TRUE)/*failed creating the path*/
+ {
+
+ Trace("CreateDirectoryW: Failed creating the directory "
+ "\"%S\" with the error code %ld.\n", szTestDir,GetLastError());
+ CleanMemory();
+ Fail("");
+ }
+
+ /* create the sub directory test_directory//sub */
+ bRc = CreateDirectoryW(szTestSubDir, NULL);
+
+ if (bRc != TRUE)/*failed creating the path*/
+ {
+ Trace("CreateDirectoryW: Failed creating the directory "
+ "\"%S\" with the error code %ld.\n",
+ szTestSubDir , GetLastError());
+
+ /* cleaning... remove parent directory */
+ bRc = RemoveDirectoryW(szTestDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with an error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ CleanMemory();
+ Fail("");
+ }
+
+ /*
+ * the director structure is test_directory//sub
+ * test creating directory " test_directory//sub//sub_sub"
+ */
+ bRc = CreateDirectoryW(szTest2SubDir, NULL);
+ if (bRc != TRUE)
+ {
+ Trace("CreateDirectoryW: Failed creating the directory "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDir , GetLastError());
+
+ /* remove parent directory test_directory//sub */
+ bRc = RemoveDirectoryW(szTestSubDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /* remove parent directory test_directory */
+ bRc = RemoveDirectoryW(szTestDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ CleanMemory();
+ Fail("");
+
+ }
+
+ /* Remove Directiry szTest2SubDir*/
+ bRc = RemoveDirectoryW(szTest2SubDir);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDir,
+ GetLastError());
+ }
+
+ /*
+ * the director structure is test_directory//sub
+ * test creating directory " test_directory//sub//sub_sub\\\\"
+ */
+ bRc = CreateDirectoryW(szTest2SubDirWinSlash, NULL);
+ if (bRc != TRUE)
+ {
+ Trace("CreateDirectoryW: Failed creating the directory "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDirWinSlash , GetLastError());
+
+ /* remove parent directory test_directory//sub */
+ bRc = RemoveDirectoryW(szTestSubDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /* remove parent directory test_directory */
+ bRc = RemoveDirectoryW(szTestDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ CleanMemory();
+ Fail("");
+
+ }
+
+ /* Remove Directiry szTest2SubDirWinSlash */
+ bRc = RemoveDirectoryW(szTest2SubDirWinSlash);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDirWinSlash,
+ GetLastError());
+ }
+
+ /*
+ * the director structure is test_directory//sub
+ * test creating directory " test_directory//sub//sub_sub///"
+ */
+ bRc = CreateDirectoryW(szTest2SubDirUnixSlash, NULL);
+ if (bRc != TRUE)
+ {
+ Trace("CreateDirectoryW: Failed creating the directory "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDirUnixSlash , GetLastError());
+
+ /* remove parent directory test_directory//sub */
+ bRc = RemoveDirectoryW(szTestSubDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /* remove parent directory test_directory */
+ bRc = RemoveDirectoryW(szTestDir);
+ if (! bRc)
+ {
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+ CleanMemory();
+ Fail("");
+
+ }
+
+ /* Remove Directiry szTest2SubDirUnixSlash.*/
+ bRc = RemoveDirectoryW(szTest2SubDirUnixSlash);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTest2SubDirUnixSlash,
+ GetLastError());
+ }
+
+ /*clean parent szTestSubDir */
+ bRc = RemoveDirectoryW(szTestSubDir);
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestSubDir,
+ GetLastError());
+ }
+
+ /*clean parent szTestDir */
+ bRc = RemoveDirectoryW(szTestDir);
+
+
+ if (! bRc)
+ {
+ clean = bRc;
+ Trace("CreateDirectoryW: RemoveDirectoryW failed to remove "
+ "\"%S\" with the error code %ld.\n",
+ szTestDir,
+ GetLastError());
+ }
+
+ if(! clean)
+ {
+ CleanMemory();
+ Fail("");
+ }
+
+ CleanMemory();
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat
new file mode 100644
index 0000000..0d98a5f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = CreateDirectoryW
+Name = Test for CreateDirectoryW
+Type = DEFAULT
+EXE1 = createdirectoryW
+Description
+= Call CreateDirectoryW with a path in which more than just
+= the last component doesn't exist.
diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt
new file mode 100644
index 0000000..8814b22
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CreateFileA.c
+)
+
+add_executable(paltest_createfilea_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_createfilea_test1 coreclrpal)
+
+target_link_libraries(paltest_createfilea_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.c b/src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.c
new file mode 100644
index 0000000..a70867a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.c
@@ -0,0 +1,145 @@
+// 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: CreateFileA.c
+**
+** Purpose: Test the PAL implementation of the CreateFileA function
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+BOOL Cleanup(void)
+{
+ char FileName[20];
+ int i;
+ BOOL bRet = TRUE; // assume success
+
+ // loop through all accesses, modes, dispositions and flags
+ for (i=0; i<4*8*4*5; ++i) {
+ sprintf(FileName, "test%03d.txt", i);
+ if (DeleteFileA(FileName) == FALSE) {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ bRet = FALSE;
+ }
+ }
+ }
+ return bRet;
+}
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ BOOL bSuccess = TRUE;
+ int nCounter = 0;
+ HANDLE hFile;
+ char lpFileName[20];
+ FILE *outFile = NULL;
+ char results[1024];
+ int i, j, k, l;
+ DWORD dwDesiredAccess[4] = {0, // 0
+ GENERIC_READ, // 1
+ GENERIC_WRITE, // 2
+ GENERIC_READ | GENERIC_WRITE}; // 3
+ DWORD dwShareMode[8] = {0, // 0
+ FILE_SHARE_READ, // 1
+ FILE_SHARE_WRITE, // 2
+ FILE_SHARE_DELETE, // 3
+ FILE_SHARE_READ | FILE_SHARE_WRITE, // 4
+ FILE_SHARE_READ | FILE_SHARE_DELETE, // 5
+ FILE_SHARE_WRITE | FILE_SHARE_DELETE, // 6
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE}; // 7
+ LPSECURITY_ATTRIBUTES lpAttr = NULL;
+ DWORD dwCreationDisp[4] = {CREATE_NEW, // 0
+ CREATE_ALWAYS, // 1
+ OPEN_EXISTING, // 2
+ OPEN_ALWAYS}; // 3
+ DWORD dwFlagsAttrib[5] = {FILE_ATTRIBUTE_NORMAL, // 0
+ FILE_FLAG_SEQUENTIAL_SCAN, // 1
+ FILE_FLAG_WRITE_THROUGH, // 2
+ FILE_FLAG_NO_BUFFERING, // 3
+ FILE_FLAG_RANDOM_ACCESS}; // 4
+ HANDLE hTemplate = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ if (!Cleanup()) {
+ Trace("Pre-test Cleanup() failed. LastError=%d\n", GetLastError());
+ return FAIL;
+ }
+
+ /* open the file to read the expected results */
+ outFile = fopen("winoutput", "r");
+ memset (results, 0, 1024);
+
+ fgets(results, 1024, outFile);
+ nCounter = (int)strlen(results);
+ fclose(outFile);
+
+ nCounter = 0;
+
+ // desired access loop
+ for (i = 0; i < 4; i++)
+ {
+ // share mode loop
+ for (j = 0; j < 8; j++)
+ {
+ // security attributes loop
+ for (k = 0; k < 4; k++)
+ {
+ // creation disp loop
+ for (l = 0; l < 5; l++)
+ {
+ sprintf(lpFileName, "test%03d.txt", nCounter);
+ hFile = CreateFile(lpFileName,
+ dwDesiredAccess[i],
+ dwShareMode[j],
+ lpAttr,
+ dwCreationDisp[k],
+ dwFlagsAttrib[l],
+ hTemplate);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ if (results[nCounter] == '1')
+ {
+ Trace("CreateFile: ERROR: Failed when expected "
+ "to pass %s [%d][%d][%d][%d]\n",
+ lpFileName, i, j, k, l);
+ bSuccess = FALSE;
+ }
+ }
+ else
+ {
+ CloseHandle(hFile);
+ if (results[nCounter] == '0')
+ {
+ Trace("CreateFile: ERROR: Passed when expected "
+ "to fail %s [%d][%d][%d][%d]\n",
+ lpFileName, i, j, k, l);
+ bSuccess = FALSE;
+ }
+ }
+ nCounter ++;
+ }
+ }
+ }
+ }
+
+ if (!Cleanup())
+ {
+ Trace("Post-test Cleanup() failed. LastError=%d\n", GetLastError());
+ return FAIL;
+ }
+
+ int exitCode = bSuccess ? PASS : FAIL;
+ PAL_TerminateEx(exitCode);
+ return exitCode;
+}
diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat
new file mode 100644
index 0000000..bb87280
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = CreateFileA
+Name = test for CreateFileA
+Type = DEFAULT
+EXE1 = createfilea
+Description
+= Attempts to create files based on all combinations of
+= options of CreateFileA
diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput b/src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput
new file mode 100644
index 0000000..3913b99
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput
@@ -0,0 +1 @@
+1111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111 \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt
new file mode 100644
index 0000000..1ff0b80
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ CreateFileW.c
+)
+
+add_executable(paltest_createfilew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_createfilew_test1 coreclrpal)
+
+target_link_libraries(paltest_createfilew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.c b/src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.c
new file mode 100644
index 0000000..4d7d20a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.c
@@ -0,0 +1,152 @@
+// 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: CreateFileW.c
+**
+** Purpose: Test the PAL implementation of the CreateFileW function
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+BOOL Cleanup(void)
+{
+ char FileName[20];
+ int i;
+ BOOL bRet = TRUE; // assume success
+
+ // loop through all accesses, modes, dispositions and flags
+ for (i=0; i<4*8*4*5; ++i) {
+ sprintf(FileName, "test%03d.txt", i);
+ if (DeleteFileA(FileName) == FALSE) {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ bRet = FALSE;
+ }
+ }
+ }
+ return bRet;
+}
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ BOOL bSuccess = TRUE;
+ int nCounter = 0;
+ HANDLE hFile = NULL;
+ WCHAR *lpFileName = NULL;
+ char* pTemp = NULL;
+ char string[40];
+ FILE *outFile = NULL;
+ char results[1024];
+ int i, j, k, l;
+ DWORD dwDesiredAccess[4] = {0, // 0
+ GENERIC_READ, // 1
+ GENERIC_WRITE, // 2
+ GENERIC_READ | GENERIC_WRITE}; // 3
+ DWORD dwShareMode[8] = {0, // 0
+ FILE_SHARE_READ, // 1
+ FILE_SHARE_WRITE, // 2
+ FILE_SHARE_DELETE, // 3
+ FILE_SHARE_READ | FILE_SHARE_WRITE, // 4
+ FILE_SHARE_READ | FILE_SHARE_DELETE, // 5
+ FILE_SHARE_WRITE | FILE_SHARE_DELETE, // 6
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE}; // 7
+ LPSECURITY_ATTRIBUTES lpAttr = NULL;
+ DWORD dwCreationDisp[4] = {CREATE_NEW, // 0
+ CREATE_ALWAYS, // 1
+ OPEN_EXISTING, // 2
+ OPEN_ALWAYS}; // 3
+ DWORD dwFlagsAttrib[5] = {FILE_ATTRIBUTE_NORMAL, // 0
+ FILE_FLAG_SEQUENTIAL_SCAN, // 1
+ FILE_FLAG_WRITE_THROUGH, // 2
+ FILE_FLAG_NO_BUFFERING, // 3
+ FILE_FLAG_RANDOM_ACCESS}; // 4
+ HANDLE hTemplate = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ if (!Cleanup()) {
+ Trace("Pre-test Cleanup() failed. LastError=%d\n", GetLastError());
+ return FAIL;
+ }
+
+ /* open the file to read the expected results */
+ outFile = fopen("winoutput", "r");
+ memset (results, 0, 1024);
+
+ fgets(results, 1024, outFile);
+ fclose(outFile);
+
+ nCounter = 0;
+
+ // desired access loop
+ for (i = 0; i < 4; i++)
+ {
+ // share mode loop
+ for (j = 0; j < 8; j++)
+ {
+ // security attributes loop
+ for (k = 0; k < 4; k++)
+ {
+ // creation disp loop
+ for (l = 0; l < 5; l++)
+ {
+ sprintf(string, "test%03d.txt", nCounter);
+ lpFileName = convert(string);
+ hFile = CreateFileW(lpFileName,
+ dwDesiredAccess[i],
+ dwShareMode[j],
+ lpAttr,
+ dwCreationDisp[k],
+ dwFlagsAttrib[l],
+ hTemplate);
+ free(lpFileName);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ if (results[nCounter] == '1')
+ {
+ pTemp = convertC(lpFileName);
+ Trace("CreateFile: ERROR: Failed when expected "
+ "to pass %s [%d][%d][%d][%d]\n",
+ pTemp, i, j, k, l);
+ free(pTemp);
+ bSuccess = FALSE;
+ }
+ }
+ else
+ {
+ CloseHandle(hFile);
+ if (results[nCounter] == '0')
+ {
+ pTemp = convertC(lpFileName);
+ Trace("CreateFile: ERROR: Passed when expected "
+ "to fail %s [%d][%d][%d][%d]\n",
+ pTemp, i, j, k, l);
+ free(pTemp);
+ bSuccess = FALSE;
+ }
+ }
+ nCounter ++;
+ }
+ }
+ }
+ }
+
+ if (!Cleanup())
+ {
+ Trace("Post-test Cleanup() failed. LastError=%d\n", GetLastError());
+ return FAIL;
+ }
+
+ int exitCode = bSuccess ? PASS : FAIL;
+ PAL_TerminateEx(exitCode);
+ return exitCode;
+}
diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat
new file mode 100644
index 0000000..2dbf159
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = CreateFileW
+Name = test for CreateFileW
+Type = DEFAULT
+EXE1 = createfilew
+Description
+= Attempts to create files based on all combinations of
+= options of CreateFileW
diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput b/src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput
new file mode 100644
index 0000000..3913b99
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput
@@ -0,0 +1 @@
+1111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111 \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt
new file mode 100644
index 0000000..b979c20
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ DeleteFileA.cpp
+)
+
+add_executable(paltest_deletefilea_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_deletefilea_test1 coreclrpal)
+
+target_link_libraries(paltest_deletefilea_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp
new file mode 100644
index 0000000..a8eb71d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp
@@ -0,0 +1,182 @@
+// 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: DeleteFileA.c
+**
+** Purpose: Tests the PAL implementation of the DeleteFileA function.
+**
+**
+**===================================================================*/
+
+// delete an existing file
+// delete a non-existant file
+// delete an open file
+// delete files using wild cards
+// delete a hidden file
+// delete a file without proper permissions
+//
+
+#define PAL_STDCPP_COMPAT
+#include <palsuite.h>
+#undef PAL_STDCPP_COMPAT
+
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ FILE *tempFile = NULL;
+ BOOL bRc = FALSE;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ //
+ // create a test file
+ //
+ tempFile = fopen("testFile01.txt", "w");
+ if (tempFile == NULL)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't create \"DeleteFileA's"
+ " testFile01.txt\"\n");
+ }
+
+ fprintf(tempFile, "DeleteFileA test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileA's"
+ " testFile01.txt\"\n");
+ }
+
+ //
+ // delete a symlink to an existing file
+ //
+ if (symlink("testFile01.txt", "testFile01_symlink") != 0)
+ {
+ Fail("DeleteFileA: ERROR: Failed to create a symlink to testFile01.txt.\n");
+ }
+
+ bRc = DeleteFileA("testFile01_symlink");
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't delete symlink!\n Error is %d\n", GetLastError());
+ }
+
+ struct stat statBuffer;
+ if (lstat("testFile01.txt", &statBuffer) != 0)
+ {
+ Fail("DeleteFileA: ERROR: Deleting a symlink deleted the file it was pointing to.\n");
+ }
+
+ if (lstat("testFile01_symlink", &statBuffer) == 0)
+ {
+ Fail("DeleteFileA: ERROR: Failed to delete a symlink.\n");
+ }
+
+ //
+ // deleting an existing file
+ //
+ bRc = DeleteFileA("testFile01.txt");
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't delete DeleteFileA's"
+ " \"testFile01.txt\"\n"
+ " Error is %d\n", GetLastError());
+ }
+
+
+ //
+ // deleting a non-existant file : should fail
+ //
+
+ bRc = DeleteFileA("testFile02.txt");
+ if (bRc != FALSE)
+ {
+ Fail ("DeleteFileA: ERROR: Was able to delete the non-existant"
+ " file \"testFile02.txt\"\n");
+ }
+
+
+
+
+ //
+ // deleting an open file
+ //
+ tempFile = fopen("testFile03.txt", "w");
+ if (tempFile == NULL)
+ {
+ Fail("DeleteFileA: ERROR: Couldn't create \"DeleteFileA's"
+ " testFile03.txt\"\n");
+ }
+
+ fprintf(tempFile, "DeleteFileA test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileA's"
+ " testFile03.txt\"\n");
+ }
+
+ bRc = DeleteFileA("testFile03.txt");
+ if (bRc != TRUE)
+ {
+ Fail("DeleteFileA: ERROR: Couldn't delete DeleteFileA's"
+ " \"testFile03.txt\"\n"
+ " Error is %d\n", GetLastError());
+ }
+ bRc = DeleteFileA("testFile03.txt");
+
+
+
+
+ //
+ // delete using wild cards
+ //
+
+ // create the test file
+ tempFile = fopen("testFile04.txt", "w");
+ if (tempFile == NULL)
+ {
+ Fail("DeleteFileA: ERROR: Couldn't create DeleteFileA's"
+ " \"testFile04.txt\"\n");
+ }
+ fprintf(tempFile, "DeleteFileA test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileA's"
+ " testFile04.txt\"\n");
+ }
+
+ // delete using '?'
+ bRc = DeleteFileA("testFile0?.txt");
+ if (bRc == TRUE)
+ {
+ Fail("DeleteFileA: ERROR: Was able to delete using the"
+ " \'?\' wildcard\n");
+ }
+
+ // delete using '*'
+ bRc = DeleteFileA("testFile*.txt");
+ if (bRc == TRUE)
+ {
+ Fail("DeleteFileA: ERROR: Was able to delete using the"
+ " \'*\' wildcard\n");
+ }
+
+ bRc = DeleteFileA("testFile04.txt");
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't delete DeleteFileA's"
+ " \"testFile04.txt\"\n"
+ " Error is %d\n", GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat
new file mode 100644
index 0000000..24283ed
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = DeleteFileA
+Name = Test for DeleteFileA (test 1)
+Type = DEFAULT
+EXE1 = deletefilea
+Description
+= Attempt to delete various files.
+
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt
new file mode 100644
index 0000000..046fd35
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ DeleteFileW.c
+)
+
+add_executable(paltest_deletefilew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_deletefilew_test1 coreclrpal)
+
+target_link_libraries(paltest_deletefilew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.c b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.c
new file mode 100644
index 0000000..fca96d1
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.c
@@ -0,0 +1,164 @@
+// 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: DeleteFileW.c
+**
+** Purpose: Tests the PAL implementation of the DeleteFileW function.
+**
+**
+**===================================================================*/
+
+// delete an existing file
+// delete a non-existant file
+// delete an open file
+// delete files using wild cards
+// delete a hidden file
+// delete a file without proper permissions
+//
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ FILE *tempFile = NULL;
+ BOOL bRc = FALSE;
+ WCHAR* pTemp = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ //
+ // deleting an existing file
+ //
+ tempFile = fopen("testFile01.tmp", "w");
+ if (tempFile == NULL)
+ {
+ Fail ("DeleteFileW: ERROR: Couldn't create \"DeleteFileW's"
+ " testFile01.tmp\"\n");
+ }
+
+ fprintf(tempFile, "DeleteFileW test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's"
+ " testFile01.tmp\"\n");
+ }
+
+ pTemp = convert("testFile01.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileW: ERROR: Couldn't delete DeleteFileW's"
+ " \"testFile01.tmp\"\n"
+ " Error is %d\n", GetLastError());
+ }
+
+
+ //
+ // deleting a non-existant file : should fail
+ //
+
+ pTemp = convert("testFile02.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc != FALSE)
+ {
+ Fail ("DeleteFileW: ERROR: Was able to delete the non-existant"
+ " file \"testFile02.tmp\"\n");
+ }
+
+
+
+
+ //
+ // deleting an open file
+ //
+ tempFile = fopen("testFile03.tmp", "w");
+ if (tempFile == NULL)
+ {
+ Fail("DeleteFileW: ERROR: Couldn't create \"DeleteFileW's"
+ " testFile03.tmp\"\n");
+ }
+
+ fprintf(tempFile, "DeleteFileW test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's"
+ " testFile03.tmp\"\n");
+ }
+
+ pTemp = convert("testFile03.tmp");
+ bRc = DeleteFileW(pTemp);
+ if (bRc != TRUE)
+ {
+ Fail("DeleteFileW: ERROR: Couldn't delete DeleteFileW's"
+ " \"testFile03.tmp\"\n"
+ " Error is %d\n", GetLastError());
+ free(pTemp);
+ }
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+
+
+
+
+ //
+ // delete using wild cards
+ //
+
+ // create the test file
+ tempFile = fopen("testFile04.tmp", "w");
+ if (tempFile == NULL)
+ {
+ Fail("DeleteFileW: ERROR: Couldn't create DeleteFileW's"
+ " \"testFile04.tmp\"\n");
+ }
+ fprintf(tempFile, "DeleteFileW test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's"
+ " testFile04.tmp\"\n");
+ }
+
+ // delete using '?'
+ pTemp = convert("testFile0?.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc == TRUE)
+ {
+ Fail("DeleteFileW: ERROR: Was able to delete using the"
+ " \'?\' wildcard\n");
+ }
+
+ // delete using '*'
+ pTemp = convert("testFile*.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc == TRUE)
+ {
+ Fail("DeleteFileW: ERROR: Was able to delete using the"
+ " \'*\' wildcard\n");
+ }
+
+ pTemp = convert("testFile04.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileW: ERROR: Couldn't delete DeleteFileW's"
+ " \"testFile04.tmp\"\n"
+ " Error is %d\n", GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat
new file mode 100644
index 0000000..db44f99
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = DeleteFileW
+Name = Test for DeleteFileW (test 1)
+Type = DEFAULT
+EXE1 = deletefilew
+Description
+= Tests DeleteFileW on various file names
+
diff --git a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt
new file mode 100644
index 0000000..0c02c98
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FILECanonicalizePath.c
+)
+
+add_executable(paltest_filecanonicalizepath_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_filecanonicalizepath_test1 coreclrpal)
+
+target_link_libraries(paltest_filecanonicalizepath_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.c b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.c
new file mode 100644
index 0000000..91bac1f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.c
@@ -0,0 +1,83 @@
+// 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: FILECanonicalizePath.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the FILECanonicalizePath function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+extern void FILECanonicalizePath(LPSTR lpUnixPath);
+
+void TestCase(LPSTR input, LPSTR expectedOutput);
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc,argv) != 0)
+ {
+ return FAIL;
+ }
+
+ // Case 01: /<name> should not change
+ TestCase("/Test", "/Test");
+
+ // Case 02: /<name>/<name2> should not change
+ TestCase("/Test/Foo", "/Test/Foo");
+
+ // Case 03: // transforms to /
+ TestCase("//", "/");
+
+ // Case 04: /./ transforms to /
+ TestCase("/./", "/");
+
+ // Case 05: /<name>/../ transforms to /
+ TestCase("/Test/../", "/");
+
+ // Case 06: /Test/Foo/.. transforms to /Test
+ TestCase("/Test/Foo/..", "/Test");
+
+ // Case 07: /Test/.. transforms to /
+ TestCase("/Test/..", "/");
+
+ // Case 08: /. transforms to /
+ TestCase("/.", "/");
+
+ // Case 09: /<name/. transforms to /<name>
+ TestCase("/Test/.", "/Test");
+
+ // Case 10: /<name>/../. transforms to /
+ TestCase("/Test/../.", "/");
+
+ // Case 11: /.. transforms to /
+ TestCase("/..", "/");
+
+ PAL_Terminate();
+ return PASS;
+}
+
+void TestCase(LPSTR input, LPSTR expectedOutput)
+{
+ // Save the input for debug logging since the input is edited in-place
+ char* pOriginalInput = (char*)malloc(strlen(input) * sizeof(char) + 1);
+ strcpy(pOriginalInput, input);
+
+ char* pInput = (char*)malloc(strlen(input) * sizeof(char) + 1);
+ strcpy(pInput, pOriginalInput);
+
+ FILECanonicalizePath(pInput);
+ if (strcmp(pInput, expectedOutput) != 0)
+ {
+ free(pOriginalInput);
+ free(pInput);
+ Fail("FILECanonicalizePath error: input %s did not match expected output %s; got %s instead", pOriginalInput, expectedOutput, pInput);
+ }
+
+ free(pOriginalInput);
+ free(pInput);
+}
diff --git a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat
new file mode 100644
index 0000000..033ad78
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat
@@ -0,0 +1,12 @@
+# 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 = FILECanonicalizePath
+Name = Test for FILECanonicalizePath (test 1)
+Type = DEFAULT
+EXE1 = filecanonicalizepath
+Description
+= Canonicalizes paths and verifies the results
diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt
new file mode 100644
index 0000000..1310542
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_filetimetodosdatetime_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_filetimetodosdatetime_test1 coreclrpal)
+
+target_link_libraries(paltest_filetimetodosdatetime_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.c b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.c
new file mode 100644
index 0000000..5f2c81f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.c
@@ -0,0 +1,116 @@
+// 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: Tests that FileTimeToDosDateTime successfully converts values.
+** Makes sure values are rounded up, and the limits of the function
+** pass. Also tests that values outside the valid range fail.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+typedef struct
+{
+ DWORD FileTimeLow;
+ DWORD FileTimeHigh;
+ WORD FatDate;
+ WORD FatTime;
+} testCase;
+
+int __cdecl main(int argc, char **argv)
+{
+ FILETIME FileTime;
+ WORD ResultDate;
+ WORD ResultTime;
+ BOOL ret;
+ int i;
+
+ testCase testCases[] =
+ {
+ /* Test a normal time */
+ {0x9BE00100, 0x1B4A02C, 0x14CF, 0x55AF}, /* 12/15/2000, 10:45:30 AM*/
+ /* Test that 12/15/2000, 10:45:29 Gets rounded up */
+ {0x9B476A80, 0x1B4A02C, 0x14CF, 0x55AF}, /* 12/15/2000, 10:45:30 AM*/
+ /* Test that 12/15/2000, 10:45:31 Gets rounded up */
+ {0x9C789780, 0x1B4A02C, 0x14CF, 0x55B0}, /* 12/15/2000, 10:45:32 AM*/
+
+ /* Test the upper and lower limits of the function */
+ {0xE1D58000, 0x1A8E79F, 0x0021, 0x0000}, /* 1/1/1980, 12:00:00 AM*/
+ {0xb9de1300, 0x1e9eede, 0x739f, 0xbf7d}, /* 12/31/2037, 11:59:58 PM*/
+
+ /* Tests that should fail */
+ {0, 0, 0, 0},
+ {0xE0A45300, 0x1A8E79F, 0, 0},
+ {0x66D29301, 0x23868B8, 0, 0}
+
+ /* All this accomplishes is for the date to overflow.
+ Likely the only reason it fails in Windows is bacause the
+ resulting date falls outside of the legal range. Under BSD,
+ it falls into a legal range. This being that BSD calculates time
+ from 1900 to 2037, not 1980 to 2107.
+ {0xFFFFFFFF, 0xFFFFFFF, 0, 0}
+ */
+ };
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ for (i=0; i<sizeof(testCases) / sizeof(testCase); i++)
+ {
+ ResultDate = 0xFFFF;
+ ResultTime = 0xFFFF;
+
+ FileTime.dwLowDateTime = testCases[i].FileTimeLow;
+ FileTime.dwHighDateTime = testCases[i].FileTimeHigh;
+
+
+ ret = FileTimeToDosDateTime(&FileTime, &ResultDate, &ResultTime);
+ if (testCases[i].FatDate != 0 || testCases[i].FatTime != 0)
+ {
+ /* Expected it to pass */
+ if (!ret)
+ {
+ Fail("FileTimeToDosDateTime failed for %X,%X!\n",
+ testCases[i].FileTimeLow, testCases[i].FileTimeHigh);
+ }
+
+ if (ResultDate != testCases[i].FatDate ||
+ ResultTime != testCases[i].FatTime)
+ {
+ Fail("FileTimeToDosDateTime did not convert %X,%X "
+ "successfully:\nExpected date to be %hX, time %hx.\n"
+ "Got %hX, %hX\n", testCases[i].FileTimeLow,
+ testCases[i].FileTimeHigh, testCases[i].FatDate,
+ testCases[i].FatTime, ResultDate, ResultTime);
+ }
+ }
+ else
+ {
+ /* Expected it to fail. */
+ if (ret)
+ {
+ Fail("FileTimeToDosDateTime passed for %X,%X!\n",
+ testCases[i].FileTimeLow, testCases[i].FileTimeHigh);
+ }
+
+ if (ResultDate != 0xFFFF || ResultTime != 0xFFFF)
+ {
+ Fail("FileTimeToDosDateTime failed, but modified output "
+ "parameters: %X %X\n", ResultDate, ResultTime);
+ }
+ }
+
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/testinfo.dat
new file mode 100644
index 0000000..b5c7e1a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/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 = FileTimeToDosDateTime
+Name = Positive Test #1 for FileTimeToDosDateTime
+TYPE = DEFAULT
+EXE1 = test1
+Description
+=Tests that FileTimeToDosDateTime successfully converts values.
+=Makes sure values are rounded up, and the limits of the function
+=pass. Also tests that values outside the valid range fail.
+
diff --git a/src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt
new file mode 100644
index 0000000..732c9f5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FindClose.c
+)
+
+add_executable(paltest_findclose_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findclose_test1 coreclrpal)
+
+target_link_libraries(paltest_findclose_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.c b/src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.c
new file mode 100644
index 0000000..3d53806
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.c
@@ -0,0 +1,275 @@
+// 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: FindClose.c
+**
+** Purpose: Tests the PAL implementation of the FindClose function.
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+
+const WCHAR szFindName[] = {'t','e', 's', 't', '0', '1', '.', 't', 'x', 't', '\0'};
+const WCHAR szFindName_02[] = {'t','e', 's', 't', '0', '2', '.', 't', 'x', 't', '\0'};
+const WCHAR szFindName_03[] = {'t','e', 's', 't', '0', '3', '.', 't', 'x', 't', '\0'};
+const WCHAR szFindNameWldCard_01[] = {'t','e', 's', 't', '0', '?', '.', 't', 'x', 't', '\0'};
+const WCHAR szFindNameWldCard_02[] = {'*', '.', 't', 'x', 't', '\0'};
+const WCHAR szDirName[] = {'t','e', 's', 't', '_', 'd', 'i', 'r', '\0'};
+const WCHAR szDirName_02[] = {'t','e', 's', 't', '_', 'd', 'i', 'r', '0', '2', '\0'};
+const WCHAR szDirNameWldCard[] = {'t','e', 's', 't', '_', '*', '\0'};
+
+
+
+BOOL createTestFile(const WCHAR* szName)
+{
+ FILE *pFile = NULL;
+ char* pTemp = NULL;
+
+ pTemp = convertC((WCHAR*)szName);
+ pFile = fopen(pTemp, "w");
+ if (pFile == NULL)
+ {
+ Trace("FindClose: ERROR -> Unable to create file \"%s\".\n", pTemp);
+ free(pTemp);
+ return FALSE;
+ }
+ else
+ {
+ fprintf(pFile, "FindClose test file, \"%s\".\n", pTemp);
+ free(pTemp);
+ fclose(pFile);
+ }
+ return TRUE;
+}
+
+
+void removeAll()
+{
+ RemoveDirectoryW(szDirName);
+ RemoveDirectoryW(szDirName_02);
+
+ DeleteFileW(szFindName);
+ DeleteFileW(szFindName_02);
+ DeleteFileW(szFindName_03);
+}
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ WIN32_FIND_DATAW findFileData;
+ WIN32_FIND_DATAW findFileData_02;
+ HANDLE hFind = NULL;
+ BOOL bRc = FALSE;
+ char* pTemp = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* do some clean up just to be sure */
+ removeAll();
+
+ /* FindClose a null handle */
+ if(FindClose(NULL)!=0)
+ {
+ Fail("FindClose: ERROR -> Closing a NULL handle succeeded.\n");
+ }
+
+ /* find a file that exists */
+ if(createTestFile(szFindName) == FALSE)
+ {
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ if(createTestFile(szFindName_02) == FALSE)
+ {
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ if(createTestFile(szFindName_03) == FALSE)
+ {
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ // close a FindFirstFileW handle
+ hFind = FindFirstFileW(szFindName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ pTemp = convertC((WCHAR*)szFindName);
+ Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ else
+ {
+ bRc = FindClose(hFind);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to close a valid"
+ " FindFirstFileW handle.\n");
+ }
+ }
+ hFind = FindFirstFileW(szFindName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ pTemp = convertC((WCHAR*)szFindName);
+ Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData);
+ if (bRc != FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Found a file that doesn't exist.\n");
+ }
+ else
+ {
+ bRc = FindClose(hFind);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to close a valid "
+ "FindNextFileW handle.\n");
+ }
+ }
+ }
+
+ /* find a directory that exists */
+ bRc = CreateDirectoryW(szDirName, NULL);
+ if (bRc == FALSE)
+ {
+ pTemp = convertC((WCHAR*)szDirName);
+ Trace("FindClose: ERROR -> Failed to create the directory \"%s\"\n",
+ pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ bRc = CreateDirectoryW(szDirName_02, NULL);
+ if (bRc == FALSE)
+ {
+ pTemp = convertC((WCHAR*)szDirName_02);
+ Trace("FindClose: ERROR -> Failed to create the directory \"%s\"\n",
+ pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ hFind = FindFirstFileW(szDirName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ pTemp = convertC((WCHAR*)szDirName);
+ Trace("FindClose: ERROR. FindFirstFileW was unable to find \"%s\"\n",
+ pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ else
+ {
+ bRc = FindClose(hFind);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to close a valid"
+ " FindFirstFileW handle of a directory.\n");
+ }
+ }
+
+ /* find a file using wild cards */
+ hFind = FindFirstFileW(szFindNameWldCard_01, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ pTemp = convertC((WCHAR*)szFindNameWldCard_01);
+ Trace("FindClose: ERROR -> FindFirstFileW was unable to find \"%s\"\n",
+ pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData_02);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to find another file.\n");
+ }
+ else
+ {
+ bRc = FindClose(hFind);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to close a valid"
+ " FindNextFileW handle.\n");
+ }
+ }
+ }
+
+ /* find a directory using wild cards */
+ hFind = FindFirstFileW(szDirNameWldCard, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ pTemp = convertC((WCHAR*)szDirNameWldCard);
+ Trace("FindClose: ERROR -> Unable to find \"%s\"\n",
+ pTemp);
+ free(pTemp);
+ removeAll();
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData_02);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to find another directory.\n");
+ }
+ else
+ {
+ bRc = FindClose(hFind);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindClose: ERROR -> Unable to close a valid"
+ " FindNextFileW handle of a directory.\n");
+ }
+ }
+ }
+
+
+ removeAll();
+ PAL_Terminate();
+
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat
new file mode 100644
index 0000000..b59bcbf
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = FindClose
+Name = Test for FindClose (test 1)
+Type = DEFAULT
+EXE1 = findclose
+Description
+= Test the FindClose on handles opened using the Find functions
+
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt
new file mode 100644
index 0000000..6613c4d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FindFirstFileA.c
+)
+
+add_executable(paltest_findfirstfilea_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findfirstfilea_test1 coreclrpal)
+
+target_link_libraries(paltest_findfirstfilea_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.c b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.c
new file mode 100644
index 0000000..6ceb6a9
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.c
@@ -0,0 +1,206 @@
+// 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: FindFirstFileA.c
+**
+** Purpose: Tests the PAL implementation of the FindFirstFileA function.
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+const char* szNoFileName = "333asdf.x77t";
+const char* szFindName = "test01.txt";
+const char* szFindNameWldCard_01 = "test0?.txt";
+const char* szFindNameWldCard_02 = "*.txt";
+const char* szDirName = "test_dir";
+const char* szDirNameSlash = "test_dir\\";
+const char* szDirNameWldCard_01 = "?est_dir";
+const char* szDirNameWldCard_02 = "test_*";
+/* Longer than MAX_LONGPATH characters */
+char szLongFindName[MAX_LONGPATH+1];
+
+BOOL CleanUp()
+{
+ DWORD dwAtt;
+ BOOL result = TRUE;
+
+ dwAtt = GetFileAttributesA(szFindName);
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+ if(!SetFileAttributesA (szFindName, FILE_ATTRIBUTE_NORMAL))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", szFindName, FILE_ATTRIBUTE_NORMAL);
+ }
+ if(!DeleteFileA (szFindName))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szFindName, dwAtt);
+ }
+ }
+
+ dwAtt = GetFileAttributesA(szDirName);
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+ if(!RemoveDirectoryA (szDirName))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szDirName, dwAtt);
+ }
+ }
+
+ return result;
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ WIN32_FIND_DATA findFileData;
+ HANDLE hFind = NULL;
+ FILE *pFile = NULL;
+ BOOL bRc = FALSE;
+ WCHAR* szwTemp = NULL;
+
+ memset(szLongFindName, 'a', MAX_LONGPATH+1);
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+
+ if(!CleanUp())
+ {
+ Fail("FindFirstFileW: ERROR : Initial Clean Up failed\n");
+ }
+
+ //
+ // find a file with a NULL pointer
+ //
+ hFind = FindFirstFileA(NULL, &findFileData);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Found invalid NULL file");
+ }
+
+
+ //
+ // find a file that doesn't exist
+ //
+ hFind = FindFirstFileA(szNoFileName, &findFileData);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Found invalid NULL file");
+ }
+
+
+ //
+ // find a file that exists
+ //
+ pFile = fopen(szFindName, "w");
+ if (pFile == NULL)
+ {
+ Fail("FindFirstFileA: ERROR -> Unable to create a test file\n");
+ }
+ else
+ {
+ fclose(pFile);
+ }
+ hFind = FindFirstFileA(szFindName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szFindName);
+ }
+ else
+ {
+ // validate we found the correct file
+ if (strcmp(szFindName, findFileData.cFileName) != 0)
+ {
+ Fail ("FindFirstFileA: ERROR -> Found the wrong file\n");
+ }
+ }
+
+
+ //
+ // find a directory that exists
+ //
+ szwTemp = convert((LPSTR)szDirName);
+ bRc = CreateDirectoryW(szwTemp, NULL);
+ free(szwTemp);
+ if (bRc == FALSE)
+ {
+ Fail("FindFirstFileA: ERROR -> Failed to create the directory "
+ "\"%s\"\n",
+ szDirName);
+ }
+
+ hFind = FindFirstFileA(szDirName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR. Unable to find \"%s\"\n", szDirName);
+ }
+ else
+ {
+ // validate we found the correct directory
+ if (strcmp(szDirName, findFileData.cFileName) != 0)
+ {
+ Fail ("FindFirstFileA: ERROR -> Found the wrong directory\n");
+ }
+ }
+
+
+ //
+ // find a directory using a trailing '\' on the directory name: should fail
+ //
+ hFind = FindFirstFileA(szDirNameSlash, &findFileData);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Able to find \"%s\": trailing "
+ "slash should have failed.\n",
+ szDirNameSlash);
+ }
+
+ // find a file using wild cards
+ hFind = FindFirstFileA(szFindNameWldCard_01, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n",
+ szFindNameWldCard_01);
+ }
+
+ hFind = FindFirstFileA(szFindNameWldCard_02, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szFindNameWldCard_02);
+ }
+
+
+ //
+ // find a directory using wild cards
+ //
+ hFind = FindFirstFileA(szDirNameWldCard_01, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szDirNameWldCard_01);
+ }
+
+ hFind = FindFirstFileA(szDirNameWldCard_02, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szDirNameWldCard_02);
+ }
+
+ if(!CleanUp())
+ {
+ Fail("FindFirstFileW: ERROR : Final Clean Up failed\n");
+ }
+
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat
new file mode 100644
index 0000000..5b92f8c
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = FindFirstFileA
+Name = Test for FindFirstFileA (test 1)
+Type = DEFAULT
+EXE1 = findfirstfilea
+Description
+= Create a number of files and try to find them
+
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt
new file mode 100644
index 0000000..23e95c7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FindFirstFileW.c
+)
+
+add_executable(paltest_findfirstfilew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findfirstfilew_test1 coreclrpal)
+
+target_link_libraries(paltest_findfirstfilew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.c b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.c
new file mode 100644
index 0000000..f69a625
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.c
@@ -0,0 +1,212 @@
+// 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: FindFirstFileW.c
+**
+** Purpose: Tests the PAL implementation of the FindFirstFileW function.
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+const char* szNoFileName = "333asdf.x77t";
+const char* szFindName = "test01.txt";
+const char* szFindNameWldCard_01 = "test0?.txt";
+const char* szFindNameWldCard_02 = "*.txt";
+const char* szDirName = "test_dir";
+const char* szDirNameSlash = "test_dir\\";
+const char* szDirNameWldCard_01 = "?est_dir";
+const char* szDirNameWldCard_02 = "test_*";
+
+
+BOOL CleanUp()
+{
+ DWORD dwAtt;
+ BOOL result = TRUE;
+
+ dwAtt = GetFileAttributesA(szFindName);
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+ if(!SetFileAttributesA (szFindName, FILE_ATTRIBUTE_NORMAL))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", szFindName, FILE_ATTRIBUTE_NORMAL);
+ }
+ if(!DeleteFileA (szFindName))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szFindName, dwAtt);
+ }
+ }
+
+ dwAtt = GetFileAttributesA(szDirName);
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+ if(!RemoveDirectoryA (szDirName))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szDirName, dwAtt);
+ }
+ }
+
+ return result;
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ WIN32_FIND_DATAW findFileData;
+ HANDLE hFind = NULL;
+ FILE *pFile = NULL;
+ BOOL bRc = FALSE;
+ WCHAR* pTemp = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ if(!CleanUp())
+ {
+ Fail("FindFirstFileW: ERROR : Initial Clean Up failed\n");
+ }
+
+ //
+ // find a file that doesn't exist
+ //
+ pTemp = convert((LPSTR)szNoFileName);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ free(pTemp);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ Fail ("FindFirstFileW: ERROR -> Found invalid NULL file\n");
+ }
+
+
+ //
+ // find a file that exists
+ //
+ pFile = fopen(szFindName, "w");
+ if (pFile == NULL)
+ {
+ Fail("FindFirstFileW: ERROR -> Unable to create a test file\n");
+ }
+ else
+ {
+ fclose(pFile);
+ }
+ pTemp = convert((LPSTR)szFindName);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ free(pTemp);
+ Fail ("FindFirstFileW: ERROR -> Unable to find \"%s\"\n", szFindName);
+ }
+ else
+ {
+ // validate we found the correct file
+ if (wcscmp(pTemp, findFileData.cFileName) != 0)
+ {
+ free(pTemp);
+ Fail ("FindFirstFileW: ERROR -> Found the wrong file\n");
+ }
+ }
+ free(pTemp);
+
+ //
+ // find a directory that exists
+ //
+ pTemp = convert((LPSTR)szDirName);
+ bRc = CreateDirectoryW(pTemp, NULL);
+ if (bRc == FALSE)
+ {
+ Fail("FindFirstFileW: ERROR[%u] -> Failed to create the directory \"%s\"\n",
+ GetLastError(), szDirName);
+ }
+
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ free(pTemp);
+ Fail("FindFirstFileW: ERROR. Unable to find \"%s\"\n", szDirName);
+ }
+ else
+ {
+ // validate we found the correct directory
+ if (wcscmp(pTemp, findFileData.cFileName) != 0)
+ {
+ free(pTemp);
+ Fail("FindFirstFileW: ERROR -> Found the wrong directory\n");
+ }
+ }
+ free(pTemp);
+
+ //
+ // find a directory using a trailing '\' on the directory name: should fail
+ //
+ pTemp = convert((LPSTR)szDirNameSlash);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ free(pTemp);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ Fail("FindFirstFileW: ERROR -> Able to find \"%s\": trailing "
+ "slash should have failed.\n",
+ szDirNameSlash);
+ }
+
+ // find a file using wild cards
+ pTemp = convert((LPSTR)szFindNameWldCard_01);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ free(pTemp);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n",
+ szFindNameWldCard_01);
+ }
+
+ pTemp = convert((LPSTR)szFindNameWldCard_02);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ free(pTemp);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n",
+ szFindNameWldCard_02);
+ }
+
+
+ //
+ // find a directory using wild cards
+ //
+
+ pTemp = convert((LPSTR)szDirNameWldCard_01);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ free(pTemp);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n",
+ szDirNameWldCard_01);
+ }
+
+ pTemp = convert((LPSTR)szDirNameWldCard_02);
+ hFind = FindFirstFileW(pTemp, &findFileData);
+ free(pTemp);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n",
+ szDirNameWldCard_02);
+ }
+
+ if(!CleanUp())
+ {
+ Fail("FindFirstFileW: ERROR : Final Clean Up failed\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat
new file mode 100644
index 0000000..c088c04
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = FindFirstFileW
+Name = Test for FindFirstFileW (test 1)
+Type = DEFAULT
+EXE1 = findfirstfilew
+Description
+= Create a number of files and try to find them
+
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt
new file mode 100644
index 0000000..efb1655
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FindNextFileA.c
+)
+
+add_executable(paltest_findnextfilea_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findnextfilea_test1 coreclrpal)
+
+target_link_libraries(paltest_findnextfilea_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.c b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.c
new file mode 100644
index 0000000..578fa00
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.c
@@ -0,0 +1,243 @@
+// 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: FindNextFileA.c
+**
+** Purpose: Tests the PAL implementation of the FindNextFileA function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+const char* szFindName = "test01.txt";
+const char* szFindName_02 = "test02.txt";
+const char* szFindNameWldCard_01 = "test0?.txt";
+const char* szFindNameWldCard_02 = "*.txt";
+const char* szDirName = "test_dir";
+const char* szDirName_02 = "test_dir_02";
+const char* szDirNameWldCard = "test_*";
+
+
+
+void removeAll()
+{
+ WCHAR* wTempPtr = NULL;
+
+ wTempPtr = convert((LPSTR)szDirName);
+ RemoveDirectoryW(wTempPtr);
+ free (wTempPtr);
+ wTempPtr = convert((LPSTR)szDirName_02);
+ RemoveDirectoryW(wTempPtr);
+ free (wTempPtr);
+ DeleteFile(szFindName);
+ DeleteFile(szFindName_02);
+}
+
+
+
+BOOL createTestFile(const char* szName)
+{
+ FILE *pFile = NULL;
+
+ pFile = fopen(szName, "w");
+ if (pFile == NULL)
+ {
+ Trace("FindNextFile: ERROR -> Unable to create file \"%s\".\n",
+ szName);
+ removeAll();
+ return FALSE;
+ }
+ else
+ {
+ fprintf(pFile, "FindNextFile test file, \"%s\".\n", szFindName);
+ fclose(pFile);
+ }
+ return TRUE;
+}
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ WIN32_FIND_DATA findFileData;
+ WIN32_FIND_DATA findFileData_02;
+ HANDLE hFind = NULL;
+ BOOL bRc = FALSE;
+ DWORD dwBytesWritten;
+ WCHAR* wTempPtr = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+ removeAll();
+
+
+ //
+ // find a file with a NULL pointer
+ //
+ hFind = FindFirstFileA(NULL, &findFileData);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ Fail("FindNextFile: ERROR -> Found invalid NULL file");
+ }
+
+ bRc = FindNextFile(hFind, &findFileData);
+ if (bRc == TRUE)
+ {
+ Fail("FindNextFile: ERROR -> Found a file based on an invalid handle");
+ }
+
+
+ //
+ // find a file that exists
+ //
+ if(createTestFile(szFindName) == FALSE)
+ {
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ if(createTestFile(szFindName_02) == FALSE)
+ {
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ hFind = FindFirstFileA(szFindName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Unable to find \"%s\"\n", szFindName);
+ }
+ else
+ {
+ bRc = FindNextFile(hFind, &findFileData);
+ if (bRc != FALSE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Found a file that doesn't exist.\n");
+ }
+ }
+
+
+ //
+ // find a directory that exists
+ //
+ wTempPtr = convert((LPSTR)szDirName);
+ bRc = CreateDirectoryW(wTempPtr, NULL);
+ free (wTempPtr);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Failed to create the directory \"%s\"\n",
+ szDirName);
+ }
+ wTempPtr = convert((LPSTR)szDirName_02);
+ bRc = CreateDirectoryW(wTempPtr, NULL);
+ free (wTempPtr);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Failed to create the directory \"%s\"\n",
+ szDirName_02);
+ }
+
+ hFind = FindFirstFileA(szDirName, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR. FindFirstFileA was unable to find \"%s\"\n",
+ szDirName);
+ }
+ else
+ {
+ bRc = FindNextFile(hFind, &findFileData);
+ if (bRc != FALSE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Found a directory that doesn't exist.\n");
+ }
+ }
+
+
+ //
+ // find a file using wild cards
+ //
+ hFind = FindFirstFileA(szFindNameWldCard_01, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> FindFirstFileA was unable to find \"%s\"\n",
+ szFindNameWldCard_01);
+ }
+ else
+ {
+ bRc = FindNextFile(hFind, &findFileData_02);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Unable to find another file.\n");
+ }
+ else
+ {
+ // validate we found the correct file
+ if (strcmp(findFileData_02.cFileName, findFileData.cFileName) == 0)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Found the same file \"%s\".\n",
+ findFileData.cFileName);
+ }
+ }
+ }
+
+
+ //
+ // find a directory using wild cards
+ //
+ hFind = FindFirstFileA(szDirNameWldCard, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Unable to find \"%s\"\n",
+ szDirNameWldCard);
+ }
+ else
+ {
+ bRc = FindNextFile(hFind, &findFileData_02);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Unable to find another directory.\n");
+ }
+ else
+ {
+ // validate we found the correct directory
+ if (strcmp(findFileData_02.cFileName, findFileData.cFileName) == 0)
+ {
+ removeAll();
+ Fail("FindNextFile: ERROR -> Found the same directory \"%s\".\n",
+ findFileData.cFileName);
+ }
+ }
+ }
+
+ //
+ // attempt to write to the hFind handle (which should fail)
+ //
+ bRc = WriteFile(hFind, "this is a test", 10, &dwBytesWritten, NULL);
+ removeAll();
+ if (bRc == TRUE)
+ {
+ Fail("FindNextFile: ERROR -> Able to write to a FindNextFile handle.\n");
+ }
+
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat
new file mode 100644
index 0000000..e1027ef
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = FindNextFileA
+Name = Test for FindNextFileA (test 1)
+Type = DEFAULT
+EXE1 = findnextfilea
+Description
+= Create test files and directories to verify FindNextFileA
+
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt
new file mode 100644
index 0000000..96821bd
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ findnextfilea.c
+)
+
+add_executable(paltest_findnextfilea_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findnextfilea_test2 coreclrpal)
+
+target_link_libraries(paltest_findnextfilea_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.c b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.c
new file mode 100644
index 0000000..c841a4d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.c
@@ -0,0 +1,107 @@
+// 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: findnextfilea.c
+**
+** Purpose: Tests the PAL implementation of the FindNextFileA function.
+** Tests '*' and '*.*' to ensure that '.' and '..' are
+** returned in the expected order
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+const char* szDot = ".";
+const char* szDotDot = "..";
+const char* szStar = "*";
+const char* szStarDotStar = "*.*";
+
+
+static void DoTest(const char* szDir,
+ const char* szResult1,
+ const char* szResult2)
+{
+ HANDLE hFind;
+ WIN32_FIND_DATA findFileData;
+
+ /*
+ ** find the first
+ */
+ if ((hFind = FindFirstFileA(szDir, &findFileData)) == INVALID_HANDLE_VALUE)
+ {
+ Fail("FindNextFileA: ERROR -> FindFirstFileA(\"%s\") failed. "
+ "GetLastError returned %u.\n",
+ szStar,
+ GetLastError());
+ }
+
+ /* did we find the expected */
+ if (strcmp(szResult1, findFileData.cFileName) != 0)
+ {
+ if (!FindClose(hFind))
+ {
+ Trace("FindNextFileA: ERROR -> Failed to close the find handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("FindNextFileA: ERROR -> FindFirstFile(\"%s\") didn't find"
+ " the expected \"%s\" but found \"%s\" instead.\n",
+ szDir,
+ szResult1,
+ findFileData.cFileName);
+ }
+
+ /* we found the first expected, let's see if we find the next expected*/
+ if (!FindNextFileA(hFind, &findFileData))
+ {
+ Trace("FindNextFileA: ERROR -> FindNextFileA should have found \"%s\""
+ " but failed. GetLastError returned %u.\n",
+ szResult2,
+ GetLastError());
+ if (!FindClose(hFind))
+ {
+ Trace("FindNextFileA: ERROR -> Failed to close the find handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* we found something, but was it '.' */
+ if (strcmp(szResult2, findFileData.cFileName) != 0)
+ {
+ if (!FindClose(hFind))
+ {
+ Trace("FindNextFileA: ERROR -> Failed to close the find handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("FindNextFileA: ERROR -> FindNextFileA based on \"%s\" didn't find"
+ " the expected \"%s\" but found \"%s\" instead.\n",
+ szDir,
+ szResult2,
+ findFileData.cFileName);
+ }
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ DoTest(szStar, szDot, szDotDot);
+ DoTest(szStarDotStar, szDot, szDotDot);
+
+
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/testinfo.dat
new file mode 100644
index 0000000..dd6c1e4
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/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 = file_io
+Function = FindNextFileA
+Name = Test for FindNextFileA (test 2)
+Type = DEFAULT
+EXE1 = findnextfilea
+Description
+= Tests the PAL implementation of the FindNextFileA function.
+= Tests '*' and '*.*' to ensure that '.' and '..' are
+= returned in the expected order
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt
new file mode 100644
index 0000000..4a283dd
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FindNextFileW.c
+)
+
+add_executable(paltest_findnextfilew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findnextfilew_test1 coreclrpal)
+
+target_link_libraries(paltest_findnextfilew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.c b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.c
new file mode 100644
index 0000000..42e2e55
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.c
@@ -0,0 +1,249 @@
+// 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: FindNextFileW.c
+**
+** Purpose: Tests the PAL implementation of the FindNextFileW function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+const char* szFindName = "test01.txt";
+const char* szFindName_02 = "test02.txt";
+const char* szFindNameWldCard_01 = "test0?.txt";
+const char* szFindNameWldCard_02 = "*.txt";
+const char* szDirName = "test_dir";
+const char* szDirName_02 = "test_dir_02";
+const char* szDirNameWldCard = "test_*";
+
+
+
+void removeAll()
+{
+ WCHAR* wTempPtr = NULL;
+
+ wTempPtr = convert((LPSTR)szDirName);
+ RemoveDirectoryW(wTempPtr);
+ free(wTempPtr);
+
+ wTempPtr = convert((LPSTR)szDirName_02);
+ RemoveDirectoryW(wTempPtr);
+ free(wTempPtr);
+
+ wTempPtr = convert((LPSTR)szFindName);
+ DeleteFileW(wTempPtr);
+ free(wTempPtr);
+
+ wTempPtr = convert((LPSTR)szFindName_02);
+ DeleteFileW(wTempPtr);
+ free(wTempPtr);
+}
+
+
+
+BOOL createTestFile(const char* szName)
+{
+ FILE *pFile = NULL;
+
+ pFile = fopen(szName, "w");
+ if (pFile == NULL)
+ {
+ Trace("FindNextFileW: ERROR -> Unable to create file \"%s\".\n", szName);
+ removeAll();
+ return FALSE;
+ }
+ else
+ {
+ fprintf(pFile, "FindNextFileW test file, \"%s\".\n", szFindName);
+ fclose(pFile);
+ }
+
+ return TRUE;
+}
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ WIN32_FIND_DATAW findFileData;
+ WIN32_FIND_DATAW findFileData_02;
+ HANDLE hFind = NULL;
+ BOOL bRc = FALSE;
+ DWORD dwBytesWritten;
+ WCHAR* wTempPtr = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+ removeAll();
+
+
+ //
+ // find a file that exists
+ //
+ if(createTestFile(szFindName) == FALSE)
+ {
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+ if(createTestFile(szFindName_02) == FALSE)
+ {
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ wTempPtr = convert((LPSTR)szFindName);
+ hFind = FindFirstFileW(wTempPtr, &findFileData);
+ free(wTempPtr);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Unable to find \"%s\"\n", szFindName);
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData);
+ if (bRc != FALSE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Found a file that doesn't exist.\n");
+ }
+ }
+
+
+ //
+ // find a directory that exists
+ //
+ wTempPtr = convert((LPSTR)szDirName);
+ bRc = CreateDirectoryW(wTempPtr, NULL);
+ free (wTempPtr);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Failed to create the directory \"%s\"\n",
+ szDirName);
+ }
+ wTempPtr = convert((LPSTR)szDirName_02);
+ bRc = CreateDirectoryW(wTempPtr, NULL);
+ free (wTempPtr);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Failed to create the directory "
+ "\"%s\"\n",
+ szDirName_02);
+ }
+
+ wTempPtr = convert((LPSTR)szDirName);
+ hFind = FindFirstFileW(wTempPtr, &findFileData);
+ free (wTempPtr);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR. FindFirstFileW was unable "
+ "to find \"%s\"\n",
+ szDirName);
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData);
+ if (bRc != FALSE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Found a directory that "
+ "doesn't exist.\n");
+ }
+ }
+
+
+ //
+ // find a file using wild cards
+ //
+ wTempPtr = convert((LPSTR)szFindNameWldCard_01);
+ hFind = FindFirstFileW(wTempPtr, &findFileData);
+ free(wTempPtr);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> FindFirstFileW was unable to "
+ "find \"%s\"\n",
+ szFindNameWldCard_01);
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData_02);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Unable to find another file.\n");
+ }
+ else
+ {
+ // validate we found the correct file
+ if (wcscmp(findFileData_02.cFileName, findFileData.cFileName) == 0)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Found the same file \"%S\".\n",
+ findFileData.cFileName);
+ }
+ }
+ }
+
+
+ //
+ // find a directory using wild cards
+ //
+ wTempPtr = convert((LPSTR)szDirNameWldCard);
+ hFind = FindFirstFileW(wTempPtr, &findFileData);
+ free(wTempPtr);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Unable to find \"%s\"\n",
+ szDirNameWldCard);
+ }
+ else
+ {
+ bRc = FindNextFileW(hFind, &findFileData_02);
+ if (bRc == FALSE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Unable to find another directory.\n");
+ }
+ else
+ {
+ // validate we found the correct directory
+ if (wcscmp(findFileData_02.cFileName, findFileData.cFileName) == 0)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Found the same directory "
+ "\"%S\".\n",
+ findFileData.cFileName);
+ }
+ }
+ }
+
+ //
+ // attempt to write to the hFind handle (which should fail)
+ //
+ bRc = WriteFile(hFind, "this is a test", 10, &dwBytesWritten, NULL);
+ if (bRc == TRUE)
+ {
+ removeAll();
+ Fail("FindNextFileW: ERROR -> Able to write to a FindNextFileW "
+ "handle.\n");
+ }
+
+ removeAll();
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat
new file mode 100644
index 0000000..3eaebef
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = FindNextFileW
+Name = Test for FindNextFileW (test 1)
+Type = DEFAULT
+EXE1 = findnextfilew
+Description
+= Create test files and directories to verify FindNextFileW
+
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt
new file mode 100644
index 0000000..2938afb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ findnextfilew.c
+)
+
+add_executable(paltest_findnextfilew_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_findnextfilew_test2 coreclrpal)
+
+target_link_libraries(paltest_findnextfilew_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.c b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.c
new file mode 100644
index 0000000..3e806c2
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.c
@@ -0,0 +1,107 @@
+// 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: FindNextFileW.c
+**
+** Purpose: Tests the PAL implementation of the FindNextFileW function.
+** Tests '*' and '*.*' to ensure that '.' and '..' are
+** returned in the expected order
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+const WCHAR szwDot[] = {'.','\0'};
+const WCHAR szwDotDot[] = {'.','.','\0'};
+const WCHAR szwStar[] = {'*','\0'};
+const WCHAR szwStarDotStar[] = {'*','.','*','\0'};
+
+
+static void DoTest(const WCHAR* szwDir,
+ const WCHAR* szwResult1,
+ const WCHAR* szwResult2)
+{
+ HANDLE hFind;
+ WIN32_FIND_DATAW findFileData;
+
+ /*
+ ** find the first
+ */
+ if ((hFind = FindFirstFileW(szwDir, &findFileData)) == INVALID_HANDLE_VALUE)
+ {
+ Fail("FindNextFileW: ERROR -> FindFirstFileW(\"%S\") failed. "
+ "GetLastError returned %u.\n",
+ szwStar,
+ GetLastError());
+ }
+
+ /* did we find the expected */
+ if (wcscmp(szwResult1, findFileData.cFileName) != 0)
+ {
+ if (!FindClose(hFind))
+ {
+ Trace("FindNextFileW: ERROR -> Failed to close the find handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("FindNextFileW: ERROR -> FindFirstFile(\"%S\") didn't find"
+ " the expected \"%S\" but found \"%S\" instead.\n",
+ szwDir,
+ szwResult1,
+ findFileData.cFileName);
+ }
+
+ /* we found the first expected, let's see if we find the next expected*/
+ if (!FindNextFileW(hFind, &findFileData))
+ {
+ Trace("FindNextFileW: ERROR -> FindNextFileW should have found \"%S\""
+ " but failed. GetLastError returned %u.\n",
+ szwResult2,
+ GetLastError());
+ if (!FindClose(hFind))
+ {
+ Trace("FindNextFileW: ERROR -> Failed to close the find handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* we found something, but was it '.' */
+ if (wcscmp(szwResult2, findFileData.cFileName) != 0)
+ {
+ if (!FindClose(hFind))
+ {
+ Trace("FindNextFileW: ERROR -> Failed to close the find handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("FindNextFileW: ERROR -> FindNextFileW based on \"%S\" didn't find"
+ " the expected \"%S\" but found \"%S\" instead.\n",
+ szwDir,
+ szwResult2,
+ findFileData.cFileName);
+ }
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ DoTest(szwStar, szwDot, szwDotDot);
+ DoTest(szwStarDotStar, szwDot, szwDotDot);
+
+
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/testinfo.dat
new file mode 100644
index 0000000..98bd5e7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/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 = file_io
+Function = FindNextFileW
+Name = Test for FindNextFileW (test 2)
+Type = DEFAULT
+EXE1 = findnextfilew
+Description
+= Tests the PAL implementation of the FindNextFileW function.
+= Tests '*' and '*.*' to ensure that '.' and '..' are
+= returned in the expected order
diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt
new file mode 100644
index 0000000..e3fbccd
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ FlushFileBuffers.c
+)
+
+add_executable(paltest_flushfilebuffers_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_flushfilebuffers_test1 coreclrpal)
+
+target_link_libraries(paltest_flushfilebuffers_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.c b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.c
new file mode 100644
index 0000000..246be64
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.c
@@ -0,0 +1,130 @@
+// 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: FlushFileBuffers.c
+**
+** Purpose: Tests the PAL implementation of the FlushFileBuffers function
+** This tests checks the return values of FlushFileBuffers -- once on an
+** open handle and once on a closed handle.
+**
+** Depends:
+** CreateFile
+** WriteFile
+** CloseHandle
+** DeleteFileA
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ int TheReturn;
+ HANDLE TheFileHandle;
+ DWORD temp;
+ DWORD originalSize=10000;
+ DWORD finalSize=10000;
+ const char* fileName="the_file";
+
+ /* 1 2 3 4*/
+ char * SomeText = "1234567890123456789012345678901234567890";
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+
+ /* Open the file to get a HANDLE */
+ TheFileHandle =
+ CreateFile(
+ fileName,
+ GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: CreateFile failed. Test depends on this function.");
+ }
+
+ /* get the file size */
+ originalSize = GetFileSize (TheFileHandle, NULL) ;
+ if(originalSize == INVALID_FILE_SIZE)
+ {
+ Fail("ERROR: call to GetFileSize faild with error "
+ "The GetLastError is %d.",GetLastError());
+ }
+
+ /* Write something too the HANDLE. Should be buffered */
+ TheReturn = WriteFile(TheFileHandle,
+ SomeText,
+ strlen(SomeText),
+ &temp,
+ NULL);
+
+ if(TheReturn == 0)
+ {
+ Fail("ERROR: WriteFile failed. Test depends on this function.");
+ }
+
+ /* Test to see that FlushFileBuffers returns a success value */
+ TheReturn = FlushFileBuffers(TheFileHandle);
+ if(TheReturn == 0)
+ {
+ Fail("ERROR: The FlushFileBuffers function returned 0, which "
+ "indicates failure, when trying to flush a valid HANDLE. "
+ "The GetLastError is %d.",GetLastError());
+ }
+
+ /* test if flush modified the file */
+ finalSize = GetFileSize (TheFileHandle, NULL) ;
+ if(finalSize==INVALID_FILE_SIZE)
+ {
+ Fail("ERROR: call to GetFileSize faild with error "
+ "The GetLastError is %d.",GetLastError());
+ }
+ if(finalSize!=(originalSize+strlen(SomeText)))
+ {
+ Fail("ERROR: FlushFileBuffers failed. data was not written to the file");
+ }
+
+
+ /* Close the Handle */
+ TheReturn = CloseHandle(TheFileHandle);
+ if(TheReturn == 0)
+ {
+ Fail("ERROR: CloseHandle failed. This function depends "
+ "upon it.");
+ }
+
+
+ /* Test to see that FlushFileBuffers returns a failure value */
+ TheReturn = FlushFileBuffers(TheFileHandle);
+ if(TheReturn != 0)
+ {
+ Fail("ERROR: The FlushFileBuffers function returned non-zero, "
+ "which indicates success, when trying to flush an invalid "
+ "HANDLE.");
+ }
+
+ /* make sure file does not exist */
+ if(DeleteFileA(fileName)== 0 )
+ {
+ Fail("ERROR: call to DeleteFileA faild with error "
+ "The GetLastError is %d.",GetLastError());
+ }
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat
new file mode 100644
index 0000000..3a0da69
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat
@@ -0,0 +1,17 @@
+# 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 = FlushFileBuffers
+Name = Positive Test for FlushFileBuffers
+TYPE = DEFAULT
+EXE1 = flushfilebuffers
+Description
+= Test the FlushFileBuffers
+= Test the return values -- ensure that the correct values are
+= returned for success and failure.
+= This test does not prove that flush worked,
+= there is no way of stopping the OS from flushing
+= the file by itself.
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt
new file mode 100644
index 0000000..131f4a5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetConsoleCP.c
+)
+
+add_executable(paltest_getconsolecp_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getconsolecp_test1 coreclrpal)
+
+target_link_libraries(paltest_getconsolecp_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.c b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.c
new file mode 100644
index 0000000..ba17d6c
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.c
@@ -0,0 +1,35 @@
+// 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: GetConsoleCP.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetConsoleCP function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ UINT uiCP = 0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ uiCP = GetConsoleCP();
+ if ((uiCP != CP_ACP) && (uiCP != GetACP()) && (uiCP != 437)) /*437 for MSDOS*/
+ {
+ Fail("GetConsoleCP: ERROR -> The invalid code page %d was returned.\n",
+ uiCP);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/testinfo.dat
new file mode 100644
index 0000000..608a01b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetConsoleCP
+Name = Positive Test for GetConsoleCP (test 1)
+Type = DEFAULT
+EXE1 = getconsolecp
+Description
+= Test GetConsoleCP. Apparently there are only two possible
+= return values: CP_ACP or 1252
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt
new file mode 100644
index 0000000..d19ab95
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetConsoleOutputCP.c
+)
+
+add_executable(paltest_getconsoleoutputcp_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getconsoleoutputcp_test1 coreclrpal)
+
+target_link_libraries(paltest_getconsoleoutputcp_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.c b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.c
new file mode 100644
index 0000000..3deaebf
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.c
@@ -0,0 +1,35 @@
+// 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: GetConsoleOutputCP.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetConsoleOutputCP function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ UINT uiCP = 0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ uiCP = GetConsoleOutputCP();
+ if ((uiCP != CP_ACP) && (uiCP != GetACP()) && (uiCP != 437)) /*437 for MSDOS*/
+ {
+ Fail("GetConsoleOutputCP: ERROR -> The invalid code page %d was returned.\n",
+ uiCP);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat
new file mode 100644
index 0000000..9ad624e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetConsoleOutputCP
+Name = Positive Test for GetConsoleOutputCP (test 1)
+Type = DEFAULT
+EXE1 = getconsoleoutputcp
+Description
+= Test GetConsoleOutputCP. Apparently there are only two possible
+= return values: CP_ACP or 1252
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt
new file mode 100644
index 0000000..f7382b0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetCurrentDirectoryA.c
+)
+
+add_executable(paltest_getcurrentdirectorya_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getcurrentdirectorya_test1 coreclrpal)
+
+target_link_libraries(paltest_getcurrentdirectorya_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.c b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.c
new file mode 100644
index 0000000..b09e8a1
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.c
@@ -0,0 +1,97 @@
+// 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: GetCurrentDirectoryA.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetCurrentDirectoryA function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szFileName = "blah";
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ DWORD dwRc2 = 0;
+ char szReturnedPath[_MAX_PATH+1];
+ char szCurrentDir[_MAX_PATH+1];
+ LPSTR pPathPtr;
+ size_t nCount = 0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ // use GetFullPathName to to get the current path by stripping
+ // the file name off the end
+ memset(szReturnedPath, 0, sizeof(char)*(_MAX_PATH+1));
+ dwRc = GetFullPathNameA(szFileName, _MAX_PATH, szReturnedPath, &pPathPtr);
+ if (dwRc == 0)
+ {
+ // GetFullPathName failed
+ Fail("GetCurrentDirectoryA: ERROR -> GetFullPathNameA failed "
+ "with error code: %ld.\n", GetLastError());
+ }
+ else if(dwRc > _MAX_PATH)
+ {
+ Fail("GetCurrentDirectoryA: ERROR -> The path name GetFullPathNameA "
+ "returned is longer than _MAX_PATH characters.\n");
+ }
+
+
+ // strip the file name from the full path to get the current path
+ nCount = strlen(szReturnedPath) - strlen(szFileName) - 1;
+ memset(szCurrentDir, 0, sizeof(char)*(_MAX_PATH+1));
+ strncpy(szCurrentDir, szReturnedPath, nCount);
+
+ // compare the results of GetCurrentDirectoryA with the above
+ memset(szReturnedPath, 0, sizeof(char)*(_MAX_PATH+1));
+ dwRc = GetCurrentDirectoryA((sizeof(char)*(_MAX_PATH+1)), szReturnedPath);
+ if (dwRc == 0)
+ {
+ Fail("GetCurrentDirectoryA: ERROR -> GetCurrentDirectoryA failed "
+ "with error code: %ld.\n", GetLastError());
+ }
+ else if(dwRc > _MAX_PATH)
+ {
+ Fail("GetCurrentDirectoryA: ERROR -> The path name "
+ "returned is longer than _MAX_PATH characters.\n");
+ }
+
+
+ /* test case the passed buffer size is not big enough
+ * function should return the size required + 1 a terminating null character
+ */
+
+ /* good buffer size */
+ dwRc = GetCurrentDirectoryA((sizeof(CHAR)*(_MAX_PATH+1)), szReturnedPath);
+
+ /* small buffer (0 size)*/
+ dwRc2 = GetCurrentDirectoryA(0, szReturnedPath);
+ if (dwRc2 != (dwRc+1) )
+ {
+ Fail("GetCurrentDirectoryA: ERROR -> failed to give the correct "
+ "return value when passed a buffer not big enough. "
+ "Expected %u while result is %u \n",(dwRc+1),dwRc2);
+
+ }
+
+ if (strcmp(szReturnedPath, szCurrentDir) != 0)
+ {
+ Fail("GetCurrentDirectoryA: ERROR -> The computed and returned "
+ "directories do not compare.\n");
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/testinfo.dat
new file mode 100644
index 0000000..c14eb42
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/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 = file_io
+Function = GetCurrentDirectoryA
+Name = Test for GetCurrentDirectoryA (test 1)
+Type = DEFAULT
+EXE1 = getcurrentdirectorya
+Description
+= Calculate the current directory name and compare to that
+= returned by GetCurrentDirectoryA
+
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt
new file mode 100644
index 0000000..ed84199
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetCurrentDirectoryW.c
+)
+
+add_executable(paltest_getcurrentdirectoryw_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getcurrentdirectoryw_test1 coreclrpal)
+
+target_link_libraries(paltest_getcurrentdirectoryw_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.c b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.c
new file mode 100644
index 0000000..4f4697b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.c
@@ -0,0 +1,106 @@
+// 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: GetCurrentDirectoryW.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetCurrentDirectoryW function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ DWORD dwRc2 = 0;
+ WCHAR szwReturnedPath[_MAX_PATH+1];
+ WCHAR szwCurrentDir[_MAX_PATH+1];
+ WCHAR szwFileName[_MAX_PATH] = {'b','l','a','h','\0'};
+ LPWSTR pPathPtr;
+ size_t nCount = 0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* use GetFullPathName to to get the current path by stripping
+ * the file name off the end */
+ memset(szwReturnedPath, 0, sizeof(WCHAR)*(_MAX_PATH+1));
+ dwRc = GetFullPathNameW(szwFileName, _MAX_PATH, szwReturnedPath, &pPathPtr);
+ if (dwRc == 0)
+ {
+ /* GetFullPathName failed */
+ Fail("GetCurrentDirectoryW: ERROR -> GetFullPathNameW failed "
+ "with error code: %ld.\n", GetLastError());
+ }
+ else if(dwRc >_MAX_PATH)
+ {
+ Fail("GetCurrentDirectoryW: ERROR -> The path name GetFullPathNameW "
+ "returned is longer than _MAX_PATH characters.\n");
+ }
+
+ /* strip the file name from the full path to get the current path */
+ nCount = wcslen(szwReturnedPath) - wcslen(szwFileName) - 1;
+ memset(szwCurrentDir, 0, sizeof(WCHAR)*(_MAX_PATH+1));
+ memcpy(szwCurrentDir, szwReturnedPath, nCount*sizeof(WCHAR));
+
+ /* compare the results of GetCurrentDirectoryW with the above */
+ memset(szwReturnedPath, 0, sizeof(WCHAR)*(_MAX_PATH+1));
+ dwRc = GetCurrentDirectoryW((sizeof(WCHAR)*(_MAX_PATH+1)), szwReturnedPath);
+ if (dwRc == 0)
+ {
+ Fail("GetCurrentDirectoryW: ERROR -> GetCurrentDirectoryW failed "
+ "with error code: %ld.\n", GetLastError());
+ }
+ else if(dwRc >_MAX_PATH)
+ {
+ Fail("GetCurrentDirectoryW: ERROR -> The path name "
+ "returned is longer than _MAX_PATH characters.\n");
+ }
+
+ /* check to see whether the length of the returned string is equal to
+ * the DWORD returned by GetCurrentDirectoryW.
+ */
+ if(wcslen(szwReturnedPath) != dwRc)
+ {
+ Fail("GetCurrentDirectoryW: ERROR -> The Length of the path name "
+ "returned \"%u\" is not equal to the return value of the "
+ "function \"%u\".\n" , wcslen(szwReturnedPath), dwRc);
+ }
+
+
+
+ /* test case the passed buffer size is not big enough
+ * function should return the size required + 1 for a terminating null character
+ */
+
+ /* good buffer size */
+ dwRc = GetCurrentDirectoryW((sizeof(WCHAR)*(_MAX_PATH+1)), szwReturnedPath);
+
+ /* small buffer (0 size)*/
+ dwRc2 = GetCurrentDirectoryW(0, szwReturnedPath);
+ if (dwRc2 != (dwRc+1) )
+ {
+ Fail("GetCurrentDirectoryW: ERROR -> failed to give the correct "
+ "return value when passed a buffer not big enough. "
+ "Expected %u while result is %u ",(dwRc+1),dwRc2);
+
+ }
+
+ if (wcsncmp(szwReturnedPath, szwCurrentDir, wcslen(szwReturnedPath)) != 0)
+ {
+ Fail("GetCurrentDirectoryW: ERROR -> The computed and returned "
+ "directories do not compare.\n");
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/testinfo.dat
new file mode 100644
index 0000000..4443a79
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/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 = file_io
+Function = GetCurrentDirectoryW
+Name = Test for GetCurrentDirectoryW (test 1)
+Type = DEFAULT
+EXE1 = getcurrentdirectoryw
+Description
+= Compute the current directory and compare with the results
+= from GetCurrentDirectoryW
+
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt
new file mode 100644
index 0000000..6b06376
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetDiskFreeSpaceW.c
+)
+
+add_executable(paltest_getdiskfreespacew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getdiskfreespacew_test1 coreclrpal)
+
+target_link_libraries(paltest_getdiskfreespacew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.c b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.c
new file mode 100644
index 0000000..c1445f6
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.c
@@ -0,0 +1,94 @@
+// 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: GetDiskFreeSpaceW.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetDiskFreeSpaceW function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwSectorsPerCluster; /* sectors per cluster */
+ DWORD dwBytesPerSector; /* bytes per sector */
+ DWORD dwSectorsPerCluster_02; /* sectors per cluster */
+ DWORD dwBytesPerSector_02; /* bytes per sector */
+ DWORD dwNumberOfFreeClusters; /* free clusters */
+ DWORD dwTotalNumberOfClusters; /* total clusters */
+ BOOL bRc = FALSE;
+ WCHAR szwRootPath[10] = {'/','\0'};
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* test the NULL option which translates to the current drive */
+ bRc = GetDiskFreeSpaceW(NULL,
+ &dwSectorsPerCluster,
+ &dwBytesPerSector,
+ &dwNumberOfFreeClusters,
+ &dwTotalNumberOfClusters);
+ if (bRc != TRUE)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> Failed with error code: %ld\n",
+ GetLastError());
+ }
+ else if (dwSectorsPerCluster == 0)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster returned 0\n");
+ }
+ else if (dwBytesPerSector == 0)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector returned 0\n");
+ }
+
+ /* test the root directory to the current drive */
+ bRc = GetDiskFreeSpaceW(szwRootPath,
+ &dwSectorsPerCluster_02,
+ &dwBytesPerSector_02,
+ &dwNumberOfFreeClusters,
+ &dwTotalNumberOfClusters);
+ if (bRc != TRUE)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> Failed with error code: %ld\n",
+ GetLastError());
+ }
+ else if (dwSectorsPerCluster == 0)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster returned 0\n");
+ }
+ else if (dwBytesPerSector == 0)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector returned 0\n");
+ }
+ /*
+ ** make sure the values returned for NULL path and root path
+ ** are the same
+ */
+ else if (dwSectorsPerCluster_02 != dwSectorsPerCluster)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster for NULL path "
+ "(%u) should have been the same as the root path (%u).\n",
+ dwSectorsPerCluster,
+ dwSectorsPerCluster_02);
+ }
+ else if (dwBytesPerSector_02 != dwBytesPerSector)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector for NULL path "
+ "(%u) should have been the same as the root path (%u).\n",
+ dwBytesPerSector,
+ dwBytesPerSector_02);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/testinfo.dat
new file mode 100644
index 0000000..61b0e55
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetDiskFreeSpaceW
+Name = Positive Test for GetDiskFreeSpaceW (test 1)
+Type = DEFAULT
+EXE1 = getdiskfreespacew
+Description
+= Test GetDiskFreeSpaceW. lpNumberOfFreeClusters and
+= lpTotalNumberOfClusters are to be ignored
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/CMakeLists.txt
new file mode 100644
index 0000000..5660b39
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ getdiskfreespacew.c
+)
+
+add_executable(paltest_getdiskfreespacew_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getdiskfreespacew_test2 coreclrpal)
+
+target_link_libraries(paltest_getdiskfreespacew_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.c b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.c
new file mode 100644
index 0000000..83dcb54
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.c
@@ -0,0 +1,65 @@
+// 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: GetDiskFreeSpaceW.c (test 2)
+**
+** Purpose: Tests the PAL implementation of the GetDiskFreeSpaceW
+** function on valid non-root paths.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwSectorsPerCluster; /* sectors per cluster */
+ DWORD dwBytesPerSector; /* bytes per sector */
+ DWORD dwNumberOfFreeClusters; /* free clusters */
+ DWORD dwTotalNumberOfClusters; /* total clusters */
+ BOOL bRc = FALSE;
+ WCHAR szwCurrentPath[MAX_LONGPATH];
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* get the current directory so we are sure to have a valid path */
+ if (!GetCurrentDirectoryW(MAX_LONGPATH, szwCurrentPath))
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> GetCurrentDirectoryW failed with "
+ "error code: %u.\n",
+ GetLastError());
+ }
+
+ /* test the current path*/
+ bRc = GetDiskFreeSpaceW(szwCurrentPath,
+ &dwSectorsPerCluster,
+ &dwBytesPerSector,
+ &dwNumberOfFreeClusters,
+ &dwTotalNumberOfClusters);
+ if (bRc != TRUE)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> Failed with error code: %u for "
+ "the path \"%S\".\n",
+ GetLastError(),
+ szwCurrentPath);
+ }
+ else if (dwSectorsPerCluster == 0)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster returned 0\n");
+ }
+ else if (dwBytesPerSector == 0)
+ {
+ Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector returned 0\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat
new file mode 100644
index 0000000..0a68724
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat
@@ -0,0 +1,12 @@
+# 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 = GetDiskFreeSpaceW
+Name = Positive Test for GetDiskFreeSpaceW (test 2)
+Type = DEFAULT
+EXE1 = getdiskfreespacew
+Description
+= Test GetDiskFreeSpaceW with valid non-root paths
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file
new file mode 100644
index 0000000..0d1ac31
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file
@@ -0,0 +1 @@
+Hidden file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file
new file mode 100644
index 0000000..8f78fcb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file
@@ -0,0 +1 @@
+.hidden_ro_file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt
new file mode 100644
index 0000000..6bf9818
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileAttributesA.c
+)
+
+add_executable(paltest_getfileattributesa_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfileattributesa_test1 coreclrpal)
+
+target_link_libraries(paltest_getfileattributesa_test1
+ pthread
+ m
+ coreclrpal
+)
+add_subdirectory(.hidden_directory)
+add_subdirectory(.hidden_ro_directory)
+add_subdirectory(normal_test_directory)
+add_subdirectory(no_directory)
+add_subdirectory(ro_test_directory)
+add_subdirectory(rw_directory)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.c b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.c
new file mode 100644
index 0000000..ff6bd0b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.c
@@ -0,0 +1,340 @@
+// 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: GetFileAttributesA.c
+**
+** Purpose: Tests the PAL implementation of the GetFileAttributesA function by
+** checking the attributes of:
+** - a normal directory and file
+** - a read only directory and file
+** - a read write directory and file
+** - a hidden directory and file
+** - a read only hidden directory and file
+** - a directory and a file with no attributes
+** - an invalid file name
+**
+**
+**===========================================================================*/
+#include <palsuite.h>
+
+const int TYPE_DIR = 0;
+const int TYPE_FILE = 1;
+/* Structure defining a test case */
+typedef struct
+{
+ char *name; /* name of the file/directory */
+ DWORD expectedAttribs; /* expected attributes */
+ HANDLE hFile; /* Handle to the file */
+ int isFile; /* is file (1) or dir (0) */
+}TestCaseFile;
+
+typedef struct
+{
+ char *name; /* name of the file/directory */
+ DWORD expectedAttribs; /* expected attributes */
+ HANDLE hFile; /* Handle to the file */
+ int isFile; /* is file (1) or dir (0) */
+}TestCaseDir;
+
+DWORD desiredAccessFile = GENERIC_READ | GENERIC_WRITE;
+DWORD shareModeFile = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
+LPSECURITY_ATTRIBUTES lpAttrFile = NULL;
+DWORD dwCreationDispFile = CREATE_NEW;
+DWORD dwFlagsAttribFile = FILE_ATTRIBUTE_NORMAL;
+HANDLE hTemplateFile = NULL;
+
+int numFileTests = 6;
+TestCaseFile gfaTestsFile[6]; /* GetFileAttributes tests list */
+
+int numDirTests = 6;
+TestCaseDir gfaTestsDir[6]; /* GetFileAttributes tests list */
+
+BOOL CleanUpFiles()
+{
+ DWORD dwAtt;
+ int i;
+ BOOL result = TRUE;
+ for (i = 0; i < numFileTests -1 ; i++ )
+ {
+ dwAtt = GetFileAttributesA(gfaTestsFile[i].name);
+
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+ //Trace("Files iteration %d\n", i);
+ if(!SetFileAttributesA (gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL);
+ }
+
+ if(!DeleteFileA (gfaTestsFile[i].name))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, dwAtt);
+ }
+
+ }
+ }
+// Trace("Value of result is %d\n", result);
+ return result;
+}
+BOOL SetUpFiles()
+{
+ int i = 0;
+ BOOL result = TRUE;
+ for (i = 0; i < numFileTests -1; i++ )
+ {
+ gfaTestsFile[i].hFile = CreateFile(gfaTestsFile[i].name,
+ desiredAccessFile,
+ shareModeFile,
+ lpAttrFile,
+ dwCreationDispFile,
+ dwFlagsAttribFile,
+ hTemplateFile);
+
+ if( gfaTestsFile[i].hFile == NULL )
+ {
+ Fail("Error while creating files for iteration %d\n", i);
+ }
+
+ if(!SetFileAttributesA (gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs);
+ }
+ }
+
+ return result;
+}
+
+BOOL CleanUpDirs()
+{
+ DWORD dwAtt;
+ int i;
+ BOOL result = TRUE;
+ for (i = 0; i < numDirTests -1 ; i++ )
+ {
+ dwAtt = GetFileAttributesA(gfaTestsDir[i].name);
+
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+
+ if(!SetFileAttributesA (gfaTestsDir[i].name, FILE_ATTRIBUTE_DIRECTORY))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, (FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY));
+ }
+
+ if(!RemoveDirectoryA (gfaTestsDir[i].name))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, dwAtt);
+ }
+
+ }
+ }
+
+ return result;
+}
+
+BOOL SetUpDirs()
+{
+ int i = 0;
+ BOOL result = TRUE;
+ DWORD ret = 0;
+ for (i = 0; i < numDirTests - 1 ; i++ )
+ {
+ result = CreateDirectory(gfaTestsDir[i].name,
+ NULL);
+
+ if(!result )
+ {
+ result = FALSE;
+ Fail("Error while creating directory for iteration %d\n", i);
+ }
+
+ if(!SetFileAttributesA (gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs);
+ }
+
+ ret = GetFileAttributesA (gfaTestsDir[i].name);
+ if(ret != gfaTestsDir[i].expectedAttribs)
+ {
+ result = FALSE;
+ Trace("ERROR: Error setting attributes [%s][%d]\n", gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs);
+ }
+ //Trace("Setup Dir setting attr [%d], returned [%d]\n", gfaTestsDir[i].expectedAttribs, ret);
+
+ }
+ //Trace("Setup dirs returning %d\n", result);
+ return result;
+}
+int __cdecl main(int argc, char **argv)
+{
+ int i;
+ BOOL bFailed = FALSE;
+ DWORD result;
+
+ char * NormalDirectoryName = "normal_test_directory";
+ char * ReadOnlyDirectoryName = "ro_test_directory";
+ char * ReadWriteDirectoryName = "rw_directory";
+ char * HiddenDirectoryName = ".hidden_directory";
+ char * HiddenReadOnlyDirectoryName = ".hidden_ro_directory";
+ char * NoDirectoryName = "no_directory";
+
+ char * NormalFileName = "normal_test_file";
+ char * ReadOnlyFileName = "ro_test_file";
+ char * ReadWriteFileName = "rw_file";
+ char * HiddenFileName = ".hidden_file";
+ char * HiddenReadOnlyFileName = ".hidden_ro_file";
+ char * NotReallyAFileName = "not_really_a_file";
+
+ /* Tests on directory */
+ gfaTestsDir[0].name = NormalDirectoryName;
+ gfaTestsDir[0].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY;
+ gfaTestsDir[0].isFile = TYPE_DIR;
+
+ gfaTestsDir[1].name = ReadOnlyDirectoryName;
+ gfaTestsDir[1].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_READONLY;
+ gfaTestsDir[1].isFile = TYPE_DIR;
+
+ gfaTestsDir[2].name = ReadWriteDirectoryName;
+ gfaTestsDir[2].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY;
+ gfaTestsDir[2].isFile = TYPE_DIR;
+
+ gfaTestsDir[3].name = HiddenDirectoryName;
+ gfaTestsDir[3].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; //|
+ //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsDir[3].isFile = TYPE_DIR;
+
+ gfaTestsDir[4].name = HiddenReadOnlyDirectoryName;
+ gfaTestsDir[4].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_READONLY; //|
+ //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsDir[4].isFile = TYPE_DIR;
+
+ gfaTestsDir[5].name = NoDirectoryName;
+ gfaTestsDir[5].expectedAttribs = INVALID_FILE_ATTRIBUTES;
+ gfaTestsDir[5].isFile = TYPE_DIR;
+
+ /* Tests on file */
+ gfaTestsFile[0].name = NormalFileName;
+ gfaTestsFile[0].expectedAttribs = FILE_ATTRIBUTE_NORMAL;
+ gfaTestsFile[0].isFile = TYPE_FILE;
+
+
+ gfaTestsFile[1].name = ReadOnlyFileName;
+ gfaTestsFile[1].expectedAttribs = FILE_ATTRIBUTE_READONLY;
+ gfaTestsFile[1].isFile = TYPE_FILE;
+
+ gfaTestsFile[2].name = ReadWriteFileName;
+ gfaTestsFile[2].expectedAttribs = FILE_ATTRIBUTE_NORMAL;
+ gfaTestsFile[2].isFile = TYPE_FILE;
+
+ gfaTestsFile[3].name = HiddenFileName;
+ gfaTestsFile[3].expectedAttribs = FILE_ATTRIBUTE_NORMAL; //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsFile[3].isFile = TYPE_FILE;
+
+ gfaTestsFile[4].name = HiddenReadOnlyFileName;
+ gfaTestsFile[4].expectedAttribs = FILE_ATTRIBUTE_READONLY; //|
+ //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsFile[4].isFile = TYPE_FILE;
+
+
+ gfaTestsFile[5].name = NotReallyAFileName;
+ gfaTestsFile[5].expectedAttribs = INVALID_FILE_ATTRIBUTES;
+ gfaTestsFile[5].isFile = TYPE_FILE;
+
+ /* Initialize PAL environment */
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ if(!CleanUpFiles())
+ {
+ Fail("GetFileAttributesA: Pre-Clean Up Files Failed\n");
+ }
+
+ if(0 == SetUpFiles())
+ {
+ Fail("GetFileAttributesA: SetUp Files Failed\n");
+ }
+
+ if(!CleanUpDirs())
+ {
+ Fail("GetFileAttributesA: Pre-Clean Up Directories Failed\n");
+ }
+
+ if(!SetUpDirs())
+ {
+ Fail("GetFileAttributesA: SetUp Directories Failed\n");
+ }
+
+ /*
+ * Go through all the test cases above,
+ * call GetFileAttributesA on the name and
+ * make sure the return value is the one expected
+ */
+ for( i = 0; i < numFileTests; i++ )
+ {
+ result = GetFileAttributesA(gfaTestsFile[i].name);
+
+ if( result != gfaTestsFile[i].expectedAttribs )
+ {
+ bFailed = TRUE;
+
+ Trace("ERROR: GetFileAttributesA Test#%u on %s "
+ "returned %u instead of %u. \n",
+ i,
+ gfaTestsFile[i].name,
+ result,
+ gfaTestsFile[i].expectedAttribs);
+
+ }
+ }
+
+
+ for( i = 0; i < numDirTests; i++ )
+ {
+ result = GetFileAttributesA(gfaTestsDir[i].name);
+
+ if( result != gfaTestsDir[i].expectedAttribs )
+ {
+ bFailed = TRUE;
+
+ Trace("ERROR: GetFileAttributesA on Directories Test#%u on %s "
+ "returned %u instead of %u. \n",
+ i,
+ gfaTestsDir[i].name,
+ result,
+ gfaTestsDir[i].expectedAttribs);
+
+ }
+ }
+
+ if(!CleanUpFiles())
+ {
+ Fail("GetFileAttributesA: Post-Clean Up Files Failed\n");
+ }
+
+ if(!CleanUpDirs())
+ {
+ Fail("GetFileAttributesA: Post-Clean Up Directories Failed\n");
+ }
+
+ /* If any errors, just call Fail() */
+ if( bFailed )
+ {
+ Fail("");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file
new file mode 100644
index 0000000..3d631e8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file
@@ -0,0 +1 @@
+No attribs file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file
new file mode 100644
index 0000000..a6e1e62
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file
@@ -0,0 +1,6 @@
+file_io
+CopyFileW
+Positive Test for CopyFileW
+test the CopyFileW function
+DEFAULT
+CopyFileW \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file
new file mode 100644
index 0000000..a6e1e62
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file
@@ -0,0 +1,6 @@
+file_io
+CopyFileW
+Positive Test for CopyFileW
+test the CopyFileW function
+DEFAULT
+CopyFileW \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file
new file mode 100644
index 0000000..39d66f0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file
@@ -0,0 +1 @@
+Read Write file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat
new file mode 100644
index 0000000..2053220
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat
@@ -0,0 +1,20 @@
+# 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 = GetFileAttributesA
+
+Name = Positive Test for GetFileAttributesA
+
+TYPE = DEFAULT
+
+EXE1 = getfileattributesa
+
+Description
+
+= Test the GetFileAttributesA function
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt
new file mode 100644
index 0000000..9a277fa
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt
@@ -0,0 +1,2 @@
+This file is here so this directory gets checked out even with the -P
+option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file
new file mode 100644
index 0000000..0d1ac31
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file
@@ -0,0 +1 @@
+Hidden file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt
new file mode 100644
index 0000000..2d299d8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_getfileattributesexw_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfileattributesexw_test1 coreclrpal)
+
+target_link_libraries(paltest_getfileattributesexw_test1
+ pthread
+ m
+ coreclrpal
+)
+add_subdirectory(.hidden_directory)
+add_subdirectory(normal_test_directory)
+add_subdirectory(ro_test_directory)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file
new file mode 100644
index 0000000..ab7622f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file
@@ -0,0 +1,6 @@
+file_io
+CopyFileW
+Positive Test for CopyFileW
+test the CopyFileW function
+DEFAULT
+CopyFileW \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file
new file mode 100644
index 0000000..ab7622f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file
@@ -0,0 +1,6 @@
+file_io
+CopyFileW
+Positive Test for CopyFileW
+test the CopyFileW function
+DEFAULT
+CopyFileW \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.c b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.c
new file mode 100644
index 0000000..7a622b6
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.c
@@ -0,0 +1,227 @@
+// 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: Tests the PAL implementation of the GetFileAttributesExW function.
+** Call the function on a normal directory and file and a read-only directory
+** and file and a hidden file and directory.
+** Ensure that the attributes returned are correct, and the
+** file times and file sizes.
+**
+**
+**===================================================================*/
+
+#define UNICODE
+#include <palsuite.h>
+
+typedef enum Item
+{
+ IS_DIR,
+ IS_FILE
+}ItemType;
+
+/*
+ This is a helper function which takes two FILETIME structures and
+ checks to see if they contain the exact same time.
+*/
+int IsEqualFileTime(FILETIME FirstTime, FILETIME SecondTime)
+{
+
+ ULONG64 TimeOne, TimeTwo;
+
+ TimeOne = ((((ULONG64)FirstTime.dwHighDateTime)<<32) |
+ ((ULONG64)FirstTime.dwLowDateTime));
+
+ TimeTwo = ((((ULONG64)SecondTime.dwHighDateTime)<<32) |
+ ((ULONG64)SecondTime.dwLowDateTime));
+
+ return(TimeOne == TimeTwo);
+}
+
+/* This function takes a structure and checks that the information
+ within the structure is correct. The 'Attribs' are the expected
+ file attributes, 'TheType' is IS_DIR or IS_FILE and the 'Name' is the
+ name of the file/directory in question.
+*/
+void VerifyInfo(WIN32_FILE_ATTRIBUTE_DATA InfoStruct,
+ DWORD Attribs, ItemType TheType, WCHAR* Name)
+{
+ HANDLE hFile;
+ FILETIME CorrectCreation, CorrectAccess, CorrectModify;
+ WCHAR CopyName[64];
+
+ wcscpy(CopyName,Name);
+ free(Name);
+
+ /* Check to see that the file attributes were recorded */
+ if(InfoStruct.dwFileAttributes != Attribs)
+ {
+ Fail("ERROR: The file attributes on the file/directory were "
+ "recorded as being %d instead of %d.\n",
+ InfoStruct.dwFileAttributes,
+ Attribs);
+ }
+
+ /* Note: We can't open a handle to a directory in windows. This
+ block of tests will only be run on files.
+ */
+ if(TheType == IS_FILE)
+ {
+
+ /* Get a handle to the file */
+ hFile = CreateFile(CopyName,
+ 0,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Could not open a handle to the file "
+ "'%S'. GetLastError() returned %d.",CopyName,
+ GetLastError());
+ }
+
+
+
+ /* Get the FileTime of the file in question */
+ if(GetFileTime(hFile, &CorrectCreation,
+ &CorrectAccess, &CorrectModify) == 0)
+ {
+ Fail("ERROR: GetFileTime failed to get the filetime of the "
+ "file. GetLastError() returned %d.",
+ GetLastError());
+ }
+
+ /* Check that the Creation, Access and Last Modified times are all
+ the same in the structure as what GetFileTime just returned.
+ */
+ if(!IsEqualFileTime(CorrectCreation, InfoStruct.ftCreationTime))
+ {
+ Fail("ERROR: The creation time of the file "
+ "does not match the creation time given from "
+ "GetFileTime.\n");
+ }
+ if(!IsEqualFileTime(CorrectAccess, InfoStruct.ftLastAccessTime))
+ {
+ Fail("ERROR: The access time of the file "
+ "does not match the access time given from "
+ "GetFileTime.\n");
+ }
+ if(!IsEqualFileTime(CorrectModify, InfoStruct.ftLastWriteTime))
+ {
+ Fail("ERROR: The write time of the file "
+ "does not match the last write time given from "
+ "GetFileTime.\n");
+ }
+
+ if(InfoStruct.nFileSizeLow != GetFileSize(hFile,NULL))
+ {
+ Fail("ERROR: The file size reported by GetFileAttributesEx "
+ "did not match the file size given by GetFileSize.\n");
+ }
+
+ if(CloseHandle(hFile) == 0)
+ {
+ Fail("ERROR: Failed to properly close the handle to the "
+ "file we're testing. GetLastError() returned %d.\n",
+ GetLastError());
+
+ }
+
+ }
+
+
+}
+
+/* Given a file/directory name, the expected attribs and whether or not it
+ is a file or directory, call GetFileAttributesEx and verify the
+ results are correct.
+*/
+
+void RunTest(char* Name, DWORD Attribs, ItemType TheType )
+{
+ WCHAR* TheName;
+ WIN32_FILE_ATTRIBUTE_DATA InfoStruct;
+ DWORD TheResult;
+
+ TheName = convert(Name);
+
+ TheResult = GetFileAttributesEx(TheName,
+ GetFileExInfoStandard,
+ &InfoStruct);
+ if(TheResult == 0)
+ {
+ free(TheName);
+ Fail("ERROR: GetFileAttributesEx returned 0, indicating failure. "
+ "GetLastError returned %d.\n",GetLastError());
+ }
+
+ VerifyInfo(InfoStruct, Attribs, TheType, TheName);
+
+}
+
+int __cdecl main(int argc, char **argv)
+{
+ DWORD TheResult;
+ WCHAR* FileName;
+ WIN32_FILE_ATTRIBUTE_DATA InfoStruct;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Test a Directroy */
+ RunTest("normal_test_directory", FILE_ATTRIBUTE_DIRECTORY, IS_DIR);
+
+
+ /* Test a Normal File */
+
+ RunTest("normal_test_file", FILE_ATTRIBUTE_NORMAL, IS_FILE);
+
+ /* Test a Read-Only Directroy */
+
+ RunTest("ro_test_directory",
+ FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_DIRECTORY, IS_DIR);
+
+ /* Test a Read-Only File */
+
+ RunTest("ro_test_file", FILE_ATTRIBUTE_READONLY, IS_FILE);
+
+ /* Test a Hidden File */
+
+ RunTest(".hidden_file", FILE_ATTRIBUTE_HIDDEN, IS_FILE);
+
+ /* Test a Hidden Directroy */
+
+ RunTest(".hidden_directory",
+ FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_DIRECTORY, IS_DIR);
+
+ /* Test a Non-Existant File */
+
+ FileName = convert("nonexistent_test_file");
+
+ TheResult = GetFileAttributesEx(FileName,
+ GetFileExInfoStandard,
+ &InfoStruct);
+
+ if(TheResult != 0)
+ {
+ free(FileName);
+ Fail("ERROR: GetFileAttributesEx returned non-zero, indicating "
+ "success when it should have failed. It was called on a "
+ "non-existent file.");
+ }
+
+ free(FileName);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/testinfo.dat
new file mode 100644
index 0000000..fbc397e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/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 = file_io
+Function = GetFileAttributesExW
+Name = Test with normal file/dir and readonly file/dir and hidden file/dir
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Tests the PAL implementation of the GetFileAttributesExW function.
+= Call the function on a normal directory and file and a read-only directory
+= and file and a hidden file and directory.
+= Ensure that the attributes returned are correct, and the
+= file times and file sizes.
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/CMakeLists.txt
new file mode 100644
index 0000000..70caac2
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/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_getfileattributesexw_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfileattributesexw_test2 coreclrpal)
+
+target_link_libraries(paltest_getfileattributesexw_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.c b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.c
new file mode 100644
index 0000000..f244a3b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.c
@@ -0,0 +1,170 @@
+// 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: getfileattributesexw.c (getfileattributesexw\test2)
+**
+** Purpose: Tests the PAL implementation of GetFileAttributesExW.
+** First get a file's attributes, modify the file,
+** re-get its attributes
+** and compare the two sets of attributes.
+**
+**
+**===================================================================*/
+#include <palsuite.h>
+
+/**
+ * This is a helper function which takes two FILETIME structures and
+ * checks that the second time isn't before the first.
+ */
+static int IsFileTimeOk(FILETIME FirstTime, FILETIME SecondTime)
+{
+
+ ULONG64 TimeOne, TimeTwo;
+
+ TimeOne = ((((ULONG64)FirstTime.dwHighDateTime)<<32) |
+ ((ULONG64)FirstTime.dwLowDateTime));
+
+ TimeTwo = ((((ULONG64)SecondTime.dwHighDateTime)<<32) |
+ ((ULONG64)SecondTime.dwLowDateTime));
+
+ return(TimeOne <= TimeTwo);
+}
+
+int __cdecl main(int argc, char **argv)
+{
+ DWORD res;
+ char fileName[MAX_PATH] = "test_file";
+ WCHAR *wFileName;
+ WIN32_FILE_ATTRIBUTE_DATA beforeAttribs;
+ WIN32_FILE_ATTRIBUTE_DATA afterAttribs;
+ FILE *testFile;
+ ULONG64 beforeFileSize;
+ ULONG64 afterFileSize;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Create the file */
+ testFile = fopen(fileName, "w+");
+ if( NULL == testFile )
+ {
+ Fail("Unexpected error: Unable to open file %S "
+ "with fopen. \n",
+ fileName);
+ }
+
+ if( EOF == fputs( "testing", testFile ) )
+ {
+ Fail("Unexpected error: Unable to write to file %S "
+ "with fputs. \n",
+ fileName);
+ }
+
+ if( 0 != fclose(testFile) )
+ {
+ Fail("Unexpected error: Unable to close file %S "
+ "with fclose. \n",
+ fileName);
+ }
+
+ /* Test the Values returned by GetFileAttributesExW
+ * before and after manipulating a file shouldn't be the same.
+ */
+
+ wFileName = convert(fileName);
+
+ res = GetFileAttributesExW(wFileName,
+ GetFileExInfoStandard,
+ &beforeAttribs);
+
+ if(res == 0)
+ {
+ Fail("ERROR: unable to get initial file attributes with "
+ "GetFileAttributesEx that returned 0 with error %d.\n",
+ GetLastError());
+ }
+
+ /* Make sure the time are different */
+ Sleep(500);
+
+ testFile = fopen(fileName, "w+");
+ if( NULL == testFile )
+ {
+ Fail("Unexpected error: Unable to open file %S "
+ "with fopen. \n",
+ fileName);
+ }
+
+ if( EOF == fputs( "testing GetFileAttributesExW", testFile ) )
+ {
+ Fail("Unexpected error: Unable to write to file %S "
+ "with fputs. \n",
+ fileName);
+ }
+
+ if( 0 != fclose(testFile) )
+ {
+ Fail("Unexpected error: Unable to close file %S "
+ "with fclose. \n",
+ fileName);
+ }
+
+ res = GetFileAttributesExW(wFileName,
+ GetFileExInfoStandard,
+ &afterAttribs);
+
+ if(res == 0)
+ {
+ Fail("ERROR: unable to get file attributes after operations with "
+ "GetFileAttributesEx that returned 0 with error %d.\n",
+ GetLastError());
+ }
+
+ /* Check the creation time */
+ if(!IsFileTimeOk(beforeAttribs.ftCreationTime,
+ afterAttribs.ftCreationTime))
+ {
+ Fail("ERROR: Creation time after the fputs operation "
+ "is earlier than the creation time before the fputs.\n");
+ }
+
+ /* Check the last access time */
+ if(!IsFileTimeOk(beforeAttribs.ftLastAccessTime,
+ afterAttribs.ftLastAccessTime))
+ {
+ Fail("ERROR: Last access time after the fputs operation "
+ "is earlier than the last access time before the fputs.\n");
+ }
+
+ /* Check the last write time */
+ if(!IsFileTimeOk(beforeAttribs.ftLastWriteTime,
+ afterAttribs.ftLastWriteTime))
+ {
+ Fail("ERROR: Last write time after the fputs operation "
+ "is earlier than the last write time before the fputs.\n");
+ }
+
+ beforeFileSize = ((ULONG64)beforeAttribs.nFileSizeHigh)<< 32 |
+ ((ULONG64)beforeAttribs.nFileSizeLow);
+
+ afterFileSize = ((ULONG64)afterAttribs.nFileSizeHigh)<< 32 |
+ ((ULONG64)afterAttribs.nFileSizeLow);
+
+ /* Check the file size */
+ if( afterFileSize <= beforeFileSize )
+ {
+ Fail("ERROR: the file should have had a bigger size "
+ "after(%d) the operations than before(%d)\n",
+ afterAttribs.nFileSizeLow,
+ beforeAttribs.nFileSizeLow);
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/testinfo.dat
new file mode 100644
index 0000000..560e3f6
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/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 = file_io
+Function = GetFileAttributesExW
+Name = Test for GetFileAttributesExW
+TYPE = DEFAULT
+EXE1 = test2
+Description
+= Tests the PAL implementation of the GetFileAttributesExW function.
+= First get a file's attributes, modify the file, re-get its attributes
+= and compare the two sets of attributes
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file
new file mode 100644
index 0000000..0d1ac31
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file
@@ -0,0 +1 @@
+Hidden file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file
new file mode 100644
index 0000000..8f78fcb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file
@@ -0,0 +1 @@
+.hidden_ro_file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt
new file mode 100644
index 0000000..7050484
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileAttributesW.c
+)
+
+add_executable(paltest_getfileattributesw_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfileattributesw_test1 coreclrpal)
+
+target_link_libraries(paltest_getfileattributesw_test1
+ pthread
+ m
+ coreclrpal
+)
+add_subdirectory(.hidden_directory)
+add_subdirectory(.hidden_ro_directory)
+add_subdirectory(normal_test_directory)
+add_subdirectory(no_directory)
+add_subdirectory(ro_test_directory)
+add_subdirectory(rw_test_directory)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.c b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.c
new file mode 100644
index 0000000..9d00da4
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.c
@@ -0,0 +1,345 @@
+// 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: GetFileAttributesW.c
+**
+** Purpose: Tests the PAL implementation of the GetFileAttributesW function by
+** checking the attributes of:
+** - a normal directory and file
+** - a read only directory and file
+** - a read write directory and file
+** - a hidden directory and file
+** - a read only hidden directory and file
+** - a directory and a file with no attributes
+** - an invalid file name
+**
+**
+**===========================================================================*/
+#include <palsuite.h>
+
+const int TYPE_DIR = 0;
+const int TYPE_FILE = 1;
+/* Structure defining a test case */
+typedef struct
+{
+ char *name; /* name of the file/directory */
+ DWORD expectedAttribs; /* expected attributes */
+ HANDLE hFile; /* Handle to the file */
+ int isFile; /* is file (1) or dir (0) */
+}TestCaseFile;
+
+typedef struct
+{
+ char *name; /* name of the file/directory */
+ DWORD expectedAttribs; /* expected attributes */
+ HANDLE hFile; /* Handle to the file */
+ int isFile; /* is file (1) or dir (0) */
+}TestCaseDir;
+
+DWORD desiredAccessFile = GENERIC_READ | GENERIC_WRITE;
+DWORD shareModeFile = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
+LPSECURITY_ATTRIBUTES lpAttrFile = NULL;
+DWORD dwCreationDispFile = CREATE_NEW;
+DWORD dwFlagsAttribFile = FILE_ATTRIBUTE_NORMAL;
+HANDLE hTemplateFile = NULL;
+
+int numFileTests = 6;
+TestCaseFile gfaTestsFile[6]; /* GetFileAttributes tests list */
+
+int numDirTests = 6;
+TestCaseDir gfaTestsDir[6]; /* GetFileAttributes tests list */
+
+BOOL CleanUpFiles()
+{
+ DWORD dwAtt;
+ int i;
+ BOOL result = TRUE;
+ for (i = 0; i < numFileTests - 1 ; i++ )
+ {
+ dwAtt = GetFileAttributesA(gfaTestsFile[i].name);
+
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+ //Trace("Files iteration %d\n", i);
+ if(!SetFileAttributesA (gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL);
+ }
+
+ if(!DeleteFileA (gfaTestsFile[i].name))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, dwAtt);
+ }
+
+ }
+ }
+// Trace("Value of result is %d\n", result);
+ return result;
+}
+BOOL SetUpFiles()
+{
+ int i = 0;
+ BOOL result = TRUE;
+ for (i = 0; i < numFileTests - 1 ; i++ )
+ {
+ gfaTestsFile[i].hFile = CreateFile(gfaTestsFile[i].name,
+ desiredAccessFile,
+ shareModeFile,
+ lpAttrFile,
+ dwCreationDispFile,
+ dwFlagsAttribFile,
+ hTemplateFile);
+
+ if( gfaTestsFile[i].hFile == NULL )
+ {
+ Fail("Error while creating files for iteration %d\n", i);
+ }
+
+ if(!SetFileAttributesA (gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs);
+ }
+ }
+
+ return result;
+}
+
+BOOL CleanUpDirs()
+{
+ DWORD dwAtt;
+ int i;
+ BOOL result = TRUE;
+ for (i = 0; i < numDirTests - 1; i++ )
+ {
+ dwAtt = GetFileAttributesA(gfaTestsDir[i].name);
+
+ if( dwAtt != INVALID_FILE_ATTRIBUTES )
+ {
+
+ if(!SetFileAttributesA (gfaTestsDir[i].name, FILE_ATTRIBUTE_DIRECTORY))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, (FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY));
+ }
+
+ if(!RemoveDirectoryA (gfaTestsDir[i].name))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, dwAtt);
+ }
+
+ }
+ }
+
+ return result;
+}
+
+BOOL SetUpDirs()
+{
+ int i = 0;
+ BOOL result = TRUE;
+ DWORD ret = 0;
+ for (i = 0; i < numDirTests - 1; i++ )
+ {
+ result = CreateDirectory(gfaTestsDir[i].name,
+ NULL);
+
+ if(!result )
+ {
+ result = FALSE;
+ Fail("Error while creating directory for iteration %d\n", i);
+ }
+
+ if(!SetFileAttributesA (gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs))
+ {
+ result = FALSE;
+ Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs);
+ }
+
+ ret = GetFileAttributesA (gfaTestsDir[i].name);
+ if(ret != gfaTestsDir[i].expectedAttribs)
+ {
+ result = FALSE;
+ Trace("ERROR: Error setting attributes [%s][%d]\n", gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs);
+ }
+ // Trace("Setup Dir setting attr [%d], returned [%d]\n", gfaTestsDir[i].expectedAttribs, ret);
+
+ }
+// Trace("Setup dirs returning %d\n", result);
+ return result;
+}
+int __cdecl main(int argc, char **argv)
+{
+ int i;
+ BOOL bFailed = FALSE;
+ DWORD result;
+
+ char * NormalDirectoryName = "normal_test_directory";
+ char * ReadOnlyDirectoryName = "ro_test_directory";
+ char * ReadWriteDirectoryName = "rw_directory";
+ char * HiddenDirectoryName = ".hidden_directory";
+ char * HiddenReadOnlyDirectoryName = ".hidden_ro_directory";
+ char * NoDirectoryName = "no_directory";
+
+ char * NormalFileName = "normal_test_file";
+ char * ReadOnlyFileName = "ro_test_file";
+ char * ReadWriteFileName = "rw_file";
+ char * HiddenFileName = ".hidden_file";
+ char * HiddenReadOnlyFileName = ".hidden_ro_file";
+ char * NotReallyAFileName = "not_really_a_file";
+
+ WCHAR *WStr;
+ /* Tests on directory */
+ gfaTestsDir[0].name = NormalDirectoryName;
+ gfaTestsDir[0].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY;
+ gfaTestsDir[0].isFile = TYPE_DIR;
+
+ gfaTestsDir[1].name = ReadOnlyDirectoryName;
+ gfaTestsDir[1].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_READONLY;
+ gfaTestsDir[1].isFile = TYPE_DIR;
+
+ gfaTestsDir[2].name = ReadWriteDirectoryName;
+ gfaTestsDir[2].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY;
+ gfaTestsDir[2].isFile = TYPE_DIR;
+
+ gfaTestsDir[3].name = HiddenDirectoryName;
+ gfaTestsDir[3].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; //|
+ //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsDir[3].isFile = TYPE_DIR;
+
+ gfaTestsDir[4].name = HiddenReadOnlyDirectoryName;
+ gfaTestsDir[4].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_READONLY; //|
+ //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsDir[4].isFile = TYPE_DIR;
+
+ gfaTestsDir[5].name = NoDirectoryName;
+ gfaTestsDir[5].expectedAttribs = INVALID_FILE_ATTRIBUTES;
+ gfaTestsDir[5].isFile = TYPE_DIR;
+
+ /* Tests on file */
+ gfaTestsFile[0].name = NormalFileName;
+ gfaTestsFile[0].expectedAttribs = FILE_ATTRIBUTE_NORMAL;
+ gfaTestsFile[0].isFile = TYPE_FILE;
+
+
+ gfaTestsFile[1].name = ReadOnlyFileName;
+ gfaTestsFile[1].expectedAttribs = FILE_ATTRIBUTE_READONLY;
+ gfaTestsFile[1].isFile = TYPE_FILE;
+
+ gfaTestsFile[2].name = ReadWriteFileName;
+ gfaTestsFile[2].expectedAttribs = FILE_ATTRIBUTE_NORMAL;
+ gfaTestsFile[2].isFile = TYPE_FILE;
+
+ gfaTestsFile[3].name = HiddenFileName;
+ gfaTestsFile[3].expectedAttribs = FILE_ATTRIBUTE_NORMAL; //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsFile[3].isFile = TYPE_FILE;
+
+ gfaTestsFile[4].name = HiddenReadOnlyFileName;
+ gfaTestsFile[4].expectedAttribs = FILE_ATTRIBUTE_READONLY; //|
+ //FILE_ATTRIBUTE_HIDDEN;
+ gfaTestsFile[4].isFile = TYPE_FILE;
+
+
+ gfaTestsFile[5].name = NotReallyAFileName;
+ gfaTestsFile[5].expectedAttribs = INVALID_FILE_ATTRIBUTES;
+ gfaTestsFile[5].isFile = TYPE_FILE;
+
+ /* Initialize PAL environment */
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ if(!CleanUpFiles())
+ {
+ Fail("GetFileAttributesW: Pre-Clean Up Files Failed\n");
+ }
+
+ if(0 == SetUpFiles())
+ {
+ Fail("GetFileAttributesW: SetUp Files Failed\n");
+ }
+
+ if(!CleanUpDirs())
+ {
+ Fail("GetFileAttributesW: Pre-Clean Up Directories Failed\n");
+ }
+
+ if(!SetUpDirs())
+ {
+ Fail("GetFileAttributesW: SetUp Directories Failed\n");
+ }
+
+ /*
+ * Go through all the test cases above,
+ * call GetFileAttributesW on the name and
+ * make sure the return value is the one expected
+ */
+ for( i = 0; i < numFileTests; i++ )
+ {
+ WStr = convert(gfaTestsFile[i].name);
+ result = GetFileAttributesW(WStr);
+
+ if( result != gfaTestsFile[i].expectedAttribs )
+ {
+ bFailed = TRUE;
+
+ Trace("ERROR: GetFileAttributesW Test#%u on %s "
+ "returned %u instead of %u. \n",
+ i,
+ gfaTestsFile[i].name,
+ result,
+ gfaTestsFile[i].expectedAttribs);
+
+ }
+ free(WStr);
+ }
+
+
+ for( i = 0; i < numDirTests; i++ )
+ {
+ WStr = convert(gfaTestsDir[i].name);
+ result = GetFileAttributesW(WStr);
+
+ if( result != gfaTestsDir[i].expectedAttribs )
+ {
+ bFailed = TRUE;
+
+ Trace("ERROR: GetFileAttributesW on Directories Test#%u on %s "
+ "returned %u instead of %u. \n",
+ i,
+ gfaTestsDir[i].name,
+ result,
+ gfaTestsDir[i].expectedAttribs);
+
+ }
+ free(WStr);
+ }
+
+ if(!CleanUpFiles())
+ {
+ Fail("GetFileAttributesW: Post-Clean Up Files Failed\n");
+ }
+
+ if(!CleanUpDirs())
+ {
+ Fail("GetFileAttributesW: Post-Clean Up Directories Failed\n");
+ }
+
+ /* If any errors, just call Fail() */
+ if( bFailed )
+ {
+ Fail("");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file
new file mode 100644
index 0000000..3d631e8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file
@@ -0,0 +1 @@
+No attribs file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file
new file mode 100644
index 0000000..a6e1e62
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file
@@ -0,0 +1,6 @@
+file_io
+CopyFileW
+Positive Test for CopyFileW
+test the CopyFileW function
+DEFAULT
+CopyFileW \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file
new file mode 100644
index 0000000..a6e1e62
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file
@@ -0,0 +1,6 @@
+file_io
+CopyFileW
+Positive Test for CopyFileW
+test the CopyFileW function
+DEFAULT
+CopyFileW \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file
new file mode 100644
index 0000000..39d66f0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file
@@ -0,0 +1 @@
+Read Write file \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt
new file mode 100644
index 0000000..a8fd227
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme
new file mode 100644
index 0000000..31eade7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme
@@ -0,0 +1 @@
+Make CVS checkout this directory even with -p option. \ No newline at end of file
diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat
new file mode 100644
index 0000000..1a8089a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat
@@ -0,0 +1,20 @@
+# 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 = GetFileAttributesW
+
+Name = Positive Test for GetFileAttributesW
+
+TYPE = DEFAULT
+
+EXE1 = getfileattributesw
+
+Description
+
+= Test the GetFileAttributesW function
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt
new file mode 100644
index 0000000..ff20de5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileSize.c
+)
+
+add_executable(paltest_getfilesize_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfilesize_test1 coreclrpal)
+
+target_link_libraries(paltest_getfilesize_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.c b/src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.c
new file mode 100644
index 0000000..fac01c9
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.c
@@ -0,0 +1,173 @@
+// 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: GetFileSize.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetFileSize function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szTextFile = "text.txt";
+
+void CleanUp(HANDLE hFile)
+{
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Fail("GetFileSize: ERROR -> Unable to close file \"%s\".\n",
+ szTextFile);
+ }
+ if (!DeleteFileA(szTextFile))
+ {
+ Fail("GetFileSize: ERROR -> Unable to delete file \"%s\".\n",
+ szTextFile);
+ }
+}
+
+void CheckFileSize(HANDLE hFile, DWORD dwOffset, DWORD dwHighOrder)
+{
+ DWORD dwRc = 0;
+ DWORD dwReturnedHighOrder = 0;
+ DWORD dwReturnedOffset = 0;
+
+ dwRc = SetFilePointer(hFile, dwOffset, (PLONG)&dwHighOrder, FILE_BEGIN);
+ if (dwRc == INVALID_SET_FILE_POINTER)
+ {
+ Trace("GetFileSize: ERROR -> Call to SetFilePointer failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+ else
+ {
+ if (!SetEndOfFile(hFile))
+ {
+ Trace("GetFileSize: ERROR -> Call to SetEndOfFile failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+ dwReturnedOffset = GetFileSize(hFile, &dwReturnedHighOrder);
+ if ((dwReturnedOffset != dwOffset) ||
+ (dwReturnedHighOrder != dwHighOrder))
+ {
+ CleanUp(hFile);
+ Fail("GetFileSize: ERROR -> File sizes do not match up.\n");
+ }
+ }
+}
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ HANDLE hFile = NULL;
+ DWORD dwRc = 0;
+ DWORD dwRc2 = 0;
+ DWORD dwHighOrder = 0;
+ DWORD lpNumberOfBytesWritten;
+ char * data = "1234567890";
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+
+ /* test on a null file handle */
+ dwRc = GetFileSize(hFile, NULL);
+ if (dwRc != INVALID_FILE_SIZE)
+ {
+ Fail("GetFileSize: ERROR -> A file size was returned for "
+ "a null handle.\n");
+ }
+
+ /* test on a null file handle using the high order option */
+ dwRc = GetFileSize(hFile, &dwHighOrder);
+ if (dwRc != INVALID_FILE_SIZE)
+ {
+ Fail("GetFileSize: ERROR -> A file size was returned for "
+ "a null handle.\n");
+ }
+
+ /* test on an invalid file handle */
+ dwRc = GetFileSize(INVALID_HANDLE_VALUE, NULL);
+ if (dwRc != INVALID_FILE_SIZE)
+ {
+ Fail("GetFileSize: ERROR -> A file size was returned for "
+ "an invalid handle.\n");
+ }
+
+ /* test on an invalid file handle using the high order option */
+ dwRc = GetFileSize(INVALID_HANDLE_VALUE, &dwHighOrder);
+ if (dwRc != INVALID_FILE_SIZE)
+ {
+ Fail("GetFileSize: ERROR -> A file size was returned for "
+ "an invalid handle.\n");
+ }
+
+
+ /* create a test file */
+ hFile = CreateFile(szTextFile,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("GetFileSize: ERROR -> Unable to create file \"%s\".\n",
+ szTextFile);
+ }
+
+ /* give the file a size */
+ CheckFileSize(hFile, 256, 0);
+
+ /* make the file large using the high order option */
+ CheckFileSize(hFile, 256, 1);
+
+
+ /* set the file size to zero */
+ CheckFileSize(hFile, 0, 0);
+
+ /* test if file size changes by writing to it. */
+ /* get file size */
+ dwRc = GetFileSize(hFile, NULL);
+
+ /* test writing to the file */
+ if(WriteFile(hFile, data, strlen(data), &lpNumberOfBytesWritten, NULL)==0)
+ {
+ Trace("GetFileSize: ERROR -> Call to WriteFile failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+
+ /* make sure the buffer flushed.*/
+ if(FlushFileBuffers(hFile)==0)
+ {
+ Trace("GetFileSize: ERROR -> Call to FlushFileBuffers failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+
+ /* get file size after writing some chars */
+ dwRc2 = GetFileSize(hFile, NULL);
+ if((dwRc2-dwRc) !=strlen(data))
+ {
+ CleanUp(hFile);
+ Fail("GetFileSize: ERROR -> File size did not increase properly after.\n"
+ "writing %d chars\n", strlen(data));
+ }
+
+ CleanUp(hFile);
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat
new file mode 100644
index 0000000..3825857
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetFileSize
+Name = Positive Test for GetFileSize (test 1)
+Type = DEFAULT
+EXE1 = getfilesize
+Description
+= Test GetFileSize on a NULL handle and valid file handles
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt
new file mode 100644
index 0000000..f6aa0cb
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt
new file mode 100644
index 0000000..1369a5d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileSizeEx.c
+)
+
+add_executable(paltest_getfilesizeex_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfilesizeex_test1 coreclrpal)
+
+target_link_libraries(paltest_getfilesizeex_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.c b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.c
new file mode 100644
index 0000000..ef5afd0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.c
@@ -0,0 +1,173 @@
+// 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: GetFileSizeEx.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetFileSizeEx function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szTextFile = "text.txt";
+
+void CleanUp(HANDLE hFile)
+{
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Fail("GetFileSizeEx: ERROR -> Unable to close file \"%s\".\n"
+ " Error is %d\n",
+ szTextFile, GetLastError());
+ }
+ if (!DeleteFileA(szTextFile))
+ {
+ Fail("GetFileSizeEx: ERROR -> Unable to delete file \"%s\".\n"
+ " Error is %d\n",
+ szTextFile, GetLastError());
+ }
+}
+
+void CheckFileSize(HANDLE hFile, DWORD dwOffset, DWORD dwHighOrder)
+{
+ DWORD dwRc = 0;
+ DWORD dwError = 0;
+ LARGE_INTEGER qwFileSize;
+
+ dwRc = SetFilePointer(hFile, dwOffset, (PLONG)&dwHighOrder, FILE_BEGIN);
+ if (dwRc == INVALID_SET_FILE_POINTER)
+ {
+ Trace("GetFileSizeEx: ERROR -> Call to SetFilePointer failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+ else
+ {
+ if (!SetEndOfFile(hFile))
+ {
+ dwError = GetLastError();
+ CleanUp(hFile);
+ if (dwError == 112)
+ {
+ Fail("GetFileSizeEx: ERROR -> SetEndOfFile failed due to lack of "
+ "disk space\n");
+ }
+ else
+ {
+ Fail("GetFileSizeEx: ERROR -> SetEndOfFile call failed "
+ "with error %ld\n", dwError);
+ }
+ }
+ else
+ {
+ GetFileSizeEx(hFile, &qwFileSize);
+ if ((qwFileSize.u.LowPart != dwOffset) ||
+ (qwFileSize.u.HighPart != dwHighOrder))
+ {
+ CleanUp(hFile);
+ Fail("GetFileSizeEx: ERROR -> File sizes do not match up.\n");
+ }
+ }
+ }
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ HANDLE hFile = NULL;
+ BOOL bRc = FALSE;
+ DWORD lpNumberOfBytesWritten;
+ LARGE_INTEGER qwFileSize;
+ LARGE_INTEGER qwFileSize2;
+ char * data = "1234567890";
+
+ qwFileSize.QuadPart = 0;
+ qwFileSize2.QuadPart = 0;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+
+ /* test on a null file */
+ bRc = GetFileSizeEx(NULL, &qwFileSize);
+ if (bRc != FALSE)
+ {
+ Fail("GetFileSizeEx: ERROR -> Returned status as TRUE for "
+ "a null handle.\n");
+ }
+
+
+ /* test on an invalid file */
+ bRc = GetFileSizeEx(INVALID_HANDLE_VALUE, &qwFileSize);
+ if (bRc != FALSE)
+ {
+ Fail("GetFileSizeEx: ERROR -> Returned status as TRUE for "
+ "an invalid handle.\n");
+ }
+
+
+ /* create a test file */
+ hFile = CreateFile(szTextFile,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("GetFileSizeEx: ERROR -> Unable to create file \"%s\".\n",
+ szTextFile);
+ }
+
+ /* give the file a size */
+ CheckFileSize(hFile, 256, 0);
+
+ /* make the file large using the high order option */
+ CheckFileSize(hFile, 256, 1);
+
+
+ /* set the file size to zero */
+ CheckFileSize(hFile, 0, 0);
+
+ /* test if file size changes by writing to it. */
+ /* get file size */
+ GetFileSizeEx(hFile, &qwFileSize);
+
+ /* test writing to the file */
+ if(WriteFile(hFile, data, strlen(data), &lpNumberOfBytesWritten, NULL)==0)
+ {
+ Trace("GetFileSizeEx: ERROR -> Call to WriteFile failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+
+ /* make sure the buffer flushed.*/
+ if(FlushFileBuffers(hFile)==0)
+ {
+ Trace("GetFileSizeEx: ERROR -> Call to FlushFileBuffers failed with %ld.\n",
+ GetLastError());
+ CleanUp(hFile);
+ Fail("");
+ }
+
+ /* get file size after writing some chars */
+ GetFileSizeEx(hFile, &qwFileSize2);
+ if((qwFileSize2.QuadPart-qwFileSize.QuadPart) !=strlen(data))
+ {
+ CleanUp(hFile);
+ Fail("GetFileSizeEx: ERROR -> File size did not increase properly after.\n"
+ "writing %d chars\n", strlen(data));
+ }
+
+ CleanUp(hFile);
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat
new file mode 100644
index 0000000..5968fe7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetFileSizeEx
+Name = Positive Test for GetFileSizeEx (test 1)
+Type = DEFAULT
+EXE1 = getfilesizeex
+Description
+= Test GetFileSizeEx on a NULL handle and valid file handles
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/CMakeLists.txt
new file mode 100644
index 0000000..19ee487
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+add_subdirectory(test4)
+add_subdirectory(test5)
+add_subdirectory(test6)
+add_subdirectory(test7)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test1/CMakeLists.txt
new file mode 100644
index 0000000..6a89846
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileTime.c
+)
+
+add_executable(paltest_getfiletime_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test1 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.c
new file mode 100644
index 0000000..fb7bcb8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.c
@@ -0,0 +1,180 @@
+// 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: GetFileTime.c
+**
+** Purpose: Tests the PAL implementation of the GetFileTime function.
+** This test checks the time of a file, writes to it, then checks the
+** time again to ensure that write time has increased. It
+** also checks that creation time is the same under WIN32 and has
+** increased under FreeBSD.
+**
+** Depends:
+** CreateFile
+** WriteFile
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ FILETIME Creation,LastAccess,LastWrite;
+ HANDLE TheFileHandle;
+ ULONG64 FirstWrite, SecondWrite, FirstCreationTime, SecondCreationTime;
+ DWORD temp;
+ BOOL result;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Open the file to get a HANDLE */
+ TheFileHandle =
+ CreateFile(
+ "the_file", // File Name
+ GENERIC_READ|GENERIC_WRITE, // Access Mode
+ 0, // Share Mode
+ NULL, // SD
+ OPEN_ALWAYS, // Howto Create
+ FILE_ATTRIBUTE_NORMAL, // File Attributes
+ NULL // Template file
+ );
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to open the file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+
+ /* Get the Last Write, Creation and Access File time of that File */
+ if(!GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite))
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure.");
+ }
+
+ /* Convert the structure to an ULONG64 */
+
+ FirstCreationTime = ((((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ FirstWrite = ((((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ /* Sleep for 3 seconds, this will ensure the time changes */
+ Sleep(3000);
+
+ /* Write to the file -- this should change write access and
+ last access
+ */
+
+ result = WriteFile(TheFileHandle, // File handle
+ "something", // String to write
+ 9, // Bytes to write
+ &temp, // Bytes written
+ NULL);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to write to file. The file must be "
+ "written to in order to test that the write time is "
+ "updated.");
+ }
+
+ /* Close the File, so the changes are recorded */
+ result = CloseHandle(TheFileHandle);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to close the file handle.");
+ }
+
+
+ /* Reopen the file */
+ TheFileHandle =
+ CreateFile(
+ "the_file", /* file name */
+ GENERIC_READ|GENERIC_WRITE, /* access mode */
+ 0, /* share mode */
+ NULL, /* SD */
+ OPEN_ALWAYS, /* how to create */
+ FILE_ATTRIBUTE_NORMAL, /* file attributes */
+ NULL /* handle to template file */
+ );
+
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to re-open the file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+
+
+ /* Call GetFileTime again */
+ if(!GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite))
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure.");
+ }
+
+ /* Store the results in a ULONG64 */
+
+ SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+
+ /* Now -- to test. We'll ensure that the Second
+ LastWrite time is larger than the first. It tells us that
+ time is passing, which is good!
+ */
+
+ if(FirstWrite >= SecondWrite)
+ {
+ Fail("ERROR: The last-write-file-time after writing did not "
+ "increase from the original. The second value should be "
+ "larger.");
+ }
+
+#if WIN32
+ /* Then we can check to make sure that the creation time
+ hasn't changed. This should always stay the same.
+ */
+
+ if(FirstCreationTime != SecondCreationTime)
+ {
+ Fail("ERROR: The creation time after writing should not "
+ "not change from the original. The second value should be "
+ "equal.");
+ }
+#else
+ /* Then we can check to make sure that the creation time
+ has changed. Under FreeBSD it changes whenever the file is
+ access or written.
+ */
+
+ if(FirstCreationTime >= SecondCreationTime)
+ {
+ Fail("ERROR: The creation time after writing should be "
+ "greater than the original. The second value should be "
+ "larger.");
+ }
+
+#endif
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test1/testinfo.dat
new file mode 100644
index 0000000..50cd352
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test1/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 = file_io
+Function = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Test the GetFileTime function. Open a file and get the time. Then write
+= to that file. This will change the write and under FreeBSD
+= the creation time. Ensure that all of these are increasing.
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test2/CMakeLists.txt
new file mode 100644
index 0000000..3d315e4
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileTime.c
+)
+
+add_executable(paltest_getfiletime_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test2 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.c
new file mode 100644
index 0000000..5b14a1e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.c
@@ -0,0 +1,195 @@
+// 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: GetFileTime.c
+**
+** Purpose: Tests the PAL implementation of the GetFileTime function
+** Test to see that access date either stays the same or increases
+** when a read is performed. Write
+** and creation time should stay unchanged. Note: Under FreeBSD
+** the Creation time should not change with just a read.
+**
+** Depends:
+** FileTimeToDosDateTime
+** CreateFile
+** ReadFile
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ FILETIME Creation,LastAccess,LastWrite;
+ HANDLE TheFileHandle;
+ ULONG64 FirstWrite, SecondWrite,
+ FirstCreationTime, SecondCreationTime;
+ DWORD temp;
+ char ReadBuffer[10];
+ BOOL result;
+ WORD DosDateOne, DosDateTwo, DosTime;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Open the file to get a HANDLE */
+ TheFileHandle =
+ CreateFile(
+ "the_file",
+ GENERIC_READ,
+ 0,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to open the file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+
+ /* Get the Last Write, Creation and Access File time of that File */
+ if(GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite)==0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure.");
+ }
+
+ /* Call FileTimeToDosDateTime so we can aquire just the date
+ portion of the Last Access FILETIME.
+ */
+ if(FileTimeToDosDateTime(&LastAccess, &DosDateOne, &DosTime) == 0)
+ {
+ Fail("ERROR: FiletimeToDosDateTime failed, returning 0. "
+ "GetLastError returned %d.\n",GetLastError());
+ }
+
+ /* Convert the structure to an ULONG64 */
+
+ FirstCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ FirstWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ /* Sleep for 3 seconds, this will ensure the time changes */
+ Sleep(3000);
+
+ /* Read from the file -- this should change
+ last access, but we'll only check the date portion, because some file
+ systems have a resolution of a day.
+ */
+
+ result = ReadFile(TheFileHandle, // handle to file
+ &ReadBuffer, // data buffer
+ 2, // number of bytes to read
+ &temp, // number of bytes read
+ NULL);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to read from the file.");
+ }
+
+
+ /* Close the File, so the changes are recorded */
+ result = CloseHandle(TheFileHandle);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to close the file handle.");
+ }
+
+
+ /* Reopen the file */
+ TheFileHandle =
+ CreateFile("the_file", /* file name */
+ GENERIC_READ, /* access mode */
+ 0, /* share mode */
+ NULL, /* SD */
+ OPEN_ALWAYS, /* how to create */
+ FILE_ATTRIBUTE_NORMAL, /* file attributes */
+ NULL /* handle to template file */
+ );
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to re-open the file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+ /* Call GetFileTime again */
+ if(GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite) == 0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure.");
+ }
+
+ /* Get the Date of the LastAccessTime here again. */
+ if(FileTimeToDosDateTime(&LastAccess, &DosDateTwo, &DosTime) == 0)
+ {
+ Fail("ERROR: FileTimeToDosDateTime failed, returning 0. "
+ "GetLastError returned %d.\n",GetLastError());
+ }
+
+
+ /* Store the results in a ULONG64 */
+
+ SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ /* Now -- to test. We'll ensure that the Second
+ LastWrite time is the same as the first. This shouldn't
+ have changed.
+ */
+
+ if(FirstWrite != SecondWrite)
+ {
+ Fail("ERROR: The last-write-file-time after reading "
+ "increased from the original. The second value should be "
+ "equal.");
+ }
+
+
+ /*
+ For LastAccessTime, just check that the date is greater or equal
+ for the second over the first. The time is not conisered on some
+ file systems. (such as fat32)
+ */
+
+ if(DosDateOne > DosDateTwo)
+ {
+ Fail("ERROR: The last-access-time after reading should have "
+ "stayed the same or increased, but it did not.\n");
+ }
+
+
+ /* Check to ensure CreationTime hasn't changed. This should not
+ have changed in either environment.
+ */
+
+ if(FirstCreationTime != SecondCreationTime)
+ {
+ Fail("ERROR: The creation time after reading should not "
+ "not change from the original. The second value should be "
+ "equal.");
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test2/testinfo.dat
new file mode 100644
index 0000000..a60dcf4
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test2/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 = file_io
+Function = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Tests the PAL implementation of the GetFileTime function
+= Test to see that access date either stays the same or increases
+= when a read is performed. Write
+= and creation time should stay unchanged. Note: Under FreeBSD
+= the Creation time should not change with just a read.
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt
new file mode 100644
index 0000000..34f7310
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileTime.c
+)
+
+add_executable(paltest_getfiletime_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test3 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.c
new file mode 100644
index 0000000..a3f46c2
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.c
@@ -0,0 +1,142 @@
+// 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: GetFileTime.c
+**
+** Purpose: Tests the PAL implementation of the GetFileTime function
+** Test to see that creation time is changed when two different files
+** are created.
+**
+** Depends:
+** CreateFile
+** ReadFile
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ FILETIME Creation;
+ HANDLE TheFileHandle, SecondFileHandle;
+ ULONG64 FirstCreationTime, SecondCreationTime;
+ BOOL result;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Open the file to get a HANDLE */
+ TheFileHandle =
+ CreateFile(
+ "the_file",
+ GENERIC_READ,
+ 0,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to open the file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+
+ /* Get the Creation time of the File */
+ if(GetFileTime(TheFileHandle,&Creation,NULL,NULL)==0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure. "
+ "Two of the params were NULL in this case, did they "
+ "cause the probleM?");
+ }
+
+ /* Convert the structure to an ULONG64 */
+
+ FirstCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+
+ /* Close the File, so the changes are recorded */
+ result = CloseHandle(TheFileHandle);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to close the file handle.");
+ }
+
+
+ /* Sleep for 3 seconds, this will ensure the time changes */
+ Sleep(3000);
+
+
+
+ /* Open another file */
+ SecondFileHandle =
+ CreateFile("the_other_file", /* file name */
+ GENERIC_READ, /* access mode */
+ 0, /* share mode */
+ NULL, /* SD */
+ CREATE_ALWAYS, /* how to create */
+ FILE_ATTRIBUTE_NORMAL, /* file attributes */
+ NULL /* handle to template file */
+ );
+
+ if(SecondFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to open the second file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+
+ /* Call GetFileTime again */
+ if(GetFileTime(SecondFileHandle,&Creation,NULL,NULL) == 0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure. "
+ "Perhaps the NULLs in the function broke it?");
+ }
+
+ /* Close the File*/
+ result = CloseHandle(SecondFileHandle);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to close the file handle.");
+ }
+
+
+ /* Store the results in a ULONG64 */
+
+ SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+
+
+ /* Now -- to test. We ensure that the FirstCreationTime is
+ less than the SecondCreationTime
+ */
+
+
+ if(FirstCreationTime >= SecondCreationTime)
+ {
+ Fail("ERROR: The creation time of the two files should be "
+ "different. The first file should have a creation "
+ "time less than the second.");
+ }
+
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test3/testinfo.dat
new file mode 100644
index 0000000..6d1eba7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test3/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 = file_io
+Function = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Test the GetFileTime function. This test creates two files and compares
+= their creation times. They should be different. It also tries to get the
+= file time of an invalid handle, which should cause the function to tail.
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test4/CMakeLists.txt
new file mode 100644
index 0000000..0c9dcf7
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test4/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileTime.c
+)
+
+add_executable(paltest_getfiletime_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test4 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.c
new file mode 100644
index 0000000..ffba516
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.c
@@ -0,0 +1,98 @@
+// 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: GetFileTime.c
+**
+** Purpose: Tests the PAL implementation of the GetFileTime function
+** Test to see that passing NULL values to GetFileTime works and that
+** calling the function on a bad HANDLE causes the correct failure.
+**
+** Depends:
+** CreateFile
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ FILETIME Creation,LastWrite,LastAccess;
+ HANDLE TheFileHandle;
+ BOOL result;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Open the file to get a HANDLE */
+ TheFileHandle =
+ CreateFile(
+ "the_file",
+ GENERIC_READ,
+ 0,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+
+ if(TheFileHandle == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to open the file. The error number "
+ "returned was %d.",GetLastError());
+ }
+
+ /* Pass all NULLs, this is useless but should still work. */
+ if(GetFileTime(TheFileHandle,NULL,NULL,NULL)==0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure. "
+ "Three of the params were NULL in this case, did they "
+ "cause the problem?");
+ }
+
+
+ /* Get the Creation time of the File */
+ if(GetFileTime(TheFileHandle,&Creation,NULL,NULL)==0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure. "
+ "Two of the params were NULL in this case, did they "
+ "cause the probleM?");
+ }
+
+ /* Get the Creation, LastWrite time of the File */
+ if(GetFileTime(TheFileHandle,&Creation,&LastWrite,NULL)==0)
+ {
+ Fail("ERROR: GetFileTime returned 0, indicating failure. "
+ "One of the params were NULL in this case, did it "
+ "cause the problem?");
+ }
+
+
+ /* Close the File, so the changes are recorded */
+ result = CloseHandle(TheFileHandle);
+
+ if(result == 0)
+ {
+ Fail("ERROR: Failed to close the file handle.");
+ }
+
+ /* Call GetFileTime again */
+ if(GetFileTime(TheFileHandle,&Creation,&LastWrite,&LastAccess) != 0)
+ {
+ Fail("ERROR: GetFileTime returned non zero, indicating success. "
+ "It was passed an invalid file HANDLE and should have "
+ "failed.");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test4/testinfo.dat
new file mode 100644
index 0000000..af90558
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/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 = file_io
+Function = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Test the GetFileTime function. This test gets the file time of a given
+= file while passing all the combonations of NULL as parameters. The
+= function should handle these as unneeded times, and still succeed.
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt
new file mode 100644
index 0000000..a82717e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ getfiletime.c
+)
+
+add_executable(paltest_getfiletime_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test5 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test5
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.c
new file mode 100644
index 0000000..d8196d8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.c
@@ -0,0 +1,224 @@
+// 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: GetFileTime.c
+**
+** Purpose: Test the PAL implementation of GetFileTime. This test
+** creates a file and compares create and write times between
+** writes, but before the close, and verifies the results are
+** as expected
+**
+** Depends:
+** CreateFile
+** WriteFile
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+ FILETIME Creation;
+ FILETIME LastAccess;
+ FILETIME LastWrite;
+ HANDLE hFile;
+ ULONG64 FirstWrite;
+ ULONG64 SecondWrite;
+ ULONG64 FirstCreationTime;
+ ULONG64 SecondCreationTime;
+ DWORD temp;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Open the file to get a HANDLE */
+ hFile = CreateFile("test.tmp",
+ GENERIC_READ|GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to create the file. The error number "
+ "returned was %u.\n",
+ GetLastError());
+ }
+
+ /* Write to the file -- this should change write access and
+ last access
+ */
+ if(!WriteFile(hFile, "something", 9, &temp, NULL))
+ {
+ Trace("ERROR: Failed to write to file. The file must be "
+ "written to in order to test that the write time is "
+ "updated. GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ FlushFileBuffers(hFile);
+
+ /* Get the Last Write, Creation and Access File time of that File */
+ if(!GetFileTime(hFile, &Creation, &LastAccess, &LastWrite))
+ {
+ Trace("ERROR: GetFileTime returned 0, indicating failure."
+ " GetLastError returned %u\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Convert the structure to an ULONG64 */
+
+ FirstCreationTime = ((((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ FirstWrite = ((((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ /* Sleep for 3 seconds, this will ensure the time changes */
+ Sleep(3000);
+
+ /* Write to the file again -- this should change write access and
+ last access
+ */
+ if(!WriteFile(hFile, "something", 9, &temp, NULL))
+ {
+ Trace("ERROR: Failed to write to file. The file must be "
+ "written to in order to test that the write time is "
+ "updated. GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+
+ FlushFileBuffers(hFile);
+
+ /* Call GetFileTime again */
+ if(!GetFileTime(hFile,&Creation,&LastAccess,&LastWrite))
+ {
+ Trace("ERROR: GetFileTime returned 0, indicating failure."
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Store the results in a ULONG64 */
+
+ SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+
+ /* Now -- to test. We'll ensure that the Second
+ LastWrite time is larger than the first. It tells us that
+ time is passing, which is good!
+ */
+
+ if(FirstWrite >= SecondWrite)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The last-write-file-time after writing did not "
+ "increase from the original. The second value should be "
+ "larger.\n");
+ }
+
+#if WIN32
+ /* Then we can check to make sure that the creation time
+ hasn't changed. This should always stay the same.
+ */
+
+ if(FirstCreationTime != SecondCreationTime)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The creation time after writing should not "
+ "not change from the original. The second value should be "
+ "equal.\n");
+ }
+#else
+ /* Then we can check to make sure that the creation time
+ has changed. Under FreeBSD it changes whenever the file is
+ access or written.
+ */
+
+ if(FirstCreationTime >= SecondCreationTime)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The creation time after writing should be "
+ "greater than the original. The second value should be "
+ "larger.\n");
+ }
+
+#endif
+
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Fail("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test5/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test5/testinfo.dat
new file mode 100644
index 0000000..fd4112b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test5/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 = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Test the PAL implementation of GetFileTime. This test
+= creates a file and compares create and write times between
+= writes, but before the close, and verifies the results are
+= as expected
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt
new file mode 100644
index 0000000..24992df
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ getfiletime.c
+)
+
+add_executable(paltest_getfiletime_test6
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test6 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test6
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.c
new file mode 100644
index 0000000..3eedddf
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.c
@@ -0,0 +1,281 @@
+// 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: GetFileTime.c
+**
+** Purpose: Tests the PAL implementation of the GetFileTime function.
+** Perform two reads from a file without closing until the end
+** of the test and verify that only the access times change.
+** Note: Under Win32, modify time changes as well so we will
+** check that it doesn't go backwards
+**
+** Depends:
+** FileTimeToDosDateTime
+** CreateFile
+** ReadFile
+** WriteFile
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+
+ FILETIME Creation;
+ FILETIME LastAccess;
+ FILETIME LastWrite;
+ HANDLE hFile;
+ ULONG64 FirstWrite = (ULONG64)0;
+ ULONG64 SecondWrite = (ULONG64)0;
+ ULONG64 FirstCreationTime = (ULONG64)0;
+ ULONG64 SecondCreationTime = (ULONG64)0;
+ DWORD temp;
+ char ReadBuffer[10];
+ WORD DosDateOne;
+ WORD DosDateTwo;
+ WORD DosTime;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+ memset(&Creation, 0, sizeof(FILETIME));
+ memset(&LastAccess, 0, sizeof(FILETIME));
+ memset(&LastWrite, 0, sizeof(FILETIME));
+
+ /* Create the file to get a HANDLE */
+ hFile = CreateFile("test.tmp",
+ GENERIC_READ|GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to create the file. The error number "
+ "returned was %u.\n",
+ GetLastError());
+ }
+
+ /* give us something to read from the file */
+ if(!WriteFile(hFile, "something", 9, &temp, NULL))
+ {
+ Trace("ERROR: Failed to write to file. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* let's do a read to set the file times for our test */
+ if(!ReadFile(hFile, &ReadBuffer, 2, &temp, NULL))
+ {
+ Trace("ERROR: Failed to read from the file. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Get the Last Write, Creation and Access File time of the file */
+ if(GetFileTime(hFile, &Creation, &LastAccess, &LastWrite)==0)
+ {
+ Trace("ERROR: GetFileTime returned 0, indicating failure."
+ " GetLastError returned %u\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Call FileTimeToDosDateTime so we can aquire just the date
+ portion of the Last Access FILETIME.
+ */
+ if(FileTimeToDosDateTime(&LastAccess, &DosDateOne, &DosTime) == 0)
+ {
+ Trace("ERROR: FiletimeToDosDateTime failed, returning 0. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Convert the structure to an ULONG64 */
+ FirstCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ FirstWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ /* Sleep for 3 seconds, this will ensure the time changes */
+ Sleep(3000);
+
+ /* Read from the file -- this should change
+ last access, but we'll only check the date portion, because some file
+ systems have a resolution of a day.
+ */
+ memset(&Creation, 0, sizeof(FILETIME));
+ memset(&LastAccess, 0, sizeof(FILETIME));
+ memset(&LastWrite, 0, sizeof(FILETIME));
+
+ if(!ReadFile(hFile, &ReadBuffer, 2, &temp, NULL))
+ {
+ Trace("ERROR: Failed to read from the file. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+
+ /* Call GetFileTime to get the updated time values*/
+ if(GetFileTime(hFile, &Creation, &LastAccess, &LastWrite) == 0)
+ {
+ Trace("ERROR: GetFileTime returned 0, indicating failure. "
+ "GetLastError returned %d.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Get the Date of the LastAccessTime here again. */
+ if(FileTimeToDosDateTime(&LastAccess, &DosDateTwo, &DosTime) == 0)
+ {
+ Trace("ERROR: FileTimeToDosDateTime failed, returning 0. "
+ "GetLastError returned %d.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+
+ /* Store the results in a ULONG64 */
+ SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ /* Now -- to test. We'll ensure that the SecondWrite
+ time is not less than the FirstWrite time
+ */
+
+ if(SecondWrite < FirstWrite)
+ {
+ Trace("ERROR: The write-file-time (%I64d) after the first read "
+ "is less than the write-file-time (%I64d) after the second "
+ "read.\n",
+ FirstWrite,
+ LastWrite);
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /*
+ For LastAccessTime, just check that the date is greater or equal
+ for the second over the first. The time is not conisered on some
+ file systems. (such as fat32)
+ */
+
+ if(DosDateOne > DosDateTwo)
+ {
+ Trace("ERROR: The last-access-time after reading should have "
+ "stayed the same or increased, but it did not.\n");
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+
+ /* Check to ensure CreationTime hasn't changed. This should not
+ have changed in either environment.
+ */
+
+ if(FirstCreationTime != SecondCreationTime)
+ {
+ Trace("ERROR: The creation time after reading should not "
+ "not change from the original. The second value should be "
+ "equal.\n");
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Close the File, so the changes are recorded */
+ if(!CloseHandle(hFile))
+ {
+ Fail("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test6/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test6/testinfo.dat
new file mode 100644
index 0000000..8440436
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test6/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 = file_io
+Function = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Tests the PAL implementation of the GetFileTime function.
+= Perform two reads from a file without closing until the end
+= of the test and verify that only the access times change.
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test7/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test7/CMakeLists.txt
new file mode 100644
index 0000000..6646fd9
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test7/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ getfiletime.c
+)
+
+add_executable(paltest_getfiletime_test7
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletime_test7 coreclrpal)
+
+target_link_libraries(paltest_getfiletime_test7
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.c b/src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.c
new file mode 100644
index 0000000..d33175b
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.c
@@ -0,0 +1,279 @@
+// 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: GetFileTime.c
+**
+** Purpose: Test the PAL implementation of GetFileTime. This test
+** creates a file and compares create and write times after
+** the buffers are flushed, but before the close, and verifies
+** the results are as expected
+**
+** Depends:
+** CreateFile
+** WriteFile
+** FlushFileBuffers
+** CloseHandle
+**
+**
+**===================================================================*/
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+ FILETIME Creation;
+ FILETIME LastAccess;
+ FILETIME LastWrite;
+ HANDLE hFile;
+ ULONG64 FirstWrite;
+ ULONG64 SecondWrite;
+ ULONG64 FirstAccess;
+ ULONG64 SecondAccess;
+ ULONG64 FirstCreationTime;
+ ULONG64 SecondCreationTime;
+ DWORD temp;
+ const char* someText = "1234567890123456789012345678901234567890";
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* Open the file to get a HANDLE */
+ hFile = CreateFile("test.tmp",
+ GENERIC_READ|GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("ERROR: Failed to create the file. The error number "
+ "returned was %u.\n",
+ GetLastError());
+ }
+
+ /* Write to the file -- this should change write access and
+ last access
+ */
+ if(!WriteFile(hFile, someText, strlen(someText), &temp, NULL))
+ {
+ Trace("ERROR: Failed to write to file. The file must be "
+ "written to in order to test that the write time is "
+ "updated. GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Flush the buffers */
+ if(!FlushFileBuffers(hFile))
+ {
+ Trace("ERROR: The FlushFileBuffers function failed. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Get the Last Write, Creation and Access File time of that File */
+ if(!GetFileTime(hFile, &Creation, &LastAccess, &LastWrite))
+ {
+ Trace("ERROR: GetFileTime returned 0, indicating failure."
+ " GetLastError returned %u\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Convert the structures to an ULONG64 */
+ FirstCreationTime = ((((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ FirstWrite = ((((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ FirstAccess = ((((ULONG64)LastAccess.dwHighDateTime)<<32) |
+ ((ULONG64)LastAccess.dwLowDateTime));
+
+ /* Sleep for 3 seconds, this will ensure the time changes */
+ Sleep(3000);
+
+ /* Write to the file again so we have something to flush */
+ if(!WriteFile(hFile, someText, strlen(someText), &temp, NULL))
+ {
+ Trace("ERROR: Failed to write to file. The file must be "
+ "written to in order to test that the write time is "
+ "updated. GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Flush the buffers forcing the access/mod time to change */
+ if(!FlushFileBuffers(hFile))
+ {
+ Trace("ERROR: The FlushFileBuffers function failed. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+
+ /* Call GetFileTime again */
+ if(!GetFileTime(hFile,&Creation,&LastAccess,&LastWrite))
+ {
+ Trace("ERROR: GetFileTime returned 0, indicating failure."
+ "GetLastError returned %u.\n",
+ GetLastError());
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("");
+ }
+
+ /* Store the results in a ULONG64 */
+
+ SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) |
+ ((ULONG64)Creation.dwLowDateTime));
+
+ SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) |
+ ((ULONG64)LastWrite.dwLowDateTime));
+
+ SecondAccess = ((((ULONG64)LastAccess.dwHighDateTime)<<32) |
+ ((ULONG64)LastAccess.dwLowDateTime));
+
+
+ /* Now -- to test. We'll ensure that the Second
+ LastWrite and access times are larger than the first.
+ It tells us that time is passing, which is good!
+ */
+
+ if(FirstWrite >= SecondWrite)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The write-file-time (%I64d) after the first flush "
+ "should be less than the write-file-time (%I64d) after the second "
+ "flush.\n",
+ FirstWrite,
+ LastWrite);
+
+ }
+
+
+ if(SecondAccess < FirstAccess)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The access-file-time (%I64d) after the first flush "
+ "should be less than or equal to the access-file-time (%I64d) "
+ "after the second flush.\n",
+ FirstAccess,
+ LastAccess);
+ }
+
+#if WIN32
+ /* Then we can check to make sure that the creation time
+ hasn't changed. This should always stay the same.
+ */
+
+ if(FirstCreationTime != SecondCreationTime)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The creation time after writing should not "
+ "not change from the original. The second value should be "
+ "equal.\n");
+ }
+#else
+ /* Then we can check to make sure that the creation time
+ has changed. Under FreeBSD it changes whenever the file is
+ access or written.
+ */
+
+ if(FirstCreationTime >= SecondCreationTime)
+ {
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Trace("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+ Fail("ERROR: The creation time after writing should be "
+ "greater than the original. The second value should be "
+ "larger.\n");
+ }
+
+#endif
+
+ /* Close the File */
+ if(!CloseHandle(hFile))
+ {
+ Fail("ERROR: Failed to close the file handle. "
+ "GetLastError returned %u.\n",
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test7/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test7/testinfo.dat
new file mode 100644
index 0000000..774f759
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileTime/test7/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 = GetFileTime
+Name = Positive Test for GetFileTime
+TYPE = DEFAULT
+EXE1 = getfiletime
+Description
+= Test the PAL implementation of GetFileTime. This test
+= creates a file and compares create and write times after
+= the buffers are flushed, but before the close, and verifies
+= the results are as expected
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt
new file mode 100644
index 0000000..1962ade
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt
new file mode 100644
index 0000000..66467e9
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFileType.c
+)
+
+add_executable(paltest_getfiletype_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletype_test1 coreclrpal)
+
+target_link_libraries(paltest_getfiletype_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.c b/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.c
new file mode 100644
index 0000000..6558c00
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.c
@@ -0,0 +1,76 @@
+// 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: GetFileType.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetFileType function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szTextFile = "text.txt";
+
+int __cdecl main(int argc, char *argv[])
+{
+ HANDLE hFile = NULL;
+ DWORD dwRc = 0;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+
+ /* test FILE_TYPE_UNKNOWN */
+ dwRc = GetFileType(hFile);
+ if (dwRc != FILE_TYPE_UNKNOWN)
+ {
+ Fail("GetFileType: ERROR -> Was expecting a return type of "
+ "FILE_TYPE_UNKNOWN but the function returned %ld.\n",
+ dwRc);
+ }
+
+
+ /* create a test file */
+ hFile = CreateFile(szTextFile,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("GetFileType: ERROR -> Unable to create file \"%s\".\n",
+ szTextFile);
+ }
+
+ dwRc = GetFileType(hFile);
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Fail("GetFileType: ERROR -> Unable to close file \"%s\".\n",
+ szTextFile);
+ }
+ if (!DeleteFileA(szTextFile))
+ {
+ Fail("GetFileType: ERROR -> Unable to delete file \"%s\".\n",
+ szTextFile);
+ }
+
+ if (dwRc != FILE_TYPE_DISK)
+ {
+ Fail("GetFileType: ERROR -> Was expecting a return type of "
+ "FILE_TYPE_DISK but the function returned %ld.\n",
+ dwRc);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileType/test1/testinfo.dat
new file mode 100644
index 0000000..f12a81a
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetFileType
+Name = Positive Test for GetFileType (test 1)
+Type = DEFAULT
+EXE1 = getfiletype
+Description
+= Test GetFileType on a NULL handle and a valid handle to a file
+
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/test2/CMakeLists.txt
new file mode 100644
index 0000000..382b27e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ getfiletype.c
+)
+
+add_executable(paltest_getfiletype_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletype_test2 coreclrpal)
+
+target_link_libraries(paltest_getfiletype_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.c b/src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.c
new file mode 100644
index 0000000..c9d4eb6
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.c
@@ -0,0 +1,95 @@
+// 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: getfiletype.c
+**
+** Purpose: Test the PAL implementation of GetFileType to ensure it
+** recognizes opened pipes.
+**
+** Depends: CreatePipe
+** CloseHandle
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char **argv)
+{
+ HANDLE hReadPipe = NULL;
+ HANDLE hWritePipe = NULL;
+ BOOL bRetVal = FALSE;
+ DWORD dwFileType;
+ SECURITY_ATTRIBUTES lpPipeAttributes;
+
+ /*Initialize the PAL*/
+ if ((PAL_Initialize(argc, argv)) != 0)
+ {
+ return (FAIL);
+ }
+
+ /*
+ ** create a pipe and make sure GetFileType returns the correct value
+ */
+
+ /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/
+ lpPipeAttributes.nLength = sizeof(lpPipeAttributes);
+ lpPipeAttributes.lpSecurityDescriptor = NULL;
+ lpPipeAttributes.bInheritHandle = TRUE;
+
+ /*Create a Pipe*/
+ bRetVal = CreatePipe(&hReadPipe, /* read handle*/
+ &hWritePipe, /* write handle */
+ &lpPipeAttributes, /* security attributes*/
+ 0); /* pipe size*/
+ if (bRetVal == FALSE)
+ {
+ Fail("ERROR: %u :Unable to create pipe.\n", GetLastError());
+ }
+
+ // Get the file type
+ dwFileType = GetFileType(hReadPipe);
+ if (dwFileType != FILE_TYPE_PIPE)
+ {
+ if (!CloseHandle(hWritePipe))
+ {
+ Trace("ERROR: %u : Unable to close write pipe handle "
+ "hWritePipe=0x%lx\n", GetLastError(), hWritePipe);
+ }
+ if (!CloseHandle(hReadPipe))
+ {
+ Trace("ERROR: %u : Unable to close read pipe handle "
+ "hReadPipe=0x%lx\n", GetLastError(), hReadPipe);
+ }
+ Fail("ERROR: GetFileType returned %u for a pipe instead of the "
+ "expected FILE_TYPE_PIPE (%u).\n",
+ dwFileType,
+ FILE_TYPE_PIPE);
+ }
+
+ /*Close write pipe handle*/
+ if (!CloseHandle(hWritePipe))
+ {
+ if (!CloseHandle(hReadPipe))
+ {
+ Trace("ERROR: %u : Unable to close read pipe handle "
+ "hReadPipe=0x%lx\n", GetLastError(), hReadPipe);
+ }
+ Fail("ERROR: %u : Unable to close write pipe handle "
+ "hWritePipe=0x%lx\n", GetLastError(), hWritePipe);
+ }
+
+ /*Close Read pipe handle*/
+ if (!CloseHandle(hReadPipe))
+ {
+ Fail("ERROR: %u : Unable to close read pipe handle "
+ "hReadPipe=0x%lx\n", GetLastError(), hReadPipe);
+ }
+
+ PAL_Terminate();
+ return (PASS);
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileType/test2/testinfo.dat
new file mode 100644
index 0000000..eb1361d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test2/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetFileType
+Name = Test for GetFileType
+TYPE = DEFAULT
+EXE1 = getfiletype
+Description
+= Test the PAL implementation of GetFileType to ensure it
+= recognizes opened pipes.
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt
new file mode 100644
index 0000000..52b6077
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ getfiletype.c
+)
+
+add_executable(paltest_getfiletype_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfiletype_test3 coreclrpal)
+
+target_link_libraries(paltest_getfiletype_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.c b/src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.c
new file mode 100644
index 0000000..6a95585
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.c
@@ -0,0 +1,72 @@
+// 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: getfiletype.c
+**
+** Purpose: Test the PAL implementation of the GetFileType on a handle
+** to a console.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ HANDLE hFile;
+#if WIN32
+ char *lpFileName = "CONIN$";
+#else
+ char *lpFileName = "/dev/null";
+#endif
+ DWORD dwFileType;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* get a handle to the console */
+ hFile = CreateFile(lpFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Fail("GetFileType: ERROR: CreateFile failed to open %s with "
+ "error %u.\n",
+ lpFileName,
+ GetLastError());
+ }
+
+ /* Get the file type */
+ if ((dwFileType = GetFileType(hFile)) != FILE_TYPE_CHAR)
+ {
+ if (!CloseHandle(hFile))
+ {
+ Trace("GetFileType: ERROR: %u : Unable to close the handle "
+ "hFile=0x%lx\n", GetLastError(), hFile);
+ }
+ Fail("GetFileType: ERROR: GetFileType returned %u for a device "
+ "instead of the expected FILE_TYPE_CHAR (%u).\n",
+ dwFileType,
+ FILE_TYPE_CHAR);
+ }
+
+ if (!CloseHandle(hFile))
+ {
+ Fail("GetFileType: ERROR: %u : Unable to close the handle "
+ "hFile=0x%lx\n", GetLastError(), hFile);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileType/test3/testinfo.dat
new file mode 100644
index 0000000..9ffd4c2
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFileType/test3/testinfo.dat
@@ -0,0 +1,13 @@
+# 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 = GetFileType
+Name = Test for GetFileTYpe
+TYPE = DEFAULT
+EXE1 = getfiletype
+Description
+= Test the PAL implementation of the GetFileType on a handle
+= to a console.
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 0000000..a3847f8
--- /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 0000000..8c10e47
--- /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 0000000..de9a266
--- /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 0000000..a4ccc95
--- /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 0000000..382b8fa
--- /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 0000000..95a1497
--- /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 0000000..b75f481
--- /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 0000000..f0f8929
--- /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 0000000..0cc39e7
--- /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 0000000..3991744
--- /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 0000000..cf0d7ff
--- /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 0000000..fb22c1f
--- /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 0000000..8a7b3b3
--- /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.
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/CMakeLists.txt
new file mode 100644
index 0000000..a3847f8
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/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/GetFullPathNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/CMakeLists.txt
new file mode 100644
index 0000000..a6f354f
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetFullPathNameW.c
+)
+
+add_executable(paltest_getfullpathnamew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamew_test1 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.c b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.c
new file mode 100644
index 0000000..592d3ad
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.c
@@ -0,0 +1,157 @@
+// 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: GetFullPathNameW.c (test 1)
+**
+** Purpose: Tests the PAL implementation of the GetFullPathNameW function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+const char* szFileName = "testing.tmp";
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ WCHAR szwReturnedPath[_MAX_DIR+1];
+ WCHAR szwShortBuff[2];
+ LPWSTR pPathPtr;
+ HANDLE hFile = NULL;
+ WCHAR* szwFileName = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ szwFileName = convert((char*)szFileName);
+
+ /* perform a short buffer test */
+ if (GetFullPathNameW(szwFileName, 2, szwShortBuff, &pPathPtr) <= 2)
+ {
+ free(szwFileName);
+ /* this test should have failed but didn't */
+ Fail("GetFullPathNameW: ERROR -> The API was passed a buffer that was"
+ " too small for the path name and yet it apparently passed.\n");
+ }
+
+
+ memset(szwReturnedPath, 0, _MAX_DIR+1);
+ dwRc = GetFullPathNameW(szwFileName,
+ _MAX_DIR,
+ szwReturnedPath,
+ &pPathPtr);
+
+ if (dwRc == 0)
+ {
+ /* this test should have passed but didn't */
+ free(szwFileName);
+ Fail("GetFullPathNameW: 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 = CreateFileW(szwFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ free(szwFileName);
+ Fail("GetFullPathNameW: ERROR -> CreateFileW failed to create "
+ "file \"%s\" with error code: %ld.\n",
+ szFileName,
+ GetLastError());
+ }
+ if (CloseHandle(hFile) != TRUE)
+ {
+ free(szwFileName);
+ Trace("GetFullPathNameW: ERROR -> CloseHandle failed with error "
+ "code: %ld.\n", GetLastError());
+ if (DeleteFileA(szFileName) != TRUE)
+ {
+ Trace("GetFullPathNameW: ERROR -> DeleteFileW failed to "
+ "delete the test file with error code: %ld.\n",
+ GetLastError());
+ }
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ /*
+ * 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 = CreateFileW(szwReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ Trace("GetFullPathNameW: ERROR -> CreateFileW was able to "
+ "CREATE_NEW the returned file \"%s\". The returned file "
+ "name is therefore apparently wrong.\n",
+ szwReturnedPath);
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Trace("GetFullPathNameW: ERROR -> CloseHandle failed with "
+ "error code: %ld.\n", GetLastError());
+ }
+ if ((DeleteFileW(szwReturnedPath) != TRUE) ||
+ (DeleteFileW(szwFileName) != TRUE))
+ {
+ Trace("GetFullPathNameW: ERROR -> DeleteFileW failed to "
+ "delete the test files with error code: %ld.\n",
+ GetLastError());
+ }
+ free(szwFileName);
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ /* now make sure the pPathPtr is the same as the file name */
+ if (wcsncmp(pPathPtr, szwFileName, wcslen(szwFileName)) != 0)
+ {
+ Trace("GetFullPathNameW: ERROR -> %s != %s\n",
+ pPathPtr, szFileName);
+ if ((DeleteFileW(szwReturnedPath) != TRUE) ||
+ (DeleteFileW(szwFileName) != TRUE))
+ {
+ Trace("GetFullPathNameW: ERROR -> DeleteFileW failed to "
+ "delete the test files with error code: %ld.\n",
+ GetLastError());
+ }
+ free(szwFileName);
+ PAL_TerminateEx(FAIL);
+ return FAIL;
+ }
+
+ /* clean up */
+ free(szwFileName);
+ if (DeleteFileA(szFileName) != TRUE)
+ {
+ Fail("GetFullPathNameW: ERROR -> DeleteFileW failed to "
+ "delete \"%s\" with error code: %ld.\n",
+ szFileName,
+ GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/testinfo.dat
new file mode 100644
index 0000000..4f70617
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/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 = file_io
+Function = GetFullPathNameW
+Name = Test for GetFullPathNameW (test 1)
+Type = DEFAULT
+EXE1 = getfullpathnamew
+Description
+= Get the full path for a file name and verify the results.
+= Also, attempt to call GetFullPathNameW with a buffer that is
+= too small for the returned path and verify the results.
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/CMakeLists.txt
new file mode 100644
index 0000000..199aa1e
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/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_getfullpathnamew_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamew_test2 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamew_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.c b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.c
new file mode 100644
index 0000000..fae042d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.c
@@ -0,0 +1,159 @@
+// 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 GetFullPathNameW function.
+** Get the full path for a file name and verify the results.
+** This test will use a relative path, containing '..\'. To
+** add to this test, we will also call SetCurrentDirectory to
+** ensure this is handled properly.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+WCHAR szwDotDot[] = {'.','.','\\','\0'};
+WCHAR szwFileName[] = {'t','e','s','t','i','n','g','.','t','m','p','\0'};
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+ WCHAR szwReturnedPath[_MAX_DIR+1];
+ WCHAR szwFullFileName[_MAX_DIR+1];
+ char *szReturnedPath;
+ char *szFileName;
+ LPWSTR pPathPtr;
+ HANDLE hFile = NULL;
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ /* change the directory */
+ if (!SetCurrentDirectoryW(szwDotDot))
+ {
+ Fail("ERROR: SetCurrentDirectoryW failed with error code %u"
+ " when passed \"%S\".\n",
+ GetLastError(),
+ szwDotDot);
+ }
+
+ /* Initialize the receiving char buffers.
+ */
+ memset(szwReturnedPath, 0, _MAX_DIR+1);
+ memset(szwFullFileName, 0, _MAX_DIR+1);
+
+ /* Create Full filename to pass, will include '..\'
+ * as a pre-fix. */
+ wcscat(szwFullFileName, szwDotDot);
+ wcscat(szwFullFileName, szwFileName);
+
+ /* Convert wide char strings to multibyte, to us
+ * incase of error messages.*/
+ szFileName = convertC(szwFileName);
+
+ /* Get the full path to the filename.
+ */
+ dwRc = GetFullPathNameW(szwFullFileName,
+ _MAX_DIR,
+ szwReturnedPath,
+ &pPathPtr);
+
+ szReturnedPath = convertC(szwReturnedPath);
+
+ if (dwRc == 0)
+ {
+ Trace("ERROR :%ld: Failed to get path to \"%s\".\n",
+ GetLastError(),
+ szReturnedPath);
+ free(szReturnedPath);
+ free(szFileName);
+ Fail("");
+ }
+
+ /*
+ * The returned value should be the parent directory with the
+ * file name appended.
+ */
+ hFile = CreateFileW(szwReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ Trace("ERROR :%ld: CreateFileW failed to create file \"%s\".\n",
+ GetLastError(),
+ szReturnedPath);
+ free(szFileName);
+ free(szReturnedPath);
+ Fail("");
+ }
+
+ /* Close the handle to the create file.*/
+ if (CloseHandle(hFile) != TRUE)
+ {
+ Trace("ERROR :%ld: Failed to close handle hFile=0x%lx.\n",
+ GetLastError(),
+ hFile);
+ goto terminate;
+ }
+
+ /* Verify that the file was created, attempt to create
+ * the file again. */
+ hFile = CreateFileW(szwReturnedPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if ((hFile != INVALID_HANDLE_VALUE) &&
+ (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ Trace("ERROR :%ld: CreateFileW succeeded to create file "
+ "\"%s\", that already existed.\n",
+ GetLastError(),
+ szReturnedPath);
+ goto terminate;
+ }
+
+ /* Verify that the returned filename is the same as the supplied.
+ */
+ if (wcsncmp(pPathPtr, szwFileName, wcslen(szwFileName)) != 0)
+ {
+ Trace("ERROR : Returned filename is not equal to \"%s\".\n",
+ szFileName);
+ goto terminate;
+ }
+
+terminate:
+ /* Delete the create file.
+ */
+ if (DeleteFileW(szwFullFileName) != TRUE)
+ {
+ Trace("ERROR :%ld: DeleteFileW failed to delete \"%s\".\n",
+ szFileName,
+ GetLastError());
+ free(szFileName);
+ free(szReturnedPath);
+ Fail("");
+ }
+
+ free(szFileName);
+ free(szReturnedPath);
+
+ /* Terminate the PAL.
+ */
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/testinfo.dat
new file mode 100644
index 0000000..b8460e0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/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 = GetFullPathNameW
+Name = Test for GetFullPathNameW (test 2)
+Type = DEFAULT
+EXE1 = test2
+Description
+= Get the full path for a file name and verify the results.
+= This test will use a relative path, containing '..\'. To
+= add to this test, we will also call SetCurrentDirectory to
+= ensure this is handled properly.
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/CMakeLists.txt
new file mode 100644
index 0000000..6284958
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/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_getfullpathnamew_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamew_test3 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamew_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.c b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.c
new file mode 100644
index 0000000..ba80cf2
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.c
@@ -0,0 +1,240 @@
+// 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 GetFullPathNameW API.
+** GetFullPathW 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,
+** DeleteFileW,
+** RemoveDirectory.
+**
+
+**
+**===================================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+#ifdef WIN32
+const WCHAR szSeperator[] = {'\\','\\','\0'};
+#else
+const WCHAR szSeperator[] = {'/','/','\0'};
+#endif
+
+const WCHAR szDotDot[] = {'.','.','\0'};
+const WCHAR szFileName[] = {'t','e','s','t','i','n','g','.','t','m','p','\0'};
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+
+ WCHAR szReturnedPath[_MAX_DIR+1];
+ WCHAR szFullFileName[_MAX_DIR+1];
+ WCHAR szDirectory[256];
+ WCHAR szCreatedDir[] = {'t','e','s','t','_','d','i','r','\0'};
+ WCHAR szCreatedNextDir[] = {'l','e','v','e','l','1','\0'};
+
+ LPWSTR 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 ( !SetCurrentDirectoryW(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.
+ */
+ wcscat(szDirectory, szCreatedDir); /* test_dir */
+
+
+ /* Create a test directory.
+ */
+ if (!CreateDirectoryW(szDirectory, NULL))
+ {
+ Fail("ERROR:%u: Unable to create directories \"%S\".\n",
+ GetLastError(),
+ szDirectory);
+ }
+
+ /* Create the path to the next level of directory to create.
+ */
+ wcscat(szDirectory, szSeperator); /* / */
+ wcscat(szDirectory, szCreatedNextDir); /* /level1 */
+
+ /* Create a test directory.
+ */
+ if (!CreateDirectoryW(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.
+ */
+ wcscat(szFullFileName, szCreatedDir); /*test_dir */
+ wcscat(szFullFileName, szSeperator); /*test_dir/ */
+ wcscat(szFullFileName, szCreatedNextDir);/*test_dir/level1 */
+ wcscat(szFullFileName, szSeperator); /*test_dir/level1/ */
+ wcscat(szFullFileName, szDotDot); /*test_dir/level1/.. */
+ wcscat(szFullFileName, szSeperator); /*test_dir/level1/../ */
+ wcscat(szFullFileName, szFileName); /*test_dir/level1/../testing.tmp */
+
+ /* Get the full path to the filename.
+ */
+ dwRc = GetFullPathNameW(szFullFileName,
+ _MAX_DIR,
+ szReturnedPath,
+ &pPathPtr);
+ if (dwRc == 0)
+ {
+ Trace("ERROR :%ld: GetFullPathNameW 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 = CreateFileW(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 = CreateFileW(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 (wcscmp(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 (DeleteFileW(szReturnedPath) != TRUE)
+ {
+ Fail("ERROR :%ld: DeleteFileA failed to delete \"%S\".\n",
+ GetLastError(),
+ szFileName);
+ }
+
+cleanUpTwo:
+
+ /* Remove the empty directory.
+ */
+ if (!RemoveDirectoryW(szDirectory))
+ {
+ Fail("ERROR:%u: Unable to remove directory \"%S\".\n",
+ GetLastError(),
+ szCreatedDir);
+ }
+
+cleanUpOne:
+
+ /* Remove the empty directory.
+ */
+ if (!RemoveDirectoryW(szCreatedDir))
+ {
+ Fail("ERROR:%u: Unable to remove directory \"%s\".\n",
+ GetLastError(),
+ szCreatedDir);
+ }
+
+ /* Terminate the PAL.*/
+ PAL_TerminateEx(bRetVal);
+ return bRetVal;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/testinfo.dat
new file mode 100644
index 0000000..1eb6a27
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/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 = GetFullPathNameW
+Name = Test for GetFullPathNameW
+Type = DEFAULT
+EXE1 = test3
+Description
+= Tests the PAL implementation of the GetFullPathNameW API.
+= GetFullPathW 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/GetFullPathNameW/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/CMakeLists.txt
new file mode 100644
index 0000000..d479b99
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/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_getfullpathnamew_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getfullpathnamew_test4 coreclrpal)
+
+target_link_libraries(paltest_getfullpathnamew_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.c b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.c
new file mode 100644
index 0000000..25eb10d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.c
@@ -0,0 +1,201 @@
+// 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 GetFullPathNameW API.
+** GetFullPathNameW 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,
+** DeleteFileW,
+** RemoveDirectory.
+**
+
+**
+**===================================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+#ifdef WIN32
+ const WCHAR szSeperator[] = {'\\','\\','\0'};
+#else
+ const WCHAR szSeperator[] = {'/','/','\0'};
+#endif
+
+const WCHAR szDotDot[] = {'.','.','\0'};
+const WCHAR szFileName[] = {'t','e','s','t','i','n','g','.','t','m','p','\0'};
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwRc = 0;
+
+ WCHAR szReturnedPath[_MAX_DIR+1];
+ WCHAR szFullFileName[_MAX_DIR+1];
+ WCHAR szDirectory[256];
+ WCHAR szCreatedDir[] = {'t','e','s','t','_','d','i','r','\0'};
+
+ LPWSTR 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.
+ */
+ wcscat(szDirectory, szDotDot); /* .. */
+ wcscat(szDirectory, szSeperator); /* ../ */
+ wcscat(szDirectory, szCreatedDir); /* ../test_directory */
+
+ /* Create a test directory.
+ */
+ if (!CreateDirectoryW(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.
+ */
+ wcscat( szFullFileName, szDotDot ); /* .. */
+ wcscat( szFullFileName, szSeperator ); /* ../ */
+ wcscat( szFullFileName, szCreatedDir ); /* ../test_directory */
+ wcscat( szFullFileName, szSeperator ); /* ../test_directory/ */
+ wcscat( szFullFileName, szFileName ); /* ../test_directory/testing.tmp */
+
+ /* Get the full path to the filename.
+ */
+ dwRc = GetFullPathNameW(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 = CreateFileW(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 = CreateFileW(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 (wcscmp(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 (DeleteFileW(szReturnedPath) != TRUE)
+ {
+ Fail("ERROR :%ld: DeleteFileA failed to delete \"%S\".\n",
+ GetLastError(),
+ szFileName);
+ }
+
+cleanUpOne:
+
+ /* Remove the empty directory.
+ */
+ if (!RemoveDirectoryW(szDirectory))
+ {
+ Fail("ERROR:%u: Unable to remove directory \"%s\".\n",
+ GetLastError(),
+ szCreatedDir);
+ }
+
+ /* Terminate the PAL.*/
+ PAL_TerminateEx(bRetVal);
+ return bRetVal;
+}
diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/testinfo.dat
new file mode 100644
index 0000000..8a7b3b3
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/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.
+
diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt
new file mode 100644
index 0000000..ef14ea5
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt
new file mode 100644
index 0000000..cf5dcd0
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ GetLongPathNameW.c
+)
+
+add_executable(paltest_getlongpathnamew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getlongpathnamew_test1 coreclrpal)
+
+target_link_libraries(paltest_getlongpathnamew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.c b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.c
new file mode 100644
index 0000000..22831dd
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.c
@@ -0,0 +1,280 @@
+// 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: GetLongPathNameW.c Win32 version(test 1)
+**
+** Purpose: Tests the PAL implementation of the GetLongPathNameW function.
+** as expected under Win32
+**
+** Depends on:
+** CreateDirectoryA
+** RemoveDirectoryW
+**
+**
+**===================================================================*/
+/*
+tests:
+ - test invalid path names
+ - test an already short path name
+ - test a long path name
+ - test with buffer size too small
+*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+/* Since GetLongPathNameW operates differently under FreeBSD and Win32 this test
+ is for Win32 only. It runs the same tests as the FreeBSD version but checks for
+ different results
+*/
+
+#if WIN32
+ DWORD dwRc = 0;
+ WCHAR szwReturnedPath[MAX_LONGPATH];
+ WCHAR szwSmallBuff[3];
+ const char szShortPathName[] = {"testing"};
+ const char szLongPathName[] = {"This_is_a_long_directory_name"};
+ const char szShortenedPathName[] = {"THIS_I~1"};
+ WCHAR* wLongPathPtr = NULL;
+ WCHAR* wShortPathPtr = NULL;
+
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR));
+ memset(szwSmallBuff, 0, 3*sizeof(WCHAR));
+ wLongPathPtr = convert((char*)szLongPathName);
+ wShortPathPtr = convert((char*)szShortenedPathName);
+
+ /* do some clean up just to be safe */
+ RemoveDirectoryW(wLongPathPtr);
+ RemoveDirectoryW(wShortPathPtr);
+
+
+ /* attempt call on an invalid short path name */
+ dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH);
+ if (dwRc != 0)
+ {
+ Trace("GetLongPathNameW: ERROR -> Call made with an invalid short "
+ "path \"%S\" returned \"%S\"\n",
+ wShortPathPtr,
+ szwReturnedPath);
+ free (wLongPathPtr);
+ free (wShortPathPtr);
+ Fail("");
+ }
+
+
+ /* attempt call on an invalid long path name */
+ dwRc = GetLongPathNameW(wLongPathPtr, szwReturnedPath, MAX_LONGPATH);
+ if (dwRc != 0)
+ {
+ Trace("GetLongPathNameW: ERROR -> Call made with an invalid long "
+ "path \"%S\" returned \"%S\"\n",
+ wLongPathPtr,
+ szwReturnedPath);
+ free (wLongPathPtr);
+ free (wShortPathPtr);
+ Fail("");
+ }
+
+
+ /* create a long directory name */
+ if (TRUE != CreateDirectoryW(wLongPathPtr, NULL))
+ {
+ free(wLongPathPtr);
+ free(wShortPathPtr);
+ Fail("GetLongPathNameW: ERROR -> CreateDirectoryW failed with an error"
+ " code of %ld when asked to create a directory called \"%s\".\n",
+ GetLastError(),
+ szLongPathName);
+ }
+
+
+ /* get the long path name */
+ memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR));
+ dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH);
+ if (dwRc == 0)
+ {
+ Trace("GetLongPathNameW: ERROR -> failed with an error"
+ " code of %ld when asked for the long version of \"%s\".\n",
+ GetLastError(),
+ szShortenedPathName);
+ if (RemoveDirectoryW(wLongPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wLongPathPtr,
+ GetLastError());
+ }
+ free(wLongPathPtr);
+ free(wShortPathPtr);
+ Fail("");
+ }
+
+ /* does the returned match the expected */
+ if (wcsncmp(wLongPathPtr, szwReturnedPath, wcslen(wLongPathPtr)) ||
+ (wcslen(wLongPathPtr) != wcslen(szwReturnedPath)))
+ {
+ if (RemoveDirectoryW(wLongPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wLongPathPtr,
+ GetLastError());
+ }
+ free(wLongPathPtr);
+ free(wShortPathPtr);
+ Fail("GetLongPathNameW: ERROR -> The returned path, \"%S\" doesn't "
+ "match the expected return, \"%s\".\n",
+ szwReturnedPath,
+ szLongPathName);
+ }
+
+ /* does the length returned match the actual length */
+ if (dwRc != wcslen(szwReturnedPath))
+ {
+ if (RemoveDirectoryW(wLongPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wLongPathPtr,
+ GetLastError());
+ }
+ free(wLongPathPtr);
+ free(wShortPathPtr);
+ Fail("GetLongPathNameW: ERROR -> The returned length, %ld, doesn't "
+ "match the string length, %ld.\n",
+ dwRc,
+ wcslen(szwReturnedPath));
+ }
+
+ if (RemoveDirectoryW(wLongPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wLongPathPtr,
+ GetLastError());
+ free(wShortPathPtr);
+ free(wLongPathPtr);
+ Fail("");
+ }
+ free(wShortPathPtr);
+ free(wLongPathPtr);
+
+
+ /* test an actual short name */
+ /* create a long directory name */
+ wShortPathPtr = convert((char*)szShortPathName);
+ RemoveDirectoryW(wShortPathPtr);
+
+ if (TRUE != CreateDirectoryW(wShortPathPtr, NULL))
+ {
+ Trace("GetLongPathNameW: ERROR -> CreateDirectoryW failed with an error"
+ " code of %ld when asked to create a directory called \"%s\".\n",
+ GetLastError(),
+ szShortPathName);
+ free(wShortPathPtr);
+ Fail("");
+ }
+
+
+ /* get the long path name */
+ memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR));
+ dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH);
+ if (dwRc == 0)
+ {
+ Trace("GetLongPathNameW: ERROR -> failed with an error"
+ " code of %ld when asked for the long version of \"%s\".\n",
+ GetLastError(),
+ szShortenedPathName);
+ if (RemoveDirectoryW(wShortPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wShortPathPtr,
+ GetLastError());
+ }
+ free(wShortPathPtr);
+ Fail("");
+ }
+
+ /* does the returned match the expected */
+ if (wcsncmp(wShortPathPtr, szwReturnedPath, wcslen(wShortPathPtr)) ||
+ (wcslen(wShortPathPtr) != wcslen(szwReturnedPath)))
+ {
+ if (RemoveDirectoryW(wShortPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wShortPathPtr,
+ GetLastError());
+ }
+ free(wShortPathPtr);
+ Fail("GetLongPathNameW: ERROR -> The returned path, \"%S\" doesn't "
+ "match the expected return, \"%s\".\n",
+ szwReturnedPath,
+ szShortPathName);
+ }
+
+ /* does the length returned match the actual length */
+ if (dwRc != wcslen(szwReturnedPath))
+ {
+ if (RemoveDirectoryW(wShortPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wShortPathPtr,
+ GetLastError());
+ }
+ free(wShortPathPtr);
+ Fail("GetLongPathNameW: ERROR -> The returned length, %ld, doesn't "
+ "match the string length, %ld.\n",
+ dwRc,
+ wcslen(szwReturnedPath));
+ }
+
+ /* test using a too small return buffer */
+ dwRc = GetLongPathNameW(wShortPathPtr, szwSmallBuff, 3);
+ if ((dwRc != (strlen(szShortPathName)+1)) || /* +1 for the required NULL */
+ szwSmallBuff[0] != '\0')
+ {
+ if (RemoveDirectoryW(wShortPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wShortPathPtr,
+ GetLastError());
+ }
+ free(wShortPathPtr);
+ Fail("GetLongPathNameW: ERROR -> using a return buffer that was too"
+ " small was not handled properly.\n");
+ }
+
+ if (RemoveDirectoryW(wShortPathPtr) != TRUE)
+ {
+ Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to "
+ " remove the directory \"%S\" with an error code of %ld.\n",
+ wShortPathPtr,
+ GetLastError());
+ free(wShortPathPtr);
+ Fail("");
+ }
+ free(wShortPathPtr);
+
+ PAL_Terminate();
+
+#endif /* WIN32 */
+
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/testinfo.dat
new file mode 100644
index 0000000..f730300
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/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 = file_io
+Function = GetLongPathNameW
+Name = Test for GetLongPathNameW Win32 (test 1)
+Type = DEFAULT
+EXE1 = getlongpathnamew
+Description
+= Tests invalid path names. Tests conversion of short to long
+= path names as well as passing it a path name that is already short.
+= Under BSD, there isn't a shortened version of directory names so
+= I just use a long path name as the short path name to ensure it returns
+= the same thing.
diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/CMakeLists.txt
new file mode 100644
index 0000000..5746ef3
--- /dev/