| 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: |
| 8 | ** |
| 9 | ** Source : test1.c |
| 10 | ** |
| 11 | ** Purpose: Test for GetTickCount() function |
| 12 | ** |
| 13 | ** |
| 14 | **=========================================================*/ |
| 15 | |
| 16 | #include <palsuite.h> |
| 17 | |
| 18 | int __cdecl main(int argc, char *argv[]) { |
| 19 | |
| 20 | DWORD FirstCount = 0; |
| 21 | DWORD SecondCount = 0; |
| 22 | |
| 23 | /* |
| 24 | * Initialize the PAL and return FAILURE if this fails |
| 25 | */ |
| 26 | |
| 27 | if(0 != (PAL_Initialize(argc, argv))) |
| 28 | { |
| 29 | return FAIL; |
| 30 | } |
| 31 | |
| 32 | /* Grab a FirstCount, then loop for a bit to make the clock increase */ |
| 33 | FirstCount = GetTickCount(); |
| 34 | |
| 35 | /* Make sure some time passes */ |
| 36 | Sleep(60); //Since the get tick count is accurate within 55 milliseconds. |
| 37 | |
| 38 | /* Get a second count */ |
| 39 | SecondCount = GetTickCount(); |
| 40 | |
| 41 | /* Make sure the second one is bigger than the first. |
| 42 | This isn't the best test, but it at least shows that it's returning a |
| 43 | DWORD which is increasing. |
| 44 | */ |
| 45 | |
| 46 | if(FirstCount >= SecondCount) |
| 47 | { |
| 48 | Fail("ERROR: The first time (%d) was greater/equal than the second time " |
| 49 | " (%d). The tick count should have increased.\n" , |
| 50 | FirstCount,SecondCount); |
| 51 | } |
| 52 | |
| 53 | PAL_Terminate(); |
| 54 | return PASS; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | |
| 59 | |