diff options
Diffstat (limited to 'src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp')
-rw-r--r-- | src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp new file mode 100644 index 0000000000..c28709db81 --- /dev/null +++ b/src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp @@ -0,0 +1,72 @@ +// 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: test4.c +** +** Dependencies: PAL_Initialize +** PAL_Terminate +** GetCurrentThread +** SleepEx +** +** Purpose: +** +** Test to ensure proper operation of the QueueUserAPC() +** API by trying to queue APC functions on the current +** thread. +** +** +**===========================================================================*/ +#include <palsuite.h> + + +static BOOL bAPCExecuted = FALSE; + +VOID PALAPI APCFunc( ULONG_PTR dwParam ) +{ + bAPCExecuted = TRUE; +} + +int __cdecl main( int argc, char **argv ) + +{ + /* local variables */ + HANDLE hThread = NULL; + DWORD ret; + + /* PAL initialization */ + if( (PAL_Initialize(argc, argv)) != 0 ) + { + return( FAIL ); + } + + /* get the current thread */ + hThread = GetCurrentThread(); + ret = QueueUserAPC( APCFunc, hThread, 0 ); + if( ret == 0 ) + { + Fail( "ERROR:%lu:QueueUserAPC call failed\n", GetLastError() ); + } + + /* call SleepEx() to put the thread in an alertable state */ + ret = SleepEx( 2000, TRUE ); + if( ret != WAIT_IO_COMPLETION ) + { + Fail( "ERROR:Expected sleep to return WAIT_IO_COMPLETION, got %lu\n", + ret ); + } + + /* check that the APC function was executed */ + if( bAPCExecuted == FALSE ) + { + Fail( "ERROR:APC function was not executed\n" ); + } + + /* PAL termination */ + PAL_Terminate(); + + /* return success */ + return PASS; +} |