VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3-timing-1-exe.c@ 104620

Last change on this file since 104620 was 98103, checked in by vboxsync, 20 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: bs3-timing-1-exe.c 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * BS3Kit - bs3-timing-1, regular executable version of the TSC test.
4 */
5
6/*
7 * Copyright (C) 2007-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/assert.h>
42#include <iprt/errcore.h>
43#include <iprt/getopt.h>
44#include <iprt/initterm.h>
45#include <iprt/message.h>
46#include <iprt/stream.h>
47#include <iprt/string.h>
48#include <iprt/time.h>
49
50/* Fake bs3kit.h bits: */
51#define Bs3TestNow RTTimeNanoTS
52#define Bs3TestPrintf RTPrintf
53#define Bs3TestFailedF RTMsgError
54#define Bs3MemZero RT_BZERO
55#define BS3_DECL(t) t
56
57#define STANDALONE_EXECUTABLE
58#include "bs3-timing-1-32.c32"
59
60
61int main(int argc, char **argv)
62{
63 /*
64 * Parse arguments.
65 */
66 static const RTGETOPTDEF s_aOptions[] =
67 {
68 { "--loops", 'l', RTGETOPT_REQ_UINT32 },
69 { "--seconds", 's', RTGETOPT_REQ_UINT32 },
70 { "--min-history", 'm', RTGETOPT_REQ_UINT32 },
71 { "--quiet", 'q', RTGETOPT_REQ_NOTHING },
72 { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
73 };
74 uint32_t cLoops = 5;
75 uint32_t cSecs = 10;
76 unsigned uVerbosity = 1;
77 unsigned iMinHistory = 17;
78
79 RTGETOPTSTATE GetState;
80 RTGETOPTUNION ValueUnion;
81
82 int rc = RTR3InitExe(argc, &argv, 0);
83 if (RT_FAILURE(rc))
84 return RTMsgInitFailure(rc);
85
86 rc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
87 AssertRC(rc);
88 while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
89 {
90 switch (rc)
91 {
92 case 'l':
93 cLoops = ValueUnion.u32;
94 break;
95 case 'm':
96 iMinHistory = ValueUnion.u32;
97 break;
98 case 's':
99 cSecs = ValueUnion.u32;
100 if (cSecs == 0 || cSecs > RT_SEC_1DAY / 2)
101 return RTMsgErrorExitFailure("Seconds value is out of range: %u (min 1, max %u)", cSecs, RT_SEC_1DAY / 2);
102 break;
103 case 'q':
104 uVerbosity = 0;
105 break;
106 case 'v':
107 uVerbosity++;
108 break;
109 case 'V':
110 RTPrintf("v0.1.0\n");
111 return RTEXITCODE_SUCCESS;
112 case 'h':
113 RTPrintf("usage: %Rbn [-q|-v] [-l <iterations>] [-s <seconds-per-iteration>] [-m <log2-big-gap>]\n", argv[0]);
114 return RTEXITCODE_SUCCESS;
115 default:
116 return RTGetOptPrintError(rc, &ValueUnion);
117 }
118 }
119
120 /*
121 * Run the test.
122 */
123 bs3Timing1_Tsc_Driver(cLoops, cSecs, uVerbosity, iMinHistory);
124 return RTEXITCODE_SUCCESS;
125}
126
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