⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 benchmarktest.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    for (i =  getOpts.first (); i <  getOpts.last (); i++)    {        if (getOpts [i].getType () == Optarg::LONGFLAG)        {            UnexpectedArgumentException e (                         getOpts [i].Value ());            throw e;        }        else if (getOpts [i].getType () == Optarg::REGULAR)        {            UnexpectedArgumentException e (                         getOpts [i].Value ());            throw e;        }        else /* getOpts [i].getType () == FLAG */        {            c = getOpts [i].getopt () [0];            switch (c)            {                case _OPTION_HOSTNAME:                {                    if (getOpts.isSet (_OPTION_HOSTNAME) > 1)                    {                        //                        // More than one hostname option was found                        //                        DuplicateOptionException e (_OPTION_HOSTNAME);                        throw e;                    }                    _hostName = getOpts [i].Value ();                    _hostNameSet = true;                    break;                }                case _OPTION_PORTNUMBER:                {                    if (getOpts.isSet (_OPTION_PORTNUMBER) > 1)                    {                        //                        // More than one portNumber option was found                        //                        DuplicateOptionException e (_OPTION_PORTNUMBER);                        throw e;                    }                    _portNumberStr = getOpts [i].Value ();                    try                    {                        getOpts [i].Value (_portNumber);                    }                    catch (const TypeMismatchException&)                    {                        InvalidOptionArgumentException e (_portNumberStr,                            _OPTION_PORTNUMBER);                        throw e;                    }            _portNumberSet = true;                    break;                }                case _OPTION_SSL:                {                    //                    // Use port 5989 as the default port for SSL                    //            _useSSL = true;                    if (!_portNumberSet)                       _portNumber = 5989;                    break;                }                case _OPTION_VERSION:                {            _displayVersion = true;                    break;                }                case _OPTION_TIMEOUT:                {                    if (getOpts.isSet (_OPTION_TIMEOUT) > 1)                    {                        //                        // More than one timeout option was found                        //                        DuplicateOptionException e (_OPTION_TIMEOUT);                        throw e;                    }                    timeoutStr = getOpts [i].Value ();                    try                    {                        getOpts [i].Value (_timeout);                    }                    catch (const TypeMismatchException&)                    {                        InvalidOptionArgumentException e (timeoutStr,                            _OPTION_TIMEOUT);                        throw e;                    }                    break;                }                case _OPTION_USERNAME:                {                    if (getOpts.isSet (_OPTION_USERNAME) > 1)                    {                        //                        // More than one username option was found                        //                        DuplicateOptionException e (_OPTION_USERNAME);                        throw e;                    }                    _userName = getOpts [i].Value ();                    _userNameSet = true;                    break;                }                case _OPTION_PASSWORD:                {                    if (getOpts.isSet (_OPTION_PASSWORD) > 1)                    {                        //                        // More than one password option was found                        //                        DuplicateOptionException e (_OPTION_PASSWORD);                        throw e;                    }                    _password = getOpts [i].Value ();                    _passwordSet = true;                    break;                }                case _OPTION_RESULTS_DIRECTORY:                {                    if (getOpts.isSet (_OPTION_RESULTS_DIRECTORY) > 1)                    {                        //                        // More than one log directory option was found                        //                        DuplicateOptionException e (_OPTION_RESULTS_DIRECTORY);                        throw e;                    }                    _resultsDirectory = getOpts [i].Value ();                    break;                }                case _OPTION_ITERATIONS:                {                    if (getOpts.isSet (_OPTION_ITERATIONS) > 1)                    {                        //                        // More than one iteration option was found                        //                        DuplicateOptionException e (_OPTION_ITERATIONS);                        throw e;                    }                    _iterationsStr = getOpts [i].Value ();                    try                    {                        getOpts [i].Value (_iterations);                    }                    catch (const TypeMismatchException&)                    {                        InvalidOptionArgumentException e (_iterationsStr,                            _OPTION_ITERATIONS);                        throw e;                    }            _iterationsSet = true;                    break;                }                case _OPTION_TESTID:                {                    if (getOpts.isSet (_OPTION_TESTID) > 1)                    {                        //                        // More than one TESTID option was found                        //                        DuplicateOptionException e (_OPTION_TESTID);                        throw e;                    }                    _testIDStr = getOpts [i].Value ();                    try                    {                        getOpts [i].Value (_testID);                    }                    catch (const TypeMismatchException&)                    {                        InvalidOptionArgumentException e (_testIDStr,                            _OPTION_TESTID);                        throw e;                    }            _testIDSet = true;                    break;                }                case _OPTION_DEBUG:                {                    //                    //                    String debugOptionStr;                    debugOptionStr = getOpts [i].Value ();                    if (debugOptionStr.size () != 1)                    {                        //                        //  Invalid debug option                        //                        InvalidOptionArgumentException e (debugOptionStr,                            _OPTION_DEBUG);                        throw e;                    }                    if (debugOptionStr [0] == _DEBUG_OPTION1)                    {                        _debugOption1 = true;                    }                    else if (debugOptionStr [0] == _DEBUG_OPTION2)                    {                        _generateReport = false;                    }                    else                    {                        //                        //  Invalid debug option                        //                        InvalidOptionArgumentException e (debugOptionStr,                            _OPTION_DEBUG);                        throw e;                    }                    break;                }                default:                    //                    //  This path should not be hit                    //                    break;            }        }    }    if (getOpts.isSet (_OPTION_PORTNUMBER) < 1)    {        //        //  No portNumber specified        //  Default to WBEM_DEFAULT_PORT        //  Already done in constructor        //    }    else    {        if (_portNumber > _MAX_PORTNUMBER)        {            //            //  Portnumber out of valid range            //            InvalidOptionArgumentException e (_portNumberStr,                _OPTION_PORTNUMBER);            throw e;        }    }    if (getOpts.isSet (_OPTION_TIMEOUT) < 1)    {        //        //  No timeout specified        //  Default to DEFAULT_TIMEOUT_MILLISECONDS        //  Already done in constructor        //    }    else    {        if (_timeout <= 0)        {            //            //  Timeout out of valid range            //            InvalidOptionArgumentException e (timeoutStr,                _OPTION_TIMEOUT);            throw e;        }    }    if (_displayVersion)    {        cout << PLATFORM_PRODUCT_VERSION << __DATE__ << endl;    }    if (_generateReport)    {        for (Uint32 i = 0; i < argc; i++)        {            cout << argv[i] << " ";        }        cout << endl <<  endl;    }}/** ErrorExit - Print out the error message and exits.    @param   errPrintWriter     The ostream to which error output should be                                written    @param   message            Text for error message    @return - None, Terminates the program    @exception - This function terminates the program*/void benchmarkTestCommand::errorExit( ostream& errPrintWriter,                               const String& message){    errPrintWriter << "benchmarkTest error: " << message << endl;    exit(1);}void benchmarkTestCommand::_getCSInfo(ostream& outPrintWriter,                                      ostream& errPrintWriter){#define CSINFO_NAMESPACE CIMNamespaceName ("root/cimv2")#define CSINFO_CLASSNAME CIMName ("PG_ComputerSystem")    Boolean isConnected = false;    CIMClient client;    client.setTimeout( _timeout );    try    {        _connectToServer( client, outPrintWriter);        isConnected = true;        Boolean deepInheritance = true;        Boolean localOnly = false;        Boolean includeQualifiers = false;        Boolean includeClassOrigin = false;        Array<CIMInstance> cimNInstances =               client.enumerateInstances(CSINFO_NAMESPACE, CSINFO_CLASSNAME,                                         deepInheritance,                                         localOnly, includeQualifiers,                                         includeClassOrigin );        if (cimNInstances.size() != 1)        {           client.disconnect();           return;        }        CIMObjectPath instanceRef = cimNInstances[0].getPath();        if ( !(instanceRef.getClassName().equal(CSINFO_CLASSNAME)))        {           errPrintWriter << "Returned ClassName = "               << instanceRef.getClassName().getString() << endl;           errPrintWriter << "Expected ClassName = "               << CSINFO_CLASSNAME.getString() << endl;           errorExit(errPrintWriter,               "EnumerateInstances failed.  Incorrect class name returned.");        }        for (Uint32 j = 0; j < cimNInstances[0].getPropertyCount(); j++)        {           CIMName propertyName = cimNInstances[0].getProperty(j).getName();           if (propertyName.equal(CIMName("OtherIdentifyingInfo")))           {               outPrintWriter << "Model = "                   << cimNInstances[0].getProperty(j).getValue().toString()                   << endl;           }        }    }  // end try    catch(...)    {       if (isConnected)          client.disconnect();       return;    }    client.disconnect();}void benchmarkTestCommand::_getOSInfo(ostream& outPrintWriter,                                      ostream& errPrintWriter){#define OSINFO_NAMESPACE CIMNamespaceName ("root/cimv2")#define OSINFO_CLASSNAME CIMName ("PG_OperatingSystem")    Boolean isConnected = false;    CIMClient client;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -