| 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 : test.c |
| 8 | ** |
| 9 | ** Purpose: Test for GlobalMemoryStatusEx() function |
| 10 | ** |
| 11 | ** |
| 12 | **=========================================================*/ |
| 13 | |
| 14 | #include <palsuite.h> |
| 15 | |
| 16 | int __cdecl main(int argc, char *argv[]) { |
| 17 | |
| 18 | MEMORYSTATUSEX memoryStatus; |
| 19 | |
| 20 | /* |
| 21 | * Initialize the PAL and return FAILURE if this fails |
| 22 | */ |
| 23 | |
| 24 | if(0 != (PAL_Initialize(argc, argv))) |
| 25 | { |
| 26 | return FAIL; |
| 27 | } |
| 28 | |
| 29 | if (!GlobalMemoryStatusEx(&memoryStatus)) |
| 30 | { |
| 31 | Fail("ERROR: GlobalMemoryStatusEx failed." ); |
| 32 | } |
| 33 | |
| 34 | printf("GlobalMemoryStatusEx:\n" ); |
| 35 | printf(" ullTotalPhys: %llu\n" , memoryStatus.ullTotalPhys); |
| 36 | printf(" ullAvailPhys: %llu\n" , memoryStatus.ullAvailPhys); |
| 37 | printf(" ullTotalVirtual: %llu\n" , memoryStatus.ullTotalVirtual); |
| 38 | printf(" ullAvailVirtual: %llu\n" , memoryStatus.ullAvailVirtual); |
| 39 | printf(" ullTotalPageFile: %llu\n" , memoryStatus.ullTotalPageFile); |
| 40 | printf(" ullAvailPageFile: %llu\n" , memoryStatus.ullAvailPageFile); |
| 41 | printf(" ullAvailExtendedVirtual: %llu\n" , memoryStatus.ullAvailExtendedVirtual); |
| 42 | printf(" dwMemoryLoad: %u\n" , memoryStatus.dwMemoryLoad); |
| 43 | |
| 44 | if (memoryStatus.ullTotalPhys == 0 || |
| 45 | memoryStatus.ullAvailPhys == 0 || |
| 46 | memoryStatus.ullTotalVirtual == 0 || |
| 47 | memoryStatus.ullAvailVirtual == 0 |
| 48 | ) |
| 49 | { |
| 50 | Fail("ERROR: GlobalMemoryStatusEx succeeded, but returned zero physical of virtual memory sizes." ); |
| 51 | } |
| 52 | |
| 53 | PAL_Terminate(); |
| 54 | return PASS; |
| 55 | } |
| 56 | |