tstPDMAsyncCompletion.cpp revision 8bed792bc65abd39393889351f22263ce6c289bf
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * PDM Asynchronous Completion Testcase.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * This testcase is for testing the async completion interface.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * It implements a file copy program which uses the interface to copy the data.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Use: ./tstPDMAsyncCompletion <source> <destination>
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Copyright (C) 2008-2009 Sun Microsystems, Inc.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * available from http://www.virtualbox.org. This file is free software;
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * you can redistribute it and/or modify it under the terms of the GNU
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * General Public License (GPL) as published by the Free Software
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * additional information or have any questions.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync/*******************************************************************************
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync* Header Files *
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync*******************************************************************************/
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Number of simultaneous active tasks.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync/* Buffers to store data in .*/
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsyncPPDMASYNCCOMPLETIONTASK g_AsyncCompletionTasks[NR_TASKS];
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsyncvoid pfnAsyncTaskCompleted(PVM pVM, void *pvUser, void *pvUser2)
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync LogFlow((TESTCASE ": %s: pVM=%p pvUser=%p pvUser2=%p\n", __FUNCTION__, pVM, pvUser, pvUser2));
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync uint32_t cTasksStillLeft = ASMAtomicDecU32(&g_cTasksLeft);
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync /* All tasks processed. Wakeup main. */
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync PPDMASYNCCOMPLETIONENDPOINT pEndpointSrc, pEndpointDst;
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync RTPrintf(TESTCASE ": Usage is ./tstPDMAsyncCompletion <source> <dest>\n");
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Little hack to avoid the VM_ASSERT_EMT assertion.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync RTTlsSet(pVM->pUVM->vm.s.idxTLS, &pVM->pUVM->aCpus[0]);
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync pVM->pUVM->aCpus[0].vm.s.NativeThreadEMT = RTThreadNativeSelf();
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Create the template.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync rc = PDMR3AsyncCompletionTemplateCreateInternal(pVM, &pTemplate, pfnAsyncTaskCompleted, NULL, "Test");
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync RTPrintf(TESTCASE ": Error while creating the template!! rc=%d\n", rc);
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Create event semaphor.
for (i=0; i < NR_TASKS; i++)
if (!g_AsyncCompletionTasksBuffer[i])
rcRet++;
return rcRet;
rcRet++;
return rcRet;
int fReadPass = true;
if (fReadPass)
? NR_TASKS
&g_AsyncCompletionTasks[i]);
&g_AsyncCompletionTasks[i]);
else if (fReadPass)
fReadPass = false;
cTasksUsed = 0;
fReadPass = true;
rcRet++;
rcRet++;
return rcRet;