Changeset 27137 in vbox for trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp
- Timestamp:
- Mar 6, 2010 7:05:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp
r27135 r27137 58 58 /** Chance to change a segment after a diff was created */ 59 59 uint32_t uChangeSegChance; 60 /** Numer of allocated blocks in the base image in percent */ 61 uint32_t uAllocatedBlocks; 60 62 } VDSNAPTEST, *PVDSNAPTEST; 61 63 … … 137 139 size_t cbWrite = paDiskSegments[i].cbSeg; 138 140 uint64_t off = paDiskSegments[i].off; 139 uint8_t *pbData = fInit ? paDiskSegments[i].pbData : paDiskSegments[i].pbDataDiff; 140 141 rc = VDWrite(pVD, off, pbData, cbWrite); 142 if (RT_FAILURE(rc)) 143 return rc; 141 uint8_t *pbData = fInit 142 ? paDiskSegments[i].pbData 143 : paDiskSegments[i].pbDataDiff; 144 145 if (pbData) 146 { 147 rc = VDWrite(pVD, off, pbData, cbWrite); 148 if (RT_FAILURE(rc)) 149 return rc; 150 } 144 151 } 145 152 } … … 169 176 return rc; 170 177 171 if ( memcmp(pbCmp, pbBuf, cbToRead))178 if (pbCmp) 172 179 { 180 if (memcmp(pbCmp, pbBuf, cbToRead)) 181 { 182 for (unsigned iCmp = 0; iCmp < cbToRead; iCmp++) 183 { 184 if (pbCmp[iCmp] != pbBuf[iCmp]) 185 { 186 RTPrintf("Unexpected data at %llu expected %#x got %#x\n", off+iCmp, pbCmp[iCmp], pbBuf[iCmp]); 187 break; 188 } 189 } 190 return VERR_INTERNAL_ERROR; 191 } 192 } 193 else 194 { 195 /* Verify that the block is 0 */ 173 196 for (unsigned iCmp = 0; iCmp < cbToRead; iCmp++) 174 197 { 175 if (pb Cmp[iCmp] != pbBuf[iCmp])198 if (pbBuf[iCmp] != 0) 176 199 { 177 RTPrintf(" Unexpected data at %llu expected %#x got %#x\n", off+i, pbCmp[iCmp], pbBuf[iCmp]);178 break;200 RTPrintf("Zero block contains data at %llu\n", off+iCmp); 201 return VERR_INTERNAL_ERROR; 179 202 } 180 203 } 181 return VERR_INTERNAL_ERROR;182 204 } 183 205 184 206 cbRead -= cbToRead; 185 207 off += cbToRead; 186 pbCmp += cbToRead; 208 209 if (pbCmp) 210 pbCmp += cbToRead; 187 211 } 188 212 } … … 225 249 paDiskSeg[i].off = cbDisk; 226 250 paDiskSeg[i].cbSeg = RT_ALIGN_64(RTRandU64Ex(512, pTest->cbTestPattern), 512); 227 paDiskSeg[i].pbData = pbTestPattern + RT_ALIGN_64(RTRandU64Ex(0, pTest->cbTestPattern - paDiskSeg[i].cbSeg - 512), 512); 251 if (tstVDSnapIsTrue(pTest->uAllocatedBlocks)) 252 paDiskSeg[i].pbData = pbTestPattern + RT_ALIGN_64(RTRandU64Ex(0, pTest->cbTestPattern - paDiskSeg[i].cbSeg - 512), 512); 253 else 254 paDiskSeg[i].pbData = NULL; /* Not allocated initially */ 228 255 cbDisk += paDiskSeg[i].cbSeg; 229 256 } … … 371 398 Test.uCreateDiffChance = 50; /* % */ 372 399 Test.uChangeSegChance = 20; /* % */ 400 Test.uAllocatedBlocks = 50; /* 50% allocated */ 373 401 tstVDOpenCreateWriteMerge(&Test); 374 402
Note:
See TracChangeset
for help on using the changeset viewer.