summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/CMakeLists.txt10
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/LockFile.h152
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/CMakeLists.txt32
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/helper.cpp86
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/test1.cpp140
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/CMakeLists.txt17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/test2.cpp94
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/CMakeLists.txt32
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/helper.cpp102
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/test3.cpp71
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/CMakeLists.txt17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/test4.cpp231
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/CMakeLists.txt32
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/helper.cpp122
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/test5.cpp161
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/CMakeLists.txt32
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/helper.cpp71
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/test6.cpp146
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/CMakeLists.txt17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/test7.cpp135
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/UnlockFile.h112
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/CMakeLists.txt32
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/helper.cpp92
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/test1.cpp154
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/CMakeLists.txt17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/test2.cpp154
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/CMakeLists.txt32
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/helper.cpp103
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/test3.cpp142
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/CMakeLists.txt17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/test4.cpp187
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/testinfo.dat16
44 files changed, 0 insertions, 2920 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt
index a573dae8cd..4f996bded0 100644
--- a/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt
+++ b/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt
@@ -13,13 +13,11 @@ add_subdirectory(HeapFree)
add_subdirectory(HeapReAlloc)
add_subdirectory(LocalAlloc)
add_subdirectory(LocalFree)
-add_subdirectory(LockFile)
add_subdirectory(MapViewOfFile)
add_subdirectory(OpenFileMappingA)
add_subdirectory(OpenFileMappingW)
add_subdirectory(ProbeMemory)
add_subdirectory(RtlMoveMemory)
-add_subdirectory(UnlockFile)
add_subdirectory(UnmapViewOfFile)
add_subdirectory(VirtualAlloc)
add_subdirectory(VirtualFree)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/CMakeLists.txt
deleted file mode 100644
index 19ee487a6a..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-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/filemapping_memmgt/LockFile/LockFile.h b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/LockFile.h
deleted file mode 100644
index 2862b6c524..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/LockFile.h
+++ /dev/null
@@ -1,152 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: LockFile.h
-**
-** Purpose: This header file has a RunHelper method which will be used to
-** start a child proccess in many LockFile testcases. The CreateAndLockFile
-** method Creates a file and calls LockFile upon it. And the two Signal
-** methods are used for IPC.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-
-int RunHelper(char* Helper)
-{
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- DWORD RetCode;
-
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
-
- if(!CreateProcess( NULL,Helper,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
- {
- Fail("ERROR: CreateProcess failed to load executable '%s'.",Helper);
- }
-
- if(WaitForSingleObject( pi.hProcess, INFINITE ) == WAIT_FAILED)
- {
- Fail("ERROR: WaitForSingleObject returned WAIT_FAILED when it was "
- "called.");
- }
-
- /* Get the return value from the helper process */
- if (GetExitCodeProcess(pi.hProcess, &RetCode) == 0)
- {
- Fail("ERROR: GetExitCodeProccess failed when attempting to retrieve "
- "the exit code of the child process.");
- }
-
- if(CloseHandle( pi.hProcess ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the process.");
- }
-
- if(CloseHandle( pi.hThread ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the thread.");
- }
-
- return RetCode;
-}
-
-HANDLE CreateAndLockFile(HANDLE TheFile, char* FileName, char* WriteBuffer,
- DWORD LockStart, DWORD LockLength)
-{
- DWORD BytesWritten;
-
- TheFile = CreateFile(FileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.",FileName,GetLastError());
- }
-
- if(WriteFile(TheFile, WriteBuffer,
- strlen(WriteBuffer),&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile has failed. It returned 0 when we "
- "attempted to write to the file '%s'. GetLastError() "
- "returned %d.",FileName,GetLastError());
- }
-
- if(FlushFileBuffers(TheFile) == 0)
- {
- Fail("ERROR: FlushFileBuffers returned failure. GetLastError() "
- "returned %d.",GetLastError());
- }
-
- if(LockFile(TheFile, LockStart, 0, LockLength, 0) == 0)
- {
- Fail("ERROR: LockFile failed. GetLastError returns %d.",
- GetLastError());
- }
-
- return TheFile;
-}
-
-void SignalAndBusyWait(HANDLE TheFile)
-{
- int size;
- DWORD BytesWritten;
-
- size = GetFileSize(TheFile,NULL)+1;
-
- if(SetFilePointer(TheFile, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
- {
- Fail("ERROR: SetFilePointer was unable to set the pointer to the "
- "end of the file. GetLastError() returned %d.",GetLastError());
- }
-
- if(WriteFile(TheFile, "x", 1,&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile was unable to write to the WaitFile. "
- "GetLastError() returned %d.",GetLastError());
- }
-
- if(FlushFileBuffers(TheFile) == 0)
- {
- Fail("ERROR: FlushFileBuffers failed when flushing the WaitFile. "
- "GetLastError() returned %d.");
- }
-
- while(GetFileSize(TheFile,NULL) == size) { Sleep(100); }
-}
-
-void SignalFinish(HANDLE TheFile)
-{
- DWORD BytesWritten;
-
- if(SetFilePointer(TheFile, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
- {
- Fail("ERROR: SetFilePointer was unable to set the pointer to the "
- "end of the WaitFile. GetLastError() returned %d.",
- GetLastError());
- }
-
- if(WriteFile(TheFile, "x", 1,&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile was unable to write to the WaitFile. "
- "GetLastError returned %d.",GetLastError());
- }
-
- if(FlushFileBuffers(TheFile) == 0)
- {
- Fail("ERROR: FlushFileBuffers failed when flushing the WaitFile. "
- "GetLastError() returned %d.");
- }
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/CMakeLists.txt
deleted file mode 100644
index a9b8869c37..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(TESTSOURCES
- test1.cpp
-)
-
-add_executable(paltest_lockfile_test1
- ${TESTSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test1 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test1
- ${COMMON_TEST_LIBRARIES}
-)
-
-
-set(HELPERSOURCES
- helper.cpp
-)
-
-add_executable(paltest_lockfile_test1_helper
- ${HELPERSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test1_helper coreclrpal)
-
-target_link_libraries(paltest_lockfile_test1_helper
- ${COMMON_TEST_LIBRARIES}
-) \ No newline at end of file
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/helper.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/helper.cpp
deleted file mode 100644
index 05b4b8451a..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/helper.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: helper.c
-**
-** Purpose: A child process which will attempt to read and write to files
-** which were locked in the parent.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-
-#define BUF_SIZE 128
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile;
- int result = 0;
- char DataBuffer[BUF_SIZE];
- DWORD BytesRead, BytesWritten;
- char fileName[] = "testfile.tmp";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open the same file that the parent has opened and locked */
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile.",fileName);
- }
-
- /* Attempt to Read 5 bytes from this file. Since it is locked, this
- should fail.
- */
-
- if(ReadFile(TheFile, DataBuffer, 5, &BytesRead, NULL) != 0)
- {
- Trace("ERROR: ReadFile should have failed! It was called on "
- "a locked file. But, it returned non-zero indicating success.");
- result = 1;
- }
-
- /* Attempt to Write 5 bytes to this file. Since it is locked this should
- fail.
- */
-
- memset(DataBuffer,'X',BUF_SIZE);
-
- if(WriteFile(TheFile, DataBuffer, 5,&BytesWritten, NULL) != 0)
- {
- Trace("ERROR: WriteFile should have failed! It was called on "
- "a locked file. But, it returned non-zero indicating success.");
- result = 1;
- }
-
- /* Check to ensure that the number of Bytes read/written is still 0,
- since nothing should have been read or written.
- */
-
- if(BytesRead != 0 || BytesWritten !=0)
- {
- Trace("ERROR: The number of bytes read is %d and written is %d. "
- "These should both be 0, as the file was locked.",
- BytesRead,BytesWritten);
- result = 1;
- }
-
- PAL_TerminateEx(result);
- return result;
-}
-
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/test1.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/test1.cpp
deleted file mode 100644
index cee223ef81..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/test1.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test1.c
-**
-** Purpose: Open a file, and lock it from start to EOF. Then create a
-** new process, which will attempt to Read and Write from the file. Check
-** to ensure both of these operations fail.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-#define HELPER "helper"
-
-int __cdecl main(int argc, char *argv[])
-{
-
- HANDLE TheFile;
- DWORD FileStart = 0;
- DWORD FileEnd = 0;
- const char lpBuffer[] = "This is a test file.";
- DWORD bytesWritten;
- BOOL bRc = TRUE;
- char fileName[] = "testfile.tmp";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Important to have sharing enabled, or there is no need for the lock. */
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile.",fileName);
- }
-
- bRc = WriteFile(TheFile,
- lpBuffer,
- (DWORD)sizeof(lpBuffer),
- &bytesWritten,
- NULL);
-
- if(!bRc)
- {
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
-
- Fail("ERROR: Could not write to file '%s' with WriteFile.",fileName);
- }
- else if(bytesWritten != (DWORD)sizeof(lpBuffer))
- {
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
-
- Fail("ERROR: Could not write the correct number of bytes to the "
- "file '%s' with WriteFile.",fileName);
- }
-
- /* Find the value for the End of the file */
- FileEnd = SetFilePointer(TheFile,0,NULL,FILE_END);
-
- if(FileEnd == INVALID_SET_FILE_POINTER)
- {
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
-
- Fail("ERROR: Could not set the file pointer to the end of the file "
- "using SetFilePointer. It returned INVALID_SET_FILE_POINTER.");
- }
-
- /* Lock the file from Start to EOF */
-
- if(LockFile(TheFile, FileStart, 0, FileEnd, 0) == 0)
- {
- Trace("ERROR: LockFile failed. GetLastError returns %d.",
- GetLastError());
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Launch another process, which will attempt to read and write from
- the locked file.
-
- If the helper program returns 1, then the test fails. More
- specific errors are given by the Helper file itself.
- */
- if(RunHelper(HELPER))
- {
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
-
- Fail("ERROR: The Helper program determined that the file was not "
- "locked properly by LockFile.");
- }
-
- if(UnlockFile(TheFile, FileStart, 0, FileEnd, 0) == 0)
- {
- Trace("ERROR: UnlockFile failed. GetLastError returns %d.",
- GetLastError());
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/testinfo.dat
deleted file mode 100644
index cbe4d94d40..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test1/testinfo.dat
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Positive test for LockFile API
-TYPE = DEFAULT
-EXE1 = test1
-EXE2 = helper
-Description
-= Open a file, and lock it from start to EOF. Then create a
-= new process, which will attempt to Read and Write from the file. Check
-= to ensure both of these operations fail.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/CMakeLists.txt
deleted file mode 100644
index 42e88c5999..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test2.cpp
-)
-
-add_executable(paltest_lockfile_test2
- ${SOURCES}
-)
-
-add_dependencies(paltest_lockfile_test2 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test2
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/test2.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/test2.cpp
deleted file mode 100644
index 8aef130ef4..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/test2.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test2.c
-**
-** Purpose: Open a file, and lock it from start to EOF. Check to ensure
-** the current process can still read and write from/to the file.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-#define FILENAME "testfile.txt"
-
-int __cdecl main(int argc, char *argv[])
-{
-
- HANDLE TheFile = NULL;
- DWORD FileStart = 0;
- DWORD FileEnd = 0;
- DWORD BytesWritten = 0;
- DWORD BytesRead = 0;
- char WriteBuffer[] = "This is some test data.";
- char DataBuffer[128];
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file.
- */
-
- FileEnd = strlen(WriteBuffer);
- TheFile = CreateAndLockFile(TheFile, FILENAME, WriteBuffer,
- FileStart, FileEnd);
-
- /* Move the file pointer to the start of the file */
- if(SetFilePointer(TheFile, 0, NULL, FILE_BEGIN) != 0)
- {
- Fail("ERROR: SetFilePointer failed to move the file pointer back "
- "to the start of the file.");
- }
-
- /* Attempt to Read 5 bytes from this file. Since the lock does not
- affect the calling process, this should succeed.
- */
-
- if(ReadFile(TheFile, DataBuffer, 5, &BytesRead, NULL) == 0)
- {
- Fail("ERROR: ReadFile has failed. Attempted to read in 5 bytes from "
- "the file '%s' after it had LockFile called upon it, but within "
- "the same process.",FILENAME);
- }
-
- if(strncmp(DataBuffer, WriteBuffer, 5) != 0)
- {
- Fail("ERROR: The data read in from ReadFile is not what should have "
- "been written in the file. '%s' ",DataBuffer);
- }
-
- /* Attempt to Write 5 bytes to this file. Since the lock does not affect
- the calling process, this should succeed.
- */
-
- memset(WriteBuffer, 'X', strlen(WriteBuffer));
-
- if(WriteFile(TheFile, WriteBuffer, 5,&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile has failed. Attempted to write 5 bytes to "
- "the file '%s' after it had LockFile called upon it, but within "
- "the same process.",FILENAME);
- }
-
- if(UnlockFile(TheFile, FileStart, 0, FileEnd, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed. GetLastError returns %d.",
- GetLastError());
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/testinfo.dat
deleted file mode 100644
index c84e7c0a0a..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test2/testinfo.dat
+++ /dev/null
@@ -1,13 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Positive test for LockFile API
-TYPE = DEFAULT
-EXE1 = test2
-Description
-= Open a file, and lock it from start to EOF. Check to ensure
-= the current process can still read and write from/to the file.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/CMakeLists.txt
deleted file mode 100644
index 299e8cf76c..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(TESTSOURCES
- test3.cpp
-)
-
-add_executable(paltest_lockfile_test3
- ${TESTSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test3 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test3
- ${COMMON_TEST_LIBRARIES}
-)
-
-
-set(HELPERSOURCES
- helper.cpp
-)
-
-add_executable(paltest_lockfile_test3_helper
- ${HELPERSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test3_helper coreclrpal)
-
-target_link_libraries(paltest_lockfile_test3_helper
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/helper.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/helper.cpp
deleted file mode 100644
index 079417fce8..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/helper.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: helper.c
-**
-** Purpose: A child process which will attempt to read and write to files
-** which were locked in the parent.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-
-#define FILENAME "testfile.txt"
-#define BUF_SIZE 128
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile;
- int result = 0;
- char DataBuffer[BUF_SIZE];
- DWORD BytesRead, BytesWritten;
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open the same file that the parent has opened and locked */
- TheFile = CreateFile(FILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returns %d.",FILENAME,GetLastError());
- }
-
- /* Attempt to Read the first 3 bytes from this file.
- Since it is unlocked, this should work properly.
- */
-
- if(ReadFile(TheFile, DataBuffer, 3, &BytesRead, NULL) == 0)
- {
- Trace("ERROR: ReadFile should have succeeded in reading the first "
- "three bytes of the file, as these bytes were not locked. "
- "GetLastError() returned %d.",GetLastError());
- result = 1;
- }
-
- /* Now, read the next 10 bytes, which should be locked. Ensure that
- ReadFile fails.
- */
-
- if(ReadFile(TheFile, DataBuffer,10, &BytesRead, NULL) != 0)
- {
- Trace("ERROR: ReadFile should have failed when attempting to read in "
- "bytes between StartOfFile+3 and EndOfFile-3.");
- result = 1;
- }
-
- /* Attempt to Write 10 bytes to this file. Since it is locked this should
- fail.
- */
-
- memset(DataBuffer,'X',BUF_SIZE);
-
- if(WriteFile(TheFile, DataBuffer, 10,&BytesWritten, NULL) != 0)
- {
- Trace("ERROR: WriteFile should have failed when attempting to write "
- "bytes between StartOfFile+3 and EOF-3.");
- result = 1;
- }
-
-
- /* Move the FilePointer to the EOF-3, where the lock ends */
- if(SetFilePointer(TheFile,-3,NULL,FILE_END) == INVALID_SET_FILE_POINTER)
- {
- Fail("ERROR: Could not set the file pointer to the EOF-3 "
- "using SetFilePointer. It returned INVALID_SET_FILE_POINTER.");
- }
-
- /* Attempt to write to those 3 unlocked bytes on the end of the file */
- if(WriteFile(TheFile, DataBuffer, 3,&BytesWritten, NULL) == 0)
- {
- Trace("ERROR: WriteFile should have succeeded when attempting "
- "to write the last three bytes of the file, as they were not "
- "locked. GetLastError() returned %d.",GetLastError());
- result = 1;
- }
-
- PAL_TerminateEx(result);
- return result;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/test3.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/test3.cpp
deleted file mode 100644
index 78662c5685..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/test3.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test3.c
-**
-** Purpose: Open a file, lock a region in the middle. Create a new process
-** and attempt to read and write directly before and after that region, which
-** should succeed. Also, check to see that reading/writing in the locked
-** region fails.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-#define HELPER "helper"
-#define FILENAME "testfile.txt"
-
-int __cdecl main(int argc, char *argv[])
-{
-
- HANDLE TheFile = NULL;
- DWORD FileStart = 0;
- DWORD FileEnd = 0;
- char* WriteBuffer = "12345678901234567890123456";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file.
- */
-
- FileEnd = strlen(WriteBuffer);
- TheFile = CreateAndLockFile(TheFile,FILENAME, WriteBuffer,
- FileStart+3, FileEnd-6);
-
-
- /* Launch another process, which will attempt to read and write from
- the locked file.
-
- If the helper program returns 1, then the test fails. More
- specific errors are given by the Helper file itself.
- */
- if(RunHelper(HELPER))
- {
- Fail("ERROR: The Helper program determined that the file was not "
- "locked properly by LockFile.");
- }
-
- if(UnlockFile(TheFile, FileStart+3, 0, FileEnd-6, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed. GetLastError returns %d.",
- GetLastError());
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file. "
- "GetLastError() returned %d.",GetLastError());
- }
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/testinfo.dat
deleted file mode 100644
index b64ec5ed03..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test3/testinfo.dat
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Positive test for LockFile API
-TYPE = DEFAULT
-EXE1 = test3
-EXE2 = helper
-Description
-= Open a file, lock a region in the middle. Create a new process
-= and attempt to read and write directly before and after that region, which
-= should succeed. Also, check to see that reading/writing in the locked
-= region fails.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/CMakeLists.txt
deleted file mode 100644
index 55cf9c64f7..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test4.cpp
-)
-
-add_executable(paltest_lockfile_test4
- ${SOURCES}
-)
-
-add_dependencies(paltest_lockfile_test4 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test4
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/test4.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/test4.cpp
deleted file mode 100644
index f5cd359fb5..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/test4.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test4.c
-**
-** Purpose:
-** - Attempt to call LockFile on a file without GENERIC_READ or
-** GENERIC_WRITE (this should fail)
-** - Attempt to overlap two locks, this should fail.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-
-char fileName[] = "testfile.tmp";
-
-void OverlapTest()
-{
- HANDLE TheFile = NULL;
- DWORD FileStart = 0;
- const char lpBuffer[] = "This is a test file.";
- DWORD bytesWritten;
- BOOL bRc = TRUE;
-
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.",fileName,GetLastError());
- }
-
- bRc = WriteFile(TheFile,
- lpBuffer,
- (DWORD)sizeof(lpBuffer),
- &bytesWritten,
- NULL);
-
- if(!bRc)
- {
- Trace("ERROR: Could not write to file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
-
- }
- else if(bytesWritten != (DWORD)sizeof(lpBuffer))
- {
- Trace("ERROR: Could not write the correct number of bytes to the "
- "file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Lock the First 5 bytes of the File */
-
- if(LockFile(TheFile, FileStart, 0, 5, 0) == 0)
- {
- Trace("ERROR: LockFile failed in Overlap test. "
- "GetLastError returns %d.",
- GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Lock from Byte 2 until 7 -- this overlaps and should return failure. */
- if(LockFile(TheFile,FileStart+2, 0, 5, 0) != 0)
- {
- Trace("ERROR: LockFile returned success when it was overlapped on "
- "an already locked region of the file.");
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Unlock the file */
- if(UnlockFile(TheFile, FileStart, 0, 5, 0) == 0)
- {
- Trace("ERROR: UnlockFile failed in Overlap test. GetLastError "
- "returns %d.",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Close the File */
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file in the Overlap "
- "test. GetLastError() returned %d.",GetLastError());
- }
-}
-
-void FlagsTest(DWORD TheFlags, int ExpectedResult)
-{
- HANDLE TheFile = NULL;
- DWORD FileStart = 0;
- int result;
-
- TheFile = CreateFile(fileName,
- TheFlags,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.",fileName,GetLastError());
- }
-
- /* Lock the First 5 bytes of the File. The result of this depends
- upon which flags were set with the CreateFile.
- */
-
- result = LockFile(TheFile, FileStart, 0, 5, 0);
-
- /* If the expected result is 1, check to ensure the result is non-zero,
- as non-zero is returned on success
- */
- if(ExpectedResult == 1)
- {
- if(result == 0)
- {
- Trace("ERROR: LockFile returned zero when the expected result "
- "was non-zero. It was passed the flag value %d.",
- TheFlags);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
- }
- /* If the expected result is 0, check to ensure the result is 0 */
- else
- {
- if(result != 0)
- {
- Trace("ERROR: LockFile returned %d when the expected result "
- "was zero. It was passed the flag value %d.",
- result, TheFlags);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
- }
-
- /* Only unlock the file if we expect it to be successfully locked */
- if(ExpectedResult)
- {
- if(UnlockFile(TheFile,FileStart,0, 5, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed in the Flags Test. GetLastError() "
- "returned %d.",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
- }
-
- /* Close the File */
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file in the Flags "
- "test. GetLastError() returned %d.",GetLastError());
- }
-}
-
-int __cdecl main(int argc, char *argv[])
-{
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* This test opens a file, then calls lock twice, overlapping the
- regions and checking to ensure that this causes an error.
- */
- OverlapTest();
-
- /* Test that LockFile fails if no flags are set */
- FlagsTest(0,0);
-
- /* Test that LockFile passes if only GENERIC_READ is set */
- FlagsTest(GENERIC_READ,1);
-
- /* Test that LockFile passes if only GENERIC_WRITE is set */
- FlagsTest(GENERIC_WRITE,1);
-
- PAL_Terminate();
- return PASS;
-}
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/testinfo.dat
deleted file mode 100644
index 0600260d82..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test4/testinfo.dat
+++ /dev/null
@@ -1,14 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Negative test for LockFile API
-TYPE = DEFAULT
-EXE1 = test4
-Description
-= - Attempt to call LockFile on a file without GENERIC_READ or
-= GENERIC_WRITE (this should fail)
-= - Attempt to overlap two locks, this should fail.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/CMakeLists.txt
deleted file mode 100644
index 82a174907e..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(TESTSOURCES
- test5.cpp
-)
-
-add_executable(paltest_lockfile_test5
- ${TESTSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test5 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test5
- ${COMMON_TEST_LIBRARIES}
-)
-
-
-set(HELPERSOURCES
- helper.cpp
-)
-
-add_executable(paltest_lockfile_test5_helper
- ${HELPERSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test5_helper coreclrpal)
-
-target_link_libraries(paltest_lockfile_test5_helper
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/helper.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/helper.cpp
deleted file mode 100644
index 1fc9b1a9a5..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/helper.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: helper.c
-**
-** Purpose: A child process which will attempt to read and write to files
-** which were locked in the parent. It will also lock another region of the
-** same file.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-#define FILENAME "testfile.txt"
-#define WAITFILENAME "waitfile"
-#define BUF_SIZE 128
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile, WaitFile;
- int result = 0;
- char DataBuffer[BUF_SIZE];
- DWORD BytesRead;
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open the same file that the parent has opened and locked */
- TheFile = CreateFile(FILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile.",FILENAME);
- result = 1;
- }
-
- /* Open up the WaitFile that we're using for IPC */
- WaitFile = CreateFile(WAITFILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (WaitFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.",WAITFILENAME,GetLastError());
- result = 1;
- }
-
- /* Lock the same file that the parent process locked, but the child
- locks bytes 11 through 20
- */
-
- if(LockFile(TheFile, 11, 0, 10, 0) == 0)
- {
- Trace("ERROR: LockFile failed in the child proccess. "
- "GetLastError returns %d.",
- GetLastError());
- result = 1;
- }
-
- /* Check to ensure the parent lock is respected */
- if(ReadFile(TheFile, DataBuffer, 10, &BytesRead, NULL) != 0)
- {
- Trace("ERROR: ReadFile returned success when it should "
- "have failed. Attempted to read the first 10 bytes "
- "of a file which was locked by the parent process.");
- result = 1;
- }
-
- /* Check to ensure the lock put on by this proccess doesn't restrict
- access
- */
-
- if(SetFilePointer(TheFile, 11, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
- {
- Trace("ERROR: SetFilePointer was unable to move the file pointer to "
- "the 11th byte in the file, within the child proccess. "
- "GetLastError() returned %d.",GetLastError());
- result = 1;
- }
-
- if(ReadFile(TheFile, DataBuffer, 10, &BytesRead, NULL) == 0)
- {
- Trace("ERROR: ReadFile failed when attempting to read a section of "
- "the file which was locked by the current process. It should "
- "have been able to read this. GetLastError() returned %d.",
- GetLastError());
- result = 1;
- }
-
- // Sleep for a bit to give the parent a chance to block before we do.
- Sleep(1000);
-
- /* Switch back to the parent, so it can check the child's locks */
- SignalAndBusyWait(WaitFile);
-
- if(UnlockFile(TheFile, 11, 0, 10, 0) == 0)
- {
- Fail("ERROR: Failed to Unlock bytes 11-20 in the file. "
- "GetLastError returned %d.",GetLastError());
- }
-
- PAL_TerminateEx(result);
- return result;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/test5.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/test5.cpp
deleted file mode 100644
index a02a3c5a49..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/test5.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test5.c
-**
-** Purpose:
-** Have two processes obtain a lock on a single file, but in different
-** regions of the file. Use Read/Write to ensure the locks are respected.
-** This requires some IPC, which is done here with a crude busy wait on a
-** file (waiting for the file size to change) to avoid too many more
-** dependencies.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-#define HELPER "helper"
-#define FILENAME "testfile.txt"
-#define WAITFILENAME "waitfile"
-#define BUF_SIZE 128
-
-int RunTest(char* Helper, HANDLE TheFile, HANDLE WaitFile)
-{
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- DWORD ChildRetCode = 0;
- DWORD ParentRetCode = 0;
- DWORD BytesRead;
- char DataBuffer[BUF_SIZE];
-
-
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
-
- /* Load up the helper Process, and then Wait until it signals that it
- is finished locking.
- */
- if(!CreateProcess( NULL,Helper,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
- {
- Fail("ERROR: CreateProcess failed to load executable '%s'.",Helper);
- }
-
- SignalAndBusyWait(WaitFile);
-
- /* Now the child proccess has locked another section of the file, from
- bytes 11 through 20. Let's check that the parent lock is still ignored
- by the parent proccess and that the child's lock is respected.
- */
-
- if(ReadFile(TheFile, DataBuffer, 10, &BytesRead, NULL) == 0)
- {
- Trace("ERROR: ReadFile failed when attempting to read a section of "
- "the file which was locked by the current process. It should "
- "have been able to read this. GetLastError() returned %d.",
- GetLastError());
- ParentRetCode = 1;
- }
-
- SetFilePointer(TheFile, 11, 0, FILE_BEGIN);
-
- if(ReadFile(TheFile, DataBuffer, 10, &BytesRead, NULL) != 0)
- {
- Trace("ERROR: ReadFile returned success when it should "
- "have failed. Attempted to read 10 bytes of the file which "
- "were locked by the child.");
- ParentRetCode = 1;
- }
-
- /* We're finished testing. Let the child proccess know so it can clean
- up, and the parent will wait until it is done.
- */
- SignalFinish(WaitFile);
- WaitForSingleObject(pi.hProcess,INFINITE);
-
- /* Get the return value from the helper process */
- if (GetExitCodeProcess(pi.hProcess, &ChildRetCode) == 0)
- {
- Fail("ERROR: GetExitCodeProccess failed when attempting to retrieve "
- "the exit code of the child process.");
- }
-
- if(CloseHandle( pi.hProcess ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the process.");
- }
-
- if(CloseHandle( pi.hThread ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the thread.");
- }
-
- return (ChildRetCode || ParentRetCode);
-}
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile = NULL;
- HANDLE WaitFile = NULL;
- char* WriteBuffer = "12345678901234567890123456";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open up the file we'll be using for some crude IPC */
- WaitFile = CreateFile(WAITFILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (WaitFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.",WAITFILENAME,GetLastError());
- }
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file from bytes 0 to 10.
- */
- TheFile = CreateAndLockFile(TheFile, FILENAME, WriteBuffer,
- 0, 10);
-
- /* Run the test. Better errors are displayed by Trace throughout. */
- if(RunTest(HELPER, TheFile, WaitFile))
- {
- Fail("ERROR: Attempting to have two processes lock different "
- "sections of the same file has failed.");
- }
-
- /* Unlock the first 10 bytes which were locked by the parent proccess */
- if(UnlockFile(TheFile, 0, 0, 10, 0) == 0)
- {
- Fail("ERROR: Failed to Unlock the first 10 bytes of the file. "
- "GetLastError returned %d.",GetLastError());
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file used for "
- "testing the locks. GetLastError() returns %d.",GetLastError());
- }
-
- if(CloseHandle(WaitFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the wait file. "
- "GetLastError() returns %d.",GetLastError());
- }
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/testinfo.dat
deleted file mode 100644
index f020933cd9..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test5/testinfo.dat
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Positive test for LockFile API
-TYPE = DEFAULT
-EXE1 = test5
-EXE2 = helper
-Description
-= Have two processes obtain a lock on a single file, but in different
-= regions of the file. Use Read/Write to ensure the locks are respected.
-= This requires some IPC, which is done here with a crude busy wait on a
-= file (waiting for the file size to change) to avoid too many more
-= dependencies.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/CMakeLists.txt
deleted file mode 100644
index fc5f90113e..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(TESTSOURCES
- test6.cpp
-)
-
-add_executable(paltest_lockfile_test6
- ${TESTSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test6 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test6
- ${COMMON_TEST_LIBRARIES}
-)
-
-
-set(HELPERSOURCES
- helper.cpp
-)
-
-add_executable(paltest_lockfile_test6_helper
- ${HELPERSOURCES}
-)
-
-add_dependencies(paltest_lockfile_test6_helper coreclrpal)
-
-target_link_libraries(paltest_lockfile_test6_helper
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/helper.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/helper.cpp
deleted file mode 100644
index 98112fc4a5..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/helper.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: helper.c
-**
-** Purpose: A child process which will attempt to append to the end of
-** a locked file.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-
-#define FILENAME "testfile.txt"
-#define BUF_SIZE 128
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile;
- int result = 0;
- char DataBuffer[BUF_SIZE];
- DWORD BytesWritten;
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open the same file that the parent has opened and locked */
- TheFile = CreateFile(FILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returns %d.",FILENAME,GetLastError());
- result = -1;
- }
-
-
- /* Move the FilePointer to the EOF */
- if(SetFilePointer(TheFile,0,NULL,FILE_END) == INVALID_SET_FILE_POINTER)
- {
- Trace("ERROR: Could not set the file pointer to the EOF "
- "using SetFilePointer. It returned INVALID_SET_FILE_POINTER.");
- result = -1;
- }
-
- memset(DataBuffer, 'X', BUF_SIZE);
-
- /* Return the result of WriteFile -- we want to check in the parent that
- this was successful. Note: WriteFile doesn't get run if something
- failed during the setup, in that case -1 is returned.
- */
-
- if(result != -1)
- {
- result = WriteFile(TheFile, DataBuffer, 3,&BytesWritten, NULL);
- }
-
- PAL_TerminateEx(result);
- return result;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/test6.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/test6.cpp
deleted file mode 100644
index ba01b9710a..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/test6.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test6.c
-**
-** Purpose:
-** Append to a file which is locked until the end of the file, and
-** append to a file which is locked past the end of the file. (The first
-** should succeed, while the second should fail)
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-#define HELPER "helper"
-#define FILENAME "testfile.txt"
-
-/* This test checks that you can append to a file which is locked from Start
- to EOF.
-*/
-void Test1()
-{
- HANDLE TheFile = NULL;
- DWORD FileStart = 0;
- DWORD FileEnd = 0;
- int result;
- char* WriteBuffer = "12345678901234567890123456";
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file.
- */
-
- FileEnd = strlen(WriteBuffer);
- TheFile = CreateAndLockFile(TheFile,FILENAME, WriteBuffer,
- FileStart, FileEnd);
-
-
- /*
- Launch another proccess which will attempt to append to the
- end of the file. Note: This returns -1 if the setup failed in some way.
- */
-
- result = RunHelper(HELPER);
-
- if(result == -1)
- {
- Fail("ERROR: The Helper program failed in setting up the "
- "test, so it could never be run.");
- }
- else if(result == 0)
- {
- Fail("ERROR: Failed to append to the file which was Locked from "
- "start until EOF. Should have been able to append to this "
- "file still. GetLastError() is %d.",GetLastError());
- }
-
- if(UnlockFile(TheFile, FileStart, 0, FileEnd, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed. GetLastError returns %d.",
- GetLastError());
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file. "
- "GetLastError() returned %d.",GetLastError());
- }
-
-}
-
-/* This test checks that you can't append to a file which is locked beyond
- EOF.
-*/
-void Test2()
-{
- HANDLE TheFile = NULL;
- DWORD FileStart = 0;
- DWORD FileEnd = 0;
- int result;
- char* WriteBuffer = "12345678901234567890123456";
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file.
- */
-
- FileEnd = strlen(WriteBuffer);
- TheFile = CreateAndLockFile(TheFile,FILENAME, WriteBuffer,
- FileStart, FileEnd+20);
-
-
- /*
- Launch another proccess which will attempt to append to the
- end of the file.
- */
-
- result = RunHelper(HELPER);
-
- if(result == -1)
- {
- Fail("ERROR: The Helper program failed in setting up the "
- "test, so it could never be run.");
- }
- else if(result > 0)
- {
- Fail("ERROR: The Helper program successfully appended to the "
- "end of the file, even though it was locked beyond EOF. This "
- "should have failed.");
- }
-
- if(UnlockFile(TheFile, FileStart, 0, FileEnd+20, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed. GetLastError returns %d.",
- GetLastError());
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file. "
- "GetLastError() returned %d.",GetLastError());
- }
-
-}
-
-
-int __cdecl main(int argc, char *argv[])
-{
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Test a file which is locked until EOF to see if you can append */
- Test1();
-
- /* Test a file which is locked past EOF to ensure you can't append */
- Test2();
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/testinfo.dat
deleted file mode 100644
index 871a9a2756..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test6/testinfo.dat
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Positive test for LockFile API
-TYPE = DEFAULT
-EXE1 = test6
-EXE2 = helper
-Description
-= Append to a file which is locked until the end of the file, and
-= append to a file which is locked past the end of the file. (The first
-= should succeed, while the second should fail)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/CMakeLists.txt
deleted file mode 100644
index c52bf55ba8..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test7.cpp
-)
-
-add_executable(paltest_lockfile_test7
- ${SOURCES}
-)
-
-add_dependencies(paltest_lockfile_test7 coreclrpal)
-
-target_link_libraries(paltest_lockfile_test7
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/test7.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/test7.cpp
deleted file mode 100644
index c572a6e653..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/test7.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test7.c
-**
-** Purpose: Try locking an invalid HANDLE and a NULL Handle.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../LockFile.h"
-
-int __cdecl main(int argc, char *argv[])
-{
-
- HANDLE TheFile = NULL;
- DWORD FileEnd = 0;
- const char lpBuffer[] = "This is a test file.";
- DWORD bytesWritten;
- BOOL bRc = TRUE;
- char fileName[] = "testfile.tmp";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.",fileName,GetLastError());
- }
-
- bRc = WriteFile(
- TheFile, // handle to file
- lpBuffer, // data buffer
- (DWORD)sizeof(lpBuffer), // number of bytes to write
- &bytesWritten, // number of bytes written
- NULL // overlapped buffer
- );
-
- if(!bRc)
- {
- Trace("ERROR: Could not write to file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
-
- }
- else if(bytesWritten != (DWORD)sizeof(lpBuffer))
- {
- Trace("ERROR: Could not write the correct number of bytes to the "
- "file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Attempt to lock a region of this file beyond EOF, to ensure this
- doesn't cause an error.
- */
- FileEnd = SetFilePointer(TheFile, 0, NULL, FILE_END);
-
- if(LockFile(TheFile, FileEnd+10, 0, 10, 0) == 0)
- {
- Trace("ERROR: LockFile failed when attempting to lock a region "
- "beyond the EOF. GetLastError() returned %d.",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(UnlockFile(TheFile, FileEnd+10, 0, 10, 0) == 0)
- {
- Trace("ERROR: UnlockFile failed when attempting to unlock the region "
- "which was locked beyond the EOF. GetLastError returned %d.",
- GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: Failed to call CloseHandle. GetLastError "
- "returned %d.",GetLastError());
- }
-
- /* Attempt to call Lockfile on an HANDLE which has been closed. This
- should fail.
- */
- if(LockFile(TheFile, 0, 0, 5, 0) != 0)
- {
- Fail("ERROR: Attempted to Lock an invalid handle and the function "
- "returned success.");
- }
-
- /* Attempt to call Lockfile by passing it NULL for a handle. This should
- fail.
- */
-
- if(LockFile(NULL, 0, 0, 5, 0) != 0)
- {
- Fail("ERROR: Attempted to Lock a NULL handle and the function "
- "returned success.");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/testinfo.dat
deleted file mode 100644
index 74e7f00306..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/LockFile/test7/testinfo.dat
+++ /dev/null
@@ -1,13 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = LockFile
-Name = Positive test for LockFile API
-TYPE = DEFAULT
-EXE1 = test7
-Description
-= Ensure that LockFile succeeds when the lock begins beyond
-= EOF. Try locking an invalid HANDLE and a NULL Handle.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/CMakeLists.txt
deleted file mode 100644
index a3847f8ca9..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-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/filemapping_memmgt/UnlockFile/UnlockFile.h b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/UnlockFile.h
deleted file mode 100644
index 8fce2695a7..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/UnlockFile.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: UnLockFile.h
-**
-** Purpose: This header file has a RunHelper method which will be used to
-** start a child proccess in many LockFile testcases. The CreateAndLockFile
-** method Creates a file and calls LockFile upon it. And the two Signal
-** methods are used for IPC.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-
-HANDLE CreateAndLockFile(HANDLE TheFile, char* FileName, char* WriteBuffer,
- DWORD LockStart, DWORD LockLength)
-{
- DWORD BytesWritten;
-
- TheFile = CreateFile(FileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",FileName,GetLastError());
- }
-
- if(WriteFile(TheFile, WriteBuffer,
- strlen(WriteBuffer),&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile has failed. It returned 0 when we "
- "attempted to write to the file '%s'. GetLastError() "
- "returned %d.\n",FileName,GetLastError());
- }
-
- if(FlushFileBuffers(TheFile) == 0)
- {
- Fail("ERROR: FlushFileBuffers returned failure. GetLastError() "
- "returned %d.\n",GetLastError());
- }
-
- if(LockFile(TheFile, LockStart, 0, LockLength, 0) == 0)
- {
- Fail("ERROR: LockFile failed. GetLastError returns %d.\n",
- GetLastError());
- }
-
- return TheFile;
-}
-
-void SignalAndBusyWait(HANDLE TheFile)
-{
- int size;
- DWORD BytesWritten;
-
- size = GetFileSize(TheFile,NULL)+1;
-
- if(SetFilePointer(TheFile, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
- {
- Fail("ERROR: SetFilePointer was unable to set the pointer to the "
- "end of the file. GetLastError() returned %d.\n",GetLastError());
- }
-
- if(WriteFile(TheFile, "x", 1,&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile was unable to write to the WaitFile. "
- "GetLastError() returned %d.\n",GetLastError());
- }
-
- if(FlushFileBuffers(TheFile) == 0)
- {
- Fail("ERROR: FlushFileBuffers failed when flushing the WaitFile. "
- "GetLastError() returned %d.\n");
- }
-
- while(GetFileSize(TheFile,NULL) == size) {}
-}
-
-void SignalFinish(HANDLE TheFile)
-{
- DWORD BytesWritten;
-
- if(SetFilePointer(TheFile, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
- {
- Fail("ERROR: SetFilePointer was unable to set the pointer to the "
- "end of the WaitFile. GetLastError() returned %d.\n",
- GetLastError());
- }
-
- if(WriteFile(TheFile, "x", 1,&BytesWritten, NULL) == 0)
- {
- Fail("ERROR: WriteFile was unable to write to the WaitFile. "
- "GetLastError returned %d.\n",GetLastError());
- }
-
- if(FlushFileBuffers(TheFile) == 0)
- {
- Fail("ERROR: FlushFileBuffers failed when flushing the WaitFile. "
- "GetLastError() returned %d.\n");
- }
-
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/CMakeLists.txt
deleted file mode 100644
index 58b0329d0d..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(TESTSOURCES
- test1.cpp
-)
-
-add_executable(paltest_unlockfile_test1
- ${TESTSOURCES}
-)
-
-add_dependencies(paltest_unlockfile_test1 coreclrpal)
-
-target_link_libraries(paltest_unlockfile_test1
- ${COMMON_TEST_LIBRARIES}
-)
-
-
-set(HELPERSOURCES
- helper.cpp
-)
-
-add_executable(paltest_unlockfile_test1_helper
- ${HELPERSOURCES}
-)
-
-add_dependencies(paltest_unlockfile_test1_helper coreclrpal)
-
-target_link_libraries(paltest_unlockfile_test1_helper
- ${COMMON_TEST_LIBRARIES}
-) \ No newline at end of file
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/helper.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/helper.cpp
deleted file mode 100644
index c2ef5a6736..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/helper.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: helper.c
-**
-** Purpose: A child process which will attempt to read from the
-** locked file to ensure it is locked. After it has been unlocked, it
-** will then read again to check that Unlock worked.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../UnlockFile.h"
-
-#define FILENAME "testfile.txt"
-#define WAITFILENAME "waitfile"
-#define BUF_SIZE 128
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile, WaitFile;
- int result = 0;
- char DataBuffer[BUF_SIZE];
- DWORD BytesRead;
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open the same file that the parent has opened and locked */
- TheFile = CreateFile(FILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile.\n",FILENAME);
- result = 1;
- }
-
- /* Open up the WaitFile that we're using for IPC */
- WaitFile = CreateFile(WAITFILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (WaitFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",WAITFILENAME,GetLastError());
- result = 1;
- }
-
-
- /* Check to ensure the parent lock is respected */
- if(ReadFile(TheFile, DataBuffer, 10, &BytesRead, NULL) != 0)
- {
- Trace("ERROR: ReadFile returned success when it should "
- "have failed. Attempted to read the first 10 bytes "
- "of a file which was locked by the parent process.\n");
- result = 1;
- }
-
- // Sleep for a bit to give the parent a chance to block before we do.
- Sleep(1000);
-
- /* Switch back to the parent, so it can unlock the file */
- SignalAndBusyWait(WaitFile);
-
- if(ReadFile(TheFile, DataBuffer, 10, &BytesRead, NULL) == 0)
- {
- Trace("ERROR: ReadFile was unable to read from the file after it "
- "had been unlocked. Attempted to read 10 bytes and ReadFile "
- "returned 0. GetLastError() returned %d.\n",GetLastError());
- result = 1;
- }
-
- PAL_TerminateEx(result);
- return result;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/test1.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/test1.cpp
deleted file mode 100644
index 14634c7f7a..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/test1.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test1.c
-**
-** Purpose:
-** Have the parent Lock a file, then have the child check the lock, then
-** have the parent unlock the file, and the child check again.
-** This requires some IPC, which is done here with a crude busy wait on a
-** file (waiting for the file size to change) to avoid too many more
-** dependencies.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../UnlockFile.h"
-
-#define HELPER "helper"
-#define FILENAME "testfile.txt"
-#define WAITFILENAME "waitfile"
-#define BUF_SIZE 128
-
-int RunTest(char* Helper, HANDLE TheFile, HANDLE WaitFile)
-{
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- DWORD ChildRetCode = 0;
- DWORD ParentRetCode = 0;
- DWORD FileEnd;
-
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
-
- /* Load up the helper Process, and then Wait until it signals that it
- is finished locking.
- */
- if(!CreateProcess( NULL, Helper, NULL,
- NULL, FALSE, 0,
- NULL, NULL, &si, &pi))
- {
- Fail("ERROR: CreateProcess failed to load executable '%s'.\n",Helper);
- }
-
- SignalAndBusyWait(WaitFile);
-
- /* When the child proccess is finished verifying the lock, find the end
- of the file and unlock the file.
- */
-
- FileEnd = SetFilePointer(TheFile, 0, NULL, FILE_END);
-
- if(FileEnd == INVALID_SET_FILE_POINTER)
- {
- Trace("ERROR: SetFilePointer failed to set the file pointer to the "
- "end of the file. GetLastError() returned %d.\n",
- GetLastError());
- ParentRetCode = 1;
- }
-
- if(UnlockFile(TheFile, 0, 0, FileEnd, 0) == 0)
- {
- Trace("ERROR: The call to UnlockFile returned 0 when attempting to "
- "unlock the file within the parent. This should have "
- "succeeded. GetLastError returned %d.\n",GetLastError());
- ParentRetCode = 1;
- }
-
- /* Switch back to the child so that it can ensure the unlock worked
- properly.
- */
-
- SignalFinish(WaitFile);
- WaitForSingleObject(pi.hProcess,INFINITE);
-
- /* Get the return value from the helper process */
- if (GetExitCodeProcess(pi.hProcess, &ChildRetCode) == 0)
- {
- Fail("ERROR: GetExitCodeProccess failed when attempting to retrieve "
- "the exit code of the child process.\n");
- }
-
- if(CloseHandle( pi.hProcess ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the process.\n");
- }
-
- if(CloseHandle( pi.hThread ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the thread.\n");
- }
-
- return (ChildRetCode || ParentRetCode);
-}
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile = NULL;
- HANDLE WaitFile = NULL;
- char* WriteBuffer = "12345678901234567890123456";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open up the file we'll be using for some crude IPC */
- WaitFile = CreateFile(WAITFILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (WaitFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",WAITFILENAME,GetLastError());
- }
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file from start to end.
- */
- TheFile = CreateAndLockFile(TheFile, FILENAME, WriteBuffer,
- 0, strlen(WriteBuffer));
-
- /* Run the test. Better errors are displayed by Trace throughout. */
- if(RunTest(HELPER, TheFile, WaitFile))
- {
- Fail("ERROR: Checking to ensure that Unlock successfully unlocked "
- "a file failed.\n");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file used for "
- "testing the locks. GetLastError() returns %d.\n",
- GetLastError());
- }
-
- if(CloseHandle(WaitFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the wait file. "
- "GetLastError() returns %d.\n",GetLastError());
- }
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/testinfo.dat
deleted file mode 100644
index 4d0ad6afc9..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test1/testinfo.dat
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = UnlockFile
-Name = Positive test for UnlockFile API
-TYPE = DEFAULT
-EXE1 = test1
-EXE2 = helper
-Description
-= Have the parent Lock a file, then have the child check the lock, then
-= have the parent unlock the file, and the child check again.
-= This requires some IPC, which is done here with a crude busy wait on a
-= file (waiting for the file size to change) to avoid too many more
-= dependencies.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/CMakeLists.txt
deleted file mode 100644
index 251d21ba65..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test2.cpp
-)
-
-add_executable(paltest_unlockfile_test2
- ${SOURCES}
-)
-
-add_dependencies(paltest_unlockfile_test2 coreclrpal)
-
-target_link_libraries(paltest_unlockfile_test2
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/test2.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/test2.cpp
deleted file mode 100644
index 22c2cce2fb..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/test2.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test2.c
-**
-** Purpose: Open a file, and call Unlock on the file, even though it has yet
-** to be locked. Then lock a portion of the file, and attempt to call unlock
-** on a larger portion of the file. Also, try to unlock a smaller portion
-** than was locked.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../UnlockFile.h"
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile = NULL;
- const char lpBuffer[] = "This is a test file.";
- DWORD bytesWritten;
- BOOL bRc = TRUE;
- char fileName[] = "testfile.tmp";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open a file which is in the directory */
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",fileName,GetLastError());
- }
-
- bRc = WriteFile(
- TheFile, // handle to file
- lpBuffer, // data buffer
- (DWORD)sizeof(lpBuffer), // number of bytes to write
- &bytesWritten, // number of bytes written
- NULL // overlapped buffer
- );
-
- if(!bRc)
- {
- Trace("ERROR: Could not write to file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
-
- }
- else if(bytesWritten != (DWORD)sizeof(lpBuffer))
- {
- Trace("ERROR: Could not write the correct number of bytes to the "
- "file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Call unlock file on an unlocked file, this should return 0 */
- if(UnlockFile(TheFile, 0, 0, 5, 0) != 0)
- {
- Trace("ERROR: Attempted to unlock a file which was not locked and "
- "the UnlockFile call was successful.\n");
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Lock the file */
- if(LockFile(TheFile, 0, 0, 5, 0) == 0)
- {
- Trace("ERROR: Failed to call LockFile on a valid file handle. "
- "GetLastError returned %d.\n",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Try to unlock more of the file than was locked by LockFile */
- if(UnlockFile(TheFile, 0, 0, 10, 0) != 0)
- {
- Trace("ERROR: Attempted to unlock bytes 0 to 9, but only bytes "
- "0 to 4 are locked. But, UnlockFile was successful, when it "
- "should have failed.\n");
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Try to unlock less of the file than was locked by LockFile */
- if(UnlockFile(TheFile, 0, 0, 3, 0) != 0)
- {
- Trace("ERROR: Attempted to unlock bytes 0 to 2, but the bytes 0 to "
- "4 were locked by LockFile. Unlockfile should have failed "
- "when attempting this operation.\n");
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Properly unlock the file */
- if(UnlockFile(TheFile, 0, 0, 5, 0) == 0)
- {
- Trace("ERROR: UnlockFile failed to unlock bytes 0 to 4 of the file. "
- "GetLastError returned %d.\n",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.\n");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/testinfo.dat
deleted file mode 100644
index 932a4a2b8a..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test2/testinfo.dat
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = UnlockFile
-Name = Positive test for UnlockFile API
-TYPE = DEFAULT
-EXE1 = test2
-Description
-= Open a file, and call Unlock on the file, even though it has yet
-= to be locked. Then lock a portion of the file, and attempt to call unlock
-= on a larger portion of the file. Also, try to unlock a smaller portion
-= than was locked.
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/CMakeLists.txt
deleted file mode 100644
index 980a9b0f75..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(TESTSOURCES
- test3.cpp
-)
-
-add_executable(paltest_unlockfile_test3
- ${TESTSOURCES}
-)
-
-add_dependencies(paltest_unlockfile_test3 coreclrpal)
-
-target_link_libraries(paltest_unlockfile_test3
- ${COMMON_TEST_LIBRARIES}
-)
-
-
-set(HELPERSOURCES
- helper.cpp
-)
-
-add_executable(paltest_unlockfile_test3_helper
- ${HELPERSOURCES}
-)
-
-add_dependencies(paltest_unlockfile_test3_helper coreclrpal)
-
-target_link_libraries(paltest_unlockfile_test3_helper
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/helper.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/helper.cpp
deleted file mode 100644
index 650abf49ad..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/helper.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: helper.c
-**
-** Purpose: A child process which will lock a portion of the file,
-** then try to unlock a portion of the file which was locked by the parent.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../UnlockFile.h"
-
-#define FILENAME "testfile.txt"
-#define WAITFILENAME "waitfile"
-#define BUF_SIZE 128
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile, WaitFile;
- int result = 0;
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open the same file that the parent has opened and locked */
- TheFile = CreateFile(FILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile.\n",FILENAME);
- result = 1;
- }
-
- /* Open up the WaitFile that we're using for IPC */
- WaitFile = CreateFile(WAITFILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (WaitFile == INVALID_HANDLE_VALUE)
- {
- Trace("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",WAITFILENAME,GetLastError());
- result = 1;
- }
-
- /* Lock a section of the file different from which was locked in the
- parent proccess
- */
- if(LockFile(TheFile, 10, 0, 10, 0) == 0)
- {
- Trace("ERROR: The LockFile call within the child failed to lock "
- "the file. GetLastError() returned %d.\n",GetLastError());
- result = 1;
- }
-
- /* Attempt to unlock the portion of the file which was locked within the
- parent process.
- */
- if(UnlockFile(TheFile, 0, 0, 10, 0) != 0)
- {
- Trace("ERROR: The UnlockFile call within the child succeeded in "
- "calling UnlockFile on the portion of the file which was "
- "locked by the parent.\n");
- result = 1;
- }
-
- // Sleep for a bit to give the parent a chance to block before we do.
- Sleep(1000);
-
- /* Switch back to the parent, so it can check the child lock */
- SignalAndBusyWait(WaitFile);
-
- /* Finally, clean up the lock which was done within this proccess and
- exit.
- */
- if(UnlockFile(TheFile, 10, 0, 10, 0) == 0)
- {
- Trace("ERROR: The UnlockFile call within the child failed to unlock "
- "the portion of the file which was locked by the child. "
- "GetLastError() returned %d.\n", GetLastError());
- result = 1;
- }
-
- PAL_TerminateEx(result);
- return result;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/test3.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/test3.cpp
deleted file mode 100644
index cf27aba0a3..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/test3.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test3.c
-**
-** Purpose:
-** Lock a portion of the file with the parent. Then have the child lock
-** another portion. Have the child attempt to call Unlock on the parent's
-** locked data, and the parent do the same to the child. Ensure that the
-** locks are respected.
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../UnlockFile.h"
-
-#define HELPER "helper"
-#define FILENAME "testfile.txt"
-#define WAITFILENAME "waitfile"
-#define BUF_SIZE 128
-
-int RunTest(char* Helper, HANDLE TheFile, HANDLE WaitFile)
-{
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- DWORD ChildRetCode = 0;
- DWORD ParentRetCode = 0;
-
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
-
- /* Load up the helper Process, and then Wait until it signals that it
- is finished locking.
- */
- if(!CreateProcess( NULL, Helper, NULL,
- NULL, FALSE, 0,
- NULL, NULL, &si, &pi))
- {
- Fail("ERROR: CreateProcess failed to load executable '%s'.\n",Helper);
- }
-
- SignalAndBusyWait(WaitFile);
-
- /* When the child proccess is finished setting its lock and testing the
- parent lock, then the parent can test the child's lock.
- */
-
- if(UnlockFile(TheFile, 10, 0, 10, 0) != 0)
- {
- Trace("ERROR: The parent proccess called Unlock on the child "
- "proccesses lock, and the function returned non-zero, when "
- "it should have failed.\n");
- ParentRetCode = 1;
- }
-
- /* Switch back to the child so that it can unlock its portion and
- cleanup.
- */
-
- SignalFinish(WaitFile);
- WaitForSingleObject(pi.hProcess,INFINITE);
-
- /* Get the return value from the helper process */
- if (GetExitCodeProcess(pi.hProcess, &ChildRetCode) == 0)
- {
- Fail("ERROR: GetExitCodeProccess failed when attempting to retrieve "
- "the exit code of the child process.\n");
- }
-
- if(CloseHandle( pi.hProcess ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the process.\n");
- }
-
- if(CloseHandle( pi.hThread ) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the thread.\n");
- }
-
- return (ChildRetCode || ParentRetCode);
-}
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile = NULL;
- HANDLE WaitFile = NULL;
- char* WriteBuffer = "12345678901234567890123456";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open up the file we'll be using for some crude IPC */
- WaitFile = CreateFile(WAITFILENAME,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (WaitFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",WAITFILENAME,GetLastError());
- }
-
- /* Call the helper function to Create a file, write 'WriteBuffer' to
- the file, and lock the file from bytes 0-9.
- */
- TheFile = CreateAndLockFile(TheFile, FILENAME, WriteBuffer,
- 0, 10);
-
- /* Run the test. Better errors are displayed by Trace throughout. */
- if(RunTest(HELPER, TheFile, WaitFile))
- {
- Fail("ERROR: The test to check that the Unlock will not work on "
- "on locks set by other proccesses failed.\n");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file used for "
- "testing the locks. GetLastError() returns %d.\n",
- GetLastError());
- }
-
- if(CloseHandle(WaitFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the wait file. "
- "GetLastError() returns %d.\n",GetLastError());
- }
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/testinfo.dat
deleted file mode 100644
index bf7ec5f809..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test3/testinfo.dat
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = UnlockFile
-Name = Positive test for UnlockFile API
-TYPE = DEFAULT
-EXE1 = test3
-EXE2 = helper
-Description
-= Lock a portion of the file with the parent. Then have the child lock
-= another portion. Have the child attempt to call Unlock on the parent's
-= locked data, and the parent do the same to the child. Ensure that the
-= locks are respected.
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/CMakeLists.txt
deleted file mode 100644
index e721b04b6c..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test4.cpp
-)
-
-add_executable(paltest_unlockfile_test4
- ${SOURCES}
-)
-
-add_dependencies(paltest_unlockfile_test4 coreclrpal)
-
-target_link_libraries(paltest_unlockfile_test4
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/test4.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/test4.cpp
deleted file mode 100644
index 55abcd24bc..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/test4.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================
-**
-** Source: test4.c
-**
-** Purpose: Pass an invalid handle to UnlockFile. Pass a null handle to
-** UnlockFile. Create a file and lock two consecuative regions and call
-** UnlockFile on the whole region (this should fail, see msdn)
-**
-**
-**============================================================*/
-
-#include <palsuite.h>
-#include "../UnlockFile.h"
-
-int __cdecl main(int argc, char *argv[])
-{
- HANDLE TheFile = NULL;
- const char lpBuffer[] = "This is a test file.";
- DWORD bytesWritten;
- BOOL bRc = TRUE;
- char fileName[] = "testfile.tmp";
-
- if(0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Open a file which is in the directory */
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",fileName,GetLastError());
- }
-
- bRc = WriteFile(
- TheFile, // handle to file
- lpBuffer, // data buffer
- (DWORD)sizeof(lpBuffer), // number of bytes to write
- &bytesWritten, // number of bytes written
- NULL // overlapped buffer
- );
-
- if(!bRc)
- {
- Trace("ERROR: Could not write to file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
-
- }
- else if(bytesWritten != (DWORD)sizeof(lpBuffer))
- {
- Trace("ERROR: Could not write the correct number of bytes to the "
- "file '%s' with WriteFile.",fileName);
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.\n");
- }
-
-
- /* Test an invalid handle and a NULL handle */
- if(UnlockFile(TheFile, 0, 0, 0, 0) != 0)
- {
- Fail("ERROR: Called UnlockFile on an invalid HANDLE and it "
- "returned a success value.\n");
- }
-
- if(UnlockFile(NULL, 0, 0, 0, 0) != 0)
- {
- Fail("ERROR: Called UnlockFile with NULL passed for the HANDLE and "
- "it returned a success value.\n");
- }
-
- /* Re-open the file */
- TheFile = CreateFile(fileName,
- GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (TheFile == INVALID_HANDLE_VALUE)
- {
- Fail("ERROR: Could not open file '%s' with CreateFile. "
- "GetLastError() returned %d.\n",fileName,GetLastError());
- }
-
- /* Lock two consecuative regions of this file */
- if(LockFile(TheFile, 0, 0, 5, 0) == 0)
- {
- Trace("ERROR: LockFile failed attempting to lock bytes 0-4. "
- "GetLastError() returned %d.\n",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(LockFile(TheFile, 5, 0, 5, 0) == 0)
- {
- Fail("ERROR: LockFile failed attempting to lock bytes 5-9. "
- "GetLastError() returned %d.\n",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- /* Attempt to unlock the entire region which was locked with one
- call to UnlockFile. This should fail.
- */
- if(UnlockFile(TheFile, 0, 0, 10, 0) != 0)
- {
- Fail("ERROR: Called UnlockFile on bytes 0-9 which were locked with "
- "two seperate LockFile calls. This should have failed. "
- "UnlockFile will not unlock consecuative locked regions.\n");
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
-
- /* Now, unlock the regions one at a time. */
- if(UnlockFile(TheFile, 0, 0, 5, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed when attempting to unlock bytes "
- "0-4 of the file. GetLastError() returned %d.\n",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(UnlockFile(TheFile, 5, 0, 5, 0) == 0)
- {
- Fail("ERROR: UnlockFile failed when attempting to unlock bytes "
- "5-9 of the file. GetLastError() returned %d.\n",GetLastError());
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.");
- }
- Fail("");
- }
-
- if(CloseHandle(TheFile) == 0)
- {
- Fail("ERROR: CloseHandle failed to close the file.\n");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/testinfo.dat
deleted file mode 100644
index 4f3885b978..0000000000
--- a/src/pal/tests/palsuite/filemapping_memmgt/UnlockFile/test4/testinfo.dat
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Filemapping_memmgt
-Function = UnlockFile
-Name = Positive test for UnlockFile API
-TYPE = DEFAULT
-EXE1 = test4
-Description
-= Pass an invalid handle to UnlockFile. Pass a null handle to
-= UnlockFile. Create a file and lock two consecuative regions and call
-= UnlockFile on the whole region (this should fail, see msdn)
-
-