c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * IPRT Testcase - Core Dumper.
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync * Copyright (C) 2010-2011 Oracle Corporation
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * available from http://www.virtualbox.org. This file is free software;
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * General Public License (GPL) as published by the Free Software
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * The contents of this file may alternatively be used under the terms
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * of the Common Development and Distribution License Version 1.0
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * VirtualBox OSE distribution, in which case the provisions of the
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * CDDL are applicable instead of those of the GPL.
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * You may elect to license modified versions of this file under the
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync * terms and conditions of either the GPL or the CDDL or both.
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync/*******************************************************************************
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync* Header Files *
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync*******************************************************************************/
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync/*******************************************************************************
c74a793852e1fd8994bf9bd2495e1b731ed4ac09vboxsync*******************************************************************************/
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsyncstatic DECLCALLBACK(int) SleepyThread(RTTHREAD hThread, void *pvUser)
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTEXITCODE rcExit = RTTestInitAndCreate("tstRTCoreDump", &hTest);
5330cda3253fc3d94ed03a7609774e8c85a4c56dvboxsync * Setup core dumping.
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTTESTI_CHECK_RC(rc = RTCoreDumperSetup(NULL, RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP | RTCOREDUMPER_FLAGS_LIVE_CORE),
5330cda3253fc3d94ed03a7609774e8c85a4c56dvboxsync * Spawn a few threads.
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync unsigned i;
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTTESTI_CHECK_RC_BREAK(RTThreadCreate(&ahThreads[i], SleepyThread, &ahThreads[i], 0, RTTHREADTYPE_DEFAULT,
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTTestIPrintf(RTTESTLVL_ALWAYS, "Spawned %d threads.\n", i);
5330cda3253fc3d94ed03a7609774e8c85a4c56dvboxsync * Write the core to disk.
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTTESTI_CHECK_RC(RTCoreDumperTakeDump(NULL, true /* fLiveCore*/), VINF_SUCCESS);
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync * Clean up.
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTTESTI_CHECK_RC(RTCoreDumperDisable(), VINF_SUCCESS);
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync while (i-- > 0)
0e3021c718d32b7803f6481d16cb5c847138cb5evboxsync RTTESTI_CHECK_RC(RTThreadUserSignal(ahThreads[i]), VINF_SUCCESS);