VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTProcCreatePrf.cpp@ 102335

Last change on this file since 102335 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: tstRTProcCreatePrf.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT Testcase - RTProcCreate Profiling.
4 */
5
6/*
7 * Copyright (C) 2012-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include <iprt/process.h>
42#include <iprt/test.h>
43#include <iprt/time.h>
44#include <iprt/path.h>
45#include <iprt/env.h>
46#include <iprt/string.h>
47
48
49int main(int argc, char **argv)
50{
51 /* the child response. */
52 if (argc != 1)
53 return 0;
54
55 RTTEST hTest;
56 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTProcCreatePrf", &hTest);
57 if (rcExit)
58 return rcExit;
59 RTTestBanner(hTest);
60
61 char szExecPath[RTPATH_MAX];
62 if (!RTProcGetExecutablePath(szExecPath, sizeof(szExecPath)))
63 RTStrCopy(szExecPath, sizeof(szExecPath), argv[0]);
64
65 const char *apszArgs[4] = { szExecPath, "child", "process", NULL };
66
67 uint64_t NsStart = RTTimeNanoTS();
68 uint32_t i;
69#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) || defined(RT_OS_DARWIN)
70 for (i = 0; i < 1000; i++)
71#else
72 for (i = 0; i < 10000; i++)
73#endif
74 {
75 RTPROCESS hProc;
76 RTTEST_CHECK_RC_BREAK(hTest, RTProcCreate(szExecPath, apszArgs, RTENV_DEFAULT, 0 /* fFlags*/, &hProc), VINF_SUCCESS);
77 RTPROCSTATUS ChildStatus;
78 RTTEST_CHECK_RC_BREAK(hTest, RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ChildStatus), VINF_SUCCESS);
79 RTTEST_CHECK_BREAK(hTest, ChildStatus.enmReason == RTPROCEXITREASON_NORMAL);
80 RTTEST_CHECK_BREAK(hTest, ChildStatus.iStatus == 0);
81 }
82 uint64_t cNsElapsed = RTTimeNanoTS() - NsStart;
83 if (i)
84 {
85 RTTestValue(hTest, "Time per process", cNsElapsed / i, RTTESTUNIT_NS);
86 }
87
88 /*
89 * Summary.
90 */
91 return RTTestSummaryAndDestroy(hTest);
92}
93
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