1 | /* $Id: tstRTR0TimerDriver.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT R0 Testcase - Timers, driver program.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2022 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/initterm.h>
|
---|
42 |
|
---|
43 | #include <iprt/errcore.h>
|
---|
44 | #include <iprt/path.h>
|
---|
45 | #include <iprt/param.h>
|
---|
46 | #include <iprt/stream.h>
|
---|
47 | #include <iprt/string.h>
|
---|
48 | #include <iprt/test.h>
|
---|
49 | #include <iprt/thread.h>
|
---|
50 | #ifdef VBOX
|
---|
51 | # include <VBox/sup.h>
|
---|
52 | # include "tstRTR0Timer.h"
|
---|
53 | #endif
|
---|
54 | #include "tstRTR0CommonDriver.h"
|
---|
55 |
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Entry point.
|
---|
59 | */
|
---|
60 | extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
|
---|
61 | {
|
---|
62 | #ifndef VBOX
|
---|
63 | RT_NOREF3(argc, argv, envp);
|
---|
64 | RTPrintf("tstRTR0Timer: SKIPPED\n");
|
---|
65 | return RTEXITCODE_SKIPPED;
|
---|
66 |
|
---|
67 | #else
|
---|
68 | RT_NOREF1(envp);
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Init.
|
---|
72 | */
|
---|
73 | RTEXITCODE rcExit = RTR3TestR0CommonDriverInit("tstRTR0Timer");
|
---|
74 | if (rcExit != RTEXITCODE_SUCCESS)
|
---|
75 | return rcExit;
|
---|
76 |
|
---|
77 | if (argc == 2 && !strcmp(argv[1], "latency"))
|
---|
78 | {
|
---|
79 | RTR3TestR0SimpleTest(TSTRTR0TIMER_LATENCY_OMNI, "Latency omni timer");
|
---|
80 | RTR3TestR0SimpleTest(TSTRTR0TIMER_LATENCY_OMNI_HIRES, "Latency omni hires timer");
|
---|
81 | }
|
---|
82 | else
|
---|
83 | {
|
---|
84 | # if 1
|
---|
85 | /*
|
---|
86 | * Standard timers.
|
---|
87 | */
|
---|
88 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_BASIC, "Basic one shot");
|
---|
89 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_BASIC, "Basic periodic");
|
---|
90 | if (RTTestErrorCount(g_hTest) == 0)
|
---|
91 | {
|
---|
92 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_RESOLUTION, "One shot resolution");
|
---|
93 | # if 1
|
---|
94 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_RESTART, "Restart one shot from callback");
|
---|
95 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_DESTROY, "Destroy one shot from callback");
|
---|
96 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_CSSD_LOOPS, "Create-start-stop-destroy loops");
|
---|
97 | for (uint32_t i = 0; i <= 7; i++)
|
---|
98 | RTR3TestR0SimpleTestWithArg(TSTRTR0TIMER_PERIODIC_CHANGE_INTERVAL, i, "Change interval from callback, variation %u", i);
|
---|
99 | # endif
|
---|
100 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_SPECIFIC, "One shot cpu specific");
|
---|
101 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_SPECIFIC, "Periodic cpu specific");
|
---|
102 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_OMNI, "Periodic omni timer");
|
---|
103 | }
|
---|
104 | # endif
|
---|
105 |
|
---|
106 | # if 1
|
---|
107 | /*
|
---|
108 | * High resolution timers.
|
---|
109 | */
|
---|
110 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_BASIC_HIRES, "Basic hires one shot");
|
---|
111 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_BASIC_HIRES, "Basic hires periodic");
|
---|
112 | if (RTTestErrorCount(g_hTest) == 0)
|
---|
113 | {
|
---|
114 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_RESOLUTION_HIRES, "One shot hires resolution");
|
---|
115 | # if 1
|
---|
116 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_RESTART_HIRES, "Restart hires one shot from callback");
|
---|
117 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_DESTROY_HIRES, "Destroy hires one shot from callback");
|
---|
118 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_CSSD_LOOPS_HIRES, "Create-start-stop-destroy loops, hires");
|
---|
119 | for (uint32_t i = 0; i <= 7; i++)
|
---|
120 | RTR3TestR0SimpleTestWithArg(TSTRTR0TIMER_PERIODIC_CHANGE_INTERVAL, i, "Change interval from callback, hires, variation %u", i);
|
---|
121 | # endif
|
---|
122 | RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_SPECIFIC_HIRES, "One shot hires cpu specific");
|
---|
123 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_SPECIFIC_HIRES, "Periodic hires cpu specific");
|
---|
124 | RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_OMNI_HIRES, "Periodic omni hires timer");
|
---|
125 | }
|
---|
126 | # endif
|
---|
127 | }
|
---|
128 |
|
---|
129 | /*
|
---|
130 | * Done.
|
---|
131 | */
|
---|
132 | return RTTestSummaryAndDestroy(g_hTest);
|
---|
133 | #endif
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | #if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
|
---|
138 | /**
|
---|
139 | * Main entry point.
|
---|
140 | */
|
---|
141 | int main(int argc, char **argv, char **envp)
|
---|
142 | {
|
---|
143 | return TrustedMain(argc, argv, envp);
|
---|
144 | }
|
---|
145 | #endif
|
---|
146 |
|
---|