Beispiel #1
0
 void include()
 {
     ErrorLogger::ErrorMessage errmsg;
     ErrorLogger::ErrorMessage::FileLocation loc;
     loc.file = "ab/cd/../ef.h";
     errmsg._callStack.push_back(loc);
     ASSERT_EQUALS("<error file=\"ab/ef.h\" line=\"0\" id=\"\" severity=\"\" msg=\"\"/>", errmsg.toXML());
     ASSERT_EQUALS("[ab/ef.h:0]: ", errmsg.toText());
 }
bool ThreadExecutor::handleRead(unsigned int &result)
{
    char type = 0;
    if (read(_pipe[0], &type, 1) <= 0)
    {
        return false;
    }

    if (type != '1' && type != '2' && type != '3')
    {
        std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
        exit(0);
    }

    unsigned int len = 0;
    if (read(_pipe[0], &len, sizeof(len)) <= 0)
    {
        std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
        exit(0);
    }

    char *buf = new char[len];
    if (read(_pipe[0], buf, len) <= 0)
    {
        std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
        exit(0);
    }

    if (type == '1')
    {
        _errorLogger.reportOut(buf);
    }
    else if (type == '2')
    {
        ErrorLogger::ErrorMessage msg;
        msg.deserialize(buf);

        // Alert only about unique errors
        std::string errmsg = msg.toText();
        if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end())
        {
            _errorList.push_back(errmsg);
            _errorLogger.reportErr(msg);
        }
    }
    else if (type == '3')
    {
        _fileCount++;
        std::istringstream iss(buf);
        unsigned int fileResult = 0;
        iss >> fileResult;
        result += fileResult;
        _errorLogger.reportStatus(_fileCount, _filenames.size());
    }
Beispiel #3
0
void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    if (_settings._xml)
    {
        reportErr(msg.toXML());
    }
    else
    {
        reportErr(msg.toText());
    }
}
Beispiel #4
0
void TestFixture::reportErr(const ErrorLogger::ErrorMessage &msg)
{
    errout << msg.toText() << std::endl;
}