[50390] | 1 | /* $Id: tstVBoxAPI.cpp 101035 2023-09-07 08:59:15Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * tstVBoxAPI - Checks VirtualBox API.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[50390] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[50390] | 26 | */
|
---|
| 27 |
|
---|
| 28 |
|
---|
[57358] | 29 | /*********************************************************************************************************************************
|
---|
| 30 | * Header Files *
|
---|
| 31 | *********************************************************************************************************************************/
|
---|
[50390] | 32 | #include <VBox/com/com.h>
|
---|
| 33 | #include <VBox/com/string.h>
|
---|
| 34 | #include <VBox/com/array.h>
|
---|
| 35 | #include <VBox/com/Guid.h>
|
---|
| 36 | #include <VBox/com/ErrorInfo.h>
|
---|
[50397] | 37 | #include <VBox/com/errorprint.h>
|
---|
[50390] | 38 | #include <VBox/com/VirtualBox.h>
|
---|
| 39 | #include <VBox/sup.h>
|
---|
| 40 |
|
---|
| 41 | #include <iprt/test.h>
|
---|
| 42 | #include <iprt/time.h>
|
---|
| 43 |
|
---|
| 44 | using namespace com;
|
---|
| 45 |
|
---|
| 46 |
|
---|
[57358] | 47 | /*********************************************************************************************************************************
|
---|
| 48 | * Global Variables *
|
---|
| 49 | *********************************************************************************************************************************/
|
---|
[50390] | 50 | static RTTEST g_hTest;
|
---|
[50439] | 51 | static Bstr tstMachineName = "tstVBoxAPI test VM";
|
---|
[50390] | 52 |
|
---|
| 53 |
|
---|
| 54 | /** Worker for TST_COM_EXPR(). */
|
---|
| 55 | static HRESULT tstComExpr(HRESULT hrc, const char *pszOperation, int iLine)
|
---|
| 56 | {
|
---|
| 57 | if (FAILED(hrc))
|
---|
| 58 | RTTestFailed(g_hTest, "%s failed on line %u with hrc=%Rhrc", pszOperation, iLine, hrc);
|
---|
| 59 | return hrc;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /** Macro that executes the given expression and report any failure.
|
---|
| 63 | * The expression must return a HRESULT. */
|
---|
| 64 | #define TST_COM_EXPR(expr) tstComExpr(expr, #expr, __LINE__)
|
---|
| 65 |
|
---|
| 66 |
|
---|
[101035] | 67 | static void tstApiIVirtualBox(IVirtualBox *pVBox)
|
---|
[50390] | 68 | {
|
---|
[95140] | 69 | HRESULT hrc;
|
---|
[50390] | 70 | Bstr bstrTmp;
|
---|
| 71 | ULONG ulTmp;
|
---|
| 72 |
|
---|
| 73 | RTTestSub(g_hTest, "IVirtualBox::version");
|
---|
[50397] | 74 | CHECK_ERROR(pVBox, COMGETTER(Version)(bstrTmp.asOutParam()));
|
---|
[95140] | 75 | if (SUCCEEDED(hrc))
|
---|
[50390] | 76 | RTTestPassed(g_hTest, "IVirtualBox::version");
|
---|
| 77 | else
|
---|
[50397] | 78 | RTTestFailed(g_hTest, "%d: IVirtualBox::version failed", __LINE__);
|
---|
[50390] | 79 |
|
---|
| 80 | RTTestSub(g_hTest, "IVirtualBox::versionNormalized");
|
---|
[50397] | 81 | CHECK_ERROR(pVBox, COMGETTER(VersionNormalized)(bstrTmp.asOutParam()));
|
---|
[95140] | 82 | if (SUCCEEDED(hrc))
|
---|
[50390] | 83 | RTTestPassed(g_hTest, "IVirtualBox::versionNormalized");
|
---|
| 84 | else
|
---|
[50397] | 85 | RTTestFailed(g_hTest, "%d: IVirtualBox::versionNormalized failed", __LINE__);
|
---|
[50390] | 86 |
|
---|
| 87 | RTTestSub(g_hTest, "IVirtualBox::revision");
|
---|
[50397] | 88 | CHECK_ERROR(pVBox, COMGETTER(Revision)(&ulTmp));
|
---|
[95140] | 89 | if (SUCCEEDED(hrc))
|
---|
[50390] | 90 | RTTestPassed(g_hTest, "IVirtualBox::revision");
|
---|
| 91 | else
|
---|
[50397] | 92 | RTTestFailed(g_hTest, "%d: IVirtualBox::revision failed", __LINE__);
|
---|
[50390] | 93 |
|
---|
| 94 | RTTestSub(g_hTest, "IVirtualBox::packageType");
|
---|
[50397] | 95 | CHECK_ERROR(pVBox, COMGETTER(PackageType)(bstrTmp.asOutParam()));
|
---|
[95140] | 96 | if (SUCCEEDED(hrc))
|
---|
[50390] | 97 | RTTestPassed(g_hTest, "IVirtualBox::packageType");
|
---|
| 98 | else
|
---|
[50397] | 99 | RTTestFailed(g_hTest, "%d: IVirtualBox::packageType failed", __LINE__);
|
---|
[50390] | 100 |
|
---|
| 101 | RTTestSub(g_hTest, "IVirtualBox::APIVersion");
|
---|
[50397] | 102 | CHECK_ERROR(pVBox, COMGETTER(APIVersion)(bstrTmp.asOutParam()));
|
---|
[95140] | 103 | if (SUCCEEDED(hrc))
|
---|
[50390] | 104 | RTTestPassed(g_hTest, "IVirtualBox::APIVersion");
|
---|
| 105 | else
|
---|
[50397] | 106 | RTTestFailed(g_hTest, "%d: IVirtualBox::APIVersion failed", __LINE__);
|
---|
[50390] | 107 |
|
---|
| 108 | RTTestSub(g_hTest, "IVirtualBox::homeFolder");
|
---|
[50397] | 109 | CHECK_ERROR(pVBox, COMGETTER(HomeFolder)(bstrTmp.asOutParam()));
|
---|
[95140] | 110 | if (SUCCEEDED(hrc))
|
---|
[50390] | 111 | RTTestPassed(g_hTest, "IVirtualBox::homeFolder");
|
---|
| 112 | else
|
---|
[50397] | 113 | RTTestFailed(g_hTest, "%d: IVirtualBox::homeFolder failed", __LINE__);
|
---|
[50390] | 114 |
|
---|
| 115 | RTTestSub(g_hTest, "IVirtualBox::settingsFilePath");
|
---|
[50397] | 116 | CHECK_ERROR(pVBox, COMGETTER(SettingsFilePath)(bstrTmp.asOutParam()));
|
---|
[95140] | 117 | if (SUCCEEDED(hrc))
|
---|
[50390] | 118 | RTTestPassed(g_hTest, "IVirtualBox::settingsFilePath");
|
---|
| 119 | else
|
---|
[50397] | 120 | RTTestFailed(g_hTest, "%d: IVirtualBox::settingsFilePath failed", __LINE__);
|
---|
[50390] | 121 |
|
---|
| 122 | com::SafeIfaceArray<IGuestOSType> guestOSTypes;
|
---|
| 123 | RTTestSub(g_hTest, "IVirtualBox::guestOSTypes");
|
---|
[50397] | 124 | CHECK_ERROR(pVBox, COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(guestOSTypes)));
|
---|
[95140] | 125 | if (SUCCEEDED(hrc))
|
---|
[50390] | 126 | RTTestPassed(g_hTest, "IVirtualBox::guestOSTypes");
|
---|
| 127 | else
|
---|
[50397] | 128 | RTTestFailed(g_hTest, "%d: IVirtualBox::guestOSTypes failed", __LINE__);
|
---|
[50390] | 129 |
|
---|
[101035] | 130 | /* For now we only test same-same architectures (host == guest). */
|
---|
| 131 | PlatformArchitecture_T enmPlatformArch;
|
---|
| 132 | #if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
|
---|
| 133 | enmPlatformArch = PlatformArchitecture_x86;
|
---|
| 134 | #elif defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64)
|
---|
| 135 | enmPlatformArch = PlatformArchitecture_ARM;
|
---|
| 136 | #else
|
---|
| 137 | # error "Port me!"
|
---|
| 138 | #endif
|
---|
| 139 |
|
---|
| 140 | /*
|
---|
| 141 | * Host
|
---|
| 142 | */
|
---|
| 143 | ComPtr<IHost> host;
|
---|
| 144 | RTTestSub(g_hTest, "IVirtualBox::host");
|
---|
| 145 | CHECK_ERROR(pVBox, COMGETTER(Host)(host.asOutParam()));
|
---|
| 146 | if (SUCCEEDED(hrc))
|
---|
| 147 | {
|
---|
| 148 | RTTestPassed(g_hTest, "IVirtualBox::host");
|
---|
| 149 | CHECK_ERROR(host, COMGETTER(Architecture)(&enmPlatformArch));
|
---|
| 150 |
|
---|
| 151 | switch (enmPlatformArch)
|
---|
| 152 | {
|
---|
| 153 | case PlatformArchitecture_x86:
|
---|
| 154 | {
|
---|
| 155 | ComPtr<IHostX86> hostX86;
|
---|
| 156 | CHECK_ERROR(host, COMGETTER(X86)(hostX86.asOutParam()));
|
---|
| 157 | break;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | default:
|
---|
| 161 | break;
|
---|
| 162 | }
|
---|
| 163 | }
|
---|
| 164 | else
|
---|
| 165 | RTTestFailed(g_hTest, "%d: IVirtualBox::host failed", __LINE__);
|
---|
| 166 |
|
---|
| 167 | ComPtr<ISystemProperties> sysprop;
|
---|
| 168 | RTTestSub(g_hTest, "IVirtualBox::systemProperties");
|
---|
| 169 | CHECK_ERROR(pVBox, COMGETTER(SystemProperties)(sysprop.asOutParam()));
|
---|
| 170 | if (SUCCEEDED(hrc))
|
---|
| 171 | {
|
---|
| 172 | RTTestPassed(g_hTest, "IVirtualBox::systemProperties");
|
---|
| 173 |
|
---|
| 174 | RTTestSub(g_hTest, "IVirtualBox::platform::::platformProperties");
|
---|
| 175 | ComPtr<IPlatformProperties> platformprop;
|
---|
| 176 | CHECK_ERROR(sysprop, COMGETTER(Platform)(platformprop.asOutParam()));
|
---|
| 177 | BOOL fTemp;
|
---|
| 178 | CHECK_ERROR(platformprop, COMGETTER(ExclusiveHwVirt)(&fTemp));
|
---|
| 179 | ULONG ulTemp;
|
---|
| 180 | CHECK_ERROR(platformprop, GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulTemp));
|
---|
| 181 | }
|
---|
| 182 | else
|
---|
| 183 | RTTestFailed(g_hTest, "%d: IVirtualBox::systemProperties failed", __LINE__);
|
---|
| 184 |
|
---|
| 185 | /*
|
---|
| 186 | * VM
|
---|
| 187 | */
|
---|
[50390] | 188 | RTTestSub(g_hTest, "IVirtualBox::CreateMachine");
|
---|
| 189 | ComPtr<IMachine> ptrMachine;
|
---|
| 190 | com::SafeArray<BSTR> groups;
|
---|
| 191 | /** Default VM settings */
|
---|
[50397] | 192 | CHECK_ERROR(pVBox, CreateMachine(NULL, /** Settings */
|
---|
| 193 | tstMachineName.raw(), /** Name */
|
---|
[101035] | 194 | enmPlatformArch,
|
---|
[50397] | 195 | ComSafeArrayAsInParam(groups), /** Groups */
|
---|
| 196 | NULL, /** OS Type */
|
---|
| 197 | NULL, /** Create flags */
|
---|
[94660] | 198 | NULL, /** Cipher */
|
---|
| 199 | NULL, /** Password id */
|
---|
| 200 | NULL, /** Password */
|
---|
[50397] | 201 | ptrMachine.asOutParam())); /** Machine */
|
---|
[95140] | 202 | if (SUCCEEDED(hrc))
|
---|
[50390] | 203 | RTTestPassed(g_hTest, "IVirtualBox::CreateMachine");
|
---|
| 204 | else
|
---|
| 205 | {
|
---|
[50397] | 206 | RTTestFailed(g_hTest, "%d: IVirtualBox::CreateMachine failed", __LINE__);
|
---|
[101035] | 207 | return;
|
---|
[50390] | 208 | }
|
---|
| 209 |
|
---|
| 210 | RTTestSub(g_hTest, "IVirtualBox::RegisterMachine");
|
---|
[50397] | 211 | CHECK_ERROR(pVBox, RegisterMachine(ptrMachine));
|
---|
[95140] | 212 | if (SUCCEEDED(hrc))
|
---|
[50390] | 213 | RTTestPassed(g_hTest, "IVirtualBox::RegisterMachine");
|
---|
| 214 | else
|
---|
| 215 | {
|
---|
[50397] | 216 | RTTestFailed(g_hTest, "%d: IVirtualBox::RegisterMachine failed", __LINE__);
|
---|
[101035] | 217 | return;
|
---|
[50390] | 218 | }
|
---|
| 219 |
|
---|
| 220 | com::SafeIfaceArray<IMachine> machines;
|
---|
[101035] | 221 | RTTestSub(g_hTest, "IVirtualBox::machines2");
|
---|
[50397] | 222 | CHECK_ERROR(pVBox, COMGETTER(Machines)(ComSafeArrayAsOutParam(machines)));
|
---|
[95140] | 223 | if (SUCCEEDED(hrc))
|
---|
[50390] | 224 | {
|
---|
[101035] | 225 | bool fFound = FALSE;
|
---|
[50390] | 226 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
| 227 | {
|
---|
| 228 | if (machines[i])
|
---|
| 229 | {
|
---|
| 230 | Bstr tmpName;
|
---|
[95140] | 231 | hrc = machines[i]->COMGETTER(Name)(tmpName.asOutParam());
|
---|
| 232 | if (SUCCEEDED(hrc))
|
---|
[50390] | 233 | {
|
---|
| 234 | if (tmpName == tstMachineName)
|
---|
| 235 | {
|
---|
[101035] | 236 | fFound = TRUE;
|
---|
[50390] | 237 | break;
|
---|
| 238 | }
|
---|
| 239 | }
|
---|
| 240 | }
|
---|
| 241 | }
|
---|
| 242 |
|
---|
[101035] | 243 | if (fFound)
|
---|
[50390] | 244 | RTTestPassed(g_hTest, "IVirtualBox::machines");
|
---|
| 245 | else
|
---|
| 246 | RTTestFailed(g_hTest, "%d: IVirtualBox::machines failed. No created machine found", __LINE__);
|
---|
| 247 | }
|
---|
| 248 | else
|
---|
[50397] | 249 | RTTestFailed(g_hTest, "%d: IVirtualBox::machines failed", __LINE__);
|
---|
[50390] | 250 |
|
---|
[101035] | 251 | RTTestSub(g_hTest, "IMachine::FirmwareSettings");
|
---|
| 252 | ComPtr<IFirmwareSettings> ptrFirmwareSettings;
|
---|
| 253 | CHECK_ERROR(ptrMachine, COMGETTER(FirmwareSettings)(ptrFirmwareSettings.asOutParam()));
|
---|
| 254 | FirmwareType_T firmwareType;
|
---|
| 255 | CHECK_ERROR(ptrFirmwareSettings, COMGETTER(FirmwareType)(&firmwareType));
|
---|
| 256 |
|
---|
| 257 | // CHECK_ERROR(ptrMachine, LockMachine());
|
---|
| 258 | // RTTestSub(g_hTest, "IMachine::saveSettings");
|
---|
| 259 | // CHECK_ERROR(ptrMachine, SaveSettings());
|
---|
| 260 |
|
---|
| 261 | Bstr bstSettingsFile;
|
---|
| 262 | CHECK_ERROR(ptrMachine, COMGETTER(SettingsFilePath)(bstSettingsFile.asOutParam()));
|
---|
| 263 | RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Settings file: %ls\n", bstSettingsFile.raw());
|
---|
| 264 | // CHECK_ERROR(ptrMachine, UnlockMachine());
|
---|
| 265 |
|
---|
[50390] | 266 | #if 0 /** Not yet implemented */
|
---|
| 267 | com::SafeIfaceArray<ISharedFolder> sharedFolders;
|
---|
| 268 | RTTestSub(g_hTest, "IVirtualBox::sharedFolders");
|
---|
[50397] | 269 | CHECK_ERROR(pVBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sharedFolders)));
|
---|
| 270 | if (SUCCEEDED(rc))
|
---|
[50390] | 271 | {
|
---|
| 272 | /** @todo Add ISharedFolders testing here. */
|
---|
| 273 | RTTestPassed(g_hTest, "IVirtualBox::sharedFolders");
|
---|
| 274 | }
|
---|
| 275 | else
|
---|
[50397] | 276 | RTTestFailed(g_hTest, "%d: IVirtualBox::sharedFolders failed", __LINE__);
|
---|
[50390] | 277 | #endif
|
---|
| 278 |
|
---|
| 279 | com::SafeIfaceArray<IMedium> hardDisks;
|
---|
| 280 | RTTestSub(g_hTest, "IVirtualBox::hardDisks");
|
---|
[50397] | 281 | CHECK_ERROR(pVBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hardDisks)));
|
---|
[95140] | 282 | if (SUCCEEDED(hrc))
|
---|
[50390] | 283 | {
|
---|
| 284 | /** @todo Add hardDisks testing here. */
|
---|
| 285 | RTTestPassed(g_hTest, "IVirtualBox::hardDisks");
|
---|
| 286 | }
|
---|
| 287 | else
|
---|
[50397] | 288 | RTTestFailed(g_hTest, "%d: IVirtualBox::hardDisks failed", __LINE__);
|
---|
[50390] | 289 |
|
---|
| 290 | com::SafeIfaceArray<IMedium> DVDImages;
|
---|
| 291 | RTTestSub(g_hTest, "IVirtualBox::DVDImages");
|
---|
[50397] | 292 | CHECK_ERROR(pVBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(DVDImages)));
|
---|
[95140] | 293 | if (SUCCEEDED(hrc))
|
---|
[50390] | 294 | {
|
---|
| 295 | /** @todo Add DVDImages testing here. */
|
---|
| 296 | RTTestPassed(g_hTest, "IVirtualBox::DVDImages");
|
---|
| 297 | }
|
---|
| 298 | else
|
---|
[50397] | 299 | RTTestFailed(g_hTest, "%d: IVirtualBox::DVDImages failed", __LINE__);
|
---|
[50390] | 300 |
|
---|
| 301 | com::SafeIfaceArray<IMedium> floppyImages;
|
---|
| 302 | RTTestSub(g_hTest, "IVirtualBox::floppyImages");
|
---|
[50397] | 303 | CHECK_ERROR(pVBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppyImages)));
|
---|
[95140] | 304 | if (SUCCEEDED(hrc))
|
---|
[50390] | 305 | {
|
---|
| 306 | /** @todo Add floppyImages testing here. */
|
---|
| 307 | RTTestPassed(g_hTest, "IVirtualBox::floppyImages");
|
---|
| 308 | }
|
---|
| 309 | else
|
---|
[50397] | 310 | RTTestFailed(g_hTest, "%d: IVirtualBox::floppyImages failed", __LINE__);
|
---|
[50390] | 311 |
|
---|
| 312 | com::SafeIfaceArray<IProgress> progressOperations;
|
---|
| 313 | RTTestSub(g_hTest, "IVirtualBox::progressOperations");
|
---|
[50397] | 314 | CHECK_ERROR(pVBox, COMGETTER(ProgressOperations)(ComSafeArrayAsOutParam(progressOperations)));
|
---|
[95140] | 315 | if (SUCCEEDED(hrc))
|
---|
[50390] | 316 | {
|
---|
| 317 | /** @todo Add IProgress testing here. */
|
---|
| 318 | RTTestPassed(g_hTest, "IVirtualBox::progressOperations");
|
---|
| 319 | }
|
---|
| 320 | else
|
---|
[50397] | 321 | RTTestFailed(g_hTest, "%d: IVirtualBox::progressOperations failed", __LINE__);
|
---|
[50390] | 322 |
|
---|
| 323 | ComPtr<IPerformanceCollector> performanceCollector;
|
---|
| 324 | RTTestSub(g_hTest, "IVirtualBox::performanceCollector");
|
---|
[50397] | 325 | CHECK_ERROR(pVBox, COMGETTER(PerformanceCollector)(performanceCollector.asOutParam()));
|
---|
[95140] | 326 | if (SUCCEEDED(hrc))
|
---|
[50390] | 327 | {
|
---|
| 328 | /** @todo Add IPerformanceCollector testing here. */
|
---|
| 329 | RTTestPassed(g_hTest, "IVirtualBox::performanceCollector");
|
---|
| 330 | }
|
---|
| 331 | else
|
---|
[50397] | 332 | RTTestFailed(g_hTest, "%d: IVirtualBox::performanceCollector failed", __LINE__);
|
---|
[50390] | 333 |
|
---|
| 334 | com::SafeIfaceArray<IDHCPServer> DHCPServers;
|
---|
| 335 | RTTestSub(g_hTest, "IVirtualBox::DHCPServers");
|
---|
[50397] | 336 | CHECK_ERROR(pVBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers)));
|
---|
[95140] | 337 | if (SUCCEEDED(hrc))
|
---|
[50390] | 338 | {
|
---|
| 339 | /** @todo Add IDHCPServers testing here. */
|
---|
| 340 | RTTestPassed(g_hTest, "IVirtualBox::DHCPServers");
|
---|
| 341 | }
|
---|
| 342 | else
|
---|
[50397] | 343 | RTTestFailed(g_hTest, "%d: IVirtualBox::DHCPServers failed", __LINE__);
|
---|
[50390] | 344 |
|
---|
| 345 | com::SafeIfaceArray<INATNetwork> NATNetworks;
|
---|
| 346 | RTTestSub(g_hTest, "IVirtualBox::NATNetworks");
|
---|
[50397] | 347 | CHECK_ERROR(pVBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(NATNetworks)));
|
---|
[95140] | 348 | if (SUCCEEDED(hrc))
|
---|
[50390] | 349 | {
|
---|
| 350 | /** @todo Add INATNetworks testing here. */
|
---|
| 351 | RTTestPassed(g_hTest, "IVirtualBox::NATNetworks");
|
---|
| 352 | }
|
---|
| 353 | else
|
---|
[50397] | 354 | RTTestFailed(g_hTest, "%d: IVirtualBox::NATNetworks failed", __LINE__);
|
---|
[50390] | 355 |
|
---|
| 356 | ComPtr<IEventSource> eventSource;
|
---|
| 357 | RTTestSub(g_hTest, "IVirtualBox::eventSource");
|
---|
[50397] | 358 | CHECK_ERROR(pVBox, COMGETTER(EventSource)(eventSource.asOutParam()));
|
---|
[95140] | 359 | if (SUCCEEDED(hrc))
|
---|
[50390] | 360 | {
|
---|
| 361 | /** @todo Add IEventSource testing here. */
|
---|
| 362 | RTTestPassed(g_hTest, "IVirtualBox::eventSource");
|
---|
| 363 | }
|
---|
| 364 | else
|
---|
[50397] | 365 | RTTestFailed(g_hTest, "%d: IVirtualBox::eventSource failed", __LINE__);
|
---|
[50390] | 366 |
|
---|
| 367 | ComPtr<IExtPackManager> extensionPackManager;
|
---|
| 368 | RTTestSub(g_hTest, "IVirtualBox::extensionPackManager");
|
---|
[50397] | 369 | CHECK_ERROR(pVBox, COMGETTER(ExtensionPackManager)(extensionPackManager.asOutParam()));
|
---|
[95140] | 370 | if (SUCCEEDED(hrc))
|
---|
[50390] | 371 | {
|
---|
| 372 | /** @todo Add IExtPackManager testing here. */
|
---|
| 373 | RTTestPassed(g_hTest, "IVirtualBox::extensionPackManager");
|
---|
| 374 | }
|
---|
| 375 | else
|
---|
[50397] | 376 | RTTestFailed(g_hTest, "%d: IVirtualBox::extensionPackManager failed", __LINE__);
|
---|
[50390] | 377 |
|
---|
| 378 | com::SafeArray<BSTR> internalNetworks;
|
---|
| 379 | RTTestSub(g_hTest, "IVirtualBox::internalNetworks");
|
---|
[50397] | 380 | CHECK_ERROR(pVBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks)));
|
---|
[95140] | 381 | if (SUCCEEDED(hrc))
|
---|
[50390] | 382 | {
|
---|
| 383 | RTTestPassed(g_hTest, "IVirtualBox::internalNetworks");
|
---|
| 384 | }
|
---|
| 385 | else
|
---|
[50397] | 386 | RTTestFailed(g_hTest, "%d: IVirtualBox::internalNetworks failed", __LINE__);
|
---|
[50390] | 387 |
|
---|
| 388 | com::SafeArray<BSTR> genericNetworkDrivers;
|
---|
| 389 | RTTestSub(g_hTest, "IVirtualBox::genericNetworkDrivers");
|
---|
[50397] | 390 | CHECK_ERROR(pVBox, COMGETTER(GenericNetworkDrivers)(ComSafeArrayAsOutParam(genericNetworkDrivers)));
|
---|
[95140] | 391 | if (SUCCEEDED(hrc))
|
---|
[50390] | 392 | {
|
---|
| 393 | RTTestPassed(g_hTest, "IVirtualBox::genericNetworkDrivers");
|
---|
| 394 | }
|
---|
| 395 | else
|
---|
[50397] | 396 | RTTestFailed(g_hTest, "%d: IVirtualBox::genericNetworkDrivers failed", __LINE__);
|
---|
[50439] | 397 | }
|
---|
| 398 |
|
---|
| 399 |
|
---|
[101035] | 400 | static void tstApiClean(IVirtualBox *pVBox)
|
---|
[50439] | 401 | {
|
---|
[95140] | 402 | HRESULT hrc;
|
---|
[50439] | 403 |
|
---|
[50397] | 404 | /** Delete created VM and its files */
|
---|
| 405 | ComPtr<IMachine> machine;
|
---|
[101035] | 406 | CHECK_ERROR(pVBox, FindMachine(Bstr(tstMachineName).raw(), machine.asOutParam()));
|
---|
[50397] | 407 | SafeIfaceArray<IMedium> media;
|
---|
[101035] | 408 | CHECK_ERROR(machine, Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(media)));
|
---|
[50397] | 409 | ComPtr<IProgress> progress;
|
---|
[101035] | 410 | CHECK_ERROR(machine, DeleteConfig(ComSafeArrayAsInParam(media), progress.asOutParam()));
|
---|
| 411 | CHECK_ERROR(progress, WaitForCompletion(-1));
|
---|
[50390] | 412 | }
|
---|
| 413 |
|
---|
| 414 |
|
---|
[63258] | 415 | int main()
|
---|
[50390] | 416 | {
|
---|
| 417 | /*
|
---|
| 418 | * Initialization.
|
---|
| 419 | */
|
---|
| 420 | RTEXITCODE rcExit = RTTestInitAndCreate("tstVBoxAPI", &g_hTest);
|
---|
| 421 | if (rcExit != RTEXITCODE_SUCCESS)
|
---|
| 422 | return rcExit;
|
---|
| 423 | SUPR3Init(NULL); /* Better time support. */
|
---|
| 424 | RTTestBanner(g_hTest);
|
---|
| 425 |
|
---|
| 426 | RTTestSub(g_hTest, "Initializing COM and singletons");
|
---|
| 427 | HRESULT hrc = com::Initialize();
|
---|
| 428 | if (SUCCEEDED(hrc))
|
---|
| 429 | {
|
---|
[60063] | 430 | ComPtr<IVirtualBoxClient> ptrVBoxClient;
|
---|
[50390] | 431 | ComPtr<IVirtualBox> ptrVBox;
|
---|
[60063] | 432 | hrc = TST_COM_EXPR(ptrVBoxClient.createInprocObject(CLSID_VirtualBoxClient));
|
---|
[50390] | 433 | if (SUCCEEDED(hrc))
|
---|
[60063] | 434 | hrc = TST_COM_EXPR(ptrVBoxClient->COMGETTER(VirtualBox)(ptrVBox.asOutParam()));
|
---|
| 435 | if (SUCCEEDED(hrc))
|
---|
[50390] | 436 | {
|
---|
| 437 | ComPtr<ISession> ptrSession;
|
---|
| 438 | hrc = TST_COM_EXPR(ptrSession.createInprocObject(CLSID_Session));
|
---|
| 439 | if (SUCCEEDED(hrc))
|
---|
| 440 | {
|
---|
| 441 | RTTestSubDone(g_hTest);
|
---|
| 442 |
|
---|
| 443 | /*
|
---|
| 444 | * Call test functions.
|
---|
| 445 | */
|
---|
| 446 |
|
---|
| 447 | /** Test IVirtualBox interface */
|
---|
| 448 | tstApiIVirtualBox(ptrVBox);
|
---|
[50439] | 449 |
|
---|
| 450 | /** Clean files/configs */
|
---|
| 451 | tstApiClean(ptrVBox);
|
---|
[50390] | 452 | }
|
---|
| 453 | }
|
---|
| 454 |
|
---|
| 455 | ptrVBox.setNull();
|
---|
[60924] | 456 | ptrVBoxClient.setNull();
|
---|
[50390] | 457 | com::Shutdown();
|
---|
| 458 | }
|
---|
| 459 | else
|
---|
| 460 | RTTestIFailed("com::Initialize failed with hrc=%Rhrc", hrc);
|
---|
| 461 | return RTTestSummaryAndDestroy(g_hTest);
|
---|
| 462 | }
|
---|