[wasm][debugger][test] Change DateTime format test (#42136)
[platform/upstream/dotnet/runtime.git] / src / coreclr / src / pal / tests / palsuite / filemapping_memmgt / CreateFileMappingA / test8 / createfilemapping.cpp
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3
4 /*=============================================================
5 **
6 ** Source:  createfilemapping.c (test 8)
7 **
8 ** Purpose: Positive test the CreateFileMapping API.
9 **          Test the un-verifiable parameter combinations.
10 **
11 **
12 **============================================================*/
13 #include <palsuite.h>
14
15 const   int MAPPINGSIZE = 2048;
16 HANDLE  SWAP_HANDLE     = ((VOID *)(-1));
17
18 int __cdecl main(int argc, char *argv[])
19 {
20     HANDLE  hFileMap;
21
22     /* Initialize the PAL environment.
23      */
24     if(0 != PAL_Initialize(argc, argv))
25     {
26         return FAIL;
27     }
28
29     /* Create a READONLY, "swap", un-named file mapping.
30      * This test is unverifiable since there is no hook back to the file map
31      * because it is un-named. As well, since it resides in "swap", and is
32      * initialized to zero, there is nothing to read.
33      */
34     hFileMap = CreateFileMapping(
35                             SWAP_HANDLE,
36                             NULL,               /*not inherited*/
37                             PAGE_READONLY,      /*read only*/
38                             0,                  /*high-order size*/
39                             MAPPINGSIZE,        /*low-order size*/
40                             NULL);              /*un-named object*/
41
42     if(NULL == hFileMap)
43     {
44         Fail("ERROR:%u: Failed to create File Mapping.\n", 
45               GetLastError());
46     }
47
48     
49     /* Create a COPYWRITE, "swap", un-named file mapping.
50      * This test is unverifiable, here is a quote from MSDN:
51      * 
52      * Copy on write access. If you create the map with PAGE_WRITECOPY and 
53      * the view with FILE_MAP_COPY, you will receive a view to file. If you 
54      * write to it, the pages are automatically swappable and the modifications
55      * you make will not go to the original data file. 
56      *
57      */
58     hFileMap = CreateFileMapping(
59                             SWAP_HANDLE,
60                             NULL,               /*not inherited*/
61                             PAGE_WRITECOPY,      /*read only*/
62                             0,                  /*high-order size*/
63                             MAPPINGSIZE,        /*low-order size*/
64                             NULL);              /*unnamed object*/
65
66     if(NULL == hFileMap)
67     {
68         Fail("ERROR:%u: Failed to create File Mapping.\n", 
69               GetLastError());
70     }
71
72
73     /* Terminate the PAL.
74      */ 
75     PAL_Terminate();
76     return PASS;
77 }
78