VirtualBox

Ignore:
Timestamp:
Mar 15, 2012 9:54:46 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76843
Message:

tstAPI: added a test case for bandwidth group

File:
1 edited

Legend:

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

    r38735 r40473  
    14231423    }
    14241424    while (FALSE);
     1425    RTPrintf("\n");
     1426#endif
     1427#if 0
     1428    // check of network bandwidth control
     1429    ///////////////////////////////////////////////////////////////////////////
     1430    do
     1431    {
     1432        // Get machine
     1433        ComPtr<IMachine> machine;
     1434        ComPtr<IBandwidthControl> bwCtrl;
     1435        ComPtr<IBandwidthGroup> bwGroup;
     1436        ComPtr<INetworkAdapter> nic;
     1437        Bstr name = argc > 1 ? argv[1] : "ubuntu";
     1438        Bstr sessionType = argc > 2 ? argv[2] : "headless";
     1439        Bstr grpName = "tstAPI";
     1440        RTPrintf("Getting a machine object named '%ls'...\n", name.raw());
     1441        CHECK_ERROR_BREAK(virtualBox, FindMachine(name.raw(), machine.asOutParam()));
     1442        /* open a session for the VM (new or shared) */
     1443        CHECK_ERROR_BREAK(machine, LockMachine(session, LockType_Shared));
     1444        SessionType_T st;
     1445        CHECK_ERROR_BREAK(session, COMGETTER(Type)(&st));
     1446        bool fRunTime = (st == SessionType_Shared);
     1447        if (fRunTime)
     1448        {
     1449            RTPrintf("Machine %ls must not be running!\n");
     1450            break;
     1451        }
     1452        /* get the mutable session machine */
     1453        session->COMGETTER(Machine)(machine.asOutParam());
     1454        CHECK_ERROR_BREAK(machine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()));
     1455
     1456        RTPrintf("Creating bandwidth group named '%ls'...\n", grpName.raw());
     1457        CHECK_ERROR_BREAK(bwCtrl, CreateBandwidthGroup(grpName.raw(), BandwidthGroupType_Network, 123));
     1458
     1459
     1460        CHECK_ERROR_BREAK(bwCtrl, GetBandwidthGroup(grpName.raw(), bwGroup.asOutParam()));
     1461        CHECK_ERROR_BREAK(machine, GetNetworkAdapter(0, nic.asOutParam()));
     1462        RTPrintf("Assigning the group to the first network adapter...\n");
     1463        CHECK_ERROR_BREAK(nic, COMSETTER(BandwidthGroup)(bwGroup));
     1464        {
     1465            ComPtr<IBandwidthGroup> bwGroupReadFromNic;
     1466            Bstr grpNameReadFromNic;
     1467            RTPrintf("Reading the group back from the first network adapter...\n");
     1468            CHECK_ERROR_BREAK(nic, COMGETTER(BandwidthGroup)(bwGroupReadFromNic.asOutParam()));
     1469            CHECK_ERROR_BREAK(bwGroupReadFromNic, COMGETTER(Name)(grpNameReadFromNic.asOutParam()));
     1470            if (grpName != grpNameReadFromNic)
     1471                RTPrintf("Error: Bandwidth group names do not match (%ls != %ls)!\n", grpName.raw(), grpNameReadFromNic.raw());
     1472            else
     1473                RTPrintf("Successfully retrieved bandwidth group attribute from NIC (name=%ls)\n", grpNameReadFromNic.raw());
     1474            ComPtr<IBandwidthGroup> bwGroupEmpty;
     1475            RTPrintf("Assigning an empty group to the first network adapter...\n");
     1476            CHECK_ERROR_BREAK(nic, COMSETTER(BandwidthGroup)(bwGroupEmpty));
     1477        }
     1478        RTPrintf("Removing bandwidth group named '%ls'...\n", grpName.raw());
     1479        CHECK_ERROR_BREAK(bwCtrl, DeleteBandwidthGroup(grpName.raw()));
     1480        RTPrintf("Press enter to close this session...");
     1481        getchar();
     1482        session->UnlockMachine();
     1483    } while (FALSE);
    14251484    RTPrintf("\n");
    14261485#endif
Note: See TracChangeset for help on using the changeset viewer.

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