tstRunTestcases.cpp revision 180d75c44949a43d3a0780eea8a4d1ae8a96d87f
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2013 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 */
#if !defined(RT_OS_LINUX)
#endif
"./tstAnimate",
"./tstMicro",
"./tstMicroGC",
"./tstVBoxDbg",
"./tstVMM-2",
"./tstPDMAsyncCompletion", /* requires parameters <source>, <dest> */
"testcase/tstHeadless", /* requires parameter */
"testcase/tstCollector", /* takes forever */
"testcase/tstnsIFileEnumerator", /* requires parameter */
"testcase/tstSimpleTypeLib", /* requires parameter */
"testcase/tstTestAtoms", /* requires parameter */
"testcase/tstTestCallTemplates", /* compile-only testcase */
"testcase/tstTestServMgr", /* fails, needs complex service setup */
"testcase/tstXptDump", /* requires parameter */
"testcase/tstXptLink", /* requires parameter */
"testcase/tstXPCOMCGlue", /* user interaction required */
"testcase/tstXPCOMCEvent", /* user interaction required */
#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)
{
/* exclude special modules based on extension. */
)
return false;
/* check by name */
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
}
{
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;
}