blob: c28709db81e9d213c63c7c9a243425ebfbd46da3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
}
|