Changeset 95143 in vbox
- Timestamp:
- May 31, 2022 9:40:45 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstVBoxMultipleVM.cpp
r95142 r95143 88 88 do { \ 89 89 hrc = iface->method; \ 90 if (FAILED( rc)) \91 RTPrintf("warning: %s->%s failed on line %u with hrc=%Rhrc\n", #iface, #method, __LINE__, rc);\90 if (FAILED(hrc)) \ 91 RTPrintf("warning: %s->%s failed on line %u with hrc=%Rhrc\n", #iface, #method, __LINE__, hrc);\ 92 92 } while (0) 93 93 … … 149 149 { 150 150 ComPtr<IMachine> machine; 151 HRESULT rc = TST_COM_EXPR(pVBox->FindMachine(machineID.raw(), machine.asOutParam()));152 if (SUCCEEDED( rc))151 HRESULT hrc = TST_COM_EXPR(pVBox->FindMachine(machineID.raw(), machine.asOutParam())); 152 if (SUCCEEDED(hrc)) 153 153 { 154 154 Bstr machineName; 155 rc = TST_COM_EXPR(machine->COMGETTER(Name)(machineName.asOutParam()));156 if (SUCCEEDED( rc))155 hrc = TST_COM_EXPR(machine->COMGETTER(Name)(machineName.asOutParam())); 156 if (SUCCEEDED(hrc)) 157 157 { 158 158 MachineState_T machineState; 159 rc = TST_COM_EXPR(machine->COMGETTER(State)(&machineState));159 hrc = TST_COM_EXPR(machine->COMGETTER(State)(&machineState)); 160 160 // check that machine is in running state 161 if ( SUCCEEDED( rc)161 if ( SUCCEEDED(hrc) 162 162 && ( machineState == MachineState_Running 163 163 || machineState == MachineState_Paused)) … … 166 166 ComPtr<IProgress> progress; 167 167 168 rc = TST_COM_EXPR(machine->LockMachine(pSession, LockType_Shared));169 if(SUCCEEDED( rc))168 hrc = TST_COM_EXPR(machine->LockMachine(pSession, LockType_Shared)); 169 if(SUCCEEDED(hrc)) 170 170 TST_COM_EXPR(pSession->COMGETTER(Console)(console.asOutParam())); 171 if(SUCCEEDED( rc))172 rc = console->PowerDown(progress.asOutParam());173 if (SUCCEEDED( rc) && !progress.isNull())171 if(SUCCEEDED(hrc)) 172 hrc = console->PowerDown(progress.asOutParam()); 173 if (SUCCEEDED(hrc) && !progress.isNull()) 174 174 { 175 175 //RTPrintf("Stopping VM %ls...\n", machineName.raw()); 176 176 CHECK_ERROR_L(progress, WaitForCompletion(-1)); 177 if (SUCCEEDED( rc))177 if (SUCCEEDED(hrc)) 178 178 { 179 179 BOOL completed = true; 180 180 CHECK_ERROR_L(progress, COMGETTER(Completed)(&completed)); 181 if (SUCCEEDED( rc))181 if (SUCCEEDED(hrc)) 182 182 { 183 183 //ASSERT(completed); 184 184 LONG iRc; 185 185 CHECK_ERROR_L(progress, COMGETTER(ResultCode)(&iRc)); 186 if (SUCCEEDED( rc))186 if (SUCCEEDED(hrc)) 187 187 { 188 188 if (FAILED(iRc)) … … 190 190 ProgressErrorInfo info(progress); 191 191 RTPrintf("Stop VM %ls failed. Warning: %ls.\n", machineName.raw(), info.getText().raw()); 192 rc = iRc;192 hrc = iRc; 193 193 } 194 194 else … … 207 207 } 208 208 } 209 return rc;209 return hrc; 210 210 } 211 211 … … 219 219 { 220 220 com::SafeIfaceArray<IMachine> machines; 221 HRESULT rc = TST_COM_EXPR(pVBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines)));222 if (SUCCEEDED( rc))221 HRESULT hrc = TST_COM_EXPR(pVBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines))); 222 if (SUCCEEDED(hrc)) 223 223 { 224 224 … … 233 233 Bstr machineName; 234 234 CHECK_ERROR_L(machines[idx], COMGETTER(Id)(bstrId.asOutParam())); 235 if (SUCCEEDED( rc))235 if (SUCCEEDED(hrc)) 236 236 CHECK_ERROR_L(machines[idx], COMGETTER(Name)(machineName.asOutParam())); 237 if (SUCCEEDED( rc))237 if (SUCCEEDED(hrc)) 238 238 { 239 239 if (Utf8Str(machineName).startsWith("umtvm")) … … 249 249 } 250 250 251 return rc;251 return hrc; 252 252 } 253 253 … … 255 255 static int tstMachinesPack(IVirtualBox *pVBox, uint32_t maxPackSize, uint32_t percentage) 256 256 { 257 HRESULT rc = S_OK;257 HRESULT hrc = S_OK; 258 258 TMachinesList machinesList; 259 259 bool alwaysUnlock = false; … … 277 277 { 278 278 ComPtr<ISession> session; 279 rc = session.createInprocObject(CLSID_Session);280 if (SUCCEEDED( rc))281 { 282 rc = tstStartVM(pVBox, session, *it, !(alwaysUnlock || g_Counter++ % percN));279 hrc = session.createInprocObject(CLSID_Session); 280 if (SUCCEEDED(hrc)) 281 { 282 hrc = tstStartVM(pVBox, session, *it, !(alwaysUnlock || g_Counter++ % percN)); 283 283 } 284 284 RTSemEventSignal(g_PingEevent); … … 291 291 { 292 292 ComPtr<ISession> session; 293 rc = session.createInprocObject(CLSID_Session);294 if (SUCCEEDED( rc))293 hrc = session.createInprocObject(CLSID_Session); 294 if (SUCCEEDED(hrc)) 295 295 { 296 296 // stop machines, skip session unlock of given % of machines 297 rc = tstStopVM(pVBox, session, *it, !(alwaysUnlock || g_Counter++ % percN));297 hrc = tstStopVM(pVBox, session, *it, !(alwaysUnlock || g_Counter++ % percN)); 298 298 } 299 299 RTSemEventSignal(g_PingEevent); 300 300 RTThreadSleep(100); 301 301 } 302 return rc;302 return hrc; 303 303 } 304 304 … … 314 314 static int tstCreateMachines(IVirtualBox *pVBox) 315 315 { 316 HRESULT rc = S_OK;316 HRESULT hrc = S_OK; 317 317 // create machines for the test 318 318 for (uint32_t i = 0; i < g_Args.numberMachines; i++) … … 332 332 NULL, /* Create flags */ 333 333 ptrMachine.asOutParam())); 334 if (SUCCEEDED( rc))334 if (SUCCEEDED(hrc)) 335 335 { 336 336 CHECK_ERROR_L(pVBox, RegisterMachine(ptrMachine)); … … 341 341 RTThreadSleep(100); 342 342 } 343 return rc;343 return hrc; 344 344 } 345 345 … … 347 347 static int tstClean(IVirtualBox *pVBox, IVirtualBoxClient *pClient) 348 348 { 349 NOREF(pClient);350 HRESULT rc = S_OK;349 RT_NOREF(pClient); 350 HRESULT hrc = S_OK; 351 351 352 352 // stop all machines created for the test … … 364 364 365 365 // try to stop it again if it was not stopped 366 if (SUCCEEDED( rc))366 if (SUCCEEDED(hrc)) 367 367 { 368 368 MachineState_T machineState; 369 369 CHECK_ERROR_L(machine, COMGETTER(State)(&machineState)); 370 if ( SUCCEEDED( rc)370 if ( SUCCEEDED(hrc) 371 371 && ( machineState == MachineState_Running 372 372 || machineState == MachineState_Paused) ) 373 373 { 374 rc = session.createInprocObject(CLSID_Session);375 if (SUCCEEDED( rc))374 hrc = session.createInprocObject(CLSID_Session); 375 if (SUCCEEDED(hrc)) 376 376 tstStopVM(pVBox, session, machineName, FALSE); 377 377 } 378 378 } 379 379 380 if (SUCCEEDED( rc))380 if (SUCCEEDED(hrc)) 381 381 CHECK_ERROR_L(machine, Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(media))); 382 if (SUCCEEDED( rc))382 if (SUCCEEDED(hrc)) 383 383 CHECK_ERROR_L(machine, DeleteConfig(ComSafeArrayAsInParam(media), progress.asOutParam())); 384 if (SUCCEEDED( rc))384 if (SUCCEEDED(hrc)) 385 385 CHECK_ERROR_L(progress, WaitForCompletion(-1)); 386 if (SUCCEEDED( rc))386 if (SUCCEEDED(hrc)) 387 387 RTPrintf("Machine '%ls' deleted.\n", machineName.raw()); 388 388 } 389 return rc;389 return hrc; 390 390 } 391 391 … … 399 399 uint32_t percentage = args->percentsUnlok; 400 400 401 HRESULT rc = com::Initialize();402 if (SUCCEEDED( rc))401 HRESULT hrc = com::Initialize(); 402 if (SUCCEEDED(hrc)) 403 403 { 404 404 ComPtr<IVirtualBoxClient> ptrVBoxClient; 405 405 ComPtr<IVirtualBox> ptrVBox; 406 406 407 rc = TST_COM_EXPR(ptrVBoxClient.createInprocObject(CLSID_VirtualBoxClient));408 if (SUCCEEDED( rc))409 rc = TST_COM_EXPR(ptrVBoxClient->COMGETTER(VirtualBox)(ptrVBox.asOutParam()));410 if (SUCCEEDED( rc))407 hrc = TST_COM_EXPR(ptrVBoxClient.createInprocObject(CLSID_VirtualBoxClient)); 408 if (SUCCEEDED(hrc)) 409 hrc = TST_COM_EXPR(ptrVBoxClient->COMGETTER(VirtualBox)(ptrVBox.asOutParam())); 410 if (SUCCEEDED(hrc)) 411 411 { 412 412 RTPrintf("Creating machines...\n"); … … 415 415 while (g_RunTest) 416 416 { 417 rc = tstMachinesPack(ptrVBox, maxPackSize, percentage);417 hrc = tstMachinesPack(ptrVBox, maxPackSize, percentage); 418 418 } 419 419 … … 430 430 com::Shutdown(); 431 431 } 432 return rc;432 return hrc; 433 433 } 434 434
Note:
See TracChangeset
for help on using the changeset viewer.