From db20f3f1bb8595633a7e16c8900fd401a453a6b5 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Tue, 27 Dec 2016 16:46:08 +0900 Subject: Imported Upstream version 1.0.0.9127 --- .../file_io/GetFileType/test1/GetFileType.cpp | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp (limited to 'src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp') diff --git a/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp b/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp new file mode 100644 index 0000000000..6558c00bdd --- /dev/null +++ b/src/pal/tests/palsuite/file_io/GetFileType/test1/GetFileType.cpp @@ -0,0 +1,76 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: GetFileType.c (test 1) +** +** Purpose: Tests the PAL implementation of the GetFileType function. +** +** +**===================================================================*/ + +#include + +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; +} -- cgit v1.2.3