Пример #1
0
def test_cppcheck_wrappers():
    cpp_analysis = test_cppcheck_common()
    issues = parse_cppcheck(cpp_analysis[1])
    i = 0
    for issue in issues:
        if issue.testid == "toomanyconfigs":
            found = issue
        i += 1
    assert found.testid == "toomanyconfigs"
    assert found.location.file.givenpath == "src/lib_json/json_value.cpp"
    assert found.location.point.line == 0
    assert found.location.point.column == 0
    assert found.severity == "style"
    assert found.notes is None
    assert found.customfields is None
    assert i > 4
Пример #2
0
 def test_cppcheck_wrappers(self):
     cpp_analysis = cppcheck(self.file_path, self.firehose_results)
     issues = parse_cppcheck(cpp_analysis[1])
     i = 0
     for issue in issues:
         if issue.testid == "toomanyconfigs":
             found = issue
         i += 1
     self.assertEquals(found.testid, "toomanyconfigs")
     self.assertEquals(found.location.file.givenpath,
             "src/lib_json/json_value.cpp")
     self.assertEquals(found.location.point.line, 0)
     self.assertEquals(found.location.point.column, 0)
     self.assertEquals(found.severity, "style")
     self.assertIsNone(found.notes)
     self.assertIsNone(found.customfields)
     self.assertTrue(i > 4)
Пример #3
0
def cppcheck(dsc, analysis):
    run_command(["dpkg-source", "-x", dsc, "source-cppcheck"])
    with cd('source-cppcheck'):
        _, err, _ = run_command(
            ['cppcheck', '-j8', '--enable=all', '.', '--xml'])

        xmlbytes = err.encode()

        failed = False
        if err.strip() == '':
            return (analysis, err, failed, None, None)

        for issue in parse_cppcheck(xmlbytes):
            analysis.results.append(issue)
            if not failed and issue.severity in [
                    'performance', 'portability', 'error', 'warning'
            ]:
                failed = True

        return (analysis, err, failed, None, None)
Пример #4
0
def cppcheck(dsc, analysis):
    run_command(["dpkg-source", "-x", dsc, "source"])
    with cd('source'):
        out, err, ret = run_command([
            'cppcheck', '-j8', '--enable=all', '.', '--xml'
        ])

        xmlbytes = err.encode()

        failed = False
        if err.strip() == '':
            return (analysis, err, failed)

        for issue in parse_cppcheck(xmlbytes):
            analysis.results.append(issue)
            if not failed and issue.severity in [
                'performance', 'portability', 'error', 'warning'
            ]:
                failed = True

        return (analysis, err, failed, None)