Changeset 20429 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jun 9, 2009 11:45:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletion.cpp
r20205 r20429 1 1 /* $Id$ */ 2 2 /** @file 3 * Async completion Testcase. 4 */ 5 6 /* 7 * Copyright (C) 2008 Sun Microsystems, Inc. 8 * 9 * Sun Microsystems, Inc. confidential 10 * All rights reserved 11 */ 12 13 /* 3 * PDM Asynchronous Completion Testcase. 4 * 14 5 * This testcase is for testing the async completion interface. 15 6 * It implements a file copy program which uses the interface to copy the data. 16 7 * 17 8 * Use: ./tstPDMAsyncCompletion <source> <destination> 9 */ 10 11 /* 12 * Copyright (C) 2008-2009 Sun Microsystems, Inc. 13 * 14 * This file is part of VirtualBox Open Source Edition (OSE), as 15 * available from http://www.virtualbox.org. This file is free software; 16 * you can redistribute it and/or modify it under the terms of the GNU 17 * General Public License (GPL) as published by the Free Software 18 * Foundation, in version 2 as it comes in the "COPYING" file of the 19 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 20 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 21 * 22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa 23 * Clara, CA 95054 USA or visit http://www.sun.com if you need 24 * additional information or have any questions. 18 25 */ 19 26 … … 80 87 { 81 88 RTPrintf(TESTCASE ": Usage is ./tstPDMAsyncCompletion <source> <dest>\n"); 82 rcRet++; 83 return rcRet; 89 return 1; 84 90 } 85 91 … … 104 110 { 105 111 RTPrintf(TESTCASE ": Error while creating the template!! rc=%d\n", rc); 106 rcRet++; 107 return rcRet; 112 return 1; 108 113 } 109 114 … … 136 141 { 137 142 RTPrintf(TESTCASE ": Error while creating the destination!! rc=%d\n", rc); 143 return 1; 138 144 rcRet++; 139 145 return rcRet; … … 155 161 int fReadPass = true; 156 162 uint64_t cbSrc, cbLeft; 157 size_t uOffsetSrc = 0;158 size_t uOffsetDst = 0;163 size_t offSrc = 0; 164 size_t offDst = 0; 159 165 uint32_t cTasksUsed = 0; 160 166 … … 167 173 if (fReadPass) 168 174 { 169 cTasksUsed = (BUFFER_SIZE * NR_TASKS) <= (cbSrc - uOffsetSrc)175 cTasksUsed = (BUFFER_SIZE * NR_TASKS) <= (cbSrc - offSrc) 170 176 ? NR_TASKS 171 : ((cbSrc - uOffsetSrc) / BUFFER_SIZE)172 + ((cbSrc - uOffsetSrc) % BUFFER_SIZE) > 0173 174 177 : ((cbSrc - offSrc) / BUFFER_SIZE) 178 + ((cbSrc - offSrc) % BUFFER_SIZE) > 0 179 ? 1 180 : 0; 175 181 176 182 g_cTasksLeft = cTasksUsed; 177 183 178 for (u nsignedi = 0; i < cTasksUsed; i++)184 for (uint32_t i = 0; i < cTasksUsed; i++) 179 185 { 180 size_t cbRead = ((size_t) uOffsetSrc + BUFFER_SIZE) <= cbSrc ? BUFFER_SIZE : cbSrc - uOffsetSrc;186 size_t cbRead = ((size_t)offSrc + BUFFER_SIZE) <= cbSrc ? BUFFER_SIZE : cbSrc - offSrc; 181 187 PDMDATASEG DataSeg; 182 188 … … 184 190 DataSeg.cbSeg = cbRead; 185 191 186 rc = PDMR3AsyncCompletionEpRead(pEndpointSrc, uOffsetSrc, &DataSeg, 1, cbRead, NULL,192 rc = PDMR3AsyncCompletionEpRead(pEndpointSrc, offSrc, &DataSeg, 1, cbRead, NULL, 187 193 &g_AsyncCompletionTasks[i]); 188 194 AssertRC(rc); 189 uOffsetSrc += cbRead;190 if ( uOffsetSrc == cbSrc)195 offSrc += cbRead; 196 if (offSrc == cbSrc) 191 197 break; 192 198 } … … 196 202 g_cTasksLeft = cTasksUsed; 197 203 198 for (u nsignedi = 0; i < cTasksUsed; i++)204 for (uint32_t i = 0; i < cTasksUsed; i++) 199 205 { 200 size_t cbWrite = ( uOffsetDst + BUFFER_SIZE) <= cbSrc ? BUFFER_SIZE : cbSrc - uOffsetDst;206 size_t cbWrite = (offDst + BUFFER_SIZE) <= cbSrc ? BUFFER_SIZE : cbSrc - offDst; 201 207 PDMDATASEG DataSeg; 202 208 … … 204 210 DataSeg.cbSeg = cbWrite; 205 211 206 rc = PDMR3AsyncCompletionEpWrite(pEndpointDst, uOffsetDst, &DataSeg, 1, cbWrite, NULL,212 rc = PDMR3AsyncCompletionEpWrite(pEndpointDst, offDst, &DataSeg, 1, cbWrite, NULL, 207 213 &g_AsyncCompletionTasks[i]); 208 214 AssertRC(rc); 209 uOffsetDst += cbWrite;210 if ( uOffsetDst == cbSrc)215 offDst += cbWrite; 216 if (offDst == cbSrc) 211 217 break; 212 218 } … … 216 222 AssertRC(rc); 217 223 218 if (!fReadPass && ( uOffsetDst == cbSrc))224 if (!fReadPass && (offDst == cbSrc)) 219 225 break; 220 226 else if (fReadPass)
Note:
See TracChangeset
for help on using the changeset viewer.