VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTThreadPoke.cpp@ 77994

Last change on this file since 77994 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: tstRTThreadPoke.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * IPRT Testcase - RTThreadPoke.
4 */
5
6/*
7 * Copyright (C) 2010-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <iprt/thread.h>
32
33#include <iprt/errcore.h>
34#include <iprt/test.h>
35#include <iprt/string.h>
36
37
38/*********************************************************************************************************************************
39* Global Variables *
40*********************************************************************************************************************************/
41static RTTEST g_hTest;
42
43
44#ifndef RT_OS_WINDOWS
45
46static DECLCALLBACK(int) test1Thread(RTTHREAD hSelf, void *pvUser)
47{
48 RT_NOREF_PV(hSelf); RT_NOREF_PV(pvUser);
49 RTTEST_CHECK_RC(g_hTest, RTThreadSleep(60*1000), VERR_INTERRUPTED);
50 return VINF_SUCCESS;
51}
52
53
54static void test1(void)
55{
56 RTTestSub(g_hTest, "Interrupt RTThreadSleep");
57 RTTHREAD hThread;
58 RTTESTI_CHECK_RC_RETV(RTThreadCreate(&hThread, test1Thread, NULL, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "test1"),
59 VINF_SUCCESS);
60 RTThreadSleep(500); RTThreadSleep(1500); /* fudge */
61 RTTESTI_CHECK_RC(RTThreadPoke(hThread), VINF_SUCCESS);
62 RTTESTI_CHECK_RC(RTThreadWait(hThread, RT_INDEFINITE_WAIT, NULL), VINF_SUCCESS);
63}
64
65#endif /* !RT_OS_WINDOWS */
66
67
68int main()
69{
70 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTThreadPoke", &g_hTest);
71 if (rcExit != RTEXITCODE_SUCCESS)
72 return rcExit;
73#ifdef RT_OS_WINDOWS
74 return RTTestSkipAndDestroy(g_hTest, "No RTThreadPoke on Windows");
75
76#else
77 test1();
78
79 return RTTestSummaryAndDestroy(g_hTest);
80#endif
81}
82
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette