diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2017-05-04 13:19:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-04 13:19:53 -0700 |
commit | bae3ded1b302abdb1d0b46346f03162bddadba40 (patch) | |
tree | d1c764a27876c9007bcec83cd515f18d67c9343c /src/pal | |
parent | 1ff9062d235630a3a47bffa6459549c669432c4a (diff) | |
download | coreclr-bae3ded1b302abdb1d0b46346f03162bddadba40.tar.gz coreclr-bae3ded1b302abdb1d0b46346f03162bddadba40.tar.bz2 coreclr-bae3ded1b302abdb1d0b46346f03162bddadba40.zip |
Reenable MapViewOfFile PAL test1 (#11393)
This change reenables the test that was having problems on systems when the /tmp
is created on tmpfs file system which doesn't support direct access (unbuffered).
The fix is to explicitly use /var/tmp instead (and /data/local/tmp/ on Android).
Diffstat (limited to 'src/pal')
-rw-r--r-- | src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp | 26 | ||||
-rw-r--r-- | src/pal/tests/palsuite/paltestlist.txt | 1 |
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 6177e0decf..6bfb73f0e8 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 f0dfe3f9ea..1e580cd596 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 |