Skip to content

Commit

Permalink
fix pal test (dotnet#66636)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmoseley authored Mar 16, 2022
1 parent a1f1ab8 commit ac20efd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/workflow/testing/coreclr/unix-test-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ To only run enabled tests for the platform the tests were built for:
artifacts/bin/coreclr/$(uname).x64.Debug/paltests/runpaltests.sh $(pwd)/artifacts/bin/coreclr/$(uname).x64.Debug/paltests
# on macOS, replace $(uname) with OSX
```
To run only specific tests, edit paltestlist.txt locally to delete the ones you don't want to run.

Test results will go into: `/tmp/PalTestOutput/default/pal_tests.xml`

Expand Down
29 changes: 12 additions & 17 deletions src/coreclr/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ PALTEST(file_io_GetSystemTime_test1_paltest_getsystemtime_test1, "file_io/GetSys
SYSTEMTIME firstTime;
SYSTEMTIME secondTime;

WORD avgDeltaFileTime = 0;

int i=0;


if (0 != PAL_Initialize(argc,argv))
{
return FAIL;
Expand Down Expand Up @@ -100,24 +95,24 @@ PALTEST(file_io_GetSystemTime_test1_paltest_getsystemtime_test1, "file_io/GetSys
"and it is currently showing %d.",TheTime.wMilliseconds);
}

/* check if two consecutive calls to system time return */
/* correct time in ms after sleep() call. */
for (i = 0; i<5 ;i++)
{
/* verify that two consecutive calls to system time return */
/* different values of seconds across sleep() call. */
/* do this 5 times in case we are super unlucky. */
float avgDeltaFileTime = 0;
for (int i = 0; i < 5; i++)
{
GetSystemTime(&firstTime);
Sleep(1000);
GetSystemTime(&secondTime);
avgDeltaFileTime += abs(firstTime.wSecond - secondTime.wSecond );

}
GetSystemTime(&secondTime);
avgDeltaFileTime += abs(firstTime.wSecond - secondTime.wSecond);
}

if( (avgDeltaFileTime/5) < 1.0)
if( (avgDeltaFileTime / 5) == 0)
{
Fail("ERROR: 2 calls for GetSystemTime interrupted"
" by a 1000 ms sleep failed Value[%f]", avgDeltaFileTime/5 );
Fail("ERROR: GetSystemTime always returning same value of seconds Value[%f]", avgDeltaFileTime / 5);
}

PAL_Terminate();
PAL_Terminate();
return PASS;
}

0 comments on commit ac20efd

Please sign in to comment.