summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/threading/SetErrorMode/test1/test1.c
blob: 238cec44218ed44f426be2db4bbabb577700b8f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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:  test1.c (SetErrorMode)
**
** Purpose: Tests the PAL implementation of the SetErrorMode function.
**          This test will set the error mode and then read the error
**          set with GetLastError().
**
**
**===================================================================*/

#include <palsuite.h>

int __cdecl main(int argc, char **argv)
{   
    DWORD dErrorReturn;
    UINT  dErrorModes[] = {SEM_NOOPENFILEERRORBOX, SEM_FAILCRITICALERRORS, 0};
    int   i;
    
    /*
     *  Initialize the Pal
     */
    if ((PAL_Initialize(argc,argv)) != 0)
    {
        return (FAIL);
    }

    /*
     *  Loop through the supported Error Modes and verify
     *  that GetLastError() returns the correct Error Mode
     */
    for (i=0; i < (sizeof(dErrorModes) / sizeof(UINT)); i++)
    {
        SetLastError(dErrorModes[i]);
        if ((dErrorReturn = GetLastError()) != dErrorModes[i])
        {   
            Fail("ERROR: SetLastError was set to 0x%4.4x but,"
                    " GetLastError returned 0x%4.4x\n", 
                    dErrorModes[i],
                    dErrorReturn);
        }
    }
        
    PAL_Terminate();
    return (PASS);
}