Changeset 36634 in vbox for trunk/src/VBox
- Timestamp:
- Apr 8, 2011 9:56:20 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71098
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/tstVDIo.cpp
r36135 r36634 280 280 static DECLCALLBACK(int) vdScriptHandlerFlush(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 281 281 static DECLCALLBACK(int) vdScriptHandlerMerge(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 282 static DECLCALLBACK(int) vdScriptHandlerCompact(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 282 283 static DECLCALLBACK(int) vdScriptHandlerClose(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 283 284 static DECLCALLBACK(int) vdScriptHandlerIoRngCreate(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); … … 341 342 /* pcszName chId enmType fFlags */ 342 343 {"disk", 'd', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 343 {"forward", 'f', VDSCRIPTARGTYPE_BOOL, VDSCRIPTARGDESC_FLAG_MANDATORY} 344 {"from", 'f', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY}, 345 {"to", 't', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY}, 346 }; 347 348 /* Compact a disk */ 349 const VDSCRIPTARGDESC g_aArgCompact[] = 350 { 351 /* pcszName chId enmType fFlags */ 352 {"disk", 'd', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 353 {"image", 'i', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY}, 344 354 }; 345 355 … … 423 433 {"close", g_aArgClose, RT_ELEMENTS(g_aArgClose), vdScriptHandlerClose}, 424 434 {"merge", g_aArgMerge, RT_ELEMENTS(g_aArgMerge), vdScriptHandlerMerge}, 435 {"compact", g_aArgCompact, RT_ELEMENTS(g_aArgCompact), vdScriptHandlerCompact}, 425 436 {"iorngcreate", g_aArgIoRngCreate, RT_ELEMENTS(g_aArgIoRngCreate), vdScriptHandlerIoRngCreate}, 426 437 {"iorngdestroy", NULL, 0, vdScriptHandlerIoRngDestroy}, … … 995 1006 static DECLCALLBACK(int) vdScriptHandlerMerge(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs) 996 1007 { 997 return VERR_NOT_IMPLEMENTED; 1008 int rc = VINF_SUCCESS; 1009 const char *pcszDisk = NULL; 1010 PVDDISK pDisk = NULL; 1011 unsigned nImageFrom = 0; 1012 unsigned nImageTo = 0; 1013 1014 for (unsigned i = 0; i < cScriptArgs; i++) 1015 { 1016 switch (paScriptArgs[i].chId) 1017 { 1018 case 'd': 1019 { 1020 pcszDisk = paScriptArgs[i].u.pcszString; 1021 break; 1022 } 1023 case 'f': 1024 { 1025 nImageFrom = (unsigned)paScriptArgs[i].u.u64; 1026 break; 1027 } 1028 case 't': 1029 { 1030 nImageTo = (unsigned)paScriptArgs[i].u.u64; 1031 break; 1032 } 1033 1034 default: 1035 AssertMsgFailed(("Invalid argument given!\n")); 1036 } 1037 1038 if (RT_FAILURE(rc)) 1039 break; 1040 } 1041 1042 if (RT_SUCCESS(rc)) 1043 { 1044 pDisk = tstVDIoGetDiskByName(pGlob, pcszDisk); 1045 if (!pDisk) 1046 rc = VERR_NOT_FOUND; 1047 else 1048 { 1049 /** @todo: Provide progress interface to test that cancelation 1050 * doesn't corrupt the data. 1051 */ 1052 rc = VDMerge(pDisk->pVD, nImageFrom, nImageTo, NULL); 1053 } 1054 } 1055 1056 return rc; 1057 } 1058 1059 static DECLCALLBACK(int) vdScriptHandlerCompact(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs) 1060 { 1061 int rc = VINF_SUCCESS; 1062 const char *pcszDisk = NULL; 1063 PVDDISK pDisk = NULL; 1064 unsigned nImage = 0; 1065 1066 for (unsigned i = 0; i < cScriptArgs; i++) 1067 { 1068 switch (paScriptArgs[i].chId) 1069 { 1070 case 'd': 1071 { 1072 pcszDisk = paScriptArgs[i].u.pcszString; 1073 break; 1074 } 1075 case 'i': 1076 { 1077 nImage = (unsigned)paScriptArgs[i].u.u64; 1078 break; 1079 } 1080 1081 default: 1082 AssertMsgFailed(("Invalid argument given!\n")); 1083 } 1084 1085 if (RT_FAILURE(rc)) 1086 break; 1087 } 1088 1089 if (RT_SUCCESS(rc)) 1090 { 1091 pDisk = tstVDIoGetDiskByName(pGlob, pcszDisk); 1092 if (!pDisk) 1093 rc = VERR_NOT_FOUND; 1094 else 1095 { 1096 /** @todo: Provide progress interface to test that cancelation 1097 * doesn't corrupt the data. 1098 */ 1099 rc = VDCompact(pDisk->pVD, nImage, NULL); 1100 } 1101 } 1102 1103 return rc; 998 1104 } 999 1105
Note:
See TracChangeset
for help on using the changeset viewer.