Changeset 30876 in vbox for trunk/src/VBox/Main/testcase/tstOVF.cpp
- Timestamp:
- Jul 16, 2010 11:32:38 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstOVF.cpp
r30635 r30876 50 50 : m_rc(rc) 51 51 { 52 m_str = pcsz; 52 m_str = "ERROR: "; 53 m_str += pcsz; 53 54 54 55 if (pProgress) … … 57 58 com::GluePrintErrorInfo(info); 58 59 } 59 else 60 else if (rc) 60 61 { 61 62 com::ErrorInfo info; 62 63 if (!info.isFullAvailable() && !info.isBasicAvailable()) 63 {64 64 com::GluePrintRCMessage(rc); 65 m_str.append("Most likely, the VirtualBox COM server is not running or failed to start.");66 }67 65 else 68 66 com::GluePrintErrorInfo(info); … … 80 78 * @param pcszOVF File to import. 81 79 */ 82 void importOVF(ComPtr<IVirtualBox> &pVirtualBox, 80 void importOVF(const char *pcszPrefix, 81 ComPtr<IVirtualBox> &pVirtualBox, 83 82 const char *pcszOVF0) 84 83 { … … 86 85 RTPathAbs(pcszOVF0, szAbsOVF, sizeof(szAbsOVF)); 87 86 88 RTPrintf(" Reading appliance \"%s\"...\n", szAbsOVF);87 RTPrintf("%s: reading appliance \"%s\"...\n", pcszPrefix, szAbsOVF); 89 88 ComPtr<IAppliance> pAppl; 90 89 HRESULT rc = pVirtualBox->CreateAppliance(pAppl.asOutParam()); 91 90 if (FAILED(rc)) 92 throw MyError(rc, "failed to create applia ce");91 throw MyError(rc, "failed to create appliance\n"); 93 92 94 93 ComPtr<IProgress> pProgress; 95 94 rc = pAppl->Read(Bstr(szAbsOVF), pProgress.asOutParam()); 96 95 if (FAILED(rc)) 97 throw MyError(rc, "Appliance::Read() failed ");96 throw MyError(rc, "Appliance::Read() failed\n"); 98 97 rc = pProgress->WaitForCompletion(-1); 99 98 if (FAILED(rc)) 100 throw MyError(rc, "Progress::WaitForCompletion() failed ");99 throw MyError(rc, "Progress::WaitForCompletion() failed\n"); 101 100 LONG rc2; 102 101 pProgress->COMGETTER(ResultCode)(&rc2); 103 102 if (FAILED(rc2)) 104 throw MyError(rc2, "Appliance::Read() failed ", pProgress);105 106 RTPrintf(" Interpreting appliance \"%s\"...\n", szAbsOVF);103 throw MyError(rc2, "Appliance::Read() failed\n", pProgress); 104 105 RTPrintf("%s: interpreting appliance \"%s\"...\n", pcszPrefix, szAbsOVF); 107 106 rc = pAppl->Interpret(); 108 107 if (FAILED(rc)) 109 throw MyError(rc, "Appliance::Interpret() failed ");108 throw MyError(rc, "Appliance::Interpret() failed\n"); 110 109 111 110 com::SafeIfaceArray<IVirtualSystemDescription> aDescriptions; 112 111 rc = pAppl->COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(aDescriptions)); 113 112 for (uint32_t u = 0; 114 115 113 u < aDescriptions.size(); 114 ++u) 116 115 { 117 116 ComPtr<IVirtualSystemDescription> pVSys = aDescriptions[u]; … … 128 127 ComSafeArrayAsOutParam(aExtraConfigValues)); 129 128 for (uint32_t u2 = 0; 130 131 129 u2 < aTypes.size(); 130 ++u2) 132 131 { 133 132 const char *pcszType; … … 221 220 222 221 default: 223 throw MyError(E_UNEXPECTED, "Invalid VirtualSystemDescriptionType ");222 throw MyError(E_UNEXPECTED, "Invalid VirtualSystemDescriptionType\n"); 224 223 break; 225 224 } … … 229 228 aOvfValues[u2], 230 229 aVboxValues[u2], 231 aExtraConfigValues[u2] 230 aExtraConfigValues[u2]); 232 231 } 233 232 } 234 233 235 RTPrintf(" Importing machines...\n");234 RTPrintf("%s: importing %d machine(s)...\n", pcszPrefix, aDescriptions.size()); 236 235 rc = pAppl->ImportMachines(pProgress.asOutParam()); 237 236 if (FAILED(rc)) 238 throw MyError(rc, "Appliance::ImportMachines() failed ");237 throw MyError(rc, "Appliance::ImportMachines() failed\n"); 239 238 rc = pProgress->WaitForCompletion(-1); 240 239 if (FAILED(rc)) 241 throw MyError(rc, "Progress::WaitForCompletion() failed ");240 throw MyError(rc, "Progress::WaitForCompletion() failed\n"); 242 241 pProgress->COMGETTER(ResultCode)(&rc2); 243 242 if (FAILED(rc2)) 244 throw MyError(rc2, "Appliance::ImportMachines() failed", pProgress); 243 throw MyError(rc2, "Progress::GetResultCode() failed\n"); 244 RTPrintf("%s: success!\n", pcszPrefix); 245 245 } 246 246 … … 256 256 int vrc = RTFileCopy("ovf-testcases/ovf-dummy.vmdk", pcszDest); 257 257 if (RT_FAILURE(vrc)) 258 throw MyError( E_UNEXPECTED, "Cannot copy ovf-dummy.vmdk");258 throw MyError(0, Utf8StrFmt("Cannot copy ovf-dummy.vmdk to %s: %Rra\n", pcszDest, vrc).c_str()); 259 259 llFiles2Delete.push_back(pcszDest); 260 260 } … … 279 279 rc = com::Initialize(); 280 280 if (FAILED(rc)) 281 throw MyError(rc, "failed to initialize COM! ");281 throw MyError(rc, "failed to initialize COM!\n"); 282 282 283 283 ComPtr<IVirtualBox> pVirtualBox; … … 287 287 rc = pVirtualBox.createLocalObject(CLSID_VirtualBox); 288 288 if (FAILED(rc)) 289 throw MyError(rc, "failed to create the VirtualBox object! ");289 throw MyError(rc, "failed to create the VirtualBox object!\n"); 290 290 291 291 rc = pSession.createInprocObject(CLSID_Session); 292 292 if (FAILED(rc)) 293 throw MyError(rc, "failed to create a session object! ");293 throw MyError(rc, "failed to create a session object!\n"); 294 294 295 295 // create the event queue … … 298 298 299 299 // testcase 1: import ovf-joomla-0.9/joomla-1.1.4-ovf.ovf 300 copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-0.vmdk"); 301 copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-1.vmdk"); 302 importOVF(pVirtualBox, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf.ovf"); 303 304 RTPrintf ("tstOVF all done, no errors!.\n"); 300 // copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-0.vmdk"); 301 // copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-1.vmdk"); 302 // importOVF("joomla-0.9", pVirtualBox, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf.ovf"); 303 304 // testcase 2: import ovf-winxp-vbox-sharedfolders/winxp.ovf 305 copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/Windows 5.1 XP 1 merged.vmdk"); 306 copyDummyDiskImage(llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/smallvdi.vmdk"); 307 importOVF("winxp-vbox-sharedfolders", pVirtualBox, "ovf-testcases/ovf-winxp-vbox-sharedfolders/winxp.ovf"); 308 309 RTPrintf ("tstOVF all done, no errors.\n"); 305 310 306 311 // todo: cleanup created machines, created disk images … … 309 314 { 310 315 rc = e.m_rc; 311 RTPrintf("%s \n", e.m_str.c_str());316 RTPrintf("%s", e.m_str.c_str()); 312 317 } 313 318
Note:
See TracChangeset
for help on using the changeset viewer.