Changeset 36128 in vbox for trunk/src/VBox/Main/testcase
- Timestamp:
- Mar 2, 2011 5:44:04 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstAPI.cpp
r33595 r36128 1222 1222 1223 1223 // Fill base metrics array 1224 Bstr baseMetricNames[] = { L"CPU/Load,RAM/Usage" }; 1224 //Bstr baseMetricNames[] = { L"CPU/Load,RAM/Usage" }; 1225 Bstr baseMetricNames[] = { L"RAM/VMM" }; 1225 1226 com::SafeArray<BSTR> baseMetrics(1); 1226 1227 baseMetricNames[0].cloneTo(&baseMetrics[0]); … … 1235 1236 Bstr sessionType = argc > 2 ? argv[2] : "headless"; 1236 1237 RTPrintf("Getting a machine object named '%ls'...\n", name.raw()); 1237 CHECK_ RC_BREAK(virtualBox->FindMachine(name, machine.asOutParam()));1238 CHECK_ERROR_BREAK(virtualBox, FindMachine(name.raw(), machine.asOutParam())); 1238 1239 1239 1240 // Open session 1240 Guid guid;1241 CHECK_RC_BREAK(machine->COMGETTER(Id)(guid.asOutParam()));1242 RTPrintf("Opening a remote session for this machine...\n");1243 1241 ComPtr<IProgress> progress; 1244 CHECK_RC_BREAK(virtualBox->OpenRemoteSession(session, guid, sessionType, 1245 NULL, progress.asOutParam())); 1246 RTPrintf("Waiting for the session to open...\n"); 1247 CHECK_RC_BREAK(progress->WaitForCompletion(-1)); 1248 ComPtr<IMachine> sessionMachine; 1249 RTPrintf("Getting machine session object...\n"); 1250 CHECK_RC_BREAK(session->COMGETTER(Machine)(sessionMachine.asOutParam())); 1242 RTPrintf("Launching VM process...\n"); 1243 CHECK_ERROR_BREAK(machine, LaunchVMProcess(session, sessionType.raw(), 1244 NULL, progress.asOutParam())); 1245 RTPrintf("Waiting for the VM to power on...\n"); 1246 CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); 1247 1248 // ComPtr<IMachine> sessionMachine; 1249 // RTPrintf("Getting machine session object...\n"); 1250 // CHECK_ERROR_BREAK(session, COMGETTER(Machine)(sessionMachine.asOutParam())); 1251 1251 1252 1252 // Setup base metrics 1253 1253 // Note that one needs to set up metrics after a session is open for a machine. 1254 1254 com::SafeIfaceArray<IPerformanceMetric> affectedMetrics; 1255 com::SafeIfaceArray<IUnknown> objects( 2);1255 com::SafeIfaceArray<IUnknown> objects(1); 1256 1256 host.queryInterfaceTo(&objects[0]); 1257 machine.queryInterfaceTo(&objects[1]);1257 //machine.queryInterfaceTo(&objects[1]); 1258 1258 CHECK_ERROR_BREAK(collector, SetupMetrics(ComSafeArrayAsInParam(baseMetrics), 1259 1259 ComSafeArrayAsInParam(objects), 1u, 10u, … … 1266 1266 ComPtr<IConsole> console; 1267 1267 RTPrintf("Getting console object...\n"); 1268 CHECK_ RC_BREAK(session->COMGETTER(Console)(console.asOutParam()));1268 CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam())); 1269 1269 1270 1270 RTThreadSleep(5000); // Sleep for 5 seconds … … 1276 1276 //RTPrintf("Press enter to pause the VM execution in the remote session..."); 1277 1277 //getchar(); 1278 CHECK_ RC(console->Pause());1278 CHECK_ERROR_BREAK(console, Pause()); 1279 1279 1280 1280 RTThreadSleep(5000); // Sleep for 5 seconds … … 1321 1321 RTPrintf("Press enter to power off VM..."); 1322 1322 getchar(); 1323 CHECK_RC(console->PowerDown()); 1323 CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam())); 1324 RTPrintf("Waiting for the VM to power down...\n"); 1325 CHECK_ERROR_BREAK(progress, WaitForCompletion(-1)); 1324 1326 RTPrintf("Press enter to close this session..."); 1325 1327 getchar(); 1326 session-> Close();1328 session->UnlockMachine(); 1327 1329 } while (false); 1328 1330 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
Note:
See TracChangeset
for help on using the changeset viewer.