VirtualBox

Changeset 16198 in vbox for trunk/src/VBox/Main/testcase


Ignore:
Timestamp:
Jan 23, 2009 12:46:45 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
41968
Message:

HostNetIf API: added findHostNetworkInterfaceByName and findHostNetworkInterfaceById to IHost.

File:
1 edited

Legend:

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

    r16188 r16198  
    11271127#endif
    11281128
     1129#if 0
     1130    do {
     1131        // Get host
     1132        ComPtr <IHost> host;
     1133        CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host) (host.asOutParam()));
     1134
     1135        ULONG uMemSize, uMemAvail;
     1136        CHECK_ERROR_BREAK (host, COMGETTER(MemorySize) (&uMemSize));
     1137        printf("Total memory (MB): %u\n", uMemSize);
     1138        CHECK_ERROR_BREAK (host, COMGETTER(MemoryAvailable) (&uMemAvail));
     1139        printf("Free memory (MB): %u\n", uMemAvail);
     1140    } while (0);
     1141#endif
     1142
    11291143#if 1
    11301144    do {
     
    11331147        CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host) (host.asOutParam()));
    11341148
    1135         ULONG uMemSize, uMemAvail;
    1136         CHECK_ERROR_BREAK (host, COMGETTER(MemorySize) (&uMemSize));
    1137         printf("Total memory (MB): %u\n", uMemSize);
    1138         CHECK_ERROR_BREAK (host, COMGETTER(MemoryAvailable) (&uMemAvail));
    1139         printf("Free memory (MB): %u\n", uMemAvail);
     1149        com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
     1150        CHECK_ERROR_BREAK(host,
     1151                          COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces)));
     1152        if (hostNetworkInterfaces.size() > 0)
     1153        {
     1154            ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[0];
     1155            Bstr interfaceName;
     1156            networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
     1157            printf("Found %d network interfaces, testing with %lS...\n", hostNetworkInterfaces.size(), interfaceName.raw());
     1158            Guid interfaceGuid;
     1159            networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
     1160            // Find the interface by its name
     1161            networkInterface.setNull();
     1162            CHECK_ERROR_BREAK(host,
     1163                              FindHostNetworkInterfaceByName (interfaceName, networkInterface.asOutParam()));
     1164            Guid interfaceGuid2;
     1165            networkInterface->COMGETTER(Id)(interfaceGuid2.asOutParam());
     1166            if (interfaceGuid2 != interfaceGuid)
     1167                printf("Failed to retrive an interface by name %lS.\n", interfaceName.raw());
     1168            // Find the interface by its guid
     1169            networkInterface.setNull();
     1170            CHECK_ERROR_BREAK(host,
     1171                              FindHostNetworkInterfaceById (interfaceGuid, networkInterface.asOutParam()));
     1172            Bstr interfaceName2;
     1173            networkInterface->COMGETTER(Name)(interfaceName2.asOutParam());
     1174            if (interfaceName != interfaceName2)
     1175                printf("Failed to retrive an interface by GUID %lS.\n", Bstr(interfaceGuid.toString()).raw());
     1176        }
     1177        else
     1178        {
     1179            printf("No network interfaces found!\n");
     1180        }
    11401181    } while (0);
    11411182#endif
     
    12551296    } while (false);
    12561297#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    1257 #if 1
     1298#if 0
    12581299    // check of OVF appliance handling
    12591300    ///////////////////////////////////////////////////////////////////////////
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