diff options
Diffstat (limited to 'src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3')
3 files changed, 96 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt new file mode 100644 index 0000000000..3b981f9564 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + setcurrentdirectoryw.c +) + +add_executable(paltest_setcurrentdirectoryw_test3 + ${SOURCES} +) + +add_dependencies(paltest_setcurrentdirectoryw_test3 coreclrpal) + +target_link_libraries(paltest_setcurrentdirectoryw_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.c b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.c new file mode 100644 index 0000000000..e8c4be2ad4 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.c @@ -0,0 +1,64 @@ +// 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: SetCurrentDirectoryW.c (test 3) +** +** Purpose: Try calling SetCurrentDirectoryW with an invalid path, +** with a valid filename and with NULL +** +** +**===================================================================*/ + +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + char szDirName[MAX_PATH] = "testing"; + WCHAR* szwDirName = NULL; + char szFileName[MAX_PATH] = "setcurrentdirectorya.c"; + WCHAR* szwFileName = NULL; + + if (0 != PAL_Initialize(argc,argv)) + { + return FAIL; + } + + /* set the current directory to an unexistant folder */ + szwDirName = convert(szDirName); + if (0 != SetCurrentDirectoryW(szwDirName)) + { + free(szwDirName); + Fail("ERROR: SetCurrentDirectoryW should have failed " + "when trying to set the current directory to " + "an invalid folder\n"); + } + free(szwDirName); + + /* set the current directory to an unexistant folder */ + szwFileName = convert(szFileName); + if (0 != SetCurrentDirectoryW(szwFileName)) + { + free(szwFileName); + Fail("ERROR: SetCurrentDirectoryW should have failed " + "when trying to set the current directory to " + "a valid file name\n"); + } + free(szwFileName); + + /* set the current directory to NULL */ + if (0 != SetCurrentDirectoryW(NULL)) + { + Fail("ERROR: SetCurrentDirectoryW should have failed " + "when trying to set the current directory to " + "NULL\n"); + } + + PAL_Terminate(); + + return PASS; +} + + diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat new file mode 100644 index 0000000000..fc931291ec --- /dev/null +++ b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat @@ -0,0 +1,13 @@ +# 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 = SetCurrentDirectoryW +Name = Negative test for SetCurrentDirectoryW (test 3) +Type = DEFAULT +EXE1 = setcurrentdirectoryw +Description += Try calling SetCurrentDirectoryW with an invalid path, += with a valid filename and with NULL |