summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp')
-rw-r--r--src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp b/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp
new file mode 100644
index 0000000000..65cc426c74
--- /dev/null
+++ b/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp
@@ -0,0 +1,58 @@
+// 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: pal_getusertempdirectoryw.c
+**
+** Purpose: Positive test the PAL_GetUserTempDirectoryW API.
+** Call PAL_GetUserTempDirectoryW to retrieve the user
+** temp directory.
+**
+**
+**============================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+#define DIRECTORYLENGTH 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ DWORD dwFileAttribute;
+ DWORD cch = DIRECTORYLENGTH;
+ WCHAR wDirectoryName[DIRECTORYLENGTH];
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //retrieve the user temp directory
+ err = PAL_GetUserTempDirectory(ddtInstallationDependentDirectory, wDirectoryName, &cch);
+
+ if(0 == err || 0 == strlen(convertC(wDirectoryName)))
+ {
+ Fail("Failed to call PAL_GetUserTempDirectoryW API!\n");
+ }
+
+
+ //retrieve the attributes of a file or directory
+ dwFileAttribute = GetFileAttributesW(wDirectoryName);
+
+
+ //check if the retrieved attribute indicates a directory
+ if( FILE_ATTRIBUTE_DIRECTORY != (FILE_ATTRIBUTE_DIRECTORY & dwFileAttribute))
+ {
+ Fail("PAL_GetUserTempDirectoryW API returned a non-directory name!\n");
+ }
+
+ printf ("PAL_GetUserTempDirectoryW returns %S\n", wDirectoryName);
+
+ PAL_Terminate();
+ return PASS;
+
+}