summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp')
-rw-r--r--src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp164
1 files changed, 164 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp
new file mode 100644
index 0000000000..fca96d1e00
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp
@@ -0,0 +1,164 @@
+// 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: DeleteFileW.c
+**
+** Purpose: Tests the PAL implementation of the DeleteFileW function.
+**
+**
+**===================================================================*/
+
+// delete an existing file
+// delete a non-existant file
+// delete an open file
+// delete files using wild cards
+// delete a hidden file
+// delete a file without proper permissions
+//
+
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ FILE *tempFile = NULL;
+ BOOL bRc = FALSE;
+ WCHAR* pTemp = NULL;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ //
+ // deleting an existing file
+ //
+ tempFile = fopen("testFile01.tmp", "w");
+ if (tempFile == NULL)
+ {
+ Fail ("DeleteFileW: ERROR: Couldn't create \"DeleteFileW's"
+ " testFile01.tmp\"\n");
+ }
+
+ fprintf(tempFile, "DeleteFileW test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's"
+ " testFile01.tmp\"\n");
+ }
+
+ pTemp = convert("testFile01.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileW: ERROR: Couldn't delete DeleteFileW's"
+ " \"testFile01.tmp\"\n"
+ " Error is %d\n", GetLastError());
+ }
+
+
+ //
+ // deleting a non-existant file : should fail
+ //
+
+ pTemp = convert("testFile02.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc != FALSE)
+ {
+ Fail ("DeleteFileW: ERROR: Was able to delete the non-existant"
+ " file \"testFile02.tmp\"\n");
+ }
+
+
+
+
+ //
+ // deleting an open file
+ //
+ tempFile = fopen("testFile03.tmp", "w");
+ if (tempFile == NULL)
+ {
+ Fail("DeleteFileW: ERROR: Couldn't create \"DeleteFileW's"
+ " testFile03.tmp\"\n");
+ }
+
+ fprintf(tempFile, "DeleteFileW test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's"
+ " testFile03.tmp\"\n");
+ }
+
+ pTemp = convert("testFile03.tmp");
+ bRc = DeleteFileW(pTemp);
+ if (bRc != TRUE)
+ {
+ Fail("DeleteFileW: ERROR: Couldn't delete DeleteFileW's"
+ " \"testFile03.tmp\"\n"
+ " Error is %d\n", GetLastError());
+ free(pTemp);
+ }
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+
+
+
+
+ //
+ // delete using wild cards
+ //
+
+ // create the test file
+ tempFile = fopen("testFile04.tmp", "w");
+ if (tempFile == NULL)
+ {
+ Fail("DeleteFileW: ERROR: Couldn't create DeleteFileW's"
+ " \"testFile04.tmp\"\n");
+ }
+ fprintf(tempFile, "DeleteFileW test file.\n");
+ if (fclose(tempFile) != 0)
+ {
+ Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's"
+ " testFile04.tmp\"\n");
+ }
+
+ // delete using '?'
+ pTemp = convert("testFile0?.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc == TRUE)
+ {
+ Fail("DeleteFileW: ERROR: Was able to delete using the"
+ " \'?\' wildcard\n");
+ }
+
+ // delete using '*'
+ pTemp = convert("testFile*.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc == TRUE)
+ {
+ Fail("DeleteFileW: ERROR: Was able to delete using the"
+ " \'*\' wildcard\n");
+ }
+
+ pTemp = convert("testFile04.tmp");
+ bRc = DeleteFileW(pTemp);
+ free(pTemp);
+ if (bRc != TRUE)
+ {
+ Fail ("DeleteFileW: ERROR: Couldn't delete DeleteFileW's"
+ " \"testFile04.tmp\"\n"
+ " Error is %d\n", GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}