| 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 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | /*===================================================================== |
| 6 | ** |
| 7 | ** Source: test1.c (SetErrorMode) |
| 8 | ** |
| 9 | ** Purpose: Tests the PAL implementation of the SetErrorMode function. |
| 10 | ** This test will set the error mode and then read the error |
| 11 | ** set with GetLastError(). |
| 12 | ** |
| 13 | ** |
| 14 | **===================================================================*/ |
| 15 | |
| 16 | #include <palsuite.h> |
| 17 | |
| 18 | int __cdecl main(int argc, char **argv) |
| 19 | { |
| 20 | DWORD dErrorReturn; |
| 21 | UINT dErrorModes[] = {SEM_NOOPENFILEERRORBOX, SEM_FAILCRITICALERRORS, 0}; |
| 22 | int i; |
| 23 | |
| 24 | /* |
| 25 | * Initialize the Pal |
| 26 | */ |
| 27 | if ((PAL_Initialize(argc,argv)) != 0) |
| 28 | { |
| 29 | return (FAIL); |
| 30 | } |
| 31 | |
| 32 | /* |
| 33 | * Loop through the supported Error Modes and verify |
| 34 | * that GetLastError() returns the correct Error Mode |
| 35 | */ |
| 36 | for (i=0; i < (sizeof(dErrorModes) / sizeof(UINT)); i++) |
| 37 | { |
| 38 | SetLastError(dErrorModes[i]); |
| 39 | if ((dErrorReturn = GetLastError()) != dErrorModes[i]) |
| 40 | { |
| 41 | Fail("ERROR: SetLastError was set to 0x%4.4x but," |
| 42 | " GetLastError returned 0x%4.4x\n" , |
| 43 | dErrorModes[i], |
| 44 | dErrorReturn); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | PAL_Terminate(); |
| 49 | return (PASS); |
| 50 | } |
| 51 | |