tstVMMFork.cpp revision c189e41dcbb9bbda9b5bc41e07ef0fce82bbff7a
/* $Id$ */
/** @file
* VMM Fork Test.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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 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 <errno.h>
#include <unistd.h>
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define TESTCASE "tstVMMFork"
#define AUTO_TEST_ARGS 1
{
int rcErrors = 0;
/*
* Initialize the runtime.
*/
RTR3Init();
#ifndef AUTO_TEST_ARGS
if (argc < 2)
{
RTPrintf("syntax: %s command [args]\n"
"\n"
"command Command to run under child process in fork.\n"
"[args] Arguments to command.\n", argv[0]);
return 1;
}
#endif
/*
* Create empty VM.
*/
if (VBOX_SUCCESS(rc))
{
/*
* Do testing.
*/
int iCowTester = 0;
char cCowTester = 'a';
#ifndef AUTO_TEST_ARGS
#else
int cArgs = 2;
char *ppszArgs[3];
#endif
if (pid < 0)
{
/* Bad. fork() failed! */
rcErrors++;
}
else if (pid == 0)
{
/*
* The child process.
* Write to some local variables to trigger copy-on-write if it's used.
*/
iCowTester = 2;
cCowTester = 'z';
for (int i = 0; i < cArgs; i++)
_exit(-1);
}
else
{
/*
* The parent process.
* Wait for child & run VMM test to ensure things are fine.
*/
int result;
;
{
rcErrors++;
}
if (rcErrors == 0)
{
}
}
if (rcErrors > 0)
else
/*
* Cleanup.
*/
if (!VBOX_SUCCESS(rc))
{
rcErrors++;
}
}
else
{
rcErrors++;
}
return rcErrors;
}