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 --- .../palsuite/c_runtime/fclose/test1/CMakeLists.txt | 2 +- .../tests/palsuite/c_runtime/fclose/test1/test1.c | 79 ---------------------- .../palsuite/c_runtime/fclose/test1/test1.cpp | 79 ++++++++++++++++++++++ .../palsuite/c_runtime/fclose/test2/CMakeLists.txt | 2 +- .../tests/palsuite/c_runtime/fclose/test2/test2.c | 77 --------------------- .../palsuite/c_runtime/fclose/test2/test2.cpp | 77 +++++++++++++++++++++ 6 files changed, 158 insertions(+), 158 deletions(-) delete mode 100644 src/pal/tests/palsuite/c_runtime/fclose/test1/test1.c create mode 100644 src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/fclose/test2/test2.c create mode 100644 src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp (limited to 'src/pal/tests/palsuite/c_runtime/fclose') diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt index 55ed7c674e..64cfef0e18 100644 --- a/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - test1.c + test1.cpp ) add_executable(paltest_fclose_test1 diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.c b/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.c deleted file mode 100644 index 0a8463823d..0000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.c +++ /dev/null @@ -1,79 +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 (fclose) -** -** Purpose: Tests the PAL implementation of the fclose function. -** This test will use fdopen to create a file stream, -** that will be used to test fclose. fclose will also -** be passed a closed file handle to make sure it handle -** it accordingly. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - FILE *fp; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*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: Unable to create pipe; returned error code %ld" - , GetLastError()); - } - - /*Get a file descriptor for the read pipe handle*/ - iFiledes = _open_osfhandle((long)hReadPipe,_O_RDONLY); - - if (iFiledes == -1) - { - Fail("ERROR: _open_osfhandle failed to open " - " hReadPipe=0x%lx", hReadPipe); - } - - /*Open read pipe handle in read mode*/ - fp = _fdopen(iFiledes, "r"); - - if (fp == NULL) - { - Fail("ERROR: unable to fdopen file descriptor" - " iFiledes=%d", iFiledes); - } - - /*Attempt to close the file stream*/ - if (fclose(fp) != 0) - { - Fail("ERROR: Unable to fclose file stream fp=0x%lx\n",fp); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp new file mode 100644 index 0000000000..0a8463823d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp @@ -0,0 +1,79 @@ +// 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 (fclose) +** +** Purpose: Tests the PAL implementation of the fclose function. +** This test will use fdopen to create a file stream, +** that will be used to test fclose. fclose will also +** be passed a closed file handle to make sure it handle +** it accordingly. +** +** +**===================================================================*/ + +#include + +int __cdecl main(int argc, char **argv) +{ + HANDLE hReadPipe = NULL; + HANDLE hWritePipe = NULL; + BOOL bRetVal = FALSE; + int iFiledes = 0; + FILE *fp; + + SECURITY_ATTRIBUTES lpPipeAttributes; + + /*Initialize the PAL*/ + if ((PAL_Initialize(argc, argv)) != 0) + { + return (FAIL); + } + + /*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: Unable to create pipe; returned error code %ld" + , GetLastError()); + } + + /*Get a file descriptor for the read pipe handle*/ + iFiledes = _open_osfhandle((long)hReadPipe,_O_RDONLY); + + if (iFiledes == -1) + { + Fail("ERROR: _open_osfhandle failed to open " + " hReadPipe=0x%lx", hReadPipe); + } + + /*Open read pipe handle in read mode*/ + fp = _fdopen(iFiledes, "r"); + + if (fp == NULL) + { + Fail("ERROR: unable to fdopen file descriptor" + " iFiledes=%d", iFiledes); + } + + /*Attempt to close the file stream*/ + if (fclose(fp) != 0) + { + Fail("ERROR: Unable to fclose file stream fp=0x%lx\n",fp); + } + + PAL_Terminate(); + return (PASS); +} diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt index 178dc7d19a..3b5538608f 100644 --- a/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - test2.c + test2.cpp ) add_executable(paltest_fclose_test2 diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.c b/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.c deleted file mode 100644 index f4da535535..0000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.c +++ /dev/null @@ -1,77 +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 (fclose) -** -** Purpose: Tests the PAL implementation of the fclose function. -** fclose will be passed a closed file handle to make -** sure it handles it accordingly. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - FILE *fp; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*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: Unable to create pipe; returned error code %ld" - , GetLastError()); - } - - /*Get a file descriptor for the read pipe handle*/ - iFiledes = _open_osfhandle((long)hReadPipe,_O_RDONLY); - - if (iFiledes == -1) - { - Fail("ERROR: _open_osfhandle failed to open " - " hReadPipe=0x%lx", hReadPipe); - } - - /*Open read pipe handle in read mode*/ - fp = _fdopen(iFiledes, "r"); - - if (fp == NULL) - { - Fail("ERROR: unable to fdopen file descriptor" - " iFiledes=%d", iFiledes); - } - - /*Attempt to close the file stream*/ - if (fclose(fp) != 0) - { - Fail("ERROR: Unable to fclose file stream fp=0x%lx\n", fp); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp new file mode 100644 index 0000000000..f4da535535 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp @@ -0,0 +1,77 @@ +// 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 (fclose) +** +** Purpose: Tests the PAL implementation of the fclose function. +** fclose will be passed a closed file handle to make +** sure it handles it accordingly. +** +** +**===================================================================*/ + +#include + +int __cdecl main(int argc, char **argv) +{ + HANDLE hReadPipe = NULL; + HANDLE hWritePipe = NULL; + BOOL bRetVal = FALSE; + int iFiledes = 0; + FILE *fp; + + SECURITY_ATTRIBUTES lpPipeAttributes; + + /*Initialize the PAL*/ + if ((PAL_Initialize(argc, argv)) != 0) + { + return (FAIL); + } + + /*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: Unable to create pipe; returned error code %ld" + , GetLastError()); + } + + /*Get a file descriptor for the read pipe handle*/ + iFiledes = _open_osfhandle((long)hReadPipe,_O_RDONLY); + + if (iFiledes == -1) + { + Fail("ERROR: _open_osfhandle failed to open " + " hReadPipe=0x%lx", hReadPipe); + } + + /*Open read pipe handle in read mode*/ + fp = _fdopen(iFiledes, "r"); + + if (fp == NULL) + { + Fail("ERROR: unable to fdopen file descriptor" + " iFiledes=%d", iFiledes); + } + + /*Attempt to close the file stream*/ + if (fclose(fp) != 0) + { + Fail("ERROR: Unable to fclose file stream fp=0x%lx\n", fp); + } + + PAL_Terminate(); + return (PASS); +} -- cgit v1.2.3