tstRunTestcases.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The number of passed testcases. */
static unsigned g_cPasses = 0;
/** The number of failed testcases. */
static unsigned g_cFailures = 0;
/** The number of skipped testcases. */
static unsigned g_cSkipped = 0;
/** The exclude list.
* @note Stripped extensions! */
static const char *g_apszExclude[] =
{
#if 1 // slow stuff
#endif
"testcase/tstHostHardwareLinux", /* must be killed with CTRL-C */
"testcase/tstR0ThreadPreemption", /* r0 driver, not directly executable */
"testcase/tstRTR0MemUserKernel", /* r0 driver, not directly executable */
"./tstRunTestcases",
"./tstAnimate",
"./tstAPI",
"./tstHeadless",
"./tstHeadless2",
"./tstMicro",
"./tstMicroGC",
"./tstVBoxDbg",
"./tstVMM-2",
"./tstTestServMgr",
"./tstPDMAsyncCompletion", /* requires parameters <source>, <dest> */
"./tstXptDump",
"./tstnsIFileEnumerator",
"./tstSimpleTypeLib",
"./tstTestAtoms",
"./tstXptLink",
"./tstXPCOMCGlue", /* user interaction required */
"./tstTestCallTemplates",
#if 1 // later
"./tstVMM",
"./tstVMReq",
"./tstVMREQ",
#endif
/* final entry*/
""
};
/**
* Checks if a testcase is include or should be skipped.
*
* @param pszTestcase The testcase (filename).
*
* @return true if the testcase is included.
* false if the testcase should be skipped.
*/
static bool IsTestcaseIncluded(const char *pszTestcase)
{
if (pszDup)
{
for (unsigned i = 0; i < RT_ELEMENTS(g_apszExclude); i++)
{
{
return false;
}
}
return true;
}
RTPrintf("tstRunTestcases: Out of memory!\n");
return false;
}
/**
* Process the testcases found in the filter.
*
* @param pszFilter The filter (winnt) to pass to RTDirOpenFiltered for
* selecting the testcases.
* @param pszDir The directory we're processing.
*/
{
/*
* Open and enumerate the directory.
*/
if (RT_SUCCESS(rc))
{
for (;;)
{
if (RT_FAILURE(rc))
{
if (rc == VERR_NO_MORE_FILES)
rc = VINF_SUCCESS;
else
break;
}
/*
* Construct the testcase name.
*/
char *pszTestcase;
if (!pszTestcase)
{
RTPrintf("tstRunTestcases: out of memory!\n");
rc = VERR_NO_MEMORY;
break;
}
{
/*
* Execute the testcase.
*/
const char *papszArgs[2];
papszArgs[0] = pszTestcase;
if (RT_SUCCESS(rc))
{
/*
* Wait for the process and collect it's return code.
* If it takes too long, we'll terminate it and continue.
*/
for (;;)
{
if (rc != VERR_PROCESS_RUNNING)
break;
{
RTThreadSleep(100);
g_cFailures++;
break;
}
RTThreadSleep(100);
}
/*
* Examin the exit status.
*/
if (RT_SUCCESS(rc))
{
&& ProcStatus.iStatus == 0)
{
g_cPasses++;
}
else
{
g_cFailures++;
}
}
else if (rc != VERR_PROCESS_RUNNING)
{
g_cFailures++;
}
}
else
{
g_cFailures++;
}
}
else
{
g_cSkipped++;
}
} /* enumeration loop */
}
else
}
{
RTR3Init();
if (argc == 1)
{
char szPath[RTPATH_MAX];
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
}
else
{
char szDir[RTPATH_MAX];
for (int i = 1; i < argc; i++)
{
if (argv[i][0] == '-')
{
switch (argv[i][1])
{
/* case '':... */
default:
return 1;
}
}
else
{
{
return 1;
}
if (!pszFilename)
{
return 1;
}
}
}
}
RTPrintf("\n"
"********************\n"
"*** PASSED: %u\n"
"*** FAILED: %u\n"
"*** SKIPPED: %u\n"
"*** TOTAL: %u\n",
return !!g_cFailures;
}