summaryrefslogtreecommitdiff
path: root/src/pal/tests
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-06-13 09:47:36 (GMT)
committerJiyoung Yun <jy910.yun@samsung.com>2017-06-13 09:47:36 (GMT)
commit61d6a817e39d3bae0f47dbc09838d51db22a5d30 (patch)
treecb37caa1784bc738b976273335d6ed04a7cc80b0 /src/pal/tests
parent5b975f8233e8c8d17b215372f89ca713b45d6a0b (diff)
downloadcoreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.zip
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.gz
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.bz2
Imported Upstream version 2.0.0.11992upstream/2.0.0.11992
Diffstat (limited to 'src/pal/tests')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp26
-rw-r--r--src/pal/tests/palsuite/paltestlist.txt1
2 files changed, 23 insertions, 4 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp
index 6177e0d..6bfb73f 100644
--- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp
+++ b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp
@@ -14,13 +14,26 @@
**============================================================*/
#include <palsuite.h>
#define MAPPINGSIZE 8192
+
+// This test is special - it doesn't work when the file is created on a tmpfs, like the /tmp folder
+// that is the default location for running PAL tests. The reason is that on such filesystem,
+// it is not possible to create file with FILE_FLAG_NO_BUFFERING.
+// So we explicitly use the /var/tmp that cannot be on tmpfs, since it it persistent over reboots.
+
+#ifndef __ANDROID__
+#define TEMP_DIRECTORY_PATH "/var/tmp/"
+#else
+// On Android, "/var/tmp/" doesn't exist; temporary files should go to /data/local/tmp/
+#define TEMP_DIRECTORY_PATH "/data/local/tmp/"
+#endif
+
int __cdecl main(int argc, char *argv[])
{
HANDLE hFile = INVALID_HANDLE_VALUE;
LPSTR buf = NULL;
CHAR ch[MAPPINGSIZE];
- CHAR lpFileName[] = "test.tmp";
+ CHAR lpFilePath[MAX_PATH];
DWORD dwBytesWritten = 0;
DWORD dwInitialSize = 0;
DWORD dwFinalSize = 0;
@@ -36,9 +49,11 @@ int __cdecl main(int argc, char *argv[])
return FAIL;
}
+ GetTempFileName(TEMP_DIRECTORY_PATH, "tst", 0, lpFilePath);
+
/* Create a file handle with CreateFile.
*/
- hFile = CreateFile( lpFileName,
+ hFile = CreateFile( lpFilePath,
GENERIC_WRITE|GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
@@ -49,7 +64,7 @@ int __cdecl main(int argc, char *argv[])
if (hFile == INVALID_HANDLE_VALUE)
{
Fail( "ERROR: %u :unable to create file \"%s\".\n",
- GetLastError(), lpFileName);
+ GetLastError(), lpFilePath);
}
/* Get the initial size of file, for latter tests.
@@ -58,7 +73,7 @@ int __cdecl main(int argc, char *argv[])
if ( INVALID_FILE_SIZE == dwInitialSize )
{
Fail("ERROR:%u: The created file \"%s\" has an invalid "
- "file size.\n",GetLastError(),lpFileName);
+ "file size.\n",GetLastError(),lpFilePath);
}
/*
@@ -220,6 +235,9 @@ int __cdecl main(int argc, char *argv[])
}
VirtualFree( buf, 0, MEM_RELEASE );
+
+ DeleteFile(lpFilePath);
+
PAL_Terminate();
return PASS;
}
diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt
index f0dfe3f..1e580cd 100644
--- a/src/pal/tests/palsuite/paltestlist.txt
+++ b/src/pal/tests/palsuite/paltestlist.txt
@@ -473,6 +473,7 @@ filemapping_memmgt/LocalFree/test1/paltest_localfree_test1
filemapping_memmgt/LocalFree/test2/paltest_localfree_test2
filemapping_memmgt/LockFile/test2/paltest_lockfile_test2
filemapping_memmgt/LockFile/test7/paltest_lockfile_test7
+filemapping_memmgt/MapViewOfFile/test1/paltest_mapviewoffile_test1
filemapping_memmgt/MapViewOfFile/test2/paltest_mapviewoffile_test2
filemapping_memmgt/MapViewOfFile/test3/paltest_mapviewoffile_test3
filemapping_memmgt/MapViewOfFile/test4/paltest_mapviewoffile_test4