diff options
author | Justin Van Patten <jvp@justinvp.com> | 2017-08-28 11:01:42 -0700 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2017-08-28 20:01:42 +0200 |
commit | c440335be80ee0762856d0be6e91ec3ea2f90504 (patch) | |
tree | 2e14d592d292bab1d9195b406d2d430d06b9250a | |
parent | 68e7669cf9cc6ad64fa0393339dbebafd03612e9 (diff) | |
download | coreclr-c440335be80ee0762856d0be6e91ec3ea2f90504.tar.gz coreclr-c440335be80ee0762856d0be6e91ec3ea2f90504.tar.bz2 coreclr-c440335be80ee0762856d0be6e91ec3ea2f90504.zip |
Delete dead PAL functions (#13613)
* Remove duplicate define
* Remove unused wincon.h defines
* Delete unused LockFile/UnlockFile
* Remove unused WszCryptGetDefaultProvider define
* Remove unused defines
* Remove unused defines
* Delete unused GetDiskFreeSpace
* Delete unused RegisterEventSource\DeregisterEventSource\ReportEvent
* Remove unused defines
* Delete unused AreFileApisANSI
* Delete unused MoveFileW
* Delete unused SetFileTime
* Delete unused GetFileTime
* Delete unused FileTimeToDosDateTime
* Delete unused GetFileType
* Delete unused GetConsoleCP
* Delete unused GetExitCodeThread
* Delete unused FlushViewOfFile
* Delete unused RtlZeroMemory
* Delete unused MoveFileA
146 files changed, 3 insertions, 9987 deletions
diff --git a/src/dlls/mscoree/mscorwks_unixexports.src b/src/dlls/mscoree/mscorwks_unixexports.src index 1076d175c4..0da8942a2b 100644 --- a/src/dlls/mscoree/mscorwks_unixexports.src +++ b/src/dlls/mscoree/mscorwks_unixexports.src @@ -44,7 +44,6 @@ FlushFileBuffers FormatMessageW FreeEnvironmentStringsW GetACP -GetConsoleCP GetConsoleOutputCP GetCurrentDirectoryW GetCurrentProcess @@ -54,7 +53,6 @@ GetEnvironmentStringsW GetEnvironmentVariableW GetFileAttributesExW GetFileSize -GetFileType GetFullPathNameW GetLongPathNameW GetProcAddress @@ -66,7 +64,6 @@ GetTempPathW LocalAlloc LocalReAlloc LocalFree -LockFile lstrlenA lstrlenW MapViewOfFile @@ -86,7 +83,6 @@ ReleaseMutex ReleaseSemaphore RemoveDirectoryW ResetEvent -RtlZeroMemory SetCurrentDirectoryW SetEndOfFile SetEnvironmentVariableW @@ -94,11 +90,9 @@ SetErrorMode SetEvent SetFileAttributesW SetFilePointer -SetFileTime SysAllocStringLen SysFreeString SysStringLen -UnlockFile UnmapViewOfFile VirtualAlloc VirtualFree diff --git a/src/inc/winwrap.h b/src/inc/winwrap.h index a67694f385..fbc565aa25 100644 --- a/src/inc/winwrap.h +++ b/src/inc/winwrap.h @@ -20,17 +20,6 @@ #if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#if !defined(WIN32_LEAN_AND_MEAN) -#define INC_OLE2 -#endif - -#ifdef _WIN64 -#define HIWORD64(p) ((ULONG_PTR)(p) >> 16) -#else -#define HIWORD64 HIWORD -#endif - -#define SAFEDELARRAY(p) if ((p) != NULL) { delete [] p; (p) = NULL; } // // WinCE uniformly uses cdecl calling convention on x86. __stdcall is defined as __cdecl in SDK. @@ -67,7 +56,6 @@ // wincrypt.h #undef CryptAcquireContext -#undef CryptGetDefaultProvider #undef CryptSignHash #undef CryptVerifySignature @@ -78,11 +66,6 @@ #undef GetEnvironmentStrings #undef FreeEnvironmentStrings #undef FormatMessage -#undef CreateMailslot -#undef EncryptFile -#undef DecryptFile -#undef OpenRaw -#undef QueryRecoveryAgents #undef lstrcmp #undef lstrcmpi #undef lstrcpyn @@ -94,18 +77,14 @@ #undef CreateSemaphore #undef OpenSemaphore #undef CreateWaitableTimer -#undef OpenWaitableTimer #undef CreateFileMapping #undef OpenFileMapping -#undef GetLogicalDriveStrings #undef LoadLibrary #undef LoadLibraryEx #undef GetModuleFileName #undef GetModuleHandle #undef GetModuleHandleEx #undef CreateProcess -#undef FatalAppExit -#undef GetStartupInfo #undef GetCommandLine #undef GetEnvironmentVariable #undef SetEnvironmentVariable @@ -113,51 +92,22 @@ #undef OutputDebugString #undef FindResource #undef FindResourceEx -#undef EnumResourceTypes -#undef EnumResourceNames -#undef EnumResourceLanguages #undef BeginUpdateResource #undef UpdateResource #undef EndUpdateResource -#undef GlobalAddAtom -#undef GlobalFindAtom -#undef GlobalGetAtomName -#undef AddAtom -#undef FindAtom -#undef GetAtomName -#undef GetProfileInt -#undef GetProfileString -#undef WriteProfileString -#undef GetProfileSection -#undef WriteProfileSection #undef GetPrivateProfileInt -#undef GetPrivateProfileString -#undef WritePrivateProfileString -#undef GetPrivateProfileSection -#undef WritePrivateProfileSection -#undef GetPrivateProfileSectionNames -#undef GetPrivateProfileStruct -#undef WritePrivateProfileStruct -#undef GetDriveType #undef GetSystemDirectory #undef GetTempPath #undef GetTempFileName -#undef GetWindowsDirectory #undef SetCurrentDirectory #undef GetCurrentDirectory -#undef GetDiskFreeSpace -#undef GetDiskFreeSpaceEx #undef CreateDirectory -#undef CreateDirectoryEx #undef RemoveDirectory #undef GetFullPathName -#undef DefineDosDevice -#undef QueryDosDevice #undef CreateFile #undef SetFileAttributes #undef GetFileAttributes #undef GetFileAttributesEx -#undef GetCompressedFileSize #undef DeleteFile #undef FindFirstFileEx #undef FindFirstFile @@ -167,191 +117,23 @@ #undef CopyFileEx #undef MoveFile #undef MoveFileEx -#undef MoveFileWithProgress -#undef CreateSymbolicLink -#undef QuerySymbolicLink #undef CreateHardLink #undef CreateNamedPipe -#undef GetNamedPipeHandleState -#undef CallNamedPipe #undef WaitNamedPipe -#undef SetVolumeLabel -#undef GetVolumeInformation -#undef ClearEventLog -#undef BackupEventLog -#undef OpenEventLog -#undef RegisterEventSource -#undef OpenBackupEventLog -#undef ReadEventLog -#undef ReportEvent -#undef AccessCheckAndAuditAlarm -#undef AccessCheckByTypeAndAuditAlarm -#undef AccessCheckByTypeResultListAndAuditAlarm -#undef ObjectOpenAuditAlarm -#undef ObjectPrivilegeAuditAlarm -#undef ObjectCloseAuditAlarm -#undef ObjectDeleteAuditAlarm -#undef PrivilegedServiceAuditAlarm -#undef SetFileSecurity -#undef GetFileSecurity -#undef FindFirstChangeNotification -#undef IsBadStringPtr -#undef LookupAccountSid -#undef LookupAccountName #undef LookupPrivilegeValue -#undef LookupPrivilegeName -#undef LookupPrivilegeDisplayName -#undef BuildCommDCB -#undef BuildCommDCBAndTimeouts -#undef CommConfigDialog -#undef GetDefaultCommConfig -#undef SetDefaultCommConfig -#undef LogonUser -#undef CreateProcessAsUser -#undef GetCurrentHwProfile #undef GetVersionEx -#undef CreateJobObject -#undef OpenJobObject -#undef SetDllDirectory // winuser.h #undef MAKEINTRESOURCE -#undef wvsprintf -#undef LoadKeyboardLayout -#undef GetKeyboardLayoutName -#undef CreateDesktop -#undef OpenDesktop -#undef EnumDesktops -#undef CreateWindowStation -#undef OpenWindowStation -#undef EnumWindowStations #undef GetUserObjectInformation -#undef SetUserObjectInformation -#undef RegisterWindowMessage -#undef SIZEZOOMSHOW -#undef WS_TILEDWINDOW #undef GetMessage -#undef DispatchMessage -#undef PeekMessage #undef SendMessage -#undef SendMessageTimeout -#undef SendNotifyMessage -#undef SendMessageCallback -#undef BroadcastSystemMessage -#undef RegisterDeviceNotification -#undef PostMessage -#undef PostThreadMessage -#undef PostAppMessage -#undef DefWindowProc -#undef CallWindowProc -#undef RegisterClass -#undef UnregisterClass -#undef GetClassInfo -#undef RegisterClassEx -#undef GetClassInfoEx -#undef CreateWindowEx -#undef CreateWindow -#undef CreateDialogParam -#undef CreateDialogIndirectParam -#undef CreateDialog -#undef CreateDialogIndirect -#undef DialogBoxParam -#undef DialogBoxIndirectParam -#undef DialogBox -#undef DialogBoxIndirect -#undef SetDlgItemText -#undef GetDlgItemText -#undef SendDlgItemMessage -#undef DefDlgProc -#undef CallMsgFilter -#undef RegisterClipboardFormat -#undef GetClipboardFormatName -#undef CharToOem -#undef OemToChar -#undef CharToOemBuff -#undef OemToCharBuff -#undef CharUpper -#undef CharUpperBuff #undef CharLower -#undef CharLowerBuff #undef CharNext -#undef IsCharAlpha -#undef IsCharAlphaNumeric -#undef IsCharUpper -#undef IsCharLower -#undef GetKeyNameText -#undef VkKeyScan -#undef VkKeyScanEx -#undef MapVirtualKey -#undef MapVirtualKeyEx -#undef LoadAccelerators -#undef CreateAcceleratorTable -#undef CopyAcceleratorTable -#undef TranslateAccelerator -#undef LoadMenu -#undef LoadMenuIndirect -#undef ChangeMenu -#undef GetMenuString -#undef InsertMenu -#undef AppendMenu -#undef ModifyMenu -#undef InsertMenuItem -#undef GetMenuItemInfo -#undef SetMenuItemInfo -#undef DrawText -#undef DrawTextEx -#undef GrayString -#undef DrawState -#undef TabbedTextOut -#undef GetTabbedTextExtent -#undef SetProp -#undef GetProp -#undef RemoveProp -#undef EnumPropsEx -#undef EnumProps -#undef SetWindowText -#undef GetWindowText -#undef GetWindowTextLength #undef MessageBox -#undef MessageBoxEx -#undef MessageBoxIndirect -#undef COLOR_3DSHADOW -#undef GetWindowLong -#undef SetWindowLong -#undef GetClassLong -#undef SetClassLong -#undef FindWindow -#undef FindWindowEx #undef GetClassName -#undef SetWindowsHook -#undef SetWindowsHook -#undef SetWindowsHookEx -#undef MFT_OWNERDRAW -#undef LoadBitmap -#undef LoadCursor -#undef LoadCursorFromFile -#undef LoadIcon -#undef LoadImage #undef LoadString -#undef IsDialogMessage -#undef DlgDirList -#undef DlgDirSelectEx -#undef DlgDirListComboBox -#undef DlgDirSelectComboBoxEx -#undef DefFrameProc -#undef DefMDIChildProc -#undef CreateMDIWindow -#undef WinHelp -#undef ChangeDisplaySettings -#undef ChangeDisplaySettingsEx -#undef EnumDisplaySettings -#undef EnumDisplayDevices -#undef SystemParametersInfo -#undef GetMonitorInfo -#undef GetWindowModuleFileName -#undef RealGetWindowClass -#undef GetAltTabInfo #undef GetCalendarInfo #undef GetDateFormat #undef GetTimeFormat @@ -372,7 +154,6 @@ // wincrypt.h #define WszCryptAcquireContext CryptAcquireContextW -#define WszCryptGetDefaultProvider CryptGetDefaultProviderW #define WszCryptSignHash CryptSignHashW #define WszCryptVerifySignature CryptVerifySignatureW @@ -384,9 +165,6 @@ #else #define WszFormatMessage CCompRC::FormatMessage #endif -#define WszCreateMailslot CreateMailslotW -#define WszOpenRaw OpenRawW -#define WszQueryRecoveryAgents QueryRecoveryAgentsW #define Wszlstrcmp lstrcmpW #define Wszlstrcmpi lstrcmpiW #define WszCreateMutex CreateMutexW @@ -394,231 +172,35 @@ #define WszCreateEvent CreateEventW #define WszOpenEvent OpenEventW #define WszCreateWaitableTimer CreateWaitableTimerW -#define WszOpenWaitableTimer OpenWaitableTimerW #define WszCreateFileMapping CreateFileMappingW #define WszOpenFileMapping OpenFileMappingW -#define WszGetLogicalDriveStrings GetLogicalDriveStringsW #define WszGetModuleHandle GetModuleHandleW #define WszGetModuleHandleEx GetModuleHandleExW -#define WszFatalAppExit FatalAppExitW -#define WszGetStartupInfo GetStartupInfoW #define WszGetCommandLine GetCommandLineW #define WszSetEnvironmentVariable SetEnvironmentVariableW #define WszExpandEnvironmentStrings ExpandEnvironmentStringsW #define WszOutputDebugString OutputDebugStringW #define WszFindResource FindResourceW #define WszFindResourceEx FindResourceExW -#define WszEnumResourceTypes EnumResourceTypesW -#define WszEnumResourceNames EnumResourceNamesW -#define WszEnumResourceLanguages EnumResourceLanguagesW #define WszBeginUpdateResource BeginUpdateResourceW #define WszUpdateResource UpdateResourceW #define WszEndUpdateResource EndUpdateResourceW -#define WszGlobalAddAtom GlobalAddAtomW -#define WszGlobalFindAtom GlobalFindAtomW -#define WszGlobalGetAtomName GlobalGetAtomNameW -#define WszAddAtom AddAtomW -#define WszFindAtom FindAtomW -#define WszGetAtomName GetAtomNameW -#define WszGetProfileInt GetProfileIntW -#define WszGetProfileString GetProfileStringW -#define WszWriteProfileString WriteProfileStringW -#define WszGetProfileSection GetProfileSectionW -#define WszWriteProfileSection WriteProfileSectionW #define WszGetPrivateProfileInt GetPrivateProfileIntW -#define WszGetPrivateProfileString GetPrivateProfileStringW -#define WszWritePrivateProfileString WritePrivateProfileStringW -#define WszGetPrivateProfileSection GetPrivateProfileSectionW -#define WszWritePrivateProfileSection WritePrivateProfileSectionW -#define WszGetPrivateProfileSectionNames GetPrivateProfileSectionNamesW -#define WszGetPrivateProfileStruct GetPrivateProfileStructW -#define WszWritePrivateProfileStruct WritePrivateProfileStructW -#define WszGetDriveType GetDriveTypeW #define WszGetSystemDirectory GetSystemDirectoryW -#define WszGetWindowsDirectory GetWindowsDirectoryW -#define WszGetDiskFreeSpace GetDiskFreeSpaceW -#define WszGetDiskFreeSpaceEx GetDiskFreeSpaceExW -#define WszDefineDosDevice DefineDosDeviceW -#define WszQueryDosDevice QueryDosDeviceW -#define WszQuerySymbolicLink QuerySymbolicLinkW #define WszCreateNamedPipe CreateNamedPipeW -#define WszGetNamedPipeHandleState GetNamedPipeHandleStateW -#define WszCallNamedPipe CallNamedPipeW #define WszWaitNamedPipe WaitNamedPipeW -#define WszSetVolumeLabel SetVolumeLabelW -#define WszGetVolumeInformation GetVolumeInformationW -#define WszClearEventLog ClearEventLogW -#define WszBackupEventLog BackupEventLogW -#define WszOpenEventLog OpenEventLogW -#define WszRegisterEventSource RegisterEventSourceW -#define WszOpenBackupEventLog OpenBackupEventLogW -#define WszReadEventLog ReadEventLogW -#define WszReportEvent ReportEventW -#define WszAccessCheckAndAuditAlarm AccessCheckAndAuditAlarmW -#define WszAccessCheckByTypeAndAuditAlarm AccessCheckByTypeAndAuditAlarmW -#define WszAccessCheckByTypeResultListAndAuditAlarm AccessCheckByTypeResultListAndAuditAlarmW -#define WszObjectOpenAuditAlarm ObjectOpenAuditAlarmW -#define WszObjectPrivilegeAuditAlarm ObjectPrivilegeAuditAlarmW -#define WszObjectCloseAuditAlarm ObjectCloseAuditAlarmW -#define WszObjectDeleteAuditAlarm ObjectDeleteAuditAlarmW -#define WszPrivilegedServiceAuditAlarm PrivilegedServiceAuditAlarmW -#define WszIsBadStringPtr __DO_NOT_USE__WszIsBadStringPtr__ -#if !defined(FEATURE_CORESYSTEM) || defined(CROSSGEN_COMPILE) -#define WszLookupAccountSid LookupAccountSidW -#endif -#define WszLookupAccountName LookupAccountNameW #define WszLookupPrivilegeValue LookupPrivilegeValueW -#define WszLookupPrivilegeName LookupPrivilegeNameW -#define WszLookupPrivilegeDisplayName LookupPrivilegeDisplayNameW -#define WszBuildCommDCB BuildCommDCBW -#define WszBuildCommDCBAndTimeouts BuildCommDCBAndTimeoutsW -#define WszCommConfigDialog CommConfigDialogW -#define WszGetDefaultCommConfig GetDefaultCommConfigW -#define WszSetDefaultCommConfig SetDefaultCommConfigW -#define WszLogonUser LogonUserW -#define WszCreateProcessAsUser CreateProcessAsUserW -#define WszGetCurrentHwProfile GetCurrentHwProfileW -#define WszCreateJobObject CreateJobObjectW -#define WszOpenJobObject OpenJobObjectW // winuser.h #define WszMAKEINTRESOURCE MAKEINTRESOURCEW -#define Wszwvsprintf wvsprintfW -#define WszLoadKeyboardLayout LoadKeyboardLayoutW -#define WszGetKeyboardLayoutName GetKeyboardLayoutNameW -#define WszCreateDesktop CreateDesktopW -#define WszOpenDesktop OpenDesktopW -#define WszEnumDesktops EnumDesktopsW -#define WszCreateWindowStation CreateWindowStationW -#define WszOpenWindowStation OpenWindowStationW -#define WszEnumWindowStations EnumWindowStationsW #define WszGetUserObjectInformation GetUserObjectInformationW -#define WszSetUserObjectInformation SetUserObjectInformationW -#define WszRegisterWindowMessage RegisterWindowMessageW -#define WszSIZEZOOMSHOW SIZEZOOMSHOWW -#define WszWS_TILEDWINDOW WS_TILEDWINDOWW #define WszGetMessage GetMessageW -#define WszDispatchMessage DispatchMessageW -#define WszPostMessage PostMessageW -#define WszPeekMessage PeekMessageW #define WszSendMessage SendMessageW -#define WszSendMessageTimeout SendMessageTimeoutW -#define WszSendNotifyMessage SendNotifyMessageW -#define WszSendMessageCallback SendMessageCallbackW -#define WszBroadcastSystemMessage BroadcastSystemMessageW -#define WszRegisterDeviceNotification RegisterDeviceNotificationW -#define WszPostMessage PostMessageW -#define WszPostThreadMessage PostThreadMessageW -#define WszPostAppMessage PostAppMessageW -#define WszDefWindowProc DefWindowProcW -#define WszCallWindowProc CallWindowProcW -#define WszRegisterClass RegisterClassW -#define WszUnregisterClass UnregisterClassW -#define WszGetClassInfo GetClassInfoW -#define WszRegisterClassEx RegisterClassExW -#define WszGetClassInfoEx GetClassInfoExW -#define WszCreateWindowEx CreateWindowExW -#define WszCreateWindow CreateWindowW -#define WszCreateDialogParam CreateDialogParamW -#define WszCreateDialogIndirectParam CreateDialogIndirectParamW -#define WszCreateDialog CreateDialogW -#define WszCreateDialogIndirect CreateDialogIndirectW -#define WszDialogBoxParam DialogBoxParamW -#define WszDialogBoxIndirectParam DialogBoxIndirectParamW -#define WszDialogBox DialogBoxW -#define WszDialogBoxIndirect DialogBoxIndirectW -#define WszSetDlgItemText SetDlgItemTextW -#define WszGetDlgItemText GetDlgItemTextW -#define WszSendDlgItemMessage SendDlgItemMessageW -#define WszDefDlgProc DefDlgProcW -#define WszCallMsgFilter CallMsgFilterW -#define WszRegisterClipboardFormat RegisterClipboardFormatW -#define WszGetClipboardFormatName GetClipboardFormatNameW -#define WszCharToOem CharToOemW -#define WszOemToChar OemToCharW -#define WszCharToOemBuff CharToOemBuffW -#define WszOemToCharBuff OemToCharBuffW -#define WszCharUpper CharUpperW -#define WszCharUpperBuff CharUpperBuffW #define WszCharLower CharLowerW -#define WszCharLowerBuff CharLowerBuffW #define WszCharNext CharNextW -#define WszIsCharAlpha IsCharAlphaW -#define WszIsCharAlphaNumeric IsCharAlphaNumericW -#define WszIsCharUpper IsCharUpperW -#define WszIsCharLower IsCharLowerW -#define WszGetKeyNameText GetKeyNameTextW -#define WszVkKeyScan VkKeyScanW -#define WszVkKeyScanEx VkKeyScanExW -#define WszMapVirtualKey MapVirtualKeyW -#define WszMapVirtualKeyEx MapVirtualKeyExW -#define WszLoadAccelerators LoadAcceleratorsW -#define WszCreateAcceleratorTable CreateAcceleratorTableW -#define WszCopyAcceleratorTable CopyAcceleratorTableW -#define WszTranslateAccelerator TranslateAcceleratorW -#define WszLoadMenu LoadMenuW -#define WszLoadMenuIndirect LoadMenuIndirectW -#define WszChangeMenu ChangeMenuW -#define WszGetMenuString GetMenuStringW -#define WszInsertMenu InsertMenuW -#define WszAppendMenu AppendMenuW -#define WszModifyMenu ModifyMenuW -#define WszInsertMenuItem InsertMenuItemW -#define WszGetMenuItemInfo GetMenuItemInfoW -#define WszSetMenuItemInfo SetMenuItemInfoW -#define WszDrawText DrawTextW -#define WszDrawTextEx DrawTextExW -#define WszGrayString GrayStringW -#define WszDrawState DrawStateW -#define WszTabbedTextOut TabbedTextOutW -#define WszGetTabbedTextExtent GetTabbedTextExtentW -#define WszSetProp SetPropW -#define WszGetProp GetPropW -#define WszRemoveProp RemovePropW -#define WszEnumPropsEx EnumPropsExW -#define WszEnumProps EnumPropsW -#define WszSetWindowText SetWindowTextW -#define WszGetWindowText GetWindowTextW -#define WszGetWindowTextLength GetWindowTextLengthW #define WszMessageBox LateboundMessageBoxW -#define WszMessageBoxEx MessageBoxExW -#define WszMessageBoxIndirect MessageBoxIndirectW -#define WszGetWindowLong GetWindowLongW -#define WszSetWindowLong SetWindowLongW -#define WszSetWindowLongPtr SetWindowLongPtrW -#define WszGetWindowLongPtr GetWindowLongPtrW -#define WszGetClassLong GetClassLongW -#define WszSetClassLong SetClassLongW -#define WszFindWindow FindWindowW -#define WszFindWindowEx FindWindowExW #define WszGetClassName GetClassNameW -#define WszSetWindowsHook SetWindowsHookW -#define WszSetWindowsHook SetWindowsHookW -#define WszSetWindowsHookEx SetWindowsHookExW -#define WszLoadBitmap LoadBitmapW -#define WszLoadCursor LoadCursorW -#define WszLoadCursorFromFile LoadCursorFromFileW -#define WszLoadIcon LoadIconW -#define WszLoadImage LoadImageW #define WszLoadString LoadStringW -#define WszIsDialogMessage IsDialogMessageW -#define WszDlgDirList DlgDirListW -#define WszDlgDirSelectEx DlgDirSelectExW -#define WszDlgDirListComboBox DlgDirListComboBoxW -#define WszDlgDirSelectComboBoxEx DlgDirSelectComboBoxExW -#define WszDefFrameProc DefFrameProcW -#define WszDefMDIChildProc DefMDIChildProcW -#define WszCreateMDIWindow CreateMDIWindowW -#define WszWinHelp WinHelpW -#define WszChangeDisplaySettings ChangeDisplaySettingsW -#define WszChangeDisplaySettingsEx ChangeDisplaySettingsExW -#define WszEnumDisplaySettings EnumDisplaySettingsW -#define WszEnumDisplayDevices EnumDisplayDevicesW -#define WszSystemParametersInfo SystemParametersInfoW -#define WszGetMonitorInfo GetMonitorInfoW -#define WszGetWindowModuleFileName GetWindowModuleFileNameW -#define WszRealGetWindowClass RealGetWindowClassW -#define WszGetAltTabInfo GetAltTabInfoW #define WszRegOpenKeyEx ClrRegOpenKeyEx #define WszRegOpenKey(hKey, wszSubKey, phkRes) ClrRegOpenKeyEx(hKey, wszSubKey, 0, KEY_ALL_ACCESS, phkRes) #define WszRegQueryValue RegQueryValueW @@ -639,8 +221,6 @@ #define WszCreateSemaphore CreateSemaphoreW #define WszQueryActCtxW QueryActCtxW -// winnetwk.h -#define WszWNetGetConnection WNetGetConnectionW #ifdef FEATURE_CORESYSTEM @@ -660,9 +240,6 @@ #define _T(str) W(str) #endif -// on win98 and higher -#define Wszlstrlen lstrlenW - //File and Directory Functions which need special handling for LongFile Names //Note only the functions which are currently used are defined #define WszLoadLibrary LoadLibraryExWrapper @@ -700,17 +277,7 @@ //NOTE: IF the following API's are enabled ensure that they can work with LongFile Names //See the usage and implementation of above API's // -//#define WszGetCompressedFileSize GetCompressedFileSizeW -//#define WszMoveFileWithProgress MoveFileWithProgressW -//#define WszEncryptFile EncryptFileW -//#define WszDecryptFile DecryptFileW -//#define WszSetFileSecurity SetFileSecurityW -//#define WszGetFileSecurity GetFileSecurityW -//#define WszFindFirstChangeNotification FindFirstChangeNotificationW -//#define WszSetDllDirectory SetDllDirectoryW //#define WszSetCurrentDirectory SetCurrentDirectoryW -//#define WszCreateDirectoryEx CreateDirectoryExW -//#define WszCreateSymbolicLink CreateSymbolicLinkW //#define WszGetBinaryType GetBinaryTypeWrapper //Coresys does not seem to have this API #if FEATURE_PAL diff --git a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs index 76b54f240d..e23d9b08fa 100644 --- a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs +++ b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs @@ -584,14 +584,6 @@ namespace Microsoft.Win32 [DllImport(KERNEL32, SetLastError = true)] internal static extern IntPtr GetStdHandle(int nStdHandle); // param is NOT a handle, but it returns one! - // From wincon.h - internal const int CTRL_C_EVENT = 0; - internal const int CTRL_BREAK_EVENT = 1; - internal const int CTRL_CLOSE_EVENT = 2; - internal const int CTRL_LOGOFF_EVENT = 5; - internal const int CTRL_SHUTDOWN_EVENT = 6; - internal const short KEY_EVENT = 1; - // From WinBase.h internal const int FILE_TYPE_DISK = 0x0001; internal const int FILE_TYPE_CHAR = 0x0002; diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 3ae25e4419..8ca391267b 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -591,7 +591,6 @@ CharNextExA( #define MB_TOPMOST 0x00040000L #define MB_NOFOCUS 0x00008000L -#define MB_SETFOREGROUND 0x00010000L #define MB_DEFAULT_DESKTOP_ONLY 0x00020000L // Note: this is the NT 4.0 and greater value. @@ -626,34 +625,6 @@ MessageBoxW( #define MessageBox MessageBoxA #endif -/***************** wincon.h Entrypoints **********************************/ - -#define CTRL_C_EVENT 0 -#define CTRL_BREAK_EVENT 1 -#define CTRL_CLOSE_EVENT 2 -// 3 is reserved! -// 4 is reserved! -#define CTRL_LOGOFF_EVENT 5 -#define CTRL_SHUTDOWN_EVENT 6 - -typedef -BOOL -(PALAPI *PHANDLER_ROUTINE)( - DWORD CtrlType - ); - -#ifndef CORECLR -PALIMPORT -BOOL -PALAPI -GenerateConsoleCtrlEvent( - IN DWORD dwCtrlEvent, - IN DWORD dwProcessGroupId - ); -#endif // !CORECLR - -//end wincon.h Entrypoints - // From win32.h #ifndef _CRTIMP #ifdef __llvm__ @@ -664,12 +635,6 @@ GenerateConsoleCtrlEvent( #endif // _CRTIMP /******************* winbase.h Entrypoints and defines ************************/ -PALIMPORT -BOOL -PALAPI -AreFileApisANSI( - VOID); - typedef struct _SECURITY_ATTRIBUTES { DWORD nLength; LPVOID lpSecurityDescriptor; @@ -735,28 +700,6 @@ CreateFileW( #define CreateFile CreateFileA #endif -PALIMPORT -BOOL -PALAPI -LockFile( - IN HANDLE hFile, - IN DWORD dwFileOffsetLow, - IN DWORD dwFileOffsetHigh, - IN DWORD nNumberOfBytesToLockLow, - IN DWORD nNumberOfBytesToLockHigh - ); - -PALIMPORT -BOOL -PALAPI -UnlockFile( - IN HANDLE hFile, - IN DWORD dwFileOffsetLow, - IN DWORD dwFileOffsetHigh, - IN DWORD nNumberOfBytesToUnlockLow, - IN DWORD nNumberOfBytesToUnlockHigh - ); - PALIMPORT DWORD @@ -806,19 +749,6 @@ DeleteFileW( -PALIMPORT -BOOL -PALAPI -MoveFileW( - IN LPCWSTR lpExistingFileName, - IN LPCWSTR lpNewFileName); - -#ifdef UNICODE -#define MoveFile MoveFileW -#else -#define MoveFile MoveFileA -#endif - #define MOVEFILE_REPLACE_EXISTING 0x00000001 #define MOVEFILE_COPY_ALLOWED 0x00000002 @@ -1090,24 +1020,6 @@ CompareFileTime( IN CONST FILETIME *lpFileTime2); PALIMPORT -BOOL -PALAPI -SetFileTime( - IN HANDLE hFile, - IN CONST FILETIME *lpCreationTime, - IN CONST FILETIME *lpLastAccessTime, - IN CONST FILETIME *lpLastWriteTime); - -PALIMPORT -BOOL -PALAPI -GetFileTime( - IN HANDLE hFile, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpLastAccessTime, - OUT LPFILETIME lpLastWriteTime); - -PALIMPORT VOID PALAPI GetSystemTimeAsFileTime( @@ -1137,15 +1049,6 @@ FileTimeToSystemTime( IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime); -PALIMPORT -BOOL -PALAPI -FileTimeToDosDateTime( - IN CONST FILETIME *lpFileTime, - OUT LPWORD lpFatDate, - OUT LPWORD lpFatTime - ); - PALIMPORT @@ -1154,24 +1057,6 @@ PALAPI FlushFileBuffers( IN HANDLE hFile); -#define FILE_TYPE_UNKNOWN 0x0000 -#define FILE_TYPE_DISK 0x0001 -#define FILE_TYPE_CHAR 0x0002 -#define FILE_TYPE_PIPE 0x0003 -#define FILE_TYPE_REMOTE 0x8000 - -PALIMPORT -DWORD -PALAPI -GetFileType( - IN HANDLE hFile); - -PALIMPORT -UINT -PALAPI -GetConsoleCP( - VOID); - PALIMPORT UINT PALAPI @@ -1664,13 +1549,6 @@ ExitThread( IN DWORD dwExitCode); PALIMPORT -BOOL -PALAPI -GetExitCodeThread( - IN HANDLE hThread, - IN LPDWORD lpExitCode); - -PALIMPORT DWORD PALAPI ResumeThread( @@ -2697,13 +2575,6 @@ MapViewOfFileEx( IN DWORD dwFileOffsetLow, IN SIZE_T dwNumberOfBytesToMap, IN LPVOID lpBaseAddress); - -PALIMPORT -BOOL -PALAPI -FlushViewOfFile( - IN LPVOID lpBaseAddress, - IN SIZE_T dwNumberOfBytesToFlush); PALIMPORT BOOL @@ -2922,13 +2793,6 @@ RtlMoveMemory( IN CONST VOID *Source, IN SIZE_T Length); -PALIMPORT -VOID -PALAPI -RtlZeroMemory( - IN PVOID Destination, - IN SIZE_T Length); - #define MoveMemory memmove #define CopyMemory memcpy #define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length)) @@ -4788,20 +4652,6 @@ GetSystemInfo( PALIMPORT BOOL PALAPI -GetDiskFreeSpaceW( - LPCWSTR lpDirectoryName, - LPDWORD lpSectorsPerCluster, - LPDWORD lpBytesPerSector, - LPDWORD lpNumberOfFreeClusters, - LPDWORD lpTotalNumberOfClusters); - -#ifdef UNICODE -#define GetDiskFreeSpace GetDiskFreeSpaceW -#endif - -PALIMPORT -BOOL -PALAPI CreatePipe( OUT PHANDLE hReadPipe, OUT PHANDLE hWritePipe, @@ -4809,33 +4659,6 @@ CreatePipe( IN DWORD nSize ); -PALIMPORT -BOOL -PALAPI -DeregisterEventSource ( - IN HANDLE hEventLog - ); - -PALIMPORT -HANDLE -PALAPI -RegisterEventSourceA ( - IN OPTIONAL LPCSTR lpUNCServerName, - IN LPCSTR lpSourceName - ); -PALIMPORT -HANDLE -PALAPI -RegisterEventSourceW ( - IN OPTIONAL LPCWSTR lpUNCServerName, - IN LPCWSTR lpSourceName - ); -#ifdef UNICODE -#define RegisterEventSource RegisterEventSourceW -#else -#define RegisterEventSource RegisterEventSourceA -#endif // !UNICODE - // // NUMA related APIs // @@ -5010,40 +4833,6 @@ GetProcessAffinityMask( #define EVENTLOG_AUDIT_FAILURE 0x0010 PALIMPORT -BOOL -PALAPI -ReportEventA ( - IN HANDLE hEventLog, - IN WORD wType, - IN WORD wCategory, - IN DWORD dwEventID, - IN OPTIONAL PSID lpUserSid, - IN WORD wNumStrings, - IN DWORD dwDataSize, - IN OPTIONAL LPCSTR *lpStrings, - IN OPTIONAL LPVOID lpRawData - ); -PALIMPORT -BOOL -PALAPI -ReportEventW ( - IN HANDLE hEventLog, - IN WORD wType, - IN WORD wCategory, - IN DWORD dwEventID, - IN OPTIONAL PSID lpUserSid, - IN WORD wNumStrings, - IN DWORD dwDataSize, - IN OPTIONAL LPCWSTR *lpStrings, - IN OPTIONAL LPVOID lpRawData - ); -#ifdef UNICODE -#define ReportEvent ReportEventW -#else -#define ReportEvent ReportEventA -#endif // !UNICODE - -PALIMPORT HRESULT PALAPI CoCreateGuid(OUT GUID * pguid); diff --git a/src/pal/inc/palprivate.h b/src/pal/inc/palprivate.h index 554a5028ad..ce1a9a99a1 100644 --- a/src/pal/inc/palprivate.h +++ b/src/pal/inc/palprivate.h @@ -61,13 +61,6 @@ DeleteFileA( PALIMPORT BOOL PALAPI -MoveFileA( - IN LPCSTR lpExistingFileName, - IN LPCSTR lpNewFileName); - -PALIMPORT -BOOL -PALAPI MoveFileExA( IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index 1d53a43884..370866ca9e 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -149,7 +149,6 @@ set(SOURCES exception/signal.cpp exception/remote-unwind.cpp file/directory.cpp - file/disk.cpp file/file.cpp file/filetime.cpp file/find.cpp diff --git a/src/pal/src/file/disk.cpp b/src/pal/src/file/disk.cpp deleted file mode 100644 index e5d6f831dd..0000000000 --- a/src/pal/src/file/disk.cpp +++ /dev/null @@ -1,180 +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. - -/*++ - - - -Module Name: - - disk.c - -Abstract: - - Implementation of the disk information functions. - -Revision History: - - - ---*/ - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/file.h" -#include "pal/stackstring.hpp" - -#include <sys/param.h> -#include <sys/mount.h> -#include <errno.h> -#if HAVE_STATVFS -#include <sys/types.h> -#include <sys/statvfs.h> -#define statfs statvfs -#if STATVFS64_PROTOTYPE_BROKEN -typedef statvfs_t pal_statfs; -#else // STATVFS64_PROTOTYPE_BROKEN -typedef struct statvfs pal_statfs; -#endif // STATVFS64_PROTOTYPE_BROKEN -#else // HAVE_STATVFS -typedef struct statfs pal_statfs; -#endif // HAVE_STATVFS - -SET_DEFAULT_DEBUG_CHANNEL(FILE); - -/*++ - -Function: - - GetDiskFreeSpaceW - -See MSDN doc. ---*/ -PALIMPORT -BOOL -PALAPI -GetDiskFreeSpaceW( - LPCWSTR lpDirectoryName, - LPDWORD lpSectorsPerCluster, - LPDWORD lpBytesPerSector, - LPDWORD lpNumberOfFreeClusters, /* Caller will ignore output value */ - LPDWORD lpTotalNumberOfClusters) /* Caller will ignore output value */ -{ - BOOL bRetVal = FALSE; - pal_statfs fsInfoBuffer; - INT statfsRetVal = 0; - DWORD dwLastError = NO_ERROR; - PathCharString dirNameBufferPathString; - size_t length; - char * dirNameBuffer; - const char * dirName; - int size; - - PERF_ENTRY(GetDiskFreeSpaceW); - ENTRY( "GetDiskFreeSpaceW( lpDirectoryName=%p (%S), lpSectorsPerCluster=%p," - "lpBytesPerSector=%p, lpNumberOfFreeClusters=%p, " - "lpTotalNumberOfClusters=%p )\n", lpDirectoryName ? lpDirectoryName : - W16_NULLSTRING, lpDirectoryName ? lpDirectoryName : - W16_NULLSTRING, lpSectorsPerCluster, lpBytesPerSector, - lpNumberOfFreeClusters, lpTotalNumberOfClusters ); - - /* Sanity checks. */ - if ( !lpSectorsPerCluster ) - { - ERROR( "lpSectorsPerCluster cannot be NULL!\n" ); - dwLastError = ERROR_INVALID_PARAMETER; - goto exit; - } - if ( !lpBytesPerSector ) - { - ERROR( "lpBytesPerSector cannot be NULL!\n" ); - dwLastError = ERROR_INVALID_PARAMETER; - goto exit; - } - if ( lpNumberOfFreeClusters || lpTotalNumberOfClusters ) - { - TRACE("GetDiskFreeSpaceW is ignoring lpNumberOfFreeClusters" - " and lpTotalNumberOfClusters\n" ); - } - if ( lpDirectoryName && PAL_wcslen( lpDirectoryName ) == 0 ) - { - ERROR( "lpDirectoryName is empty.\n" ); - dwLastError = ERROR_INVALID_PARAMETER; - goto exit; - } - - /* Fusion uses this API to round file sizes up to their actual size - on-disk based on the BytesPerSector * SectorsPerCluster. - The intent is to avoid computing the sum of all file sizes in the - cache just in bytes and not account for the cluster-sized slop, when - determining if the cache is too large or not. */ - - if ( lpDirectoryName ) - { - length = (PAL_wcslen(lpDirectoryName)+1) * 3; - dirNameBuffer = dirNameBufferPathString.OpenStringBuffer(length); - if (NULL == dirNameBuffer) - { - dwLastError = ERROR_NOT_ENOUGH_MEMORY; - goto exit; - } - - size = WideCharToMultiByte( CP_ACP, 0, lpDirectoryName, -1, - dirNameBuffer,length, 0, 0 ); - dirNameBufferPathString.CloseBuffer(size); - if ( size != 0 ) - { - FILEDosToUnixPathA( dirNameBuffer ); - dirName = dirNameBuffer; - } - else - { - ASSERT( "Unable to convert the lpDirectoryName to multibyte.\n" ); - dwLastError = ERROR_INTERNAL_ERROR; - goto exit; - } - } - else - { - dirName = "/"; - } - - statfsRetVal = statfs( dirName, &fsInfoBuffer ); - - if ( statfsRetVal == 0 ) - { - *lpBytesPerSector = fsInfoBuffer.f_bsize; - *lpSectorsPerCluster = 1; - bRetVal = TRUE; - } - else - { - if ( errno == ENOTDIR || errno == ENOENT ) - { - FILEGetProperNotFoundError( dirNameBuffer, &dwLastError ); - goto exit; - } - dwLastError = FILEGetLastErrorFromErrno(); - if ( ERROR_INTERNAL_ERROR == dwLastError ) - { - ASSERT("statfs() not expected to fail with errno:%d (%s)\n", - errno, strerror(errno)); - } - else - { - TRACE("statfs() failed, errno:%d (%s)\n", errno, strerror(errno)); - } - } - -exit: - if ( NO_ERROR != dwLastError ) - { - SetLastError( dwLastError ); - } - - LOGEXIT( "GetDiskFreeSpace returning %s.\n", bRetVal == TRUE ? "TRUE" : "FALSE" ); - PERF_EXIT(GetDiskFreeSpaceW); - return bRetVal; -} - diff --git a/src/pal/src/file/file.cpp b/src/pal/src/file/file.cpp index e7003c00af..33316266f9 100644 --- a/src/pal/src/file/file.cpp +++ b/src/pal/src/file/file.cpp @@ -1250,67 +1250,6 @@ done: /*++ Function: - MoveFileA - -See MSDN doc. ---*/ -BOOL -PALAPI -MoveFileA( - IN LPCSTR lpExistingFileName, - IN LPCSTR lpNewFileName) -{ - BOOL bRet; - - PERF_ENTRY(MoveFileA); - ENTRY("MoveFileA(lpExistingFileName=%p (%s), lpNewFileName=%p (%s))\n", - lpExistingFileName?lpExistingFileName:"NULL", - lpExistingFileName?lpExistingFileName:"NULL", - lpNewFileName?lpNewFileName:"NULL", - lpNewFileName?lpNewFileName:"NULL"); - - bRet = MoveFileExA( lpExistingFileName, - lpNewFileName, - MOVEFILE_COPY_ALLOWED ); - - LOGEXIT("MoveFileA returns BOOL %d\n", bRet); - PERF_EXIT(MoveFileA); - return bRet; -} - - -/*++ -Function: - MoveFileW - -See MSDN doc. ---*/ -BOOL -PALAPI -MoveFileW( - IN LPCWSTR lpExistingFileName, - IN LPCWSTR lpNewFileName) -{ - BOOL bRet; - - PERF_ENTRY(MoveFileW); - ENTRY("MoveFileW(lpExistingFileName=%p (%S), lpNewFileName=%p (%S))\n", - lpExistingFileName?lpExistingFileName:W16_NULLSTRING, - lpExistingFileName?lpExistingFileName:W16_NULLSTRING, - lpNewFileName?lpNewFileName:W16_NULLSTRING, - lpNewFileName?lpNewFileName:W16_NULLSTRING); - - bRet = MoveFileExW( lpExistingFileName, - lpNewFileName, - MOVEFILE_COPY_ALLOWED ); - - LOGEXIT("MoveFileW returns BOOL %d\n", bRet); - PERF_EXIT(MoveFileW); - return bRet; -} - -/*++ -Function: MoveFileExA See MSDN doc. @@ -3191,145 +3130,6 @@ FlushFileBuffers( return NO_ERROR == palError; } -PAL_ERROR -CorUnix::InternalGetFileType( - CPalThread *pThread, - HANDLE hFile, - DWORD *pdwFileType - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pFileObject = NULL; - CFileProcessLocalData *pLocalData = NULL; - IDataLock *pLocalDataLock = NULL; - - struct stat stat_data; - - if (INVALID_HANDLE_VALUE == hFile) - { - ERROR( "Invalid file handle\n" ); - palError = ERROR_INVALID_HANDLE; - goto InternalGetFileTypeExit; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - GENERIC_READ, - &pFileObject - ); - - if (NO_ERROR != palError) - { - goto InternalGetFileTypeExit; - } - - palError = pFileObject->GetProcessLocalData( - pThread, - ReadLock, - &pLocalDataLock, - reinterpret_cast<void**>(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalGetFileTypeExit; - } - - if (pLocalData->open_flags_deviceaccessonly == TRUE) - { - ERROR("File open for device access only\n"); - palError = ERROR_ACCESS_DENIED; - goto InternalGetFileTypeExit; - } - - if (fstat(pLocalData->unix_fd, &stat_data) != 0) - { - ERROR("fstat failed of file descriptor %d\n", pLocalData->unix_fd); - palError = FILEGetLastErrorFromErrno(); - goto InternalGetFileTypeExit; - } - - TRACE("st_mode & S_IFMT = %#x\n", stat_data.st_mode & S_IFMT); - if (S_ISREG(stat_data.st_mode) || S_ISDIR(stat_data.st_mode)) - { - *pdwFileType = FILE_TYPE_DISK; - } - else if (S_ISCHR(stat_data.st_mode)) - { - *pdwFileType = FILE_TYPE_CHAR; - } - else if (S_ISFIFO(stat_data.st_mode)) - { - *pdwFileType = FILE_TYPE_PIPE; - } - else - { - *pdwFileType = FILE_TYPE_UNKNOWN; - } - - -InternalGetFileTypeExit: - - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - - return palError; - -} - - -/*++ -Function: - GetFileType - -See MSDN doc. - ---*/ -DWORD -PALAPI -GetFileType( - IN HANDLE hFile) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pThread; - DWORD dwFileType; - - PERF_ENTRY(GetFileType); - ENTRY("GetFileType(hFile=%p)\n", hFile); - - pThread = InternalGetCurrentThread(); - - palError = InternalGetFileType( - pThread, - hFile, - &dwFileType - ); - - if (NO_ERROR != palError) - { - dwFileType = FILE_TYPE_UNKNOWN; - pThread->SetLastError(palError); - } - else if (FILE_TYPE_UNKNOWN == dwFileType) - { - pThread->SetLastError(palError); - } - - - LOGEXIT("GetFileType returns DWORD %#x\n", dwFileType); - PERF_EXIT(GetFileType); - return dwFileType; -} - #define ENSURE_UNIQUE_NOT_ZERO \ if ( uUniqueSeed == 0 ) \ {\ @@ -4319,261 +4119,6 @@ CreatePipe( return NO_ERROR == palError; } -PAL_ERROR -CorUnix::InternalLockFile( - CPalThread *pThread, - HANDLE hFile, - DWORD dwFileOffsetLow, - DWORD dwFileOffsetHigh, - DWORD nNumberOfBytesToLockLow, - DWORD nNumberOfBytesToLockHigh - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pFileObject = NULL; - CFileProcessLocalData *pLocalData = NULL; - IDataLock *pLocalDataLock = NULL; - - if (INVALID_HANDLE_VALUE == hFile) - { - ERROR( "Invalid file handle\n" ); - palError = ERROR_INVALID_HANDLE; - goto InternalLockFileExit; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - GENERIC_READ, - &pFileObject - ); - - if (NO_ERROR != palError) - { - goto InternalLockFileExit; - } - - palError = pFileObject->GetProcessLocalData( - pThread, - ReadLock, - &pLocalDataLock, - reinterpret_cast<void**>(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalLockFileExit; - } - - if (NULL != pLocalData->pLockController) - { - palError = pLocalData->pLockController->CreateFileLock( - pThread, - dwFileOffsetLow, - dwFileOffsetHigh, - nNumberOfBytesToLockLow, - nNumberOfBytesToLockHigh, - IFileLockController::ExclusiveFileLock, - IFileLockController::FailImmediately - ); - } - else - { - // - // This isn't a lockable file (e.g., it may be a pipe) - // - - palError = ERROR_ACCESS_DENIED; - goto InternalLockFileExit; - } - -InternalLockFileExit: - - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - - return palError; -} - - -/*++ -Function: - LockFile - -See MSDN doc. ---*/ -PALIMPORT -BOOL -PALAPI -LockFile(HANDLE hFile, - DWORD dwFileOffsetLow, - DWORD dwFileOffsetHigh, - DWORD nNumberOfBytesToLockLow, - DWORD nNumberOfBytesToLockHigh) -{ - CPalThread *pThread; - PAL_ERROR palError = NO_ERROR; - - PERF_ENTRY(LockFile); - ENTRY("LockFile(hFile:%p, offsetLow:%u, offsetHigh:%u, nbBytesLow:%u," - " nbBytesHigh:%u\n", hFile, dwFileOffsetLow, dwFileOffsetHigh, - nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh); - - pThread = InternalGetCurrentThread(); - - palError = InternalLockFile( - pThread, - hFile, - dwFileOffsetLow, - dwFileOffsetHigh, - nNumberOfBytesToLockLow, - nNumberOfBytesToLockHigh - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("LockFile returns %s\n", NO_ERROR == palError ? "TRUE":"FALSE"); - PERF_EXIT(LockFile); - return NO_ERROR == palError; -} - -PAL_ERROR -CorUnix::InternalUnlockFile( - CPalThread *pThread, - HANDLE hFile, - DWORD dwFileOffsetLow, - DWORD dwFileOffsetHigh, - DWORD nNumberOfBytesToUnlockLow, - DWORD nNumberOfBytesToUnlockHigh - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pFileObject = NULL; - CFileProcessLocalData *pLocalData = NULL; - IDataLock *pLocalDataLock = NULL; - - if (INVALID_HANDLE_VALUE == hFile) - { - ERROR( "Invalid file handle\n" ); - palError = ERROR_INVALID_HANDLE; - goto InternalUnlockFileExit; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - GENERIC_READ, - &pFileObject - ); - - if (NO_ERROR != palError) - { - goto InternalUnlockFileExit; - } - - palError = pFileObject->GetProcessLocalData( - pThread, - ReadLock, - &pLocalDataLock, - reinterpret_cast<void**>(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalUnlockFileExit; - } - - if (NULL != pLocalData->pLockController) - { - palError = pLocalData->pLockController->ReleaseFileLock( - pThread, - dwFileOffsetLow, - dwFileOffsetHigh, - nNumberOfBytesToUnlockLow, - nNumberOfBytesToUnlockHigh - ); - } - else - { - // - // This isn't a lockable file (e.g., it may be a pipe) - // - - palError = ERROR_ACCESS_DENIED; - goto InternalUnlockFileExit; - } - -InternalUnlockFileExit: - - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - - return palError; -} - -/*++ -Function: - UnlockFile - -See MSDN doc. ---*/ -PALIMPORT -BOOL -PALAPI -UnlockFile(HANDLE hFile, - DWORD dwFileOffsetLow, - DWORD dwFileOffsetHigh, - DWORD nNumberOfBytesToUnlockLow, - DWORD nNumberOfBytesToUnlockHigh) -{ - CPalThread *pThread; - PAL_ERROR palError = NO_ERROR; - - PERF_ENTRY(UnlockFile); - ENTRY("UnlockFile(hFile:%p, offsetLow:%u, offsetHigh:%u, nbBytesLow:%u," - "nbBytesHigh:%u\n", hFile, dwFileOffsetLow, dwFileOffsetHigh, - nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh); - - pThread = InternalGetCurrentThread(); - - palError = InternalUnlockFile( - pThread, - hFile, - dwFileOffsetLow, - dwFileOffsetHigh, - nNumberOfBytesToUnlockLow, - nNumberOfBytesToUnlockHigh - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("UnlockFile returns %s\n", NO_ERROR == palError ? "TRUE" : "FALSE"); - PERF_EXIT(UnlockFile); - return NO_ERROR == palError; -} - /*++ init_std_handle [static] diff --git a/src/pal/src/file/filetime.cpp b/src/pal/src/file/filetime.cpp index ca36e04d9d..6cc8dacc72 100644 --- a/src/pal/src/file/filetime.cpp +++ b/src/pal/src/file/filetime.cpp @@ -148,351 +148,6 @@ CompareFileTime( } - -/*++ -Function: - SetFileTime - -Notes: This function will drop one digit (radix 10) of precision from -the supplied times, since Unix can set to the microsecond (at most, i.e. -if the futimes() function is available). - -As noted in the file header, there is no analog to "creation time" on Unix -systems, so the lpCreationTime argument to this function will always be -ignored, and the inode change time will be set to the current time. ---*/ -BOOL -PALAPI -SetFileTime( - IN HANDLE hFile, - IN CONST FILETIME *lpCreationTime, - IN CONST FILETIME *lpLastAccessTime, - IN CONST FILETIME *lpLastWriteTime) -{ - CPalThread *pThread; - PAL_ERROR palError = NO_ERROR; - const UINT64 MAX_FILETIMEVALUE = 0x8000000000000000LL; - - PERF_ENTRY(SetFileTime); - ENTRY("SetFileTime(hFile=%p, lpCreationTime=%p, lpLastAccessTime=%p, " - "lpLastWriteTime=%p)\n", hFile, lpCreationTime, lpLastAccessTime, - lpLastWriteTime); - - pThread = InternalGetCurrentThread(); - - /* validate filetime values */ - if ( (lpCreationTime && (((UINT64)lpCreationTime->dwHighDateTime << 32) + - lpCreationTime->dwLowDateTime >= MAX_FILETIMEVALUE)) || - (lpLastAccessTime && (((UINT64)lpLastAccessTime->dwHighDateTime << 32) + - lpLastAccessTime->dwLowDateTime >= MAX_FILETIMEVALUE)) || - (lpLastWriteTime && (((UINT64)lpLastWriteTime->dwHighDateTime << 32) + - lpLastWriteTime->dwLowDateTime >= MAX_FILETIMEVALUE))) - { - pThread->SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - palError = InternalSetFileTime( - pThread, - hFile, - lpCreationTime, - lpLastAccessTime, - lpLastWriteTime - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("SetFileTime returns BOOL %s\n", NO_ERROR == palError ? "TRUE":"FALSE"); - PERF_EXIT(SetFileTime); - return NO_ERROR == palError; -} - -PAL_ERROR -CorUnix::InternalSetFileTime( - CPalThread *pThread, - IN HANDLE hFile, - IN CONST FILETIME *lpCreationTime, - IN CONST FILETIME *lpLastAccessTime, - IN CONST FILETIME *lpLastWriteTime) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pFileObject = NULL; - CFileProcessLocalData *pLocalData = NULL; - IDataLock *pLocalDataLock = NULL; - struct timeval Times[2]; - int fd; - long nsec; - struct stat stat_buf; - - if (INVALID_HANDLE_VALUE == hFile) - { - ERROR( "Invalid file handle\n" ); - palError = ERROR_INVALID_HANDLE; - goto InternalSetFileTimeExit; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - GENERIC_READ, - &pFileObject - ); - - if (NO_ERROR != palError) - { - goto InternalSetFileTimeExit; - } - - palError = pFileObject->GetProcessLocalData( - pThread, - ReadLock, - &pLocalDataLock, - reinterpret_cast<void**>(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalSetFileTimeExit; - } - - if (lpCreationTime) - { - palError = ERROR_NOT_SUPPORTED; - goto InternalSetFileTimeExit; - } - - if( !lpLastAccessTime && !lpLastWriteTime ) - { - // if both pointers are NULL, the function simply returns. - goto InternalSetFileTimeExit; - } - else if( !lpLastAccessTime || !lpLastWriteTime ) - { - // if either pointer is NULL, fstat will need to be called. - fd = pLocalData->unix_fd; - if ( fd == -1 ) - { - TRACE("pLocalData = [%p], fd = %d\n", pLocalData, fd); - palError = ERROR_INVALID_HANDLE; - goto InternalSetFileTimeExit; - } - - if ( fstat(fd, &stat_buf) != 0 ) - { - TRACE("fstat failed on file descriptor %d\n", fd); - palError = FILEGetLastErrorFromErrno(); - goto InternalSetFileTimeExit; - } - } - - if (lpLastAccessTime) - { - Times[0].tv_sec = FILEFileTimeToUnixTime( *lpLastAccessTime, &nsec ); - Times[0].tv_usec = nsec / 1000; /* convert to microseconds */ - } - else - { - Times[0].tv_sec = stat_buf.st_atime; - Times[0].tv_usec = ST_ATIME_NSEC(&stat_buf) / 1000; - } - - if (lpLastWriteTime) - { - Times[1].tv_sec = FILEFileTimeToUnixTime( *lpLastWriteTime, &nsec ); - Times[1].tv_usec = nsec / 1000; /* convert to microseconds */ - } - else - { - Times[1].tv_sec = stat_buf.st_mtime; - Times[1].tv_usec = ST_MTIME_NSEC(&stat_buf) / 1000; - } - - TRACE("Setting atime = [%ld.%ld], mtime = [%ld.%ld]\n", - Times[0].tv_sec, Times[0].tv_usec, - Times[1].tv_sec, Times[1].tv_usec); - -#if HAVE_FUTIMES - if ( futimes(pLocalData->unix_fd, Times) != 0 ) -#elif HAVE_UTIMES - if ( utimes(pLocalData->unix_filename, Times) != 0 ) -#else - #error Operating system not supported -#endif - { - palError = FILEGetLastErrorFromErrno(); - } - -InternalSetFileTimeExit: - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - - return palError; -} - - -/*++ -Function: - GetFileTime - -Notes: As noted at the top of this file, there is no analog to "creation -time" on Unix systems, so the inode change time is used instead. Also, Win32 -LastAccessTime is updated after a write operation, but it is not on Unix. -To be consistent with Win32, this function returns the greater of mtime and -atime for LastAccessTime. ---*/ -BOOL -PALAPI -GetFileTime( - IN HANDLE hFile, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpLastAccessTime, - OUT LPFILETIME lpLastWriteTime) -{ - CPalThread *pThread; - PAL_ERROR palError = NO_ERROR; - - PERF_ENTRY(GetFileTime); - ENTRY("GetFileTime(hFile=%p, lpCreationTime=%p, lpLastAccessTime=%p, " - "lpLastWriteTime=%p)\n", - hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime); - - pThread = InternalGetCurrentThread(); - - palError = InternalGetFileTime( - pThread, - hFile, - lpCreationTime, - lpLastAccessTime, - lpLastWriteTime - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("GetFileTime returns BOOL %s\n", NO_ERROR == palError ? "TRUE":"FALSE"); - PERF_EXIT(GetFileTime); - return NO_ERROR == palError; -} - -PAL_ERROR -CorUnix::InternalGetFileTime( - CPalThread *pThread, - IN HANDLE hFile, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpLastAccessTime, - OUT LPFILETIME lpLastWriteTime) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pFileObject = NULL; - CFileProcessLocalData *pLocalData = NULL; - IDataLock *pLocalDataLock = NULL; - int Fd = -1; - - struct stat StatData; - - if (INVALID_HANDLE_VALUE == hFile) - { - ERROR( "Invalid file handle\n" ); - palError = ERROR_INVALID_HANDLE; - goto InternalGetFileTimeExit; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - GENERIC_READ, - &pFileObject - ); - - if (NO_ERROR != palError) - { - goto InternalGetFileTimeExit; - } - - palError = pFileObject->GetProcessLocalData( - pThread, - ReadLock, - &pLocalDataLock, - reinterpret_cast<void**>(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalGetFileTimeExit; - } - - Fd = pLocalData->unix_fd; - - if ( Fd == -1 ) - { - TRACE("pLocalData = [%p], Fd = %d\n", pLocalData, Fd); - palError = ERROR_INVALID_HANDLE; - goto InternalGetFileTimeExit; - } - - if ( fstat(Fd, &StatData) != 0 ) - { - TRACE("fstat failed on file descriptor %d\n", Fd); - palError = FILEGetLastErrorFromErrno(); - goto InternalGetFileTimeExit; - } - - if ( lpCreationTime ) - { - *lpCreationTime = FILEUnixTimeToFileTime(StatData.st_ctime, - ST_CTIME_NSEC(&StatData)); - } - if ( lpLastWriteTime ) - { - *lpLastWriteTime = FILEUnixTimeToFileTime(StatData.st_mtime, - ST_MTIME_NSEC(&StatData)); - } - if ( lpLastAccessTime ) - { - *lpLastAccessTime = FILEUnixTimeToFileTime(StatData.st_atime, - ST_ATIME_NSEC(&StatData)); - /* if Unix mtime is greater than atime, return mtime as the last - access time */ - if ( lpLastWriteTime && - CompareFileTime(lpLastAccessTime, lpLastWriteTime) < 0 ) - { - *lpLastAccessTime = *lpLastWriteTime; - } - } - -InternalGetFileTimeExit: - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - - return palError; -} - - - - - - /*++ Function: GetSystemTimeAsFileTime @@ -711,84 +366,3 @@ BOOL PALAPI FileTimeToSystemTime( CONST FILETIME * lpFileTime, } } - - -/** -Function: - FileTimeToDosDateTime - - Notes due to the difference between how BSD and Windows - calculates time, this function can only repersent dates between - 1980 and 2037. 2037 is the upperlimit for the BSD time functions( 1900 - - 2037 range ). - -See msdn for more details. ---*/ -BOOL -PALAPI -FileTimeToDosDateTime( - IN CONST FILETIME *lpFileTime, - OUT LPWORD lpFatDate, - OUT LPWORD lpFatTime ) -{ - BOOL bRetVal = FALSE; - - PERF_ENTRY(FileTimeToDosDateTime); - ENTRY( "FileTimeToDosDateTime( lpFileTime=%p, lpFatDate=%p, lpFatTime=%p )\n", - lpFileTime, lpFatDate, lpFatTime ); - - /* Sanity checks. */ - if ( !lpFileTime || !lpFatDate || !lpFatTime ) - { - ERROR( "Incorrect parameters.\n" ); - SetLastError( ERROR_INVALID_PARAMETER ); - } - else - { - /* Do conversion. */ - SYSTEMTIME SysTime; - if ( FileTimeToSystemTime( lpFileTime, &SysTime ) ) - { - if ( SysTime.wYear >= 1980 && SysTime.wYear <= 2037 ) - { - *lpFatDate = 0; - *lpFatTime = 0; - - *lpFatDate |= ( SysTime.wDay & 0x1F ); - *lpFatDate |= ( ( SysTime.wMonth & 0xF ) << 5 ); - *lpFatDate |= ( ( ( SysTime.wYear - 1980 ) & 0x7F ) << 9 ); - - if ( SysTime.wSecond % 2 == 0 ) - { - *lpFatTime |= ( ( SysTime.wSecond / 2 ) & 0x1F ); - } - else - { - *lpFatTime |= ( ( SysTime.wSecond / 2 + 1 ) & 0x1F ); - } - - *lpFatTime |= ( ( SysTime.wMinute & 0x3F ) << 5 ); - *lpFatTime |= ( ( SysTime.wHour & 0x1F ) << 11 ); - - bRetVal = TRUE; - } - else - { - ERROR( "The function can only repersent dates between 1/1/1980" - " and 12/31/2037\n" ); - SetLastError( ERROR_INVALID_PARAMETER ); - } - } - else - { - ERROR( "Unable to convert file time to system time.\n" ); - SetLastError( ERROR_INVALID_PARAMETER ); - bRetVal = FALSE; - } - } - - LOGEXIT( "returning BOOL %d\n", bRetVal ); - PERF_EXIT(FileTimeToDosDateTime); - return bRetVal; -} - diff --git a/src/pal/src/include/pal/file.hpp b/src/pal/src/include/pal/file.hpp index 22e4187675..b34ad75dc2 100644 --- a/src/pal/src/include/pal/file.hpp +++ b/src/pal/src/include/pal/file.hpp @@ -102,13 +102,6 @@ namespace CorUnix ); PAL_ERROR - InternalGetFileType( - CPalThread *pThread, - HANDLE hFile, - DWORD *pdwFileType - ); - - PAL_ERROR InternalCreatePipe( CPalThread *pThread, HANDLE *phReadPipe, @@ -118,26 +111,6 @@ namespace CorUnix ); PAL_ERROR - InternalLockFile( - CPalThread *pThread, - HANDLE hFile, - DWORD dwFileOffsetLow, - DWORD dwFileOffsetHigh, - DWORD nNumberOfBytesToLockLow, - DWORD nNumberOfBytesToLockHigh - ); - - PAL_ERROR - InternalUnlockFile( - CPalThread *pThread, - HANDLE hFile, - DWORD dwFileOffsetLow, - DWORD dwFileOffsetHigh, - DWORD nNumberOfBytesToUnlockLow, - DWORD nNumberOfBytesToUnlockHigh - ); - - PAL_ERROR InternalSetFilePointer( CPalThread *pThread, HANDLE hFile, @@ -147,24 +120,6 @@ namespace CorUnix PLONG lpNewFilePointerLow ); - PAL_ERROR - InternalSetFileTime( - CPalThread *pThread, - IN HANDLE hFile, - IN CONST FILETIME *lpCreationTime, - IN CONST FILETIME *lpLastAccessTime, - IN CONST FILETIME *lpLastWriteTime - ); - - PAL_ERROR - InternalGetFileTime( - CPalThread *pThread, - IN HANDLE hFile, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpLastAccessTime, - OUT LPFILETIME lpLastWriteTime - ); - BOOL RealPathHelper(LPCSTR lpUnixPath, PathCharString& lpBuffer); /*++ diff --git a/src/pal/src/locale/unicode.cpp b/src/pal/src/locale/unicode.cpp index 69214735d1..97d4731198 100644 --- a/src/pal/src/locale/unicode.cpp +++ b/src/pal/src/locale/unicode.cpp @@ -283,61 +283,6 @@ CharNextExA( } - -/*++ -Function: -AreFileApisANSI - -The AreFileApisANSI function determines whether the file I/O functions -are using the ANSI or OEM character set code page. This function is -useful for 8-bit console input and output operations. - -Return Values - -If the set of file I/O functions is using the ANSI code page, the return value is nonzero. - -If the set of file I/O functions is using the OEM code page, the return value is zero. - -In the ROTOR version we always return true since there is no concept -of OEM code pages. - ---*/ -BOOL -PALAPI -AreFileApisANSI( - VOID) -{ - PERF_ENTRY(AreFileApisANSI); - ENTRY("AreFileApisANSI ()\n"); - - LOGEXIT("AreFileApisANSI returns BOOL TRUE\n"); - PERF_EXIT(AreFileApisANSI); - return TRUE; -} - - -/*++ -Function: -GetConsoleCP - -See MSDN doc. ---*/ -UINT -PALAPI -GetConsoleCP( - VOID) -{ - UINT nRet = 0; - PERF_ENTRY(GetConsoleCP); - ENTRY("GetConsoleCP()\n"); - - nRet = GetACP(); - - LOGEXIT("GetConsoleCP returns UINT %d\n", nRet ); - PERF_EXIT(GetConsoleCP); - return nRet; -} - /*++ Function: GetConsoleOutputCP diff --git a/src/pal/src/map/map.cpp b/src/pal/src/map/map.cpp index bf73ab74d7..4a435f8cef 100644 --- a/src/pal/src/map/map.cpp +++ b/src/pal/src/map/map.cpp @@ -1041,79 +1041,6 @@ MapViewOfFileEx( return pvMappedBaseAddress; } -/*++ -Function: - FlushViewOfFile - -See MSDN doc. ---*/ -BOOL -PALAPI -FlushViewOfFile( - IN LPVOID lpBaseAddress, - IN SIZE_T dwNumberOfBytesToFlush) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pThread = NULL; - PMAPPED_VIEW_LIST pView = NULL; - BOOL fResult = TRUE; - - PERF_ENTRY(FlushViewOfFile); - ENTRY("FlushViewOfFile(lpBaseAddress=%p, dwNumberOfBytesToFlush=%u)\n", - lpBaseAddress, dwNumberOfBytesToFlush); - - pThread = InternalGetCurrentThread(); - - InternalEnterCriticalSection(pThread, &mapping_critsec); - - pView = MAPGetViewForAddress(lpBaseAddress); - if (NULL == pView) - { - ERROR("lpBaseAddress has to be the address returned by MapViewOfFile[Ex]"); - palError = ERROR_INVALID_HANDLE; - goto Exit; - } - - if (dwNumberOfBytesToFlush == 0) - { - dwNumberOfBytesToFlush = pView->NumberOfBytesToMap; - } - - // <ROTORTODO>we should only use MS_SYNC if the file has been opened - // with FILE_FLAG_WRITE_THROUGH - if (msync(lpBaseAddress, dwNumberOfBytesToFlush, MS_SYNC) == -1) - { - if (errno == EINVAL) - { - WARN("msync failed; %s\n", strerror(errno)); - palError = ERROR_INVALID_PARAMETER; - } - else if (errno == EIO) - { - WARN("msync failed; %s\n", strerror(errno)); - palError = ERROR_WRITE_FAULT; - } - else - { - ERROR("msync failed; %s\n", strerror(errno)); - palError = ERROR_INTERNAL_ERROR; - } - } - -Exit: - InternalLeaveCriticalSection(pThread, &mapping_critsec); - - if (NO_ERROR != palError) - { - fResult = FALSE; - pThread->SetLastError(palError); - } - - LOGEXIT("FlushViewOfFile returning %d.\n", fResult); - PERF_EXIT(FlushViewOfFile); - return fResult; -} - /*++ Function: diff --git a/src/pal/src/memory/heap.cpp b/src/pal/src/memory/heap.cpp index 5757da83b7..ccee77ff50 100644 --- a/src/pal/src/memory/heap.cpp +++ b/src/pal/src/memory/heap.cpp @@ -63,28 +63,6 @@ RtlMoveMemory( /*++ Function: - RtlZeroMemory - -See MSDN doc. ---*/ -VOID -PALAPI -RtlZeroMemory( - PVOID Destination, - SIZE_T Length -) -{ - PERF_ENTRY(RtlZeroMemory); - ENTRY("RtlZeroMemory(Destination:%p, Length:%x)\n", Destination, Length); - - memset(Destination, 0, Length); - - LOGEXIT("RtlZeroMemory returning.\n"); - PERF_EXIT(RtlZeroMemory); -} - -/*++ -Function: HeapCreate See MSDN doc. diff --git a/src/pal/src/misc/eventlog.cpp b/src/pal/src/misc/eventlog.cpp deleted file mode 100644 index 9eb67ffb1c..0000000000 --- a/src/pal/src/misc/eventlog.cpp +++ /dev/null @@ -1,423 +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. - -/*++ - - - -Module Name: - - eventlog.cpp - -Abstract: - - (Rudimentary) implementation of Event Log. - - Defaults to BSD syslog. On Mac OS X, uses the superior asl. - - Caviats: - * Neither are real handles that you can lock. If that is necessary, the - PAL handle functionality can be used. - * Neither are kept in a table so that if you ask for the same event source - twice, you get the same handle. - * The resource file is not consulted, so we just print out the replacement - strings. Fortunately, for the CLR, there's the resources just have the single - replacement string. - -Revision History: - - 5/21/09 -- initial - - - ---*/ - -#include "pal/malloc.hpp" -#include "pal/dbgmsg.h" - -#ifdef __APPLE__ -#define USE_ASL -#endif // __APPLE__ - -#ifdef USE_ASL -#include <asl.h> -#else // USE_ASL -#include <syslog.h> -#endif // USE_ASL else - -using namespace CorUnix; - -SET_DEFAULT_DEBUG_CHANNEL(MISC); - -HANDLE -PALAPI -RegisterEventSourceA ( - IN OPTIONAL LPCSTR lpUNCServerName, - IN LPCSTR lpSourceName - ) -{ - HANDLE hRet = INVALID_HANDLE_VALUE; - - PERF_ENTRY(RegisterEventSourceA); - ENTRY("RegisterEventSourceA(lpUNCServerName=%p (%s), lpSourceName=%p (%s))\n", - lpUNCServerName, lpUNCServerName?lpUNCServerName:"NULL", - lpSourceName, lpSourceName?lpSourceName:"NULL"); - - if (NULL != lpUNCServerName) - { - SetLastError(ERROR_NOT_SUPPORTED); - return hRet; - } - - if (NULL == lpSourceName) - { - ERROR("lpSourceName has to be a valid parameter\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return hRet; - } - -#ifdef USE_ASL - // In asl parlance, the EventSource handle is an aslclient; it's not - // guaranteed to be the same as a different call to this with the same - // source name. - aslclient asl = asl_open(lpSourceName, NULL /* facility */, 0 /* opts */); - hRet = (HANDLE)asl; -#else // USE_ASL - // In syslog parlance, the EventSource handle is just a string name - // representing the source. - size_t sizeSyslogHandle = strlen(lpSourceName) + 1; - char *syslogHandle = (char *)PAL_malloc(sizeSyslogHandle); - if (syslogHandle) - { - strcpy_s(syslogHandle, sizeSyslogHandle, lpSourceName); - hRet = (HANDLE)syslogHandle; - } -#endif // USE_ASL else - - if (INVALID_HANDLE_VALUE == hRet) - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - - LOGEXIT("RegisterEventSourceA returns %p\n", hRet); - PERF_EXIT(RegisterEventSourceA); - return hRet; -} - -HANDLE -PALAPI -RegisterEventSourceW ( - IN OPTIONAL LPCWSTR lpUNCServerName, - IN LPCWSTR lpSourceName - ) -{ - HANDLE hRet = INVALID_HANDLE_VALUE; - int size; - CHAR *inBuff = NULL; - - PERF_ENTRY(RegisterEventSourceW); - ENTRY("RegisterEventSourceW(lpUNCServerName=%p (%S), lpSourceName=%p (%S))\n", - lpUNCServerName, lpUNCServerName?lpUNCServerName:W16_NULLSTRING, - lpSourceName, lpSourceName?lpSourceName:W16_NULLSTRING); - - if (NULL != lpUNCServerName) - { - SetLastError(ERROR_NOT_SUPPORTED); - return hRet; - } - - size = WideCharToMultiByte(CP_ACP, 0, lpSourceName, -1, NULL, 0, NULL, NULL); - - if (0 == size) - { - ERROR("lpSourceName has to be a valid parameter\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return hRet; - } - inBuff = (CHAR *)PAL_malloc(size); - if (NULL == inBuff) - { - ERROR("malloc failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return hRet; - } - - if (0 == WideCharToMultiByte(CP_ACP, 0, lpSourceName, -1, inBuff, size, NULL, NULL)) - { - ASSERT( "WideCharToMultiByte failed!\n" ); - SetLastError(ERROR_INTERNAL_ERROR); - goto done; - } - - hRet = RegisterEventSourceA(NULL, inBuff); - -done: - PAL_free(inBuff); - - LOGEXIT("RegisterEventSourceW returns %p\n", hRet); - PERF_EXIT(RegisterEventSourceW); - return hRet; -} - -BOOL -PALAPI -DeregisterEventSource ( - IN HANDLE hEventLog - ) -{ - BOOL bRet = FALSE; - - PERF_ENTRY(DeregisterEventSource) - ENTRY("DeregisterEventSource(hEventLog=%p)\n", hEventLog); - - if (INVALID_HANDLE_VALUE == hEventLog || - NULL == hEventLog) - { - SetLastError(ERROR_INVALID_HANDLE); - goto done; - } - -#ifdef USE_ASL - asl_close((aslclient)hEventLog); -#else // USE_ASL - PAL_free(hEventLog); -#endif // USE_ASL else - - bRet = TRUE; - -done: - - LOGEXIT("DeregisterEventSource returns BOOL %d\n", bRet); - PERF_EXIT(DeregisterEventSource); - return bRet; -} - -BOOL -PALAPI -ReportEventA ( - IN HANDLE hEventLog, - IN WORD wType, - IN WORD wCategory, - IN DWORD dwEventID, - IN OPTIONAL PSID lpUserSid, - IN WORD wNumStrings, - IN DWORD dwDataSize, - IN OPTIONAL LPCSTR *lpStrings, - IN OPTIONAL LPVOID lpRawData - ) -{ - BOOL bRet = FALSE; - - PERF_ENTRY(ReportEventA); - ENTRY("ReportEventA(hEventLog=%p, wType=0x%hx, wCategory=0x%hx, dwEventID=0x%x, " - "lpUserSid=%p, wNumStrings=%hu, dwDataSize=%u, lpStrings=%p, lpRawData=%p)\n", - hEventLog, wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, - lpStrings, lpRawData); - - if (INVALID_HANDLE_VALUE == hEventLog) - { - ERROR("hEventLog has to be a valid parameter\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return bRet; - } - - if (wNumStrings > 0 && NULL == lpStrings) - { - ERROR("lpStrings has to be a valid parameter if wNumStrings is non-zero\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return bRet; - } - - if (NULL != lpUserSid || 0 != dwDataSize || 1 != wNumStrings) - { - SetLastError(ERROR_NOT_SUPPORTED); - return bRet; - } - -#ifdef USE_ASL - int level; - switch (wType) - { - case EVENTLOG_SUCCESS: - case EVENTLOG_AUDIT_SUCCESS: - level = ASL_LEVEL_NOTICE; - break; - - case EVENTLOG_INFORMATION_TYPE: - level = ASL_LEVEL_INFO; - break; - - case EVENTLOG_ERROR_TYPE: - case EVENTLOG_AUDIT_FAILURE: - level = ASL_LEVEL_ERR; - break; - - case EVENTLOG_WARNING_TYPE: - level = ASL_LEVEL_WARNING; - break; - - default: - ERROR("Unknown RecordEvent type.\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return bRet; - } - - aslmsg msg; - msg = asl_new(ASL_TYPE_MSG); - int aslRet; - - if (msg) - { - char szNumber[11]; - - sprintf_s(szNumber, sizeof(szNumber) / sizeof(*szNumber), "%hu", wCategory); - aslRet = asl_set(msg, "Category", szNumber); - if (aslRet != 0) - WARN("Could not set Category %s on aslmsg (%p)", szNumber, msg); - sprintf_s(szNumber, sizeof(szNumber) / sizeof(*szNumber), "%u", dwEventID); - aslRet = asl_set(msg, "EventID", szNumber); - if (aslRet != 0) - WARN("Could not set EventID %s on aslmsg (%p)", szNumber, msg); - - aslRet = asl_log((aslclient)hEventLog, msg, level, "%s", lpStrings[0]); - - asl_free(msg); - } - else - { - // Yikes, fall back to worse syslog behavior due to low mem or asl issue. - aslRet = asl_log((aslclient)hEventLog, NULL, level, "[%hx:%x] %s", wCategory, dwEventID, lpStrings[0]); - } - - if (aslRet != 0) - SetLastError(ERROR_INTERNAL_ERROR); - else - bRet = TRUE; -#else // USE_ASL - int priority; - switch (wType) - { - case EVENTLOG_SUCCESS: - case EVENTLOG_AUDIT_SUCCESS: - case EVENTLOG_INFORMATION_TYPE: - priority = LOG_INFO; - break; - - case EVENTLOG_ERROR_TYPE: - case EVENTLOG_AUDIT_FAILURE: - priority = LOG_ERR; - break; - - case EVENTLOG_WARNING_TYPE: - priority = LOG_WARNING; - break; - - default: - ERROR("Unknown RecordEvent type.\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return bRet; - } - - openlog((char *)hEventLog, LOG_CONS | LOG_PID, LOG_USER); - - syslog(priority, "[%hx:%x] %s", wCategory, dwEventID, lpStrings[0]); - - closelog(); - - bRet = TRUE; -#endif // USE_ASL else - - LOGEXIT("ReportEventA returns BOOL %d\n", bRet); - PERF_EXIT(ReportEventA); - return bRet; -} - -BOOL -PALAPI -ReportEventW ( - IN HANDLE hEventLog, - IN WORD wType, - IN WORD wCategory, - IN DWORD dwEventID, - IN OPTIONAL PSID lpUserSid, - IN WORD wNumStrings, - IN DWORD dwDataSize, - IN OPTIONAL LPCWSTR *lpStrings, - IN OPTIONAL LPVOID lpRawData - ) -{ - BOOL bRet = FALSE; - LPCSTR *lpMBStrings = NULL; - - PERF_ENTRY(ReportEventW); - ENTRY("ReportEventW(hEventLog=%p, wType=0x%hx, wCategory=0x%hx, dwEventID=0x%x, " - "lpUserSid=%p, wNumStrings=%hu, dwDataSize=%u, lpStrings=%p, lpRawData=%p)\n", - hEventLog, wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, - lpStrings, lpRawData); - - if (wNumStrings > 0 && NULL == lpStrings) - { - ERROR("lpStrings has to be a valid parameter if wNumStrings is non-zero\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return bRet; - } - - if (wNumStrings > 0) - { - lpMBStrings = (LPCSTR *)PAL_malloc(wNumStrings * sizeof(CHAR *)); - if (!lpMBStrings) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return bRet; - } - - for (WORD iString = 0; iString < wNumStrings; iString++) - { - int size; - bool fConverted; - CHAR *sz; - - size = WideCharToMultiByte(CP_ACP, 0, lpStrings[iString], -1, NULL, 0, NULL, NULL); - if (0 == size) - { - ERROR("lpStrings[%d] has to be a valid parameter\n", iString); - SetLastError(ERROR_INVALID_PARAMETER); - wNumStrings = iString; // so that free only frees earlier converted lpStrings. - goto done; - } - - sz = (LPSTR)PAL_malloc(size); - if (!sz) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - wNumStrings = iString; // so that free only frees earlier converted lpStrings. - goto done; - } - fConverted = (0 != WideCharToMultiByte(CP_ACP, 0, lpStrings[iString], -1, - sz, size, NULL, NULL)); - lpMBStrings[iString] = sz; // no const-cast needed. - if (!fConverted) - { - ASSERT("WideCharToMultiByte failed!\n"); - SetLastError(ERROR_INTERNAL_ERROR); - wNumStrings = iString + 1; // so that free only frees earlier converted lpStrings. - goto done; - } - } - } - - bRet = ReportEventA(hEventLog, wType, wCategory, dwEventID, lpUserSid, wNumStrings, - dwDataSize, lpMBStrings, lpRawData); - -done: - - if (wNumStrings > 0) - { - for (WORD iString = 0; iString < wNumStrings; iString++) - PAL_free((PVOID)lpMBStrings[iString]); - PAL_free(lpMBStrings); - } - - LOGEXIT("ReportEventW returns BOOL %d\n", bRet); - PERF_EXIT(ReportEventW); - return bRet; -} diff --git a/src/pal/src/thread/thread.cpp b/src/pal/src/thread/thread.cpp index 2bd9477334..c6bbfb81f2 100644 --- a/src/pal/src/thread/thread.cpp +++ b/src/pal/src/thread/thread.cpp @@ -855,80 +855,6 @@ ExitThread( /*++ Function: - GetExitCodeThread - -See MSDN doc. ---*/ -BOOL -PALAPI -GetExitCodeThread( - IN HANDLE hThread, - IN LPDWORD lpExitCode) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pthrCurrent = NULL; - CPalThread *pthrTarget = NULL; - IPalObject *pobjThread = NULL; - BOOL fExitCodeSet; - - PERF_ENTRY(GetExitCodeThread); - ENTRY("GetExitCodeThread(hThread = %p, lpExitCode = %p)\n", - hThread, lpExitCode); - - if (NULL == lpExitCode) - { - WARN("Got NULL lpExitCode\n"); - palError = ERROR_INVALID_PARAMETER; - goto done; - } - - pthrCurrent = InternalGetCurrentThread(); - palError = InternalGetThreadDataFromHandle( - pthrCurrent, - hThread, - 0, - &pthrTarget, - &pobjThread - ); - - pthrTarget->Lock(pthrCurrent); - - fExitCodeSet = pthrTarget->GetExitCode(lpExitCode); - if (!fExitCodeSet) - { - if (TS_DONE == pthrTarget->synchronizationInfo.GetThreadState()) - { -#ifdef FEATURE_PAL_SXS - // The thread exited without ever calling ExitThread. - // It must have wandered in. - *lpExitCode = 0; -#else // FEATURE_PAL_SXS - ASSERT("exit code not set but thread is dead\n"); -#endif // FEATURE_PAL_SXS - } - else - { - *lpExitCode = STILL_ACTIVE; - } - } - - pthrTarget->Unlock(pthrCurrent); - -done: - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pthrCurrent); - } - - LOGEXIT("GetExitCodeThread returns BOOL %d\n", NO_ERROR == palError); - PERF_EXIT(GetExitCodeThread); - - return NO_ERROR == palError; -} - - -/*++ -Function: InternalEndCurrentThread Does any necessary memory clean up, signals waiting threads, and then forces diff --git a/src/pal/tests/palsuite/README.txt b/src/pal/tests/palsuite/README.txt index 577fc543f0..1cc930b9b0 100644 --- a/src/pal/tests/palsuite/README.txt +++ b/src/pal/tests/palsuite/README.txt @@ -15,7 +15,6 @@ 4. ADDITIONAL NOTES ON TESTING/SPECIFIC TEST CASE ISSUES C_runtime: _fdopen testing issues - File_IO: getfiletime/test5 File_IO: getfilesize/test1, setfilepointer/test(5,6,7) File_IO: gettempfilename(a,w)/test2 File_IO: setfileattributesa/test(1,4), setfileattributesw/test(1,4) @@ -93,11 +92,6 @@ The modes that will not be tested are as follows: -File_IO: getfiletime/test5 - -This test case is NTFS specific. - - File_IO: getfilesize/test1, getfilesizeex/test1 setfilepointer/test(5,6,7) These tests cases create a large number of temporary files which require diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt b/src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d9..0000000000 --- a/src/pal/tests/palsuite/file_io/AreFileApisANSI/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.cpp b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.cpp deleted file mode 100644 index ec61f0cb7d..0000000000 --- a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/AreFileApisANSI.cpp +++ /dev/null @@ -1,40 +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: AreFileApisANSI.c -** -** Purpose: Tests the PAL implementation of the AreFileApisANSI function. -** The only possible return is TRUE. -** -** -**===================================================================*/ - - - -#include <palsuite.h> - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = FALSE; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - bRc = AreFileApisANSI(); - - - if (bRc == FALSE) - { - Fail("AreFileApisANSI: ERROR: Function returned FALSE whereas only TRUE " - "is acceptable.\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt deleted file mode 100644 index ac76e5dc12..0000000000 --- a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - AreFileApisANSI.cpp -) - -add_executable(paltest_arefileapisansi_test1 - ${SOURCES} -) - -add_dependencies(paltest_arefileapisansi_test1 coreclrpal) - -target_link_libraries(paltest_arefileapisansi_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/testinfo.dat deleted file mode 100644 index 5e6b422ae4..0000000000 --- a/src/pal/tests/palsuite/file_io/AreFileApisANSI/test1/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 = file_io -Function = AreFileApisANSI -Name = Positive Test for AreFileApisANSI -Type = DEFAULT -EXE1 = arefileapisansi -Description -=Ensure the return is TRUE because FALSE is not an option in FreeBSD - diff --git a/src/pal/tests/palsuite/file_io/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CMakeLists.txt index 3d6eff1379..09fb686c1a 100644 --- a/src/pal/tests/palsuite/file_io/CMakeLists.txt +++ b/src/pal/tests/palsuite/file_io/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 2.8.12.2) -add_subdirectory(AreFileApisANSI) add_subdirectory(CompareFileTime) add_subdirectory(CopyFileA) add_subdirectory(CopyFileW) @@ -12,25 +11,20 @@ add_subdirectory(DeleteFileA) add_subdirectory(DeleteFileW) add_subdirectory(errorpathnotfound) add_subdirectory(FILECanonicalizePath) -add_subdirectory(FileTimeToDosDateTime) add_subdirectory(FindClose) add_subdirectory(FindFirstFileA) add_subdirectory(FindFirstFileW) add_subdirectory(FindNextFileA) add_subdirectory(FindNextFileW) add_subdirectory(FlushFileBuffers) -add_subdirectory(GetConsoleCP) add_subdirectory(GetConsoleOutputCP) add_subdirectory(GetCurrentDirectoryA) add_subdirectory(GetCurrentDirectoryW) -add_subdirectory(GetDiskFreeSpaceW) add_subdirectory(GetFileAttributesA) add_subdirectory(GetFileAttributesExW) add_subdirectory(GetFileAttributesW) add_subdirectory(GetFileSize) add_subdirectory(GetFileSizeEx) -add_subdirectory(GetFileTime) -add_subdirectory(GetFileType) add_subdirectory(GetFullPathNameA) add_subdirectory(GetFullPathNameW) add_subdirectory(GetLongPathNameW) @@ -41,10 +35,8 @@ add_subdirectory(GetTempFileNameA) add_subdirectory(GetTempFileNameW) add_subdirectory(gettemppatha) add_subdirectory(GetTempPathW) -add_subdirectory(MoveFileA) add_subdirectory(MoveFileExA) add_subdirectory(MoveFileExW) -add_subdirectory(MoveFileW) add_subdirectory(ReadFile) add_subdirectory(RemoveDirectoryA) add_subdirectory(RemoveDirectoryW) @@ -56,6 +48,5 @@ add_subdirectory(SetEndOfFile) add_subdirectory(SetFileAttributesA) add_subdirectory(SetFileAttributesW) add_subdirectory(SetFilePointer) -add_subdirectory(SetFileTime) add_subdirectory(WriteFile) diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d9..0000000000 --- a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt deleted file mode 100644 index 9d5c678be3..0000000000 --- a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_filetimetodosdatetime_test1 - ${SOURCES} -) - -add_dependencies(paltest_filetimetodosdatetime_test1 coreclrpal) - -target_link_libraries(paltest_filetimetodosdatetime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.cpp b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.cpp deleted file mode 100644 index 5f2c81ff98..0000000000 --- a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/test1.cpp +++ /dev/null @@ -1,116 +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: Tests that FileTimeToDosDateTime successfully converts values. -** Makes sure values are rounded up, and the limits of the function -** pass. Also tests that values outside the valid range fail. -** -** -**===================================================================*/ - -#include <palsuite.h> - -typedef struct -{ - DWORD FileTimeLow; - DWORD FileTimeHigh; - WORD FatDate; - WORD FatTime; -} testCase; - -int __cdecl main(int argc, char **argv) -{ - FILETIME FileTime; - WORD ResultDate; - WORD ResultTime; - BOOL ret; - int i; - - testCase testCases[] = - { - /* Test a normal time */ - {0x9BE00100, 0x1B4A02C, 0x14CF, 0x55AF}, /* 12/15/2000, 10:45:30 AM*/ - /* Test that 12/15/2000, 10:45:29 Gets rounded up */ - {0x9B476A80, 0x1B4A02C, 0x14CF, 0x55AF}, /* 12/15/2000, 10:45:30 AM*/ - /* Test that 12/15/2000, 10:45:31 Gets rounded up */ - {0x9C789780, 0x1B4A02C, 0x14CF, 0x55B0}, /* 12/15/2000, 10:45:32 AM*/ - - /* Test the upper and lower limits of the function */ - {0xE1D58000, 0x1A8E79F, 0x0021, 0x0000}, /* 1/1/1980, 12:00:00 AM*/ - {0xb9de1300, 0x1e9eede, 0x739f, 0xbf7d}, /* 12/31/2037, 11:59:58 PM*/ - - /* Tests that should fail */ - {0, 0, 0, 0}, - {0xE0A45300, 0x1A8E79F, 0, 0}, - {0x66D29301, 0x23868B8, 0, 0} - - /* All this accomplishes is for the date to overflow. - Likely the only reason it fails in Windows is bacause the - resulting date falls outside of the legal range. Under BSD, - it falls into a legal range. This being that BSD calculates time - from 1900 to 2037, not 1980 to 2107. - {0xFFFFFFFF, 0xFFFFFFF, 0, 0} - */ - }; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - for (i=0; i<sizeof(testCases) / sizeof(testCase); i++) - { - ResultDate = 0xFFFF; - ResultTime = 0xFFFF; - - FileTime.dwLowDateTime = testCases[i].FileTimeLow; - FileTime.dwHighDateTime = testCases[i].FileTimeHigh; - - - ret = FileTimeToDosDateTime(&FileTime, &ResultDate, &ResultTime); - if (testCases[i].FatDate != 0 || testCases[i].FatTime != 0) - { - /* Expected it to pass */ - if (!ret) - { - Fail("FileTimeToDosDateTime failed for %X,%X!\n", - testCases[i].FileTimeLow, testCases[i].FileTimeHigh); - } - - if (ResultDate != testCases[i].FatDate || - ResultTime != testCases[i].FatTime) - { - Fail("FileTimeToDosDateTime did not convert %X,%X " - "successfully:\nExpected date to be %hX, time %hx.\n" - "Got %hX, %hX\n", testCases[i].FileTimeLow, - testCases[i].FileTimeHigh, testCases[i].FatDate, - testCases[i].FatTime, ResultDate, ResultTime); - } - } - else - { - /* Expected it to fail. */ - if (ret) - { - Fail("FileTimeToDosDateTime passed for %X,%X!\n", - testCases[i].FileTimeLow, testCases[i].FileTimeHigh); - } - - if (ResultDate != 0xFFFF || ResultTime != 0xFFFF) - { - Fail("FileTimeToDosDateTime failed, but modified output " - "parameters: %X %X\n", ResultDate, ResultTime); - } - } - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/test1/testinfo.dat deleted file mode 100644 index b5c7e1ae52..0000000000 --- a/src/pal/tests/palsuite/file_io/FileTimeToDosDateTime/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 = file_io -Function = FileTimeToDosDateTime -Name = Positive Test #1 for FileTimeToDosDateTime -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that FileTimeToDosDateTime successfully converts values. -=Makes sure values are rounded up, and the limits of the function -=pass. Also tests that values outside the valid range fail. - diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d9..0000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleCP/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt deleted file mode 100644 index 7753cadea4..0000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetConsoleCP.cpp -) - -add_executable(paltest_getconsolecp_test1 - ${SOURCES} -) - -add_dependencies(paltest_getconsolecp_test1 coreclrpal) - -target_link_libraries(paltest_getconsolecp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.cpp b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.cpp deleted file mode 100644 index ba17d6c64d..0000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/GetConsoleCP.cpp +++ /dev/null @@ -1,35 +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: GetConsoleCP.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetConsoleCP function. -** -** -**===================================================================*/ - -#include <palsuite.h> - - -int __cdecl main(int argc, char *argv[]) -{ - UINT uiCP = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - uiCP = GetConsoleCP(); - if ((uiCP != CP_ACP) && (uiCP != GetACP()) && (uiCP != 437)) /*437 for MSDOS*/ - { - Fail("GetConsoleCP: ERROR -> The invalid code page %d was returned.\n", - uiCP); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/testinfo.dat deleted file mode 100644 index 608a01b2ef..0000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleCP/test1/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 = file_io -Function = GetConsoleCP -Name = Positive Test for GetConsoleCP (test 1) -Type = DEFAULT -EXE1 = getconsolecp -Description -= Test GetConsoleCP. Apparently there are only two possible -= return values: CP_ACP or 1252 diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt deleted file mode 100644 index ef14ea5352..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt deleted file mode 100644 index e0238707e5..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetDiskFreeSpaceW.cpp -) - -add_executable(paltest_getdiskfreespacew_test1 - ${SOURCES} -) - -add_dependencies(paltest_getdiskfreespacew_test1 coreclrpal) - -target_link_libraries(paltest_getdiskfreespacew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.cpp b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.cpp deleted file mode 100644 index c1445f654f..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/GetDiskFreeSpaceW.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: GetDiskFreeSpaceW.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetDiskFreeSpaceW function. -** -** -**===================================================================*/ - -#include <palsuite.h> - - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwSectorsPerCluster; /* sectors per cluster */ - DWORD dwBytesPerSector; /* bytes per sector */ - DWORD dwSectorsPerCluster_02; /* sectors per cluster */ - DWORD dwBytesPerSector_02; /* bytes per sector */ - DWORD dwNumberOfFreeClusters; /* free clusters */ - DWORD dwTotalNumberOfClusters; /* total clusters */ - BOOL bRc = FALSE; - WCHAR szwRootPath[10] = {'/','\0'}; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* test the NULL option which translates to the current drive */ - bRc = GetDiskFreeSpaceW(NULL, - &dwSectorsPerCluster, - &dwBytesPerSector, - &dwNumberOfFreeClusters, - &dwTotalNumberOfClusters); - if (bRc != TRUE) - { - Fail("GetDiskFreeSpaceW: ERROR -> Failed with error code: %ld\n", - GetLastError()); - } - else if (dwSectorsPerCluster == 0) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster returned 0\n"); - } - else if (dwBytesPerSector == 0) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector returned 0\n"); - } - - /* test the root directory to the current drive */ - bRc = GetDiskFreeSpaceW(szwRootPath, - &dwSectorsPerCluster_02, - &dwBytesPerSector_02, - &dwNumberOfFreeClusters, - &dwTotalNumberOfClusters); - if (bRc != TRUE) - { - Fail("GetDiskFreeSpaceW: ERROR -> Failed with error code: %ld\n", - GetLastError()); - } - else if (dwSectorsPerCluster == 0) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster returned 0\n"); - } - else if (dwBytesPerSector == 0) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector returned 0\n"); - } - /* - ** make sure the values returned for NULL path and root path - ** are the same - */ - else if (dwSectorsPerCluster_02 != dwSectorsPerCluster) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster for NULL path " - "(%u) should have been the same as the root path (%u).\n", - dwSectorsPerCluster, - dwSectorsPerCluster_02); - } - else if (dwBytesPerSector_02 != dwBytesPerSector) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector for NULL path " - "(%u) should have been the same as the root path (%u).\n", - dwBytesPerSector, - dwBytesPerSector_02); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/testinfo.dat deleted file mode 100644 index 61b0e55fae..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test1/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 = file_io -Function = GetDiskFreeSpaceW -Name = Positive Test for GetDiskFreeSpaceW (test 1) -Type = DEFAULT -EXE1 = getdiskfreespacew -Description -= Test GetDiskFreeSpaceW. lpNumberOfFreeClusters and -= lpTotalNumberOfClusters are to be ignored diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/CMakeLists.txt deleted file mode 100644 index fb6a08789b..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/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 - getdiskfreespacew.cpp -) - -add_executable(paltest_getdiskfreespacew_test2 - ${SOURCES} -) - -add_dependencies(paltest_getdiskfreespacew_test2 coreclrpal) - -target_link_libraries(paltest_getdiskfreespacew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.cpp b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.cpp deleted file mode 100644 index 83dcb54b51..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/getdiskfreespacew.cpp +++ /dev/null @@ -1,65 +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: GetDiskFreeSpaceW.c (test 2) -** -** Purpose: Tests the PAL implementation of the GetDiskFreeSpaceW -** function on valid non-root paths. -** -** -**===================================================================*/ - -#include <palsuite.h> - - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwSectorsPerCluster; /* sectors per cluster */ - DWORD dwBytesPerSector; /* bytes per sector */ - DWORD dwNumberOfFreeClusters; /* free clusters */ - DWORD dwTotalNumberOfClusters; /* total clusters */ - BOOL bRc = FALSE; - WCHAR szwCurrentPath[MAX_LONGPATH]; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* get the current directory so we are sure to have a valid path */ - if (!GetCurrentDirectoryW(MAX_LONGPATH, szwCurrentPath)) - { - Fail("GetDiskFreeSpaceW: ERROR -> GetCurrentDirectoryW failed with " - "error code: %u.\n", - GetLastError()); - } - - /* test the current path*/ - bRc = GetDiskFreeSpaceW(szwCurrentPath, - &dwSectorsPerCluster, - &dwBytesPerSector, - &dwNumberOfFreeClusters, - &dwTotalNumberOfClusters); - if (bRc != TRUE) - { - Fail("GetDiskFreeSpaceW: ERROR -> Failed with error code: %u for " - "the path \"%S\".\n", - GetLastError(), - szwCurrentPath); - } - else if (dwSectorsPerCluster == 0) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwSectorsPerCluster returned 0\n"); - } - else if (dwBytesPerSector == 0) - { - Fail("GetDiskFreeSpaceW: ERROR -> dwBytesPerSector returned 0\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat deleted file mode 100644 index 0a687240ea..0000000000 --- a/src/pal/tests/palsuite/file_io/GetDiskFreeSpaceW/test2/testinfo.dat +++ /dev/null @@ -1,12 +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 = file_io -Function = GetDiskFreeSpaceW -Name = Positive Test for GetDiskFreeSpaceW (test 2) -Type = DEFAULT -EXE1 = getdiskfreespacew -Description -= Test GetDiskFreeSpaceW with valid non-root paths diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp index 7a622b628c..af279ed1ef 100644 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp +++ b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp @@ -9,8 +9,7 @@ ** Purpose: Tests the PAL implementation of the GetFileAttributesExW function. ** Call the function on a normal directory and file and a read-only directory ** and file and a hidden file and directory. -** Ensure that the attributes returned are correct, and the -** file times and file sizes. +** Ensure that the returned attributes and file sizes are correct. ** ** **===================================================================*/ @@ -24,24 +23,6 @@ typedef enum Item IS_FILE }ItemType; -/* - This is a helper function which takes two FILETIME structures and - checks to see if they contain the exact same time. -*/ -int IsEqualFileTime(FILETIME FirstTime, FILETIME SecondTime) -{ - - ULONG64 TimeOne, TimeTwo; - - TimeOne = ((((ULONG64)FirstTime.dwHighDateTime)<<32) | - ((ULONG64)FirstTime.dwLowDateTime)); - - TimeTwo = ((((ULONG64)SecondTime.dwHighDateTime)<<32) | - ((ULONG64)SecondTime.dwLowDateTime)); - - return(TimeOne == TimeTwo); -} - /* This function takes a structure and checks that the information within the structure is correct. The 'Attribs' are the expected file attributes, 'TheType' is IS_DIR or IS_FILE and the 'Name' is the @@ -88,38 +69,6 @@ void VerifyInfo(WIN32_FILE_ATTRIBUTE_DATA InfoStruct, GetLastError()); } - - - /* Get the FileTime of the file in question */ - if(GetFileTime(hFile, &CorrectCreation, - &CorrectAccess, &CorrectModify) == 0) - { - Fail("ERROR: GetFileTime failed to get the filetime of the " - "file. GetLastError() returned %d.", - GetLastError()); - } - - /* Check that the Creation, Access and Last Modified times are all - the same in the structure as what GetFileTime just returned. - */ - if(!IsEqualFileTime(CorrectCreation, InfoStruct.ftCreationTime)) - { - Fail("ERROR: The creation time of the file " - "does not match the creation time given from " - "GetFileTime.\n"); - } - if(!IsEqualFileTime(CorrectAccess, InfoStruct.ftLastAccessTime)) - { - Fail("ERROR: The access time of the file " - "does not match the access time given from " - "GetFileTime.\n"); - } - if(!IsEqualFileTime(CorrectModify, InfoStruct.ftLastWriteTime)) - { - Fail("ERROR: The write time of the file " - "does not match the last write time given from " - "GetFileTime.\n"); - } if(InfoStruct.nFileSizeLow != GetFileSize(hFile,NULL)) { diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/CMakeLists.txt deleted file mode 100644 index 19ee487a6a..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/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/file_io/GetFileTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test1/CMakeLists.txt deleted file mode 100644 index 3c95a5d992..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileTime.cpp -) - -add_executable(paltest_getfiletime_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test1 coreclrpal) - -target_link_libraries(paltest_getfiletime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.cpp deleted file mode 100644 index fb7bcb8513..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test1/GetFileTime.cpp +++ /dev/null @@ -1,180 +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: GetFileTime.c -** -** Purpose: Tests the PAL implementation of the GetFileTime function. -** This test checks the time of a file, writes to it, then checks the -** time again to ensure that write time has increased. It -** also checks that creation time is the same under WIN32 and has -** increased under FreeBSD. -** -** Depends: -** CreateFile -** WriteFile -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME Creation,LastAccess,LastWrite; - HANDLE TheFileHandle; - ULONG64 FirstWrite, SecondWrite, FirstCreationTime, SecondCreationTime; - DWORD temp; - BOOL result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Open the file to get a HANDLE */ - TheFileHandle = - CreateFile( - "the_file", // File Name - GENERIC_READ|GENERIC_WRITE, // Access Mode - 0, // Share Mode - NULL, // SD - OPEN_ALWAYS, // Howto Create - FILE_ATTRIBUTE_NORMAL, // File Attributes - NULL // Template file - ); - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.",GetLastError()); - } - - - /* Get the Last Write, Creation and Access File time of that File */ - if(!GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite)) - { - Fail("ERROR: GetFileTime returned 0, indicating failure."); - } - - /* Convert the structure to an ULONG64 */ - - FirstCreationTime = ((((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - FirstWrite = ((((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - /* Sleep for 3 seconds, this will ensure the time changes */ - Sleep(3000); - - /* Write to the file -- this should change write access and - last access - */ - - result = WriteFile(TheFileHandle, // File handle - "something", // String to write - 9, // Bytes to write - &temp, // Bytes written - NULL); - - if(result == 0) - { - Fail("ERROR: Failed to write to file. The file must be " - "written to in order to test that the write time is " - "updated."); - } - - /* Close the File, so the changes are recorded */ - result = CloseHandle(TheFileHandle); - - if(result == 0) - { - Fail("ERROR: Failed to close the file handle."); - } - - - /* Reopen the file */ - TheFileHandle = - CreateFile( - "the_file", /* file name */ - GENERIC_READ|GENERIC_WRITE, /* access mode */ - 0, /* share mode */ - NULL, /* SD */ - OPEN_ALWAYS, /* how to create */ - FILE_ATTRIBUTE_NORMAL, /* file attributes */ - NULL /* handle to template file */ - ); - - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to re-open the file. The error number " - "returned was %d.",GetLastError()); - } - - - - /* Call GetFileTime again */ - if(!GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite)) - { - Fail("ERROR: GetFileTime returned 0, indicating failure."); - } - - /* Store the results in a ULONG64 */ - - SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - - /* Now -- to test. We'll ensure that the Second - LastWrite time is larger than the first. It tells us that - time is passing, which is good! - */ - - if(FirstWrite >= SecondWrite) - { - Fail("ERROR: The last-write-file-time after writing did not " - "increase from the original. The second value should be " - "larger."); - } - -#if WIN32 - /* Then we can check to make sure that the creation time - hasn't changed. This should always stay the same. - */ - - if(FirstCreationTime != SecondCreationTime) - { - Fail("ERROR: The creation time after writing should not " - "not change from the original. The second value should be " - "equal."); - } -#else - /* Then we can check to make sure that the creation time - has changed. Under FreeBSD it changes whenever the file is - access or written. - */ - - if(FirstCreationTime >= SecondCreationTime) - { - Fail("ERROR: The creation time after writing should be " - "greater than the original. The second value should be " - "larger."); - } - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test1/testinfo.dat deleted file mode 100644 index 50cd35214d..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test1/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Test the GetFileTime function. Open a file and get the time. Then write -= to that file. This will change the write and under FreeBSD -= the creation time. Ensure that all of these are increasing. diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test2/CMakeLists.txt deleted file mode 100644 index 329d8c6553..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/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 - GetFileTime.cpp -) - -add_executable(paltest_getfiletime_test2 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test2 coreclrpal) - -target_link_libraries(paltest_getfiletime_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.cpp deleted file mode 100644 index 5b14a1e357..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test2/GetFileTime.cpp +++ /dev/null @@ -1,195 +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: GetFileTime.c -** -** Purpose: Tests the PAL implementation of the GetFileTime function -** Test to see that access date either stays the same or increases -** when a read is performed. Write -** and creation time should stay unchanged. Note: Under FreeBSD -** the Creation time should not change with just a read. -** -** Depends: -** FileTimeToDosDateTime -** CreateFile -** ReadFile -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME Creation,LastAccess,LastWrite; - HANDLE TheFileHandle; - ULONG64 FirstWrite, SecondWrite, - FirstCreationTime, SecondCreationTime; - DWORD temp; - char ReadBuffer[10]; - BOOL result; - WORD DosDateOne, DosDateTwo, DosTime; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Open the file to get a HANDLE */ - TheFileHandle = - CreateFile( - "the_file", - GENERIC_READ, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.",GetLastError()); - } - - - /* Get the Last Write, Creation and Access File time of that File */ - if(GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite)==0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure."); - } - - /* Call FileTimeToDosDateTime so we can aquire just the date - portion of the Last Access FILETIME. - */ - if(FileTimeToDosDateTime(&LastAccess, &DosDateOne, &DosTime) == 0) - { - Fail("ERROR: FiletimeToDosDateTime failed, returning 0. " - "GetLastError returned %d.\n",GetLastError()); - } - - /* Convert the structure to an ULONG64 */ - - FirstCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - FirstWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - /* Sleep for 3 seconds, this will ensure the time changes */ - Sleep(3000); - - /* Read from the file -- this should change - last access, but we'll only check the date portion, because some file - systems have a resolution of a day. - */ - - result = ReadFile(TheFileHandle, // handle to file - &ReadBuffer, // data buffer - 2, // number of bytes to read - &temp, // number of bytes read - NULL); - - if(result == 0) - { - Fail("ERROR: Failed to read from the file."); - } - - - /* Close the File, so the changes are recorded */ - result = CloseHandle(TheFileHandle); - - if(result == 0) - { - Fail("ERROR: Failed to close the file handle."); - } - - - /* Reopen the file */ - TheFileHandle = - CreateFile("the_file", /* file name */ - GENERIC_READ, /* access mode */ - 0, /* share mode */ - NULL, /* SD */ - OPEN_ALWAYS, /* how to create */ - FILE_ATTRIBUTE_NORMAL, /* file attributes */ - NULL /* handle to template file */ - ); - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to re-open the file. The error number " - "returned was %d.",GetLastError()); - } - - /* Call GetFileTime again */ - if(GetFileTime(TheFileHandle,&Creation,&LastAccess,&LastWrite) == 0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure."); - } - - /* Get the Date of the LastAccessTime here again. */ - if(FileTimeToDosDateTime(&LastAccess, &DosDateTwo, &DosTime) == 0) - { - Fail("ERROR: FileTimeToDosDateTime failed, returning 0. " - "GetLastError returned %d.\n",GetLastError()); - } - - - /* Store the results in a ULONG64 */ - - SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - /* Now -- to test. We'll ensure that the Second - LastWrite time is the same as the first. This shouldn't - have changed. - */ - - if(FirstWrite != SecondWrite) - { - Fail("ERROR: The last-write-file-time after reading " - "increased from the original. The second value should be " - "equal."); - } - - - /* - For LastAccessTime, just check that the date is greater or equal - for the second over the first. The time is not conisered on some - file systems. (such as fat32) - */ - - if(DosDateOne > DosDateTwo) - { - Fail("ERROR: The last-access-time after reading should have " - "stayed the same or increased, but it did not.\n"); - } - - - /* Check to ensure CreationTime hasn't changed. This should not - have changed in either environment. - */ - - if(FirstCreationTime != SecondCreationTime) - { - Fail("ERROR: The creation time after reading should not " - "not change from the original. The second value should be " - "equal."); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test2/testinfo.dat deleted file mode 100644 index a60dcf45a4..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Tests the PAL implementation of the GetFileTime function -= Test to see that access date either stays the same or increases -= when a read is performed. Write -= and creation time should stay unchanged. Note: Under FreeBSD -= the Creation time should not change with just a read. diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt deleted file mode 100644 index d154a8810b..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileTime.cpp -) - -add_executable(paltest_getfiletime_test3 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test3 coreclrpal) - -target_link_libraries(paltest_getfiletime_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.cpp deleted file mode 100644 index a3f46c2bf8..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test3/GetFileTime.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: GetFileTime.c -** -** Purpose: Tests the PAL implementation of the GetFileTime function -** Test to see that creation time is changed when two different files -** are created. -** -** Depends: -** CreateFile -** ReadFile -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME Creation; - HANDLE TheFileHandle, SecondFileHandle; - ULONG64 FirstCreationTime, SecondCreationTime; - BOOL result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Open the file to get a HANDLE */ - TheFileHandle = - CreateFile( - "the_file", - GENERIC_READ, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.",GetLastError()); - } - - - /* Get the Creation time of the File */ - if(GetFileTime(TheFileHandle,&Creation,NULL,NULL)==0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure. " - "Two of the params were NULL in this case, did they " - "cause the probleM?"); - } - - /* Convert the structure to an ULONG64 */ - - FirstCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - - /* Close the File, so the changes are recorded */ - result = CloseHandle(TheFileHandle); - - if(result == 0) - { - Fail("ERROR: Failed to close the file handle."); - } - - - /* Sleep for 3 seconds, this will ensure the time changes */ - Sleep(3000); - - - - /* Open another file */ - SecondFileHandle = - CreateFile("the_other_file", /* file name */ - GENERIC_READ, /* access mode */ - 0, /* share mode */ - NULL, /* SD */ - CREATE_ALWAYS, /* how to create */ - FILE_ATTRIBUTE_NORMAL, /* file attributes */ - NULL /* handle to template file */ - ); - - if(SecondFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the second file. The error number " - "returned was %d.",GetLastError()); - } - - - /* Call GetFileTime again */ - if(GetFileTime(SecondFileHandle,&Creation,NULL,NULL) == 0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure. " - "Perhaps the NULLs in the function broke it?"); - } - - /* Close the File*/ - result = CloseHandle(SecondFileHandle); - - if(result == 0) - { - Fail("ERROR: Failed to close the file handle."); - } - - - /* Store the results in a ULONG64 */ - - SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - - - /* Now -- to test. We ensure that the FirstCreationTime is - less than the SecondCreationTime - */ - - - if(FirstCreationTime >= SecondCreationTime) - { - Fail("ERROR: The creation time of the two files should be " - "different. The first file should have a creation " - "time less than the second."); - } - - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test3/testinfo.dat deleted file mode 100644 index 6d1eba739d..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test3/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Test the GetFileTime function. This test creates two files and compares -= their creation times. They should be different. It also tries to get the -= file time of an invalid handle, which should cause the function to tail. diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test4/CMakeLists.txt deleted file mode 100644 index 416db15a06..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/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 - GetFileTime.cpp -) - -add_executable(paltest_getfiletime_test4 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test4 coreclrpal) - -target_link_libraries(paltest_getfiletime_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.cpp deleted file mode 100644 index ffba516e35..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test4/GetFileTime.cpp +++ /dev/null @@ -1,98 +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: GetFileTime.c -** -** Purpose: Tests the PAL implementation of the GetFileTime function -** Test to see that passing NULL values to GetFileTime works and that -** calling the function on a bad HANDLE causes the correct failure. -** -** Depends: -** CreateFile -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME Creation,LastWrite,LastAccess; - HANDLE TheFileHandle; - BOOL result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Open the file to get a HANDLE */ - TheFileHandle = - CreateFile( - "the_file", - GENERIC_READ, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.",GetLastError()); - } - - /* Pass all NULLs, this is useless but should still work. */ - if(GetFileTime(TheFileHandle,NULL,NULL,NULL)==0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure. " - "Three of the params were NULL in this case, did they " - "cause the problem?"); - } - - - /* Get the Creation time of the File */ - if(GetFileTime(TheFileHandle,&Creation,NULL,NULL)==0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure. " - "Two of the params were NULL in this case, did they " - "cause the probleM?"); - } - - /* Get the Creation, LastWrite time of the File */ - if(GetFileTime(TheFileHandle,&Creation,&LastWrite,NULL)==0) - { - Fail("ERROR: GetFileTime returned 0, indicating failure. " - "One of the params were NULL in this case, did it " - "cause the problem?"); - } - - - /* Close the File, so the changes are recorded */ - result = CloseHandle(TheFileHandle); - - if(result == 0) - { - Fail("ERROR: Failed to close the file handle."); - } - - /* Call GetFileTime again */ - if(GetFileTime(TheFileHandle,&Creation,&LastWrite,&LastAccess) != 0) - { - Fail("ERROR: GetFileTime returned non zero, indicating success. " - "It was passed an invalid file HANDLE and should have " - "failed."); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test4/testinfo.dat deleted file mode 100644 index af90558cae..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Test the GetFileTime function. This test gets the file time of a given -= file while passing all the combonations of NULL as parameters. The -= function should handle these as unneeded times, and still succeed. diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt deleted file mode 100644 index 4072a52fbc..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - getfiletime.cpp -) - -add_executable(paltest_getfiletime_test5 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test5 coreclrpal) - -target_link_libraries(paltest_getfiletime_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.cpp deleted file mode 100644 index d8196d84bc..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test5/getfiletime.cpp +++ /dev/null @@ -1,224 +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: GetFileTime.c -** -** Purpose: Test the PAL implementation of GetFileTime. This test -** creates a file and compares create and write times between -** writes, but before the close, and verifies the results are -** as expected -** -** Depends: -** CreateFile -** WriteFile -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - FILETIME Creation; - FILETIME LastAccess; - FILETIME LastWrite; - HANDLE hFile; - ULONG64 FirstWrite; - ULONG64 SecondWrite; - ULONG64 FirstCreationTime; - ULONG64 SecondCreationTime; - DWORD temp; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Open the file to get a HANDLE */ - hFile = CreateFile("test.tmp", - GENERIC_READ|GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to create the file. The error number " - "returned was %u.\n", - GetLastError()); - } - - /* Write to the file -- this should change write access and - last access - */ - if(!WriteFile(hFile, "something", 9, &temp, NULL)) - { - Trace("ERROR: Failed to write to file. The file must be " - "written to in order to test that the write time is " - "updated. GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - FlushFileBuffers(hFile); - - /* Get the Last Write, Creation and Access File time of that File */ - if(!GetFileTime(hFile, &Creation, &LastAccess, &LastWrite)) - { - Trace("ERROR: GetFileTime returned 0, indicating failure." - " GetLastError returned %u\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Convert the structure to an ULONG64 */ - - FirstCreationTime = ((((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - FirstWrite = ((((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - /* Sleep for 3 seconds, this will ensure the time changes */ - Sleep(3000); - - /* Write to the file again -- this should change write access and - last access - */ - if(!WriteFile(hFile, "something", 9, &temp, NULL)) - { - Trace("ERROR: Failed to write to file. The file must be " - "written to in order to test that the write time is " - "updated. GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - - FlushFileBuffers(hFile); - - /* Call GetFileTime again */ - if(!GetFileTime(hFile,&Creation,&LastAccess,&LastWrite)) - { - Trace("ERROR: GetFileTime returned 0, indicating failure." - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Store the results in a ULONG64 */ - - SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - - /* Now -- to test. We'll ensure that the Second - LastWrite time is larger than the first. It tells us that - time is passing, which is good! - */ - - if(FirstWrite >= SecondWrite) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The last-write-file-time after writing did not " - "increase from the original. The second value should be " - "larger.\n"); - } - -#if WIN32 - /* Then we can check to make sure that the creation time - hasn't changed. This should always stay the same. - */ - - if(FirstCreationTime != SecondCreationTime) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The creation time after writing should not " - "not change from the original. The second value should be " - "equal.\n"); - } -#else - /* Then we can check to make sure that the creation time - has changed. Under FreeBSD it changes whenever the file is - access or written. - */ - - if(FirstCreationTime >= SecondCreationTime) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The creation time after writing should be " - "greater than the original. The second value should be " - "larger.\n"); - } - -#endif - - /* Close the File */ - if(!CloseHandle(hFile)) - { - Fail("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test5/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test5/testinfo.dat deleted file mode 100644 index fd4112b1fa..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test5/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Test the PAL implementation of GetFileTime. This test -= creates a file and compares create and write times between -= writes, but before the close, and verifies the results are -= as expected diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt deleted file mode 100644 index 83d652461b..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - getfiletime.cpp -) - -add_executable(paltest_getfiletime_test6 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test6 coreclrpal) - -target_link_libraries(paltest_getfiletime_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.cpp deleted file mode 100644 index 3eedddf82d..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test6/getfiletime.cpp +++ /dev/null @@ -1,281 +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: GetFileTime.c -** -** Purpose: Tests the PAL implementation of the GetFileTime function. -** Perform two reads from a file without closing until the end -** of the test and verify that only the access times change. -** Note: Under Win32, modify time changes as well so we will -** check that it doesn't go backwards -** -** Depends: -** FileTimeToDosDateTime -** CreateFile -** ReadFile -** WriteFile -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME Creation; - FILETIME LastAccess; - FILETIME LastWrite; - HANDLE hFile; - ULONG64 FirstWrite = (ULONG64)0; - ULONG64 SecondWrite = (ULONG64)0; - ULONG64 FirstCreationTime = (ULONG64)0; - ULONG64 SecondCreationTime = (ULONG64)0; - DWORD temp; - char ReadBuffer[10]; - WORD DosDateOne; - WORD DosDateTwo; - WORD DosTime; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - memset(&Creation, 0, sizeof(FILETIME)); - memset(&LastAccess, 0, sizeof(FILETIME)); - memset(&LastWrite, 0, sizeof(FILETIME)); - - /* Create the file to get a HANDLE */ - hFile = CreateFile("test.tmp", - GENERIC_READ|GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to create the file. The error number " - "returned was %u.\n", - GetLastError()); - } - - /* give us something to read from the file */ - if(!WriteFile(hFile, "something", 9, &temp, NULL)) - { - Trace("ERROR: Failed to write to file. " - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* let's do a read to set the file times for our test */ - if(!ReadFile(hFile, &ReadBuffer, 2, &temp, NULL)) - { - Trace("ERROR: Failed to read from the file. " - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Get the Last Write, Creation and Access File time of the file */ - if(GetFileTime(hFile, &Creation, &LastAccess, &LastWrite)==0) - { - Trace("ERROR: GetFileTime returned 0, indicating failure." - " GetLastError returned %u\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Call FileTimeToDosDateTime so we can aquire just the date - portion of the Last Access FILETIME. - */ - if(FileTimeToDosDateTime(&LastAccess, &DosDateOne, &DosTime) == 0) - { - Trace("ERROR: FiletimeToDosDateTime failed, returning 0. " - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Convert the structure to an ULONG64 */ - FirstCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - FirstWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - /* Sleep for 3 seconds, this will ensure the time changes */ - Sleep(3000); - - /* Read from the file -- this should change - last access, but we'll only check the date portion, because some file - systems have a resolution of a day. - */ - memset(&Creation, 0, sizeof(FILETIME)); - memset(&LastAccess, 0, sizeof(FILETIME)); - memset(&LastWrite, 0, sizeof(FILETIME)); - - if(!ReadFile(hFile, &ReadBuffer, 2, &temp, NULL)) - { - Trace("ERROR: Failed to read from the file. " - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - - /* Call GetFileTime to get the updated time values*/ - if(GetFileTime(hFile, &Creation, &LastAccess, &LastWrite) == 0) - { - Trace("ERROR: GetFileTime returned 0, indicating failure. " - "GetLastError returned %d.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Get the Date of the LastAccessTime here again. */ - if(FileTimeToDosDateTime(&LastAccess, &DosDateTwo, &DosTime) == 0) - { - Trace("ERROR: FileTimeToDosDateTime failed, returning 0. " - "GetLastError returned %d.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - - /* Store the results in a ULONG64 */ - SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - /* Now -- to test. We'll ensure that the SecondWrite - time is not less than the FirstWrite time - */ - - if(SecondWrite < FirstWrite) - { - Trace("ERROR: The write-file-time (%I64d) after the first read " - "is less than the write-file-time (%I64d) after the second " - "read.\n", - FirstWrite, - LastWrite); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* - For LastAccessTime, just check that the date is greater or equal - for the second over the first. The time is not conisered on some - file systems. (such as fat32) - */ - - if(DosDateOne > DosDateTwo) - { - Trace("ERROR: The last-access-time after reading should have " - "stayed the same or increased, but it did not.\n"); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - - /* Check to ensure CreationTime hasn't changed. This should not - have changed in either environment. - */ - - if(FirstCreationTime != SecondCreationTime) - { - Trace("ERROR: The creation time after reading should not " - "not change from the original. The second value should be " - "equal.\n"); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Close the File, so the changes are recorded */ - if(!CloseHandle(hFile)) - { - Fail("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test6/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test6/testinfo.dat deleted file mode 100644 index 844043689c..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test6/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Tests the PAL implementation of the GetFileTime function. -= Perform two reads from a file without closing until the end -= of the test and verify that only the access times change. diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test7/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileTime/test7/CMakeLists.txt deleted file mode 100644 index 34a08db686..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/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 - getfiletime.cpp -) - -add_executable(paltest_getfiletime_test7 - ${SOURCES} -) - -add_dependencies(paltest_getfiletime_test7 coreclrpal) - -target_link_libraries(paltest_getfiletime_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.cpp b/src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.cpp deleted file mode 100644 index d33175b8ec..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test7/getfiletime.cpp +++ /dev/null @@ -1,279 +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: GetFileTime.c -** -** Purpose: Test the PAL implementation of GetFileTime. This test -** creates a file and compares create and write times after -** the buffers are flushed, but before the close, and verifies -** the results are as expected -** -** Depends: -** CreateFile -** WriteFile -** FlushFileBuffers -** CloseHandle -** -** -**===================================================================*/ - - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - FILETIME Creation; - FILETIME LastAccess; - FILETIME LastWrite; - HANDLE hFile; - ULONG64 FirstWrite; - ULONG64 SecondWrite; - ULONG64 FirstAccess; - ULONG64 SecondAccess; - ULONG64 FirstCreationTime; - ULONG64 SecondCreationTime; - DWORD temp; - const char* someText = "1234567890123456789012345678901234567890"; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Open the file to get a HANDLE */ - hFile = CreateFile("test.tmp", - GENERIC_READ|GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to create the file. The error number " - "returned was %u.\n", - GetLastError()); - } - - /* Write to the file -- this should change write access and - last access - */ - if(!WriteFile(hFile, someText, strlen(someText), &temp, NULL)) - { - Trace("ERROR: Failed to write to file. The file must be " - "written to in order to test that the write time is " - "updated. GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Flush the buffers */ - if(!FlushFileBuffers(hFile)) - { - Trace("ERROR: The FlushFileBuffers function failed. " - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Get the Last Write, Creation and Access File time of that File */ - if(!GetFileTime(hFile, &Creation, &LastAccess, &LastWrite)) - { - Trace("ERROR: GetFileTime returned 0, indicating failure." - " GetLastError returned %u\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Convert the structures to an ULONG64 */ - FirstCreationTime = ((((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - FirstWrite = ((((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - FirstAccess = ((((ULONG64)LastAccess.dwHighDateTime)<<32) | - ((ULONG64)LastAccess.dwLowDateTime)); - - /* Sleep for 3 seconds, this will ensure the time changes */ - Sleep(3000); - - /* Write to the file again so we have something to flush */ - if(!WriteFile(hFile, someText, strlen(someText), &temp, NULL)) - { - Trace("ERROR: Failed to write to file. The file must be " - "written to in order to test that the write time is " - "updated. GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Flush the buffers forcing the access/mod time to change */ - if(!FlushFileBuffers(hFile)) - { - Trace("ERROR: The FlushFileBuffers function failed. " - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - - /* Call GetFileTime again */ - if(!GetFileTime(hFile,&Creation,&LastAccess,&LastWrite)) - { - Trace("ERROR: GetFileTime returned 0, indicating failure." - "GetLastError returned %u.\n", - GetLastError()); - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* Store the results in a ULONG64 */ - - SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | - ((ULONG64)Creation.dwLowDateTime)); - - SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | - ((ULONG64)LastWrite.dwLowDateTime)); - - SecondAccess = ((((ULONG64)LastAccess.dwHighDateTime)<<32) | - ((ULONG64)LastAccess.dwLowDateTime)); - - - /* Now -- to test. We'll ensure that the Second - LastWrite and access times are larger than the first. - It tells us that time is passing, which is good! - */ - - if(FirstWrite >= SecondWrite) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The write-file-time (%I64d) after the first flush " - "should be less than the write-file-time (%I64d) after the second " - "flush.\n", - FirstWrite, - LastWrite); - - } - - - if(SecondAccess < FirstAccess) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The access-file-time (%I64d) after the first flush " - "should be less than or equal to the access-file-time (%I64d) " - "after the second flush.\n", - FirstAccess, - LastAccess); - } - -#if WIN32 - /* Then we can check to make sure that the creation time - hasn't changed. This should always stay the same. - */ - - if(FirstCreationTime != SecondCreationTime) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The creation time after writing should not " - "not change from the original. The second value should be " - "equal.\n"); - } -#else - /* Then we can check to make sure that the creation time - has changed. Under FreeBSD it changes whenever the file is - access or written. - */ - - if(FirstCreationTime >= SecondCreationTime) - { - /* Close the File */ - if(!CloseHandle(hFile)) - { - Trace("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("ERROR: The creation time after writing should be " - "greater than the original. The second value should be " - "larger.\n"); - } - -#endif - - /* Close the File */ - if(!CloseHandle(hFile)) - { - Fail("ERROR: Failed to close the file handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetFileTime/test7/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileTime/test7/testinfo.dat deleted file mode 100644 index 774f759adc..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileTime/test7/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 = file_io -Function = GetFileTime -Name = Positive Test for GetFileTime -TYPE = DEFAULT -EXE1 = getfiletime -Description -= Test the PAL implementation of GetFileTime. This test -= creates a file and compares create and write times after -= the buffers are flushed, but before the close, and verifies -= the results are as expected diff --git a/src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt deleted file mode 100644 index 1962ade358..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt deleted file mode 100644 index c0acc6e484..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileType.cpp -) - -add_executable(paltest_getfiletype_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfiletype_test1 coreclrpal) - -target_link_libraries(paltest_getfiletype_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp b/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp deleted file mode 100644 index 6558c00bdd..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp +++ /dev/null @@ -1,76 +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: GetFileType.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetFileType function. -** -** -**===================================================================*/ - -#include <palsuite.h> - -const char* szTextFile = "text.txt"; - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwRc = 0; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - /* test FILE_TYPE_UNKNOWN */ - dwRc = GetFileType(hFile); - if (dwRc != FILE_TYPE_UNKNOWN) - { - Fail("GetFileType: ERROR -> Was expecting a return type of " - "FILE_TYPE_UNKNOWN but the function returned %ld.\n", - dwRc); - } - - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("GetFileType: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - dwRc = GetFileType(hFile); - if (CloseHandle(hFile) != TRUE) - { - Fail("GetFileType: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Fail("GetFileType: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - - if (dwRc != FILE_TYPE_DISK) - { - Fail("GetFileType: ERROR -> Was expecting a return type of " - "FILE_TYPE_DISK but the function returned %ld.\n", - dwRc); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileType/test1/testinfo.dat deleted file mode 100644 index f12a81a20b..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test1/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 = file_io -Function = GetFileType -Name = Positive Test for GetFileType (test 1) -Type = DEFAULT -EXE1 = getfiletype -Description -= Test GetFileType on a NULL handle and a valid handle to a file - diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/test2/CMakeLists.txt deleted file mode 100644 index 1f2ee78f75..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/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 - getfiletype.cpp -) - -add_executable(paltest_getfiletype_test2 - ${SOURCES} -) - -add_dependencies(paltest_getfiletype_test2 coreclrpal) - -target_link_libraries(paltest_getfiletype_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.cpp b/src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.cpp deleted file mode 100644 index c9d4eb6572..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test2/getfiletype.cpp +++ /dev/null @@ -1,95 +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: getfiletype.c -** -** Purpose: Test the PAL implementation of GetFileType to ensure it -** recognizes opened pipes. -** -** Depends: CreatePipe -** CloseHandle -** -** -**===================================================================*/ - -#include <palsuite.h> - - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - DWORD dwFileType; - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /* - ** create a pipe and make sure GetFileType returns the correct value - */ - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR: %u :Unable to create pipe.\n", GetLastError()); - } - - // Get the file type - dwFileType = GetFileType(hReadPipe); - if (dwFileType != FILE_TYPE_PIPE) - { - if (!CloseHandle(hWritePipe)) - { - Trace("ERROR: %u : Unable to close write pipe handle " - "hWritePipe=0x%lx\n", GetLastError(), hWritePipe); - } - if (!CloseHandle(hReadPipe)) - { - Trace("ERROR: %u : Unable to close read pipe handle " - "hReadPipe=0x%lx\n", GetLastError(), hReadPipe); - } - Fail("ERROR: GetFileType returned %u for a pipe instead of the " - "expected FILE_TYPE_PIPE (%u).\n", - dwFileType, - FILE_TYPE_PIPE); - } - - /*Close write pipe handle*/ - if (!CloseHandle(hWritePipe)) - { - if (!CloseHandle(hReadPipe)) - { - Trace("ERROR: %u : Unable to close read pipe handle " - "hReadPipe=0x%lx\n", GetLastError(), hReadPipe); - } - Fail("ERROR: %u : Unable to close write pipe handle " - "hWritePipe=0x%lx\n", GetLastError(), hWritePipe); - } - - /*Close Read pipe handle*/ - if (!CloseHandle(hReadPipe)) - { - Fail("ERROR: %u : Unable to close read pipe handle " - "hReadPipe=0x%lx\n", GetLastError(), hReadPipe); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileType/test2/testinfo.dat deleted file mode 100644 index eb1361d3f6..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/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 = file_io -Function = GetFileType -Name = Test for GetFileType -TYPE = DEFAULT -EXE1 = getfiletype -Description -= Test the PAL implementation of GetFileType to ensure it -= recognizes opened pipes. diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt deleted file mode 100644 index ed70e6c96c..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - getfiletype.cpp -) - -add_executable(paltest_getfiletype_test3 - ${SOURCES} -) - -add_dependencies(paltest_getfiletype_test3 coreclrpal) - -target_link_libraries(paltest_getfiletype_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.cpp b/src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.cpp deleted file mode 100644 index 6a95585bab..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test3/getfiletype.cpp +++ /dev/null @@ -1,72 +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: getfiletype.c -** -** Purpose: Test the PAL implementation of the GetFileType on a handle -** to a console. -** -** -**===================================================================*/ - -#include <palsuite.h> - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile; -#if WIN32 - char *lpFileName = "CONIN$"; -#else - char *lpFileName = "/dev/null"; -#endif - DWORD dwFileType; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* get a handle to the console */ - hFile = CreateFile(lpFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetFileType: ERROR: CreateFile failed to open %s with " - "error %u.\n", - lpFileName, - GetLastError()); - } - - /* Get the file type */ - if ((dwFileType = GetFileType(hFile)) != FILE_TYPE_CHAR) - { - if (!CloseHandle(hFile)) - { - Trace("GetFileType: ERROR: %u : Unable to close the handle " - "hFile=0x%lx\n", GetLastError(), hFile); - } - Fail("GetFileType: ERROR: GetFileType returned %u for a device " - "instead of the expected FILE_TYPE_CHAR (%u).\n", - dwFileType, - FILE_TYPE_CHAR); - } - - if (!CloseHandle(hFile)) - { - Fail("GetFileType: ERROR: %u : Unable to close the handle " - "hFile=0x%lx\n", GetLastError(), hFile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileType/test3/testinfo.dat deleted file mode 100644 index 9ffd4c2b15..0000000000 --- a/src/pal/tests/palsuite/file_io/GetFileType/test3/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 = file_io -Function = GetFileType -Name = Test for GetFileTYpe -TYPE = DEFAULT -EXE1 = getfiletype -Description -= Test the PAL implementation of the GetFileType on a handle -= to a console. diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp b/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp index f4fe03195d..47b1eba599 100644 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp +++ b/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp @@ -96,15 +96,6 @@ int __cdecl main(int argc, char *argv[]) GetLastError()); } - /* check if the file type is correct for the handle */ - if((dwFileType = GetFileType(hFile)) != FILE_TYPE_CHAR) - { - Fail("GetStdHandle: ERROR -> GetFileType returned %u for " - "STD_ERROR_HANDLE instead of the expected FILE_TYPE_CHAR (%u).\n", - dwFileType, - FILE_TYPE_CHAR); - } - /* check to see if we can CloseHandle works on the STD_ERROR_HANDLE */ if (!CloseHandle(hFile)) { diff --git a/src/pal/tests/palsuite/file_io/MoveFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d9..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/MoveFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileA/test1/CMakeLists.txt deleted file mode 100644 index b8f445b1e7..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MoveFileA.cpp -) - -add_executable(paltest_movefilea_test1 - ${SOURCES} -) - -add_dependencies(paltest_movefilea_test1 coreclrpal) - -target_link_libraries(paltest_movefilea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/MoveFileA/test1/ExpectedResults.txt b/src/pal/tests/palsuite/file_io/MoveFileA/test1/ExpectedResults.txt deleted file mode 100644 index 43b67af6b2..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileA/test1/ExpectedResults.txt +++ /dev/null @@ -1 +0,0 @@ -0101000001010000
\ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/MoveFileA/test1/MoveFileA.cpp b/src/pal/tests/palsuite/file_io/MoveFileA/test1/MoveFileA.cpp deleted file mode 100644 index 6d1337af03..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileA/test1/MoveFileA.cpp +++ /dev/null @@ -1,469 +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: MoveFileA.c -** -** Purpose: Tests the PAL implementation of the MoveFileA function. -** -** -**===================================================================*/ - -#include <palsuite.h> - -LPSTR lpSource[4] = {"src_existing.txt", - "src_non-existant.txt", - "src_dir_existing", - "src_dir_non-existant"}; -LPSTR lpDestination[4] = {"dst_existing.txt", - "dst_non-existant.txt", - "dst_dir_existing", - "dst_dir_non-existant"}; - - -/* Create all the required test files */ -int createExisting(void) -{ - FILE* tempFile = NULL; - DWORD dwError; - BOOL bRc = FALSE; - char szBuffer[100]; - - /* create the src_existing file */ - tempFile = fopen(lpSource[0], "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileA test file: src_existing.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create %s\n", lpSource[0]); - return FAIL; - } - - /* create the src_dir_existing directory and files */ - bRc = CreateDirectoryA(lpSource[2], NULL); - if (bRc != TRUE) - { - Trace("MoveFileA: ERROR: couldn't create \"%s\" because of " - "error code %ld\n", - lpSource[2], - GetLastError()); - return FAIL; - } - - memset(szBuffer, 0, 100); - sprintf_s(szBuffer, _countof(szBuffer), "%s/test01.txt", lpSource[2]); - tempFile = fopen(szBuffer, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileA test file: %s\n", szBuffer); - fclose(tempFile); - } - else - { - Trace("ERROR[%ld]:MoveFileA couldn't create %s\n", GetLastError(), szBuffer); - return FAIL; - } - - memset(szBuffer, 0, 100); - sprintf_s(szBuffer, _countof(szBuffer), "%s/test02.txt", lpSource[2]); - tempFile = fopen(szBuffer, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileA test file: %s\n", szBuffer); - fclose(tempFile); - } - else - { - Trace("ERROR[%ld]: couldn't create %s\n", GetLastError(), szBuffer); - return FAIL; - } - - - /* create the dst_existing file */ - tempFile = fopen(lpDestination[0], "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileA test file: dst_existing.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR[%ld]:MoveFileA couldn't create \"%s\"\n", GetLastError(), lpDestination[0]); - return FAIL; - } - - /* create the dst_dir_existing directory and files */ - bRc = CreateDirectoryA(lpDestination[2], NULL); - if (bRc != TRUE) - { - dwError = GetLastError(); - Trace("Error[%ld]:MoveFileA: couldn't create \"%s\"\n", GetLastError(), lpDestination[2]); - return FAIL; - } - - tempFile = fopen("dst_dir_existing/test01.txt", "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileA test file: dst_dir_existing/test01.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create dst_dir_existing/test01.txt\n"); - return FAIL; - } - tempFile = fopen("dst_dir_existing/test02.txt", "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileA test file: dst_dir_existing/test02.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR[%ul]: couldn't create dst_dir_existing/test02.txt\n", GetLastError()); - return FAIL; - } - - return PASS; -} - - - -void removeDirectoryHelper(LPSTR dir, int location) -{ - DWORD dwAtt = GetFileAttributesA(dir); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - if(!RemoveDirectoryA(dir)) - { - Fail("ERROR: Failed to remove Directory [%s], Error Code [%d], location [%d]\n", dir, GetLastError(), location); - } - } -} - -void removeFileHelper(LPSTR pfile, int location) -{ - FILE *fp; - fp = fopen( pfile, "r"); - - if (fp != NULL) - { - if(fclose(fp)) - { - Fail("ERROR: Failed to close the file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - - if(!DeleteFileA(pfile)) - { - Fail("ERROR: Failed to delete file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - else - { - // Trace("Success: deleted file [%S], Error Code [%d], location [%d]\n", wfile, GetLastError(), location); - } - } - -} - - -/* remove all created files in preparation for the next test */ -void removeAll(void) -{ - char szTemp[40]; - DWORD dwAtt; - - /* get rid of source dirs and files */ - removeFileHelper(lpSource[0], 1); - removeFileHelper(lpSource[1], 2); - - dwAtt = GetFileAttributesA(lpSource[2]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpSource[2]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpSource[2]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpSource[2], 103); - } - else - { - removeFileHelper(lpSource[2], 17); - } - - - dwAtt = GetFileAttributesA(lpSource[3]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpSource[3]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpSource[3]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpSource[3], 103); - } - else - { - removeFileHelper(lpSource[3], 17); - } - - /* get rid of destination dirs and files */ - dwAtt = GetFileAttributesA(lpDestination[0]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[0]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[0]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[0], 103); - } - else - { - removeFileHelper(lpDestination[0], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[1]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[1]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[1]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[1], 103); - } - else - { - removeFileHelper(lpDestination[1], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[2]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[2]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[2]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[2], 103); - } - else - { - removeFileHelper(lpDestination[2], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[3]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[3]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[3]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[3], 103); - } - else - { - removeFileHelper(lpDestination[3], 17); - } - -} - - - - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = TRUE; - BOOL bSuccess = TRUE; - char results[40]; - FILE* resultsFile = NULL; - int nCounter = 0; - int i, j; - char tempSource[] = {'t','e','m','p','k','.','t','m','p','\0'}; - char tempDest[] = {'t','e','m','p','2','.','t','m','p','\0'}; - HANDLE hFile; - DWORD result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* read in the expected results to compare with actual results */ - memset (results, 0, 20); - resultsFile = fopen("expectedresults.txt", "r"); - if (resultsFile == NULL) - { - Fail("MoveFileA ERROR[%ul]: Unable to open \"expectedresults.txt\"\n", GetLastError()); - } - - fgets(results, 20, resultsFile); - fclose(resultsFile); - - /* clean the slate */ - removeAll(); - - if (createExisting() != 0) - { - removeAll(); - } - - - /* lpSource loop */ - for (i = 0; i < 4; i++) - { - /* lpDestination loop */ - for (j = 0; j < 4; j++) - { - bRc = MoveFileA(lpSource[i], lpDestination[j]); - if (!( - ((bRc == TRUE) && (results[nCounter] == '1')) - || - ((bRc == FALSE ) && (results[nCounter] == '0')) ) - ) - { - Trace("MoveFileA: FAILED: test[%d][%d]: \"%s\" -> \"%s\"\n", - i, j, lpSource[i], lpDestination[j]); - bSuccess = FALSE; - } - - /* undo the last move */ - removeAll(); - createExisting(); - - nCounter++; - } - } - - removeAll(); - if (bSuccess == FALSE) - { - Fail("MoveFileA: Test Failed"); - } - - /* create the temp source file */ - hFile = CreateFileA(tempSource, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - - if( hFile == INVALID_HANDLE_VALUE ) - { - Fail("Error[%ul]:MoveFileA: CreateFile failed to " - "create the file correctly.\n", GetLastError()); - } - - bRc = CloseHandle(hFile); - if(!bRc) - { - Trace("MoveFileA: CloseHandle failed to close the " - "handle correctly. ERROR:%u\n",GetLastError()); - - /* delete the created file */ - bRc = DeleteFileA(tempSource); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - Fail(""); - } - - /* set the file attributes to be readonly */ - bRc = SetFileAttributesA(tempSource, FILE_ATTRIBUTE_READONLY); - if(!bRc) - { - Trace("MoveFileA: SetFileAttributes failed to set file " - "attributes correctly. GetLastError returned %u\n",GetLastError()); - /* delete the created file */ - bRc = DeleteFileA(tempSource); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - Fail(""); - } - - /* move the file to the new location */ - bRc = MoveFileA(tempSource, tempDest); - if(!bRc) - { - /* delete the created file */ - bRc = DeleteFileA(tempSource); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - - Fail("Error[%ul]:MoveFileA(%S, %S): GetFileAttributes " - "failed to get the file's attributes.\n", - GetLastError(), tempSource, tempDest); - } - - /* check that the newly moved file has the same file attributes - as the original */ - result = GetFileAttributesA(tempDest); - if(result == 0) - { - /* delete the created file */ - bRc = DeleteFileA(tempDest); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - - Fail("Error[%ul]:MoveFileA: GetFileAttributes failed to get " - "the file's attributes.\n", GetLastError()); - } - - if((result & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY) - { - /* delete the newly moved file */ - bRc = DeleteFileA(tempDest); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - - Fail("Error[%ul]MoveFileA: GetFileAttributes failed to get " - "the correct file attributes.\n", GetLastError()); - } - - /* set the file attributes back to normal, to be deleted */ - bRc = SetFileAttributesA(tempDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - /* delete the newly moved file */ - bRc = DeleteFileA(tempDest); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - - Fail("Error[%ul]:MoveFileA: SetFileAttributes failed to set " - "file attributes correctly.\n", GetLastError()); - } - - /* delete the newly moved file */ - bRc = DeleteFileA(tempDest); - if(!bRc) - { - Fail("Error[%ul]:MoveFileA: DeleteFileA failed to delete the" - "file correctly.\n", GetLastError()); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/MoveFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/MoveFileA/test1/testinfo.dat deleted file mode 100644 index 685072fcd9..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileA/test1/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 = file_io -Function = MoveFileA -Name = Positive Test for MoveFileA -TYPE = DEFAULT -EXE1 = movefilea -Description -=Performs a number of MoveFileA tests and uses the -=file ExpectedResults.txt to determine if the test passed/failed diff --git a/src/pal/tests/palsuite/file_io/MoveFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d9..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/MoveFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileW/test1/CMakeLists.txt deleted file mode 100644 index 03b7ab907c..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MoveFileW.cpp -) - -add_executable(paltest_movefilew_test1 - ${SOURCES} -) - -add_dependencies(paltest_movefilew_test1 coreclrpal) - -target_link_libraries(paltest_movefilew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/MoveFileW/test1/ExpectedResults.txt b/src/pal/tests/palsuite/file_io/MoveFileW/test1/ExpectedResults.txt deleted file mode 100644 index 43b67af6b2..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileW/test1/ExpectedResults.txt +++ /dev/null @@ -1 +0,0 @@ -0101000001010000
\ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/MoveFileW/test1/MoveFileW.cpp b/src/pal/tests/palsuite/file_io/MoveFileW/test1/MoveFileW.cpp deleted file mode 100644 index 8a7fae5983..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileW/test1/MoveFileW.cpp +++ /dev/null @@ -1,478 +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: MoveFileW.c -** -** Purpose: Tests the PAL implementation of the MoveFileW function. -** -** -**===================================================================*/ - -#include <palsuite.h> - -LPSTR lpSource[4] = {"src_existing.txt", - "src_non-existant.txt", - "src_dir_existing", - "src_dir_non-existant"}; -LPSTR lpDestination[4] = {"dst_existing.txt", - "dst_non-existant.txt", - "dst_dir_existing", - "dst_dir_non-existant"}; - - -/* Create all the required test files */ -int createExisting(void) -{ - FILE* tempFile = NULL; - DWORD dwError; - BOOL bRc = FALSE; - WCHAR* wPtr = NULL; - char szBuffer[100]; - - /* create the src_existing file */ - tempFile = fopen(lpSource[0], "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFile test file: src_existing.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create %s\n", lpSource[0]); - return FAIL; - } - - /* create the src_dir_existing directory and files */ - wPtr = convert(lpSource[2]); - bRc = CreateDirectoryW(wPtr, NULL); - free(wPtr); - if (bRc != TRUE) - { - Trace("MoveFileW: ERROR: couldn't create \"%s\" because of " - "error code %ld\n", - lpSource[2], - GetLastError()); - return FAIL; - } - - memset(szBuffer, 0, 100); - sprintf_s(szBuffer, _countof(szBuffer), "%s/test01.txt", lpSource[2]); - tempFile = fopen(szBuffer, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileW test file: %s\n", szBuffer); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create %s\n", szBuffer); - return FAIL; - } - - memset(szBuffer, 0, 100); - sprintf_s(szBuffer, _countof(szBuffer), "%s/test02.txt", lpSource[2]); - tempFile = fopen(szBuffer, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileW test file: %s\n", szBuffer); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create %s\n", szBuffer); - return FAIL; - } - - - /* create the dst_existing file */ - tempFile = fopen(lpDestination[0], "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileW test file: dst_existing.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create \"%s\"\n", lpDestination[0]); - return FAIL; - } - - /* create the dst_dir_existing directory and files */ - wPtr = convert(lpDestination[2]); - bRc = CreateDirectoryW(wPtr, NULL); - free(wPtr); - if (bRc != TRUE) - { - dwError = GetLastError(); - Trace("MoveFileW: ERROR: couldn't create \"%s\"\n", lpDestination[2]); - return FAIL; - } - - tempFile = fopen("dst_dir_existing/test01.txt", "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileW test file: dst_dir_existing/test01.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create dst_dir_existing/test01.txt\n"); - return FAIL; - } - tempFile = fopen("dst_dir_existing/test02.txt", "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "MoveFileW test file: dst_dir_existing/test02.txt\n"); - fclose(tempFile); - } - else - { - Trace("ERROR: couldn't create dst_dir_existing/test02.txt\n"); - return FAIL; - } - - return PASS; -} - -void removeDirectoryHelper(LPSTR dir, int location) -{ - DWORD dwAtt = GetFileAttributesA(dir); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - if(!RemoveDirectoryA(dir)) - { - Fail("ERROR: Failed to remove Directory [%s], Error Code [%d], location [%d]\n", dir, GetLastError(), location); - } - } -} - -void removeFileHelper(LPSTR pfile, int location) -{ - FILE *fp; - fp = fopen( pfile, "r"); - - if (fp != NULL) - { - if(fclose(fp)) - { - Fail("ERROR: Failed to close the file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - - if(!DeleteFileA(pfile)) - { - Fail("ERROR: Failed to delete file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - else - { - // Trace("Success: deleted file [%S], Error Code [%d], location [%d]\n", wfile, GetLastError(), location); - } - } - -} - -/* remove all created files in preparation for the next test */ -void removeAll(void) -{ - char szTemp[40]; - DWORD dwAtt; - - /* get rid of source dirs and files */ - removeFileHelper(lpSource[0], 1); - removeFileHelper(lpSource[1], 2); - - dwAtt = GetFileAttributesA(lpSource[2]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpSource[2]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpSource[2]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpSource[2], 103); - } - else - { - removeFileHelper(lpSource[2], 17); - } - - - dwAtt = GetFileAttributesA(lpSource[3]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpSource[3]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpSource[3]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpSource[3], 103); - } - else - { - removeFileHelper(lpSource[3], 17); - } - - /* get rid of destination dirs and files */ - dwAtt = GetFileAttributesA(lpDestination[0]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[0]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[0]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[0], 103); - } - else - { - removeFileHelper(lpDestination[0], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[1]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[1]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[1]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[1], 103); - } - else - { - removeFileHelper(lpDestination[1], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[2]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[2]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[2]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[2], 103); - } - else - { - removeFileHelper(lpDestination[2], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[3]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - sprintf_s(szTemp, _countof(szTemp), "%s/test01.txt", lpDestination[3]); - removeFileHelper(szTemp, 18); - - sprintf_s(szTemp, _countof(szTemp), "%s/test02.txt", lpDestination[3]); - removeFileHelper(szTemp, 19); - removeDirectoryHelper(lpDestination[3], 103); - } - else - { - removeFileHelper(lpDestination[3], 17); - } - -} - - - - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = TRUE; - BOOL bSuccess = TRUE; - char results[40]; - FILE* resultsFile = NULL; - int nCounter = 0; - int i, j; - WCHAR* wSource = NULL; - WCHAR* wDest = NULL; - WCHAR tempSource[] = {'t','e','m','p','k','.','t','m','p','\0'}; - WCHAR tempDest[] = {'t','e','m','p','2','.','t','m','p','\0'}; - HANDLE hFile; - DWORD result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* read in the expected results to compare with actual results */ - memset (results, 0, 20); - resultsFile = fopen("expectedresults.txt", "r"); - if (resultsFile == NULL) - { - Fail("MoveFileW ERROR: Unable to open \"expectedresults.txt\"\n"); - } - - fgets(results, 20, resultsFile); - fclose(resultsFile); - - /* clean the slate */ - removeAll(); - - if (createExisting() != 0) - { - removeAll(); - } - - - /* lpSource loop */ - for (i = 0; i < 4; i++) - { - /* lpDestination loop */ - for (j = 0; j < 4; j++) - { - - wSource = convert(lpSource[i]); - wDest = convert(lpDestination[j]); - bRc = MoveFileW(wSource, wDest); - free(wSource); - free(wDest); - if (!( - ((bRc == TRUE) && (results[nCounter] == '1')) - || - ((bRc == FALSE ) && (results[nCounter] == '0')) ) - ) - { - Trace("MoveFileW: FAILED: test[%d][%d]: \"%s\" -> \"%s\"\n", - i, j, lpSource[i], lpDestination[j]); - bSuccess = FALSE; - } - - /* undo the last move */ - removeAll(); - createExisting(); - - nCounter++; - } - } - - removeAll(); - if (bSuccess == FALSE) - { - Fail("MoveFileW: Test Failed"); - } - - /* create the temp source file */ - hFile = CreateFileW(tempSource, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - - if( hFile == INVALID_HANDLE_VALUE ) - { - Fail("MoveFileW: CreateFile failed to " - "create the file correctly.\n"); - } - - bRc = CloseHandle(hFile); - if(!bRc) - { - Trace("MoveFileW: CloseHandle failed to close the " - "handle correctly. ERROR:%u\n",GetLastError()); - - /* delete the created file */ - bRc = DeleteFileW(tempSource); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - Fail(""); - } - - /* set the file attributes to be readonly */ - bRc = SetFileAttributesW(tempSource, FILE_ATTRIBUTE_READONLY); - if(!bRc) - { - Trace("MoveFileW: SetFileAttributes failed to set file " - "attributes correctly. GetLastError returned %u\n",GetLastError()); - /* delete the created file */ - bRc = DeleteFileW(tempSource); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - Fail(""); - } - - /* move the file to the new location */ - bRc = MoveFileW(tempSource, tempDest); - if(!bRc) - { - /* delete the created file */ - bRc = DeleteFileW(tempSource); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - - Fail("MoveFileW(%S, %S): GetFileAttributes " - "failed to get the file's attributes.\n", - tempSource, tempDest); - } - - /* check that the newly moved file has the same file attributes - as the original */ - result = GetFileAttributesW(tempDest); - if(result == 0) - { - /* delete the created file */ - bRc = DeleteFileW(tempDest); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - - Fail("MoveFileW: GetFileAttributes failed to get " - "the file's attributes.\n"); - } - - if((result & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY) - { - /* delete the newly moved file */ - bRc = DeleteFileW(tempDest); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - - Fail("MoveFileW: GetFileAttributes failed to get " - "the correct file attributes.\n"); - } - - /* set the file attributes back to normal, to be deleted */ - bRc = SetFileAttributesW(tempDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - /* delete the newly moved file */ - bRc = DeleteFileW(tempDest); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - - Fail("MoveFileW: SetFileAttributes failed to set " - "file attributes correctly.\n"); - } - - /* delete the newly moved file */ - bRc = DeleteFileW(tempDest); - if(!bRc) - { - Fail("MoveFileW: DeleteFileW failed to delete the" - "file correctly.\n"); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/MoveFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/MoveFileW/test1/testinfo.dat deleted file mode 100644 index 8852a03ca2..0000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileW/test1/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 = file_io -Function = MoveFileW -Name = Positive Test for MoveFileW -TYPE = DEFAULT -EXE1 = movefilew -Description -=Performs a number of MoveFileW tests and uses the -=file ExpectedResults.txt to determine if the test passed/failed diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileTime/CMakeLists.txt deleted file mode 100644 index a3847f8ca9..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/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/file_io/SetFileTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileTime/test1/CMakeLists.txt deleted file mode 100644 index e9d8dce966..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileTime.cpp -) - -add_executable(paltest_setfiletime_test1 - ${SOURCES} -) - -add_dependencies(paltest_setfiletime_test1 coreclrpal) - -target_link_libraries(paltest_setfiletime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test1/SetFileTime.cpp b/src/pal/tests/palsuite/file_io/SetFileTime/test1/SetFileTime.cpp deleted file mode 100644 index 4711aeba89..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test1/SetFileTime.cpp +++ /dev/null @@ -1,129 +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: SetFileTime.c -** -** Purpose: Tests the PAL implementation of the SetFileTime function. -** This test first sets a valid file time on the file which is opened. -** Then it calls GetFileTime, and compares the values. They should -** be the same. Note: Access time isn't checked in this test. It will -** be dealt with seperatly due to odd behaviour. -** -** Depends: -** CreateFile -** GetFileTime -** -** -**===================================================================*/ - -#include <palsuite.h> - -int __cdecl main(int argc, char **argv) -{ - -#if WIN32 - FILETIME Creation; - FILETIME SetCreation; -#endif - FILETIME LastWrite; - FILETIME SetLastWrite; - HANDLE TheFileHandle; - BOOL result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Populate some FILETIME structures with values - These values are valid Creation, Access and Write times - which I generated, and should work properly. - */ -#if WIN32 - SetCreation.dwLowDateTime = 458108416; - SetCreation.dwHighDateTime = 29436904; -#endif - - SetLastWrite.dwLowDateTime = -1995099136; - SetLastWrite.dwHighDateTime = 29436915; - - - /* Open the file to get a HANDLE */ - TheFileHandle = CreateFile("the_file", - GENERIC_READ|GENERIC_WRITE, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.\n",GetLastError()); - } - - /* Set the new file time */ -#if WIN32 - result = SetFileTime(TheFileHandle, - &SetCreation, NULL, &SetLastWrite); -#else - result = SetFileTime(TheFileHandle, - NULL, NULL, &SetLastWrite); -#endif - if(result == 0) - { - Fail("ERROR: SetFileTime failed when trying to set the " - "new file time. The GetLastError was %d.\n",GetLastError()); - } - - - /* Then get the file time of the file */ -#if WIN32 - result = GetFileTime(TheFileHandle, &Creation, NULL, &LastWrite); -#else - result = GetFileTime(TheFileHandle, NULL, NULL, &LastWrite); -#endif - - if(result == 0) - { - Fail("ERROR: GetFileTime failed, and this tests depends " - "upon it working properly, in order to ensure that the " - "file time was set with SetFileTime. GetLastError() " - "returned %d.\n",GetLastError()); - } - - /* Compare the write time we Set to the write time aquired with - Get. They should be the same. - */ - - if(LastWrite.dwLowDateTime != SetLastWrite.dwLowDateTime || - LastWrite.dwHighDateTime != SetLastWrite.dwHighDateTime) - { - Fail("ERROR: After setting the write time, it is not " - "equal to what it was set to. Either Set of GetFileTime are " - "broken.\n"); - } - - /* Within FreeBSD, the Creation time is ignored when SetFileTime - is called. Since FreeBSD has no equivalent. For that reason, - it is not checked with the following test. - */ - -#if WIN32 - if(Creation.dwHighDateTime != SetCreation.dwHighDateTime || - Creation.dwLowDateTime != SetCreation.dwLowDateTime) - { - Fail("ERROR: After setting the file time, the Creation " - "time is not what it should be. Either Set or GetFileTime " - "are broken."); - } -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileTime/test1/testinfo.dat deleted file mode 100644 index 09dfa0b623..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/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 = file_io -Function = SetFileTime -Name = Positive Test for SetFileTime -TYPE = DEFAULT -EXE1 = setfiletime -Description -= Test the SetFileTime function. -= This test calls SetFileTime and sets a file to a given time. It then -= calls GetFileTime, and compares the values of the two, which should be -= equal diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileTime/test2/CMakeLists.txt deleted file mode 100644 index 12ec26c9f8..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/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 - SetFileTime.cpp -) - -add_executable(paltest_setfiletime_test2 - ${SOURCES} -) - -add_dependencies(paltest_setfiletime_test2 coreclrpal) - -target_link_libraries(paltest_setfiletime_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test2/SetFileTime.cpp b/src/pal/tests/palsuite/file_io/SetFileTime/test2/SetFileTime.cpp deleted file mode 100644 index e950153bb0..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test2/SetFileTime.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileTime.c -** -** Purpose: Tests the PAL implementation of the SetFileTime -** This test first tries to SetFileTime on a HANDLE which doesn't have -** GENERIC_WRITE set, which should fail. -** -** -** Depends: -** CreateFile -** CloseHandle -** -** -**===================================================================*/ - -#include <palsuite.h> - - - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME SetCreation,SetLastAccess,SetLastWrite; - HANDLE TheFileHandle; - BOOL result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Populate some FILETIME structures with values - These values are valid Creation, Access and Write times - which I generated, and should work properly. - - The access times are not seperated into WIN32 and FreeBSD here, - but it should be fine, as no comparisons are being done in this - test. - */ - - SetCreation.dwLowDateTime = 458108416; - SetCreation.dwHighDateTime = 29436904; - - SetLastAccess.dwLowDateTime = 341368832; - SetLastAccess.dwHighDateTime = 29436808; - - SetLastWrite.dwLowDateTime = -1995099136; - SetLastWrite.dwHighDateTime = 29436915; - - -/* Open the file to get a HANDLE, without GENERIC WRITE */ - - TheFileHandle = - CreateFile( - "the_file", - GENERIC_READ, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.",GetLastError()); - } - - /* This SetFileTime should fail, because the HANDLE isn't set with - GENERIC_WRITE - */ - result = SetFileTime(TheFileHandle, - &SetCreation,&SetLastAccess,&SetLastWrite); - - if(result != 0) - { - Fail("ERROR: SetFileTime should have failed, but returned a " - "non-zero result. The File HANDLE passed was no set Writable " - "which should cause failure."); - } - - result = CloseHandle(TheFileHandle); - - if(result == 0) - { - Fail("ERROR: CloseHandle failed. This test depends upon " - "it working."); - } - - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileTime/test2/testinfo.dat deleted file mode 100644 index f1699facaf..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test2/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 = file_io -Function = SetFileTime -Name = Negative Test for SetFileTime -TYPE = DEFAULT -EXE1 = setfiletime -Description -= Test the SetFileTime function. -= This test first tries to SetFileTime on a HANDLE which doesn't have -= GENERIC_WRITE set, which should fail. Then it attempts to set the file -= time with bad FILETIME structures, which should also fail diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileTime/test3/CMakeLists.txt deleted file mode 100644 index ca0ed659f5..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileTime.cpp -) - -add_executable(paltest_setfiletime_test3 - ${SOURCES} -) - -add_dependencies(paltest_setfiletime_test3 coreclrpal) - -target_link_libraries(paltest_setfiletime_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test3/SetFileTime.cpp b/src/pal/tests/palsuite/file_io/SetFileTime/test3/SetFileTime.cpp deleted file mode 100644 index 97f49495d7..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test3/SetFileTime.cpp +++ /dev/null @@ -1,66 +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: SetFileTime.c -** -** Purpose: Tests the PAL implementation of the SetFileTime function. -** This test checks to ensure that the function fails when passed an -** invalid file HANDLE -** -** -**===================================================================*/ - - - -#include <palsuite.h> - - - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME SetCreation, SetLastWrite, SetLastAccess; - HANDLE TheFileHandle = NULL; - BOOL result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Populate some FILETIME structures with values - These values are valid Creation, Access and Write times - which I generated, and should work properly. - */ - - SetCreation.dwLowDateTime = 458108416; - SetCreation.dwHighDateTime = 29436904; - - SetLastAccess.dwLowDateTime = 341368832; - SetLastAccess.dwHighDateTime = 29436808; - - SetLastWrite.dwLowDateTime = -1995099136; - SetLastWrite.dwHighDateTime = 29436915; - - - /* Pass this function an invalid file HANDLE and it should - fail. - */ - - result = SetFileTime(TheFileHandle, - &SetCreation,&SetLastAccess,&SetLastWrite); - - if(result != 0) - { - Fail("ERROR: Passed an invalid file HANDLE to SetFileTime, but it " - "returned non-zero. This should return zero for failure."); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileTime/test3/testinfo.dat deleted file mode 100644 index e27280469e..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test3/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 = file_io -Function = SetFileTime -Name = Negative Test for SetFileTime -TYPE = DEFAULT -EXE1 = setfiletime -Description -= Test the SetFileTime function. -= This test checks to ensure that the function fails when passed an -= invalid file HANDLE diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileTime/test4/CMakeLists.txt deleted file mode 100644 index 432ebe594f..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/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 - SetFileTime.cpp -) - -add_executable(paltest_setfiletime_test4 - ${SOURCES} -) - -add_dependencies(paltest_setfiletime_test4 coreclrpal) - -target_link_libraries(paltest_setfiletime_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test4/SetFileTime.cpp b/src/pal/tests/palsuite/file_io/SetFileTime/test4/SetFileTime.cpp deleted file mode 100644 index 3edd2403c4..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/test4/SetFileTime.cpp +++ /dev/null @@ -1,108 +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: SetFileTime.c -** -** Purpose: Tests the PAL implementation of the SetFileTime function -** This passes a variety of NULL values as parameters to the function. -** It should still succeed. -** -** Depends: -** CreateFile -** - -** -**===================================================================*/ - -#include <palsuite.h> - - - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - FILETIME Creation; -#endif - FILETIME LastWrite,LastAccess; - HANDLE TheFileHandle; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Populate some FILETIME structures with values - These values are valid Creation, Access and Write times - which I generated, and should work properly. - - These values aren't being used for comparison, so they should - work ok, even though they weren't generated specifically for - FreeBSD or WIN32 ... - */ -#if WIN32 - Creation.dwLowDateTime = 458108416; - Creation.dwHighDateTime = 29436904; -#endif - LastAccess.dwLowDateTime = 341368832; - LastAccess.dwHighDateTime = 29436808; - - LastWrite.dwLowDateTime = -1995099136; - LastWrite.dwHighDateTime = 29436915; - - /* Open the file to get a HANDLE */ - TheFileHandle = - CreateFile( - "the_file", - GENERIC_READ|GENERIC_WRITE, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Failed to open the file. The error number " - "returned was %d.",GetLastError()); - } - - /* Pass all NULLs, this is useless but should still work. */ - if(SetFileTime(TheFileHandle,NULL,NULL,NULL)==0) - { - Fail("ERROR: SetFileTime returned 0, indicating failure. " - "Three of the params were NULL in this case, did they " - "cause the problem?"); - } - -#if WIN32 - /* Set the Creation time of the File */ - if(SetFileTime(TheFileHandle,&Creation,NULL,NULL)==0) - { - Fail("ERROR: SetFileTime returned 0, indicating failure. " - "Two of the params were NULL in this case, did they " - "cause the problem?"); - } -#endif - -#if WIN32 - /* Set the Creation, LastWrite time of the File */ - if(SetFileTime(TheFileHandle,&Creation,&LastWrite,NULL)==0) -#else - /* Set the LastWrite time of the File */ - if(SetFileTime(TheFileHandle,NULL,&LastWrite,NULL)==0) -#endif - { - Fail("ERROR: SetFileTime returned 0, indicating failure. " - "One of the params were NULL in this case, did it " - "cause the problem?"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileTime/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileTime/test4/testinfo.dat deleted file mode 100644 index a3dfdd02f0..0000000000 --- a/src/pal/tests/palsuite/file_io/SetFileTime/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 = file_io -Function = SetFileTime -Name = Positive Test for SetFileTime -TYPE = DEFAULT -EXE1 = setfiletime -Description -= Test the SetFileTime function. -= This passes a variety of NULL values as parameters to the function. -= It should still succeed diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt b/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt index a3847f8ca9..1962ade358 100644 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt +++ b/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt @@ -3,5 +3,4 @@ cmake_minimum_required(VERSION 2.8.12.2) add_subdirectory(test1) add_subdirectory(test2) add_subdirectory(test3) -add_subdirectory(test4) diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp index 5c2ab86b99..b9177ece4e 100644 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp +++ b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp @@ -18,7 +18,7 @@ ** Functions covered by this test are: -** MoveFileW, FindFirstFileA, FindFirstFileW, +** FindFirstFileA, FindFirstFileW, ** GetFileAttributesA, GetFileAttributesW, @@ -95,80 +95,6 @@ int __cdecl main(int argc, char *argv[]) - /*...................Test MoveFileW.............................*/ - - - - /* test with an invalid path */ - - bRc = MoveFileW(wBadFilePath,wDest); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("MoveFileW: calling GetLastError() after moving a file" - - " with wrong path returned [%u] while it should return [%u]\n" - - ,GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - testPass = FALSE; - - } - - - - /* test with invalid file name */ - - bRc = MoveFileW(wBadFileName,wDest); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("MoveFileW: calling GetLastError() after moving a file" - - " with wrong name returned [%u] while it should return [%u]\n" - - ,GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("MoveFileW: managed to move a file with wrong name\n"); - - testPass = FALSE; - - } - - - /*............. Test FindFirstFileA..................................*/ diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat index c5a61b949a..ddc5081c11 100644 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat +++ b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat @@ -26,7 +26,7 @@ Description = Functions covered by this test are: -= MoveFileW, FindFirstFileA, FindFirstFileW, += FindFirstFileA, FindFirstFileW, = GetFileAttributesA, GetFileAttributesW, diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/CMakeLists.txt deleted file mode 100644 index 00621296d0..0000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/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_errorpathnotfound_test4 - ${SOURCES} -) - -add_dependencies(paltest_errorpathnotfound_test4 coreclrpal) - -target_link_libraries(paltest_errorpathnotfound_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/test4.cpp b/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/test4.cpp deleted file mode 100644 index e1b68995b0..0000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/test4.cpp +++ /dev/null @@ -1,351 +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: Test the return value of GetLastError() after calling - -** some file_io functions with an invalid path. - -** - -** Functions covered by this test are: - -** GetDiskFreeSpaceW, GetTempFileNameA - -** and GetTempFileNameW - -** -** - -** - - - -** - -**===================================================================*/ - - - -#include <palsuite.h> - - - -int __cdecl main(int argc, char *argv[]) - -{ - - - - BOOL testPass = TRUE; - - BOOL bRc = TRUE; - - DWORD lastErr=-50; - - DWORD dwSectorsPerCluster_02; /* sectors per cluster */ - - DWORD dwBytesPerSector_02; /* bytes per sector */ - - DWORD dwNumberOfFreeClusters; /* free clusters */ - - DWORD dwTotalNumberOfClusters; /* total clusters */ - - - - UINT uiError = 0; - - char szReturnedName[256]; - - const UINT uUnique = 0; - - const char* sDot = {"tmpr"}; - - const char* sPrefix = {"cfr"}; - - - - WCHAR wzReturnedName[256]; - - const WCHAR wDot[] = {'t','m','p','r','\0'}; - - const WCHAR wPrefix[] = {'c','f','r','\0'}; - - - - - - const WCHAR wBadFilePath[] = - - {'w','b','a','d','/','b','a', - - 'd','.','t','m','p','\0'}; - - const WCHAR wBadFileName[] = - - {'w','B','a','d','.','t','m','p','\0'}; - - - - - - - - if (0 != PAL_Initialize(argc,argv)) - - { - - return FAIL; - - } - - - - /* test .................. GetDiskFreeSpaceW .................. */ - - - - /* test with invalid file name */ - - bRc = GetDiskFreeSpaceW(wBadFileName, - - &dwSectorsPerCluster_02, - - &dwBytesPerSector_02, - - &dwNumberOfFreeClusters, - - &dwTotalNumberOfClusters); - - if (bRc != TRUE) - - - - { - - lastErr=GetLastError(); - - - - if(lastErr != ERROR_FILE_NOT_FOUND) - - { - - Trace("GetDiskFreeSpaceW: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad File Name\n", - - lastErr,ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetDiskFreeSpaceW: GetDiskFreeSpaceW succeeded when given " - - "a bad fileName\n"); - - testPass = FALSE; - - - - } - - - - - - /* test with invalid path name */ - - bRc = GetDiskFreeSpaceW(wBadFilePath, - - &dwSectorsPerCluster_02, - - &dwBytesPerSector_02, - - &dwNumberOfFreeClusters, - - &dwTotalNumberOfClusters); - - if (bRc != TRUE) - - - - { - - lastErr=GetLastError(); - - if(lastErr != ERROR_PATH_NOT_FOUND) - - { - - Trace("GetDiskFreeSpaceW: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad File Name\n", - - lastErr,ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetDiskFreeSpaceW: GetDiskFreeSpaceW succeeded when given " - - "a bad fileName\n"); - - testPass = FALSE; - - - - - - } - - - - - - /* test .................. GetTempFileNameA .................. */ - - - - /* test with invalid path name */ - - uiError = GetTempFileNameA(sDot, sPrefix, uUnique, szReturnedName); - - if (uiError == 0) - - { - - lastErr=GetLastError(); - - if(lastErr != ERROR_DIRECTORY) - - { - - - - Trace("GetTempFileNameA: calling GetLastError() returned [%u] " - - "while it should return [%u] for invalid path name\n", - - lastErr,ERROR_DIRECTORY); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetTempFileNameA: GetTempFileNameA succeeded when given " - - "invalid path name\n"); - - testPass = FALSE; - - } - - - - - - - - /* test .................. GetTempFileNameW .................. */ - - - - /* test with invalid path name */ - - uiError = GetTempFileNameW(wDot, wPrefix, uUnique, wzReturnedName); - - if (uiError == 0) - - { - - lastErr=GetLastError(); - - if(lastErr != ERROR_DIRECTORY) - - { - - - - Trace("GetTempFileNameW: calling GetLastError() returned [%u] " - - "while it should return [%u] for an invalid path name\n", - - lastErr,ERROR_DIRECTORY); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetTempFileNameW: GetTempFileNameW succeeded when given" - - " an invalid path name\n"); - - testPass = FALSE; - - } - - - - if(! testPass) - - { - - Fail(""); - - } - - - - - - - - - - - - - - PAL_Terminate(); - - return PASS; - -} - - - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/testinfo.dat deleted file mode 100644 index d7b707fca9..0000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test4/testinfo.dat +++ /dev/null @@ -1,34 +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 = file_io - -Function = some File_io functions - -Name = errorpathnotfound - checking GetLastError. - -Type = DEFAULT - -EXE1 = test4 - -Description - -= Test the return value of GetLastError() after calling - -= some file_io functions with an invalid path. - -= Functions covered by this test are: - -= MoveFIlew, FindFirstFileA, FindFirstFileW, - -= GetFileAttributesA, GetFileAttributesW, - -= SetFileAttributesA, SetFileAttributesW. - 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) - - diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt index 0c8892a4a0..ea088d75a2 100644 --- a/src/pal/tests/palsuite/paltestlist.txt +++ b/src/pal/tests/palsuite/paltestlist.txt @@ -471,8 +471,6 @@ filemapping_memmgt/HeapReAlloc/test5/paltest_heaprealloc_test5 filemapping_memmgt/LocalAlloc/test1/paltest_localalloc_test1 filemapping_memmgt/LocalFree/test1/paltest_localfree_test1 filemapping_memmgt/LocalFree/test2/paltest_localfree_test2 -filemapping_memmgt/LockFile/test2/paltest_lockfile_test2 -filemapping_memmgt/LockFile/test7/paltest_lockfile_test7 filemapping_memmgt/MapViewOfFile/test1/paltest_mapviewoffile_test1 filemapping_memmgt/MapViewOfFile/test2/paltest_mapviewoffile_test2 filemapping_memmgt/MapViewOfFile/test3/paltest_mapviewoffile_test3 @@ -485,8 +483,6 @@ filemapping_memmgt/RtlMoveMemory/test1/paltest_rtlmovememory_test1 filemapping_memmgt/RtlMoveMemory/test3/paltest_rtlmovememory_test3 filemapping_memmgt/RtlMoveMemory/test4/paltest_rtlmovememory_test4 filemapping_memmgt/RtlMoveMemory/test5/paltest_rtlmovememory_test5 -filemapping_memmgt/UnlockFile/test2/paltest_unlockfile_test2 -filemapping_memmgt/UnlockFile/test4/paltest_unlockfile_test4 filemapping_memmgt/UnmapViewOfFile/test1/paltest_unmapviewoffile_test1 filemapping_memmgt/UnmapViewOfFile/test2/paltest_unmapviewoffile_test2 filemapping_memmgt/VirtualAlloc/test1/paltest_virtualalloc_test1 @@ -520,7 +516,6 @@ filemapping_memmgt/VirtualProtect/test4/paltest_virtualprotect_test4 filemapping_memmgt/VirtualProtect/test6/paltest_virtualprotect_test6 filemapping_memmgt/VirtualProtect/test7/paltest_virtualprotect_test7 filemapping_memmgt/VirtualQuery/test1/paltest_virtualquery_test1 -file_io/AreFileApisANSI/test1/paltest_arefileapisansi_test1 file_io/CompareFileTime/test1/paltest_comparefiletime_test1 file_io/CopyFileA/test1/paltest_copyfilea_test1 file_io/CopyFileA/test2/paltest_copyfilea_test2 @@ -535,7 +530,6 @@ file_io/DeleteFileW/test1/paltest_deletefilew_test1 file_io/errorpathnotfound/test2/paltest_errorpathnotfound_test2 file_io/errorpathnotfound/test3/paltest_errorpathnotfound_test3 file_io/FILECanonicalizePath/paltest_filecanonicalizepath_test1 -file_io/FileTimeToDosDateTime/test1/paltest_filetimetodosdatetime_test1 file_io/FindClose/test1/paltest_findclose_test1 file_io/FindFirstFileA/test1/paltest_findfirstfilea_test1 file_io/FindFirstFileW/test1/paltest_findfirstfilew_test1 @@ -544,27 +538,14 @@ file_io/FindNextFileA/test2/paltest_findnextfilea_test2 file_io/FindNextFileW/test1/paltest_findnextfilew_test1 file_io/FindNextFileW/test2/paltest_findnextfilew_test2 file_io/FlushFileBuffers/test1/paltest_flushfilebuffers_test1 -file_io/GetConsoleCP/test1/paltest_getconsolecp_test1 file_io/GetConsoleOutputCP/test1/paltest_getconsoleoutputcp_test1 file_io/GetCurrentDirectoryA/test1/paltest_getcurrentdirectorya_test1 file_io/GetCurrentDirectoryW/test1/paltest_getcurrentdirectoryw_test1 -file_io/GetDiskFreeSpaceW/test1/paltest_getdiskfreespacew_test1 -file_io/GetDiskFreeSpaceW/test2/paltest_getdiskfreespacew_test2 file_io/GetFileAttributesA/test1/paltest_getfileattributesa_test1 file_io/GetFileAttributesExW/test2/paltest_getfileattributesexw_test2 file_io/GetFileAttributesW/test1/paltest_getfileattributesw_test1 file_io/GetFileSize/test1/paltest_getfilesize_test1 file_io/GetFileSizeEx/test1/paltest_getfilesizeex_test1 -file_io/GetFileTime/test1/paltest_getfiletime_test1 -file_io/GetFileTime/test2/paltest_getfiletime_test2 -file_io/GetFileTime/test3/paltest_getfiletime_test3 -file_io/GetFileTime/test4/paltest_getfiletime_test4 -file_io/GetFileTime/test5/paltest_getfiletime_test5 -file_io/GetFileTime/test6/paltest_getfiletime_test6 -file_io/GetFileTime/test7/paltest_getfiletime_test7 -file_io/GetFileType/test1/paltest_getfiletype_test1 -file_io/GetFileType/test2/paltest_getfiletype_test2 -file_io/GetFileType/test3/paltest_getfiletype_test3 file_io/GetFullPathNameA/test1/paltest_getfullpathnamea_test1 file_io/GetFullPathNameA/test3/paltest_getfullpathnamea_test3 file_io/GetFullPathNameA/test4/paltest_getfullpathnamea_test4 @@ -611,10 +592,6 @@ file_io/SetFilePointer/test4/paltest_setfilepointer_test4 file_io/SetFilePointer/test5/paltest_setfilepointer_test5 file_io/SetFilePointer/test6/paltest_setfilepointer_test6 file_io/SetFilePointer/test7/paltest_setfilepointer_test7 -file_io/SetFileTime/test1/paltest_setfiletime_test1 -file_io/SetFileTime/test2/paltest_setfiletime_test2 -file_io/SetFileTime/test3/paltest_setfiletime_test3 -file_io/SetFileTime/test4/paltest_setfiletime_test4 file_io/WriteFile/test1/paltest_writefile_test1 file_io/WriteFile/test3/paltest_writefile_test3 file_io/WriteFile/test4/paltest_writefile_test4 diff --git a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt index 4dac7e94c6..0199ad12f1 100644 --- a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt +++ b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt @@ -72,11 +72,6 @@ filemapping_memmgt/GetModuleFileNameA/test1/paltest_getmodulefilenamea_test1 filemapping_memmgt/GetModuleFileNameW/test1/paltest_getmodulefilenamew_test1 filemapping_memmgt/GetProcAddress/test1/paltest_getprocaddress_test1 filemapping_memmgt/GetProcAddress/test2/paltest_getprocaddress_test2 -filemapping_memmgt/LockFile/test1/paltest_lockfile_test1 -filemapping_memmgt/LockFile/test3/paltest_lockfile_test3 -filemapping_memmgt/LockFile/test4/paltest_lockfile_test4 -filemapping_memmgt/LockFile/test5/paltest_lockfile_test5 -filemapping_memmgt/LockFile/test6/paltest_lockfile_test6 filemapping_memmgt/OpenFileMappingA/test1/paltest_openfilemappinga_test1 filemapping_memmgt/OpenFileMappingA/test2/paltest_openfilemappinga_test2 filemapping_memmgt/OpenFileMappingA/test3/paltest_openfilemappinga_test3 @@ -86,15 +81,12 @@ filemapping_memmgt/OpenFileMappingW/test3/paltest_openfilemappingw_test3 filemapping_memmgt/ReadProcessMemory/ReadProcessMemory_neg1/paltest_readprocessmemory_readprocessmemory_neg1 filemapping_memmgt/ReadProcessMemory/test1/paltest_readprocessmemory_test1 filemapping_memmgt/ReadProcessMemory/test2/paltest_readprocessmemory_test2 -filemapping_memmgt/UnlockFile/test1/paltest_unlockfile_test1 -filemapping_memmgt/UnlockFile/test3/paltest_unlockfile_test3 file_io/CopyFileW/test1/paltest_copyfilew_test1 file_io/CreateDirectoryA/test2/paltest_createdirectorya_test2 file_io/CreateDirectoryW/test2/paltest_createdirectoryw_test2 file_io/CreateFileA/test1/paltest_createfilea_test1 file_io/CreateFileW/test1/paltest_createfilew_test1 file_io/errorpathnotfound/test1/paltest_errorpathnotfound_test1 -file_io/errorpathnotfound/test4/paltest_errorpathnotfound_test4 file_io/GetFileAttributesExW/test1/paltest_getfileattributesexw_test1 file_io/GetFullPathNameA/test2/paltest_getfullpathnamea_test2 file_io/GetFullPathNameW/test2/paltest_getfullpathnamew_test2 @@ -103,10 +95,8 @@ file_io/GetTempFileNameW/test1/paltest_gettempfilenamew_test1 file_io/GetTempFileNameW/test2/paltest_gettempfilenamew_test2 file_io/gettemppatha/test1/paltest_gettemppatha_test1 file_io/GetTempPathW/test1/paltest_gettemppathw_test1 -file_io/MoveFileA/test1/paltest_movefilea_test1 file_io/MoveFileExA/test1/paltest_movefileexa_test1 file_io/MoveFileExW/test1/paltest_movefileexw_test1 -file_io/MoveFileW/test1/paltest_movefilew_test1 file_io/ReadFile/test1/paltest_readfile_test1 file_io/SetFileAttributesA/test1/paltest_setfileattributesa_test1 file_io/SetFileAttributesA/test4/paltest_setfileattributesa_test4 diff --git a/src/pal/tests/palsuite/palverify.dat b/src/pal/tests/palsuite/palverify.dat index d4cb311010..cdcb4cb4e3 100644 --- a/src/pal/tests/palsuite/palverify.dat +++ b/src/pal/tests/palsuite/palverify.dat @@ -498,7 +498,6 @@ exception_handling/pal_try_leave_finally/test1,1 exception_handling/raiseexception/test1,1 exception_handling/raiseexception/test2,1 exception_handling/raiseexception/test3,1 -file_io/arefileapisansi/test1,1 file_io/comparefiletime/test1,1 file_io/copyfilea/test1,1 file_io/copyfilea/test2,1 @@ -515,32 +514,19 @@ file_io/deletefilew/test1,1 file_io/errorpathnotfound/test1,1 file_io/errorpathnotfound/test2,1 file_io/errorpathnotfound/test3,1 -#file_io/errorpathnotfound/test4,1 -file_io/filetimetodosdatetime/test1,1 file_io/findclose/test1,1 file_io/findfirstfilea/test1,1 #file_io/findfirstfilew/test1,1 file_io/findnextfilea/test1,1 file_io/findnextfilew/test1,1 file_io/flushfilebuffers/test1,1 -file_io/getconsolecp/test1,1 file_io/getconsoleoutputcp/test1,1 file_io/getcurrentdirectorya/test1,1 file_io/getcurrentdirectoryw/test1,1 -file_io/getdiskfreespacew/test1,1 #file_io/getfileattributesa/test1,1 #file_io/getfileattributesexw/test1,1 file_io/getfileattributesexw/test2,1 #file_io/getfileattributesw/test1,1 -file_io/getfiletime/test1,1 -file_io/getfiletime/test2,1 -file_io/getfiletime/test3,1 -file_io/getfiletime/test4,1 -file_io/getfiletime/test6,1 -file_io/getfiletime/test7,1 -file_io/getfiletype/test1,1 -file_io/getfiletype/test2,1 -file_io/getfiletype/test3,1 file_io/getfullpathnamea/test1,1 file_io/getfullpathnamea/test2,1 file_io/getfullpathnamea/test3,1 @@ -560,7 +546,6 @@ file_io/gettempfilenamew/test3,1 file_io/gettemppatha/test1,1 file_io/gettemppathw/test1,1 file_io/movefileexw/test1,1 -file_io/movefilew/test1,1 #file_io/readfile/test1,1 file_io/readfile/test2,1 file_io/readfile/test3,1 @@ -585,10 +570,6 @@ file_io/setfilepointer/test1,1 file_io/setfilepointer/test2,1 file_io/setfilepointer/test3,1 file_io/setfilepointer/test4,1 -file_io/setfiletime/test1,1 -file_io/setfiletime/test2,1 -file_io/setfiletime/test3,1 -file_io/setfiletime/test4,1 file_io/writefile/test1,1 file_io/writefile/test2,1 file_io/writefile/test3,1 |