tstRTProcCreatePrf.cpp revision e75babe1e6dafc9f3859ca5f34d571563e7618b2
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * IPRT Testcase - RTProcCreate Profiling.
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * Copyright (C) 2012 Oracle Corporation
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * available from http://www.virtualbox.org. This file is free software;
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * General Public License (GPL) as published by the Free Software
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * The contents of this file may alternatively be used under the terms
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * of the Common Development and Distribution License Version 1.0
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * VirtualBox OSE distribution, in which case the provisions of the
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * CDDL are applicable instead of those of the GPL.
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * You may elect to license modified versions of this file under the
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync * terms and conditions of either the GPL or the CDDL or both.
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync/*******************************************************************************
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync* Header Files *
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync*******************************************************************************/
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync /* the child response. */
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTEXITCODE rcExit = RTTestInitAndCreate("tstRTProcCreatePrf", &hTest);
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync if (!RTProcGetExecutablePath(szExecPath, sizeof(szExecPath)))
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTStrCopy(szExecPath, sizeof(szExecPath), argv[0]);
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync const char *apszArgs[4] = { szExecPath, "child", "process", NULL };
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync for (i = 0; i < 1000; i++)
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync for (i = 0; i < 10000; i++)
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTTEST_CHECK_RC_BREAK(hTest, RTProcCreate(szExecPath, apszArgs, RTENV_DEFAULT, 0 /* fFlags*/, &hProc), VINF_SUCCESS);
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTTEST_CHECK_RC_BREAK(hTest, RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ChildStatus), VINF_SUCCESS);
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTTEST_CHECK_BREAK(hTest, ChildStatus.enmReason == RTPROCEXITREASON_NORMAL);
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTTEST_CHECK_BREAK(hTest, ChildStatus.iStatus == 0);
e75babe1e6dafc9f3859ca5f34d571563e7618b2vboxsync RTTestValue(hTest, "Time per process", cNsElapsed / i, RTTESTUNIT_NS);