**============================================================*/
#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;
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,
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.
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);
}
/*
}
VirtualFree( buf, 0, MEM_RELEASE );
+
+ DeleteFile(lpFilePath);
+
PAL_Terminate();
return PASS;
}
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