VirtualBox

Ignore:
Timestamp:
Jul 16, 2010 11:32:38 AM (14 years ago)
Author:
vboxsync
Message:

Main/OVF: another testcase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstOVF.cpp

    r30635 r30876  
    5050        : m_rc(rc)
    5151    {
    52         m_str = pcsz;
     52        m_str = "ERROR: ";
     53        m_str += pcsz;
    5354
    5455        if (pProgress)
     
    5758            com::GluePrintErrorInfo(info);
    5859        }
    59         else
     60        else if (rc)
    6061        {
    6162            com::ErrorInfo info;
    6263            if (!info.isFullAvailable() && !info.isBasicAvailable())
    63             {
    6464                com::GluePrintRCMessage(rc);
    65                 m_str.append("Most likely, the VirtualBox COM server is not running or failed to start.");
    66             }
    6765            else
    6866                com::GluePrintErrorInfo(info);
     
    8078 * @param pcszOVF File to import.
    8179 */
    82 void importOVF(ComPtr<IVirtualBox> &pVirtualBox,
     80void importOVF(const char *pcszPrefix,
     81               ComPtr<IVirtualBox> &pVirtualBox,
    8382               const char *pcszOVF0)
    8483{
     
    8685    RTPathAbs(pcszOVF0, szAbsOVF, sizeof(szAbsOVF));
    8786
    88     RTPrintf("Reading appliance \"%s\"...\n", szAbsOVF);
     87    RTPrintf("%s: reading appliance \"%s\"...\n", pcszPrefix, szAbsOVF);
    8988    ComPtr<IAppliance> pAppl;
    9089    HRESULT rc = pVirtualBox->CreateAppliance(pAppl.asOutParam());
    9190    if (FAILED(rc))
    92         throw MyError(rc, "failed to create appliace");
     91        throw MyError(rc, "failed to create appliance\n");
    9392
    9493    ComPtr<IProgress> pProgress;
    9594    rc = pAppl->Read(Bstr(szAbsOVF), pProgress.asOutParam());
    9695    if (FAILED(rc))
    97         throw MyError(rc, "Appliance::Read() failed");
     96        throw MyError(rc, "Appliance::Read() failed\n");
    9897    rc = pProgress->WaitForCompletion(-1);
    9998    if (FAILED(rc))
    100         throw MyError(rc, "Progress::WaitForCompletion() failed");
     99        throw MyError(rc, "Progress::WaitForCompletion() failed\n");
    101100    LONG rc2;
    102101    pProgress->COMGETTER(ResultCode)(&rc2);
    103102    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);
    107106    rc = pAppl->Interpret();
    108107    if (FAILED(rc))
    109         throw MyError(rc, "Appliance::Interpret() failed");
     108        throw MyError(rc, "Appliance::Interpret() failed\n");
    110109
    111110    com::SafeIfaceArray<IVirtualSystemDescription> aDescriptions;
    112111    rc = pAppl->COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(aDescriptions));
    113112    for (uint32_t u = 0;
    114             u < aDescriptions.size();
    115             ++u)
     113         u < aDescriptions.size();
     114         ++u)
    116115    {
    117116        ComPtr<IVirtualSystemDescription> pVSys = aDescriptions[u];
     
    128127                                   ComSafeArrayAsOutParam(aExtraConfigValues));
    129128        for (uint32_t u2 = 0;
    130                 u2 < aTypes.size();
    131                 ++u2)
     129             u2 < aTypes.size();
     130             ++u2)
    132131        {
    133132            const char *pcszType;
     
    221220
    222221                default:
    223                     throw MyError(E_UNEXPECTED, "Invalid VirtualSystemDescriptionType");
     222                    throw MyError(E_UNEXPECTED, "Invalid VirtualSystemDescriptionType\n");
    224223                break;
    225224            }
     
    229228                     aOvfValues[u2],
    230229                     aVboxValues[u2],
    231                      aExtraConfigValues[u2]                         );
     230                     aExtraConfigValues[u2]);
    232231        }
    233232    }
    234233
    235     RTPrintf("Importing machines...\n");
     234    RTPrintf("%s: importing %d machine(s)...\n", pcszPrefix, aDescriptions.size());
    236235    rc = pAppl->ImportMachines(pProgress.asOutParam());
    237236    if (FAILED(rc))
    238         throw MyError(rc, "Appliance::ImportMachines() failed");
     237        throw MyError(rc, "Appliance::ImportMachines() failed\n");
    239238    rc = pProgress->WaitForCompletion(-1);
    240239    if (FAILED(rc))
    241         throw MyError(rc, "Progress::WaitForCompletion() failed");
     240        throw MyError(rc, "Progress::WaitForCompletion() failed\n");
    242241    pProgress->COMGETTER(ResultCode)(&rc2);
    243242    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);
    245245}
    246246
     
    256256    int vrc = RTFileCopy("ovf-testcases/ovf-dummy.vmdk", pcszDest);
    257257    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());
    259259    llFiles2Delete.push_back(pcszDest);
    260260}
     
    279279        rc = com::Initialize();
    280280        if (FAILED(rc))
    281             throw MyError(rc, "failed to initialize COM!");
     281            throw MyError(rc, "failed to initialize COM!\n");
    282282
    283283        ComPtr<IVirtualBox> pVirtualBox;
     
    287287        rc = pVirtualBox.createLocalObject(CLSID_VirtualBox);
    288288        if (FAILED(rc))
    289             throw MyError(rc, "failed to create the VirtualBox object!");
     289            throw MyError(rc, "failed to create the VirtualBox object!\n");
    290290
    291291        rc = pSession.createInprocObject(CLSID_Session);
    292292        if (FAILED(rc))
    293             throw MyError(rc, "failed to create a session object!");
     293            throw MyError(rc, "failed to create a session object!\n");
    294294
    295295        // create the event queue
     
    298298
    299299        // 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");
    305310
    306311        // todo: cleanup created machines, created disk images
     
    309314    {
    310315        rc = e.m_rc;
    311         RTPrintf("%s\n", e.m_str.c_str());
     316        RTPrintf("%s", e.m_str.c_str());
    312317    }
    313318
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette