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/CopyFileA/test1/CMakeLists.txt | 2 +- .../palsuite/file_io/CopyFileA/test1/CopyFileA.c | 159 --------------------- .../palsuite/file_io/CopyFileA/test1/CopyFileA.cpp | 159 +++++++++++++++++++++ 3 files changed, 160 insertions(+), 160 deletions(-) delete mode 100644 src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c create mode 100644 src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp (limited to 'src/pal/tests/palsuite/file_io/CopyFileA/test1') diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt index b52e5076fa..13abbc0979 100644 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt +++ b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES - CopyFileA.c + CopyFileA.cpp ) add_executable(paltest_copyfilea_test1 diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c deleted file mode 100644 index bfea85b7cb..0000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.c +++ /dev/null @@ -1,159 +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: CopyFileA.c -** -** Purpose: Tests the PAL implementation of the CopyFileA function -** -** -**===================================================================*/ - -/* - 1. copy an existing file to existing with overwrite true - 2. copy an existing file to existing with overwrite false - 3. copy an existing file to non-existant with overwrite true - 4. copy an existing file to non-existant with overwrite false - 5. copy non-existant file to existing with overwrite true - 6. copy non-existant file to existing with overwrite false - 7. copy non-existant file to non-existant with overwrite true - 8. copy non-existant file to non-existant with overwrite false -*/ - -#include - -struct TESTS{ - char* lpSource; - char* lpDestination; - BOOL bFailIfExists; - int nResult; - }; - - -int __cdecl main(int argc, char *argv[]) -{ - char szSrcExisting[] = {"src_existing.tmp"}; - char szSrcNonExistant[] = {"src_non-existant.tmp"}; - char szDstExisting[] = {"dst_existing.tmp"}; - char szDstNonExistant[] = {"dst_non-existant.tmp"}; - BOOL bRc = TRUE; - BOOL bSuccess = TRUE; - FILE* tempFile = NULL; - int i; - struct TESTS testCase[] = - { - {szSrcExisting, szDstExisting, FALSE, 1}, - {szSrcExisting, szDstExisting, TRUE, 0}, - {szSrcExisting, szDstNonExistant, FALSE, 1}, - {szSrcExisting, szDstNonExistant, TRUE, 1}, - {szSrcNonExistant, szDstExisting, FALSE, 0}, - {szSrcNonExistant, szDstExisting, TRUE, 0}, - {szSrcNonExistant, szDstNonExistant, FALSE, 0}, - {szSrcNonExistant, szDstNonExistant, TRUE, 0} - }; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the src_existing file */ - tempFile = fopen(szSrcExisting, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "CopyFileA test file: src_existing.tmp\n"); - fclose(tempFile); - } - else - { - Fail("CopyFileA: ERROR-> Couldn't create \"src_existing.tmp\" with " - "error %ld\n", - GetLastError()); - } - - /* create the dst_existing file */ - tempFile = fopen(szDstExisting, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "CopyFileA test file: dst_existing.tmp\n"); - fclose(tempFile); - } - else - { - Fail("CopyFileA: ERROR-> Couldn't create \"dst_existing.tmp\" with " - "error %ld\n", - GetLastError()); - } - - - - for (i = 0; i < (sizeof(testCase) / sizeof(struct TESTS)); i++) - { - bRc = CopyFileA(testCase[i].lpSource, - testCase[i].lpDestination, - testCase[i].bFailIfExists); - if (!bRc) - { - if (testCase[i].nResult == 1) - { - Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d " - "with error %ld\n", - testCase[i].lpSource, - testCase[i].lpDestination, - testCase[i].bFailIfExists, - GetLastError()); - bSuccess = FALSE; - } - } - else - { - if (testCase[i].nResult == 0) - { - Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d\n", - testCase[i].lpSource, - testCase[i].lpDestination, - testCase[i].bFailIfExists); - bSuccess = FALSE; - } - else - { - /* verify the file was moved */ - if (GetFileAttributesA(testCase[i].lpDestination) == -1) - { - Trace("CopyFileA: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - bSuccess = FALSE; - } - else if (GetFileAttributesA(testCase[i].lpSource) == -1) - { - Trace("CopyFileA: GetFileAttributes of source file " - "failed with error code %ld. \n", - GetLastError()); - bSuccess = FALSE; - } - else - { - /* verify attributes of destination file to source file*/ - if(GetFileAttributes(testCase[i].lpSource) != - GetFileAttributes(testCase[i].lpDestination)) - { - Trace("CopyFileA : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - bSuccess = FALSE; - } - } - } - } - /* delete file file but don't worry if it fails */ - DeleteFileA(szDstNonExistant); - } - - int exitCode = bSuccess ? PASS : FAIL; - PAL_TerminateEx(exitCode); - return exitCode; -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp new file mode 100644 index 0000000000..bfea85b7cb --- /dev/null +++ b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp @@ -0,0 +1,159 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: CopyFileA.c +** +** Purpose: Tests the PAL implementation of the CopyFileA function +** +** +**===================================================================*/ + +/* + 1. copy an existing file to existing with overwrite true + 2. copy an existing file to existing with overwrite false + 3. copy an existing file to non-existant with overwrite true + 4. copy an existing file to non-existant with overwrite false + 5. copy non-existant file to existing with overwrite true + 6. copy non-existant file to existing with overwrite false + 7. copy non-existant file to non-existant with overwrite true + 8. copy non-existant file to non-existant with overwrite false +*/ + +#include + +struct TESTS{ + char* lpSource; + char* lpDestination; + BOOL bFailIfExists; + int nResult; + }; + + +int __cdecl main(int argc, char *argv[]) +{ + char szSrcExisting[] = {"src_existing.tmp"}; + char szSrcNonExistant[] = {"src_non-existant.tmp"}; + char szDstExisting[] = {"dst_existing.tmp"}; + char szDstNonExistant[] = {"dst_non-existant.tmp"}; + BOOL bRc = TRUE; + BOOL bSuccess = TRUE; + FILE* tempFile = NULL; + int i; + struct TESTS testCase[] = + { + {szSrcExisting, szDstExisting, FALSE, 1}, + {szSrcExisting, szDstExisting, TRUE, 0}, + {szSrcExisting, szDstNonExistant, FALSE, 1}, + {szSrcExisting, szDstNonExistant, TRUE, 1}, + {szSrcNonExistant, szDstExisting, FALSE, 0}, + {szSrcNonExistant, szDstExisting, TRUE, 0}, + {szSrcNonExistant, szDstNonExistant, FALSE, 0}, + {szSrcNonExistant, szDstNonExistant, TRUE, 0} + }; + + + if (0 != PAL_Initialize(argc,argv)) + { + return FAIL; + } + + /* create the src_existing file */ + tempFile = fopen(szSrcExisting, "w"); + if (tempFile != NULL) + { + fprintf(tempFile, "CopyFileA test file: src_existing.tmp\n"); + fclose(tempFile); + } + else + { + Fail("CopyFileA: ERROR-> Couldn't create \"src_existing.tmp\" with " + "error %ld\n", + GetLastError()); + } + + /* create the dst_existing file */ + tempFile = fopen(szDstExisting, "w"); + if (tempFile != NULL) + { + fprintf(tempFile, "CopyFileA test file: dst_existing.tmp\n"); + fclose(tempFile); + } + else + { + Fail("CopyFileA: ERROR-> Couldn't create \"dst_existing.tmp\" with " + "error %ld\n", + GetLastError()); + } + + + + for (i = 0; i < (sizeof(testCase) / sizeof(struct TESTS)); i++) + { + bRc = CopyFileA(testCase[i].lpSource, + testCase[i].lpDestination, + testCase[i].bFailIfExists); + if (!bRc) + { + if (testCase[i].nResult == 1) + { + Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d " + "with error %ld\n", + testCase[i].lpSource, + testCase[i].lpDestination, + testCase[i].bFailIfExists, + GetLastError()); + bSuccess = FALSE; + } + } + else + { + if (testCase[i].nResult == 0) + { + Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d\n", + testCase[i].lpSource, + testCase[i].lpDestination, + testCase[i].bFailIfExists); + bSuccess = FALSE; + } + else + { + /* verify the file was moved */ + if (GetFileAttributesA(testCase[i].lpDestination) == -1) + { + Trace("CopyFileA: GetFileAttributes of destination file " + "failed with error code %ld. \n", + GetLastError()); + bSuccess = FALSE; + } + else if (GetFileAttributesA(testCase[i].lpSource) == -1) + { + Trace("CopyFileA: GetFileAttributes of source file " + "failed with error code %ld. \n", + GetLastError()); + bSuccess = FALSE; + } + else + { + /* verify attributes of destination file to source file*/ + if(GetFileAttributes(testCase[i].lpSource) != + GetFileAttributes(testCase[i].lpDestination)) + { + Trace("CopyFileA : The file attributes of the " + "destination file do not match the file " + "attributes of the source file.\n"); + bSuccess = FALSE; + } + } + } + } + /* delete file file but don't worry if it fails */ + DeleteFileA(szDstNonExistant); + } + + int exitCode = bSuccess ? PASS : FAIL; + PAL_TerminateEx(exitCode); + return exitCode; +} -- cgit v1.2.3