tstRTR0TimerDriver.cpp revision 22ca45c3863de72dfa6ed4c31b712de13d61aa23
2675fd1e482998dd3a2e947b1aa7484317dd094evboxsync/* $Id$ */
2675fd1e482998dd3a2e947b1aa7484317dd094evboxsync/** @file
2675fd1e482998dd3a2e947b1aa7484317dd094evboxsync * IPRT R0 Testcase - Timers, driver program.
2675fd1e482998dd3a2e947b1aa7484317dd094evboxsync */
2675fd1e482998dd3a2e947b1aa7484317dd094evboxsync
2675fd1e482998dd3a2e947b1aa7484317dd094evboxsync/*
ce00b469e756b0f651b7aa020c9440e991d3442dvboxsync * Copyright (C) 2009-2014 Oracle Corporation
ce00b469e756b0f651b7aa020c9440e991d3442dvboxsync *
ce00b469e756b0f651b7aa020c9440e991d3442dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
ce00b469e756b0f651b7aa020c9440e991d3442dvboxsync * available from http://www.virtualbox.org. This file is free software;
ce00b469e756b0f651b7aa020c9440e991d3442dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
ce00b469e756b0f651b7aa020c9440e991d3442dvboxsync * General Public License (GPL) as published by the Free Software
2909d70e58e87e2111fdc5265d1ab32a08d557a3vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2909d70e58e87e2111fdc5265d1ab32a08d557a3vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2909d70e58e87e2111fdc5265d1ab32a08d557a3vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2909d70e58e87e2111fdc5265d1ab32a08d557a3vboxsync *
2909d70e58e87e2111fdc5265d1ab32a08d557a3vboxsync * The contents of this file may alternatively be used under the terms
2909d70e58e87e2111fdc5265d1ab32a08d557a3vboxsync * of the Common Development and Distribution License Version 1.0
9875b4d1f31a47c8c0f71430b7c9e0113104d064vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
9875b4d1f31a47c8c0f71430b7c9e0113104d064vboxsync * VirtualBox OSE distribution, in which case the provisions of the
9875b4d1f31a47c8c0f71430b7c9e0113104d064vboxsync * CDDL are applicable instead of those of the GPL.
9875b4d1f31a47c8c0f71430b7c9e0113104d064vboxsync *
9875b4d1f31a47c8c0f71430b7c9e0113104d064vboxsync * You may elect to license modified versions of this file under the
9875b4d1f31a47c8c0f71430b7c9e0113104d064vboxsync * terms and conditions of either the GPL or the CDDL or both.
3d8242e90019d302159795040e410b3d774a4b0bvboxsync */
3d8242e90019d302159795040e410b3d774a4b0bvboxsync
3d8242e90019d302159795040e410b3d774a4b0bvboxsync/*******************************************************************************
3d8242e90019d302159795040e410b3d774a4b0bvboxsync* Header Files *
3d8242e90019d302159795040e410b3d774a4b0bvboxsync*******************************************************************************/
3d8242e90019d302159795040e410b3d774a4b0bvboxsync#include <iprt/initterm.h>
534226d9c71bac7817fbcfeace5cf548084d7f6cvboxsync
534226d9c71bac7817fbcfeace5cf548084d7f6cvboxsync#include <iprt/err.h>
534226d9c71bac7817fbcfeace5cf548084d7f6cvboxsync#include <iprt/path.h>
534226d9c71bac7817fbcfeace5cf548084d7f6cvboxsync#include <iprt/param.h>
3d8242e90019d302159795040e410b3d774a4b0bvboxsync#include <iprt/stream.h>
534226d9c71bac7817fbcfeace5cf548084d7f6cvboxsync#include <iprt/string.h>
b10aac1b449f12e70468efd9eb414ba4d2a0c029vboxsync#include <iprt/test.h>
b10aac1b449f12e70468efd9eb414ba4d2a0c029vboxsync#include <iprt/thread.h>
b10aac1b449f12e70468efd9eb414ba4d2a0c029vboxsync#ifdef VBOX
b10aac1b449f12e70468efd9eb414ba4d2a0c029vboxsync# include <VBox/sup.h>
3d8242e90019d302159795040e410b3d774a4b0bvboxsync# include "tstRTR0Timer.h"
b10aac1b449f12e70468efd9eb414ba4d2a0c029vboxsync#endif
5896bf5b1db43d4c2d0974e137cb1d2ad174643fvboxsync#include "tstRTR0CommonDriver.h"
5896bf5b1db43d4c2d0974e137cb1d2ad174643fvboxsync
5896bf5b1db43d4c2d0974e137cb1d2ad174643fvboxsync
5896bf5b1db43d4c2d0974e137cb1d2ad174643fvboxsyncint main(int argc, char **argv)
5896bf5b1db43d4c2d0974e137cb1d2ad174643fvboxsync{
5896bf5b1db43d4c2d0974e137cb1d2ad174643fvboxsync#ifndef VBOX
8cde32eca33c0b47371ed3ba58e4d2cceed0b548vboxsync RTPrintf("tstRTR0Timer: SKIPPED\n");
8cde32eca33c0b47371ed3ba58e4d2cceed0b548vboxsync return RTEXITCODE_SKIPPED;
8cde32eca33c0b47371ed3ba58e4d2cceed0b548vboxsync#else
8cde32eca33c0b47371ed3ba58e4d2cceed0b548vboxsync /*
8cde32eca33c0b47371ed3ba58e4d2cceed0b548vboxsync * Init.
8cde32eca33c0b47371ed3ba58e4d2cceed0b548vboxsync */
f5840fca26963de38533fd43c951758c386ed60avboxsync RTEXITCODE rcExit = RTR3TestR0CommonDriverInit("tstRTR0Timer");
f5840fca26963de38533fd43c951758c386ed60avboxsync if (rcExit != RTEXITCODE_SUCCESS)
f5840fca26963de38533fd43c951758c386ed60avboxsync return rcExit;
f5840fca26963de38533fd43c951758c386ed60avboxsync
f5840fca26963de38533fd43c951758c386ed60avboxsync if (argc == 2 && !strcmp(argv[1], "latency"))
f5840fca26963de38533fd43c951758c386ed60avboxsync {
1400154bf298b7208c611e81321e0c82b721afd7vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_LATENCY_OMNI, "Latency omni timer");
1400154bf298b7208c611e81321e0c82b721afd7vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_LATENCY_OMNI_HIRES, "Latency omni hires timer");
1400154bf298b7208c611e81321e0c82b721afd7vboxsync }
1400154bf298b7208c611e81321e0c82b721afd7vboxsync else
1400154bf298b7208c611e81321e0c82b721afd7vboxsync {
1400154bf298b7208c611e81321e0c82b721afd7vboxsync# if 1
af66a95ff0d75da2d50719eb14a686a9de7bff76vboxsync /*
af66a95ff0d75da2d50719eb14a686a9de7bff76vboxsync * Standard timers.
af66a95ff0d75da2d50719eb14a686a9de7bff76vboxsync */
af66a95ff0d75da2d50719eb14a686a9de7bff76vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_BASIC, "Basic one shot");
af66a95ff0d75da2d50719eb14a686a9de7bff76vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_BASIC, "Basic periodic");
af66a95ff0d75da2d50719eb14a686a9de7bff76vboxsync if (RTTestErrorCount(g_hTest) == 0)
8d56e4d4be56ac2cbe2c03ce678432c6d8d1d7d3vboxsync {
8d56e4d4be56ac2cbe2c03ce678432c6d8d1d7d3vboxsync# if 1
8d56e4d4be56ac2cbe2c03ce678432c6d8d1d7d3vboxsync# ifndef RT_OS_SOLARIS /* Solaris cannot call back into cyclic subsystem from a cyclic callback. */
8d56e4d4be56ac2cbe2c03ce678432c6d8d1d7d3vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_RESTART, "Restart one shot from callback");
8d56e4d4be56ac2cbe2c03ce678432c6d8d1d7d3vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_DESTROY, "Destroy one shot from callback");
8d56e4d4be56ac2cbe2c03ce678432c6d8d1d7d3vboxsync# endif
5a1e64cee1eec57da3361ccda90351bd9c2e97a6vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_CSSD_LOOPS, "Create-start-stop-destroy loops");
5a1e64cee1eec57da3361ccda90351bd9c2e97a6vboxsync for (uint32_t i = 0; i <= 7; i++)
5a1e64cee1eec57da3361ccda90351bd9c2e97a6vboxsync RTR3TestR0SimpleTestWithArg(TSTRTR0TIMER_PERIODIC_CHANGE_INTERVAL, i, "Change interval from callback, variation %u", i);
5a1e64cee1eec57da3361ccda90351bd9c2e97a6vboxsync# endif
5a1e64cee1eec57da3361ccda90351bd9c2e97a6vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_SPECIFIC, "One shot cpu specific");
5a1e64cee1eec57da3361ccda90351bd9c2e97a6vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_SPECIFIC, "Periodic cpu specific");
fdb7d72fbf00de23e58088243b932f48684e83davboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_OMNI, "Periodic omni timer");
fdb7d72fbf00de23e58088243b932f48684e83davboxsync }
fdb7d72fbf00de23e58088243b932f48684e83davboxsync# endif
fdb7d72fbf00de23e58088243b932f48684e83davboxsync
fdb7d72fbf00de23e58088243b932f48684e83davboxsync# if 1
fdb7d72fbf00de23e58088243b932f48684e83davboxsync /*
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync * High resolution timers.
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync */
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_BASIC_HIRES, "Basic hires one shot");
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_BASIC_HIRES, "Basic hires periodic");
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync if (RTTestErrorCount(g_hTest) == 0)
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync {
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync# if 1
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync# ifndef RT_OS_SOLARIS /* Solaris cannot call back into cyclic subsystem from a cyclic callback. */
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_RESTART_HIRES, "Restart hires one shot from callback");
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_DESTROY_HIRES, "Destroy hires one shot from callback");
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync# endif
0a45dc6fc6692b57703e7e251f63b36476cc3435vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_CSSD_LOOPS_HIRES, "Create-start-stop-destroy loops, hires");
e5ece1e2eda83c3ac47fc02dc4d343e430009381vboxsync for (uint32_t i = 0; i <= 7; i++)
e5ece1e2eda83c3ac47fc02dc4d343e430009381vboxsync RTR3TestR0SimpleTestWithArg(TSTRTR0TIMER_PERIODIC_CHANGE_INTERVAL, i, "Change interval from callback, hires, variation %u", i);
e5ece1e2eda83c3ac47fc02dc4d343e430009381vboxsync# endif
e5ece1e2eda83c3ac47fc02dc4d343e430009381vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_ONE_SHOT_SPECIFIC_HIRES, "One shot hires cpu specific");
4148135d7797d294ed20b17713f3792aedb4426dvboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_SPECIFIC_HIRES, "Periodic hires cpu specific");
e5ece1e2eda83c3ac47fc02dc4d343e430009381vboxsync RTR3TestR0SimpleTest(TSTRTR0TIMER_PERIODIC_OMNI, "Periodic omni hires timer");
b9966c0aebbaadea7fafdb13bd9cc7dec1dde6e2vboxsync }
b9966c0aebbaadea7fafdb13bd9cc7dec1dde6e2vboxsync# endif
b9966c0aebbaadea7fafdb13bd9cc7dec1dde6e2vboxsync }
b9966c0aebbaadea7fafdb13bd9cc7dec1dde6e2vboxsync
b9966c0aebbaadea7fafdb13bd9cc7dec1dde6e2vboxsync /*
b9966c0aebbaadea7fafdb13bd9cc7dec1dde6e2vboxsync * Done.
05b0c045e695a3e2dfe0e3f3ad0909f061f28272vboxsync */
5db64e99b90067bcff9b0c080746edf83cf9dae6vboxsync return RTTestSummaryAndDestroy(g_hTest);
5db64e99b90067bcff9b0c080746edf83cf9dae6vboxsync#endif
5db64e99b90067bcff9b0c080746edf83cf9dae6vboxsync}
5db64e99b90067bcff9b0c080746edf83cf9dae6vboxsync
5db64e99b90067bcff9b0c080746edf83cf9dae6vboxsync