Changeset 95140 in vbox for trunk/src/VBox/Main/testcase
- Timestamp:
- May 31, 2022 9:11:39 AM (3 years ago)
- Location:
- trunk/src/VBox/Main/testcase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstAPI.cpp
r93115 r95140 57 57 HRESULT readAndChangeMachineSettings(IMachine *machine, IMachine *readonlyMachine = 0) 58 58 { 59 HRESULT rc = S_OK;59 HRESULT hrc = S_OK; 60 60 61 61 Bstr name; 62 62 RTPrintf("Getting machine name...\n"); 63 CHECK_ERROR_RET(machine, COMGETTER(Name)(name.asOutParam()), rc);63 CHECK_ERROR_RET(machine, COMGETTER(Name)(name.asOutParam()), hrc); 64 64 RTPrintf("Name: {%ls}\n", name.raw()); 65 65 … … 67 67 Bstr guid; 68 68 CHECK_ERROR(machine, COMGETTER(Id)(guid.asOutParam())); 69 if (SUCCEEDED( rc) && !guid.isEmpty()) {69 if (SUCCEEDED(hrc) && !guid.isEmpty()) { 70 70 RTPrintf("Guid::toString(): {%s}\n", Utf8Str(guid).c_str()); 71 71 } else { … … 75 75 ULONG memorySize; 76 76 RTPrintf("Getting memory size...\n"); 77 CHECK_ERROR_RET(machine, COMGETTER(MemorySize)(&memorySize), rc);77 CHECK_ERROR_RET(machine, COMGETTER(MemorySize)(&memorySize), hrc); 78 78 RTPrintf("Memory size: %d\n", memorySize); 79 79 80 80 MachineState_T machineState; 81 81 RTPrintf("Getting machine state...\n"); 82 CHECK_ERROR_RET(machine, COMGETTER(State)(&machineState), rc);82 CHECK_ERROR_RET(machine, COMGETTER(State)(&machineState), hrc); 83 83 RTPrintf("Machine state: %d\n", machineState); 84 84 … … 86 86 RTPrintf("Are any settings modified?...\n"); 87 87 CHECK_ERROR(machine, COMGETTER(SettingsModified)(&modified)); 88 if (SUCCEEDED( rc))88 if (SUCCEEDED(hrc)) 89 89 RTPrintf("%s\n", modified ? "yes" : "no"); 90 90 … … 93 93 CHECK_ERROR(machine, COMSETTER(MemorySize)(memorySizeBig)); 94 94 95 if (SUCCEEDED( rc))95 if (SUCCEEDED(hrc)) 96 96 { 97 97 RTPrintf("Are any settings modified now?...\n"); 98 CHECK_ERROR_RET(machine, COMGETTER(SettingsModified)(&modified), rc);98 CHECK_ERROR_RET(machine, COMGETTER(SettingsModified)(&modified), hrc); 99 99 RTPrintf("%s\n", modified ? "yes" : "no"); 100 100 ASSERT_RET(modified, 0); … … 102 102 ULONG memorySizeGot; 103 103 RTPrintf("Getting memory size again...\n"); 104 CHECK_ERROR_RET(machine, COMGETTER(MemorySize)(&memorySizeGot), rc);104 CHECK_ERROR_RET(machine, COMGETTER(MemorySize)(&memorySizeGot), hrc); 105 105 RTPrintf("Memory size: %d\n", memorySizeGot); 106 106 ASSERT_RET(memorySizeGot == memorySizeBig, 0); … … 116 116 117 117 RTPrintf("Discarding recent changes...\n"); 118 CHECK_ERROR_RET(machine, DiscardSettings(), rc);118 CHECK_ERROR_RET(machine, DiscardSettings(), hrc); 119 119 RTPrintf("Are any settings modified after discarding?...\n"); 120 CHECK_ERROR_RET(machine, COMGETTER(SettingsModified)(&modified), rc);120 CHECK_ERROR_RET(machine, COMGETTER(SettingsModified)(&modified), hrc); 121 121 RTPrintf("%s\n", modified ? "yes" : "no"); 122 122 ASSERT_RET(!modified, 0); 123 123 124 124 RTPrintf("Getting memory size once more...\n"); 125 CHECK_ERROR_RET(machine, COMGETTER(MemorySize)(&memorySizeGot), rc);125 CHECK_ERROR_RET(machine, COMGETTER(MemorySize)(&memorySizeGot), hrc); 126 126 RTPrintf("Memory size: %d\n", memorySizeGot); 127 127 ASSERT_RET(memorySizeGot == memorySize, 0); … … 129 129 memorySize = memorySize > 128 ? memorySize / 2 : memorySize * 2; 130 130 RTPrintf("Changing memory size to %d...\n", memorySize); 131 CHECK_ERROR_RET(machine, COMSETTER(MemorySize)(memorySize), rc);131 CHECK_ERROR_RET(machine, COMSETTER(MemorySize)(memorySize), hrc); 132 132 } 133 133 134 134 Bstr desc; 135 135 RTPrintf("Getting description...\n"); 136 CHECK_ERROR_RET(machine, COMGETTER(Description)(desc.asOutParam()), rc);136 CHECK_ERROR_RET(machine, COMGETTER(Description)(desc.asOutParam()), hrc); 137 137 RTPrintf("Description is: \"%ls\"\n", desc.raw()); 138 138 139 139 desc = L"This is an exemplary description (changed)."; 140 140 RTPrintf("Setting description to \"%ls\"...\n", desc.raw()); 141 CHECK_ERROR_RET(machine, COMSETTER(Description)(desc.raw()), rc);141 CHECK_ERROR_RET(machine, COMSETTER(Description)(desc.raw()), hrc); 142 142 143 143 RTPrintf("Saving machine settings...\n"); 144 144 CHECK_ERROR(machine, SaveSettings()); 145 if (SUCCEEDED( rc))145 if (SUCCEEDED(hrc)) 146 146 { 147 147 RTPrintf("Are any settings modified after saving?...\n"); 148 CHECK_ERROR_RET(machine, COMGETTER(SettingsModified)(&modified), rc);148 CHECK_ERROR_RET(machine, COMGETTER(SettingsModified)(&modified), hrc); 149 149 RTPrintf("%s\n", modified ? "yes" : "no"); 150 150 ASSERT_RET(!modified, 0); … … 162 162 Bstr extraData; 163 163 RTPrintf("Getting extra data key {%ls}...\n", extraDataKey.raw()); 164 CHECK_ERROR_RET(machine, GetExtraData(extraDataKey.raw(), extraData.asOutParam()), rc);164 CHECK_ERROR_RET(machine, GetExtraData(extraDataKey.raw(), extraData.asOutParam()), hrc); 165 165 if (!extraData.isEmpty()) { 166 166 RTPrintf("Extra data value: {%ls}\n", extraData.raw()); … … 177 177 CHECK_ERROR(machine, SetExtraData(extraDataKey.raw(), extraData.raw())); 178 178 179 if (SUCCEEDED( rc)) {179 if (SUCCEEDED(hrc)) { 180 180 RTPrintf("Getting extra data key {%ls} again...\n", extraDataKey.raw()); 181 CHECK_ERROR_RET(machine, GetExtraData(extraDataKey.raw(), extraData.asOutParam()), rc);181 CHECK_ERROR_RET(machine, GetExtraData(extraDataKey.raw(), extraData.asOutParam()), hrc); 182 182 if (!extraData.isEmpty()) { 183 183 RTPrintf("Extra data value: {%ls}\n", extraData.raw()); … … 187 187 } 188 188 189 return rc;189 return hrc; 190 190 } 191 191 … … 201 201 RTR3InitExe(argc, &argv, 0); 202 202 203 HRESULT rc;203 HRESULT hrc; 204 204 205 205 { … … 211 211 RTPrintf("Initializing COM...\n"); 212 212 213 rc = com::Initialize();214 if (FAILED( rc))213 hrc = com::Initialize(); 214 if (FAILED(hrc)) 215 215 { 216 216 RTPrintf("ERROR: failed to initialize COM!\n"); 217 return rc;217 return hrc; 218 218 } 219 219 … … 243 243 244 244 RTPrintf("Creating VirtualBox object...\n"); 245 rc = virtualBoxClient.createInprocObject(CLSID_VirtualBoxClient);246 if (SUCCEEDED( rc))247 rc = virtualBoxClient->COMGETTER(VirtualBox)(virtualBox.asOutParam());248 if (FAILED( rc))245 hrc = virtualBoxClient.createInprocObject(CLSID_VirtualBoxClient); 246 if (SUCCEEDED(hrc)) 247 hrc = virtualBoxClient->COMGETTER(VirtualBox)(virtualBox.asOutParam()); 248 if (FAILED(hrc)) 249 249 RTPrintf("ERROR: failed to create the VirtualBox object!\n"); 250 250 else 251 251 { 252 rc = session.createInprocObject(CLSID_Session);253 if (FAILED( rc))252 hrc = session.createInprocObject(CLSID_Session); 253 if (FAILED(hrc)) 254 254 RTPrintf("ERROR: failed to create a session object!\n"); 255 255 } 256 256 257 if (FAILED( rc))257 if (FAILED(hrc)) 258 258 { 259 259 com::ErrorInfo info; 260 260 if (!info.isFullAvailable() && !info.isBasicAvailable()) 261 261 { 262 com::GluePrintRCMessage( rc);262 com::GluePrintRCMessage(hrc); 263 263 RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n"); 264 264 } … … 1592 1592 RTPrintf("tstAPI FINISHED.\n"); 1593 1593 1594 return rc;1594 return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 1595 1595 } 1596 1596 -
trunk/src/VBox/Main/testcase/tstVBoxAPI.cpp
r94660 r95140 57 57 static BOOL tstApiIVirtualBox(IVirtualBox *pVBox) 58 58 { 59 HRESULT rc;59 HRESULT hrc; 60 60 Bstr bstrTmp; 61 61 ULONG ulTmp; … … 63 63 RTTestSub(g_hTest, "IVirtualBox::version"); 64 64 CHECK_ERROR(pVBox, COMGETTER(Version)(bstrTmp.asOutParam())); 65 if (SUCCEEDED( rc))65 if (SUCCEEDED(hrc)) 66 66 RTTestPassed(g_hTest, "IVirtualBox::version"); 67 67 else … … 70 70 RTTestSub(g_hTest, "IVirtualBox::versionNormalized"); 71 71 CHECK_ERROR(pVBox, COMGETTER(VersionNormalized)(bstrTmp.asOutParam())); 72 if (SUCCEEDED( rc))72 if (SUCCEEDED(hrc)) 73 73 RTTestPassed(g_hTest, "IVirtualBox::versionNormalized"); 74 74 else … … 77 77 RTTestSub(g_hTest, "IVirtualBox::revision"); 78 78 CHECK_ERROR(pVBox, COMGETTER(Revision)(&ulTmp)); 79 if (SUCCEEDED( rc))79 if (SUCCEEDED(hrc)) 80 80 RTTestPassed(g_hTest, "IVirtualBox::revision"); 81 81 else … … 84 84 RTTestSub(g_hTest, "IVirtualBox::packageType"); 85 85 CHECK_ERROR(pVBox, COMGETTER(PackageType)(bstrTmp.asOutParam())); 86 if (SUCCEEDED( rc))86 if (SUCCEEDED(hrc)) 87 87 RTTestPassed(g_hTest, "IVirtualBox::packageType"); 88 88 else … … 91 91 RTTestSub(g_hTest, "IVirtualBox::APIVersion"); 92 92 CHECK_ERROR(pVBox, COMGETTER(APIVersion)(bstrTmp.asOutParam())); 93 if (SUCCEEDED( rc))93 if (SUCCEEDED(hrc)) 94 94 RTTestPassed(g_hTest, "IVirtualBox::APIVersion"); 95 95 else … … 98 98 RTTestSub(g_hTest, "IVirtualBox::homeFolder"); 99 99 CHECK_ERROR(pVBox, COMGETTER(HomeFolder)(bstrTmp.asOutParam())); 100 if (SUCCEEDED( rc))100 if (SUCCEEDED(hrc)) 101 101 RTTestPassed(g_hTest, "IVirtualBox::homeFolder"); 102 102 else … … 105 105 RTTestSub(g_hTest, "IVirtualBox::settingsFilePath"); 106 106 CHECK_ERROR(pVBox, COMGETTER(SettingsFilePath)(bstrTmp.asOutParam())); 107 if (SUCCEEDED( rc))107 if (SUCCEEDED(hrc)) 108 108 RTTestPassed(g_hTest, "IVirtualBox::settingsFilePath"); 109 109 else … … 113 113 RTTestSub(g_hTest, "IVirtualBox::guestOSTypes"); 114 114 CHECK_ERROR(pVBox, COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(guestOSTypes))); 115 if (SUCCEEDED( rc))115 if (SUCCEEDED(hrc)) 116 116 RTTestPassed(g_hTest, "IVirtualBox::guestOSTypes"); 117 117 else … … 132 132 NULL, /** Password */ 133 133 ptrMachine.asOutParam())); /** Machine */ 134 if (SUCCEEDED( rc))134 if (SUCCEEDED(hrc)) 135 135 RTTestPassed(g_hTest, "IVirtualBox::CreateMachine"); 136 136 else … … 142 142 RTTestSub(g_hTest, "IVirtualBox::RegisterMachine"); 143 143 CHECK_ERROR(pVBox, RegisterMachine(ptrMachine)); 144 if (SUCCEEDED( rc))144 if (SUCCEEDED(hrc)) 145 145 RTTestPassed(g_hTest, "IVirtualBox::RegisterMachine"); 146 146 else … … 153 153 RTTestSub(g_hTest, "IVirtualBox::host"); 154 154 CHECK_ERROR(pVBox, COMGETTER(Host)(host.asOutParam())); 155 if (SUCCEEDED( rc))155 if (SUCCEEDED(hrc)) 156 156 { 157 157 /** @todo Add IHost testing here. */ … … 164 164 RTTestSub(g_hTest, "IVirtualBox::systemProperties"); 165 165 CHECK_ERROR(pVBox, COMGETTER(SystemProperties)(sysprop.asOutParam())); 166 if (SUCCEEDED( rc))166 if (SUCCEEDED(hrc)) 167 167 { 168 168 /** @todo Add ISystemProperties testing here. */ … … 175 175 RTTestSub(g_hTest, "IVirtualBox::machines"); 176 176 CHECK_ERROR(pVBox, COMGETTER(Machines)(ComSafeArrayAsOutParam(machines))); 177 if (SUCCEEDED( rc))177 if (SUCCEEDED(hrc)) 178 178 { 179 179 bool bFound = FALSE; … … 183 183 { 184 184 Bstr tmpName; 185 rc = machines[i]->COMGETTER(Name)(tmpName.asOutParam());186 if (SUCCEEDED( rc))185 hrc = machines[i]->COMGETTER(Name)(tmpName.asOutParam()); 186 if (SUCCEEDED(hrc)) 187 187 { 188 188 if (tmpName == tstMachineName) … … 219 219 RTTestSub(g_hTest, "IVirtualBox::hardDisks"); 220 220 CHECK_ERROR(pVBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hardDisks))); 221 if (SUCCEEDED( rc))221 if (SUCCEEDED(hrc)) 222 222 { 223 223 /** @todo Add hardDisks testing here. */ … … 230 230 RTTestSub(g_hTest, "IVirtualBox::DVDImages"); 231 231 CHECK_ERROR(pVBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(DVDImages))); 232 if (SUCCEEDED( rc))232 if (SUCCEEDED(hrc)) 233 233 { 234 234 /** @todo Add DVDImages testing here. */ … … 241 241 RTTestSub(g_hTest, "IVirtualBox::floppyImages"); 242 242 CHECK_ERROR(pVBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppyImages))); 243 if (SUCCEEDED( rc))243 if (SUCCEEDED(hrc)) 244 244 { 245 245 /** @todo Add floppyImages testing here. */ … … 252 252 RTTestSub(g_hTest, "IVirtualBox::progressOperations"); 253 253 CHECK_ERROR(pVBox, COMGETTER(ProgressOperations)(ComSafeArrayAsOutParam(progressOperations))); 254 if (SUCCEEDED( rc))254 if (SUCCEEDED(hrc)) 255 255 { 256 256 /** @todo Add IProgress testing here. */ … … 263 263 RTTestSub(g_hTest, "IVirtualBox::performanceCollector"); 264 264 CHECK_ERROR(pVBox, COMGETTER(PerformanceCollector)(performanceCollector.asOutParam())); 265 if (SUCCEEDED( rc))265 if (SUCCEEDED(hrc)) 266 266 { 267 267 /** @todo Add IPerformanceCollector testing here. */ … … 274 274 RTTestSub(g_hTest, "IVirtualBox::DHCPServers"); 275 275 CHECK_ERROR(pVBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers))); 276 if (SUCCEEDED( rc))276 if (SUCCEEDED(hrc)) 277 277 { 278 278 /** @todo Add IDHCPServers testing here. */ … … 285 285 RTTestSub(g_hTest, "IVirtualBox::NATNetworks"); 286 286 CHECK_ERROR(pVBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(NATNetworks))); 287 if (SUCCEEDED( rc))287 if (SUCCEEDED(hrc)) 288 288 { 289 289 /** @todo Add INATNetworks testing here. */ … … 296 296 RTTestSub(g_hTest, "IVirtualBox::eventSource"); 297 297 CHECK_ERROR(pVBox, COMGETTER(EventSource)(eventSource.asOutParam())); 298 if (SUCCEEDED( rc))298 if (SUCCEEDED(hrc)) 299 299 { 300 300 /** @todo Add IEventSource testing here. */ … … 307 307 RTTestSub(g_hTest, "IVirtualBox::extensionPackManager"); 308 308 CHECK_ERROR(pVBox, COMGETTER(ExtensionPackManager)(extensionPackManager.asOutParam())); 309 if (SUCCEEDED( rc))309 if (SUCCEEDED(hrc)) 310 310 { 311 311 /** @todo Add IExtPackManager testing here. */ … … 318 318 RTTestSub(g_hTest, "IVirtualBox::internalNetworks"); 319 319 CHECK_ERROR(pVBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks))); 320 if (SUCCEEDED( rc))320 if (SUCCEEDED(hrc)) 321 321 { 322 322 RTTestPassed(g_hTest, "IVirtualBox::internalNetworks"); … … 328 328 RTTestSub(g_hTest, "IVirtualBox::genericNetworkDrivers"); 329 329 CHECK_ERROR(pVBox, COMGETTER(GenericNetworkDrivers)(ComSafeArrayAsOutParam(genericNetworkDrivers))); 330 if (SUCCEEDED( rc))330 if (SUCCEEDED(hrc)) 331 331 { 332 332 RTTestPassed(g_hTest, "IVirtualBox::genericNetworkDrivers"); … … 341 341 static BOOL tstApiClean(IVirtualBox *pVBox) 342 342 { 343 HRESULT rc;343 HRESULT hrc; 344 344 345 345 /** Delete created VM and its files */
Note:
See TracChangeset
for help on using the changeset viewer.