Esempio n. 1
0
def parse_sbuild_log(log, sut):
    gccversion = None
    stats = None

    for line in log.splitlines():
        flag = "Toolchain package versions: "
        stat = STATS.match(line)
        if stat:
            info = stat.groupdict()
            hours, minutes, seconds = [int(x) for x in info['time'].split(":")]
            timed = timedelta(hours=hours, minutes=minutes, seconds=seconds)
            stats = Stats(timed.total_seconds())
        if line.startswith(flag):
            line = line[len(flag):].strip()
            packages = line.split(" ")
            versions = {}
            for package in packages:
                if "_" not in package:
                    continue
                b, bv = package.split("_", 1)
                versions[b] = bv
            vs = list(filter(lambda x: x.startswith("gcc"), versions))
            if vs == []:
                continue
            vs = vs[0]
            gccversion = versions[vs]

    obj = fgcc.parse_file(
        StringIO(log),
        sut=sut,
        gccversion=gccversion,
        stats=stats
    )

    return obj
 def test_multiple_warnings_per_func(self, mock_parse_warning):
     # we expect that upon reaching "None", it will stop looking for
     # warnings, and thus the last MagicMock won't be counted
     mock_parse_warning.side_effect = [mock.MagicMock(), mock.MagicMock(), None, mock.MagicMock()]
     lines = self.create_mock_file(["unix/arlib.c: In function 'ar_scan':", "", "", "", ""])
     analysis = gcc.parse_file(lines, "4.7.2")
     self.assertEqual(len(analysis.results), 2)
Esempio n. 3
0
def parse_sbuild_log(log, sut):
    gccversion = None
    stats = None

    for line in log.splitlines():
        flag = "Toolchain package versions: "
        stat = STATS.match(line)
        if stat:
            info = stat.groupdict()
            hours, minutes, seconds = [int(x) for x in info['time'].split(":")]
            timed = timedelta(hours=hours, minutes=minutes, seconds=seconds)
            stats = Stats(timed.total_seconds())
        if line.startswith(flag):
            line = line[len(flag):].strip()
            packages = line.split(" ")
            versions = {}
            for package in packages:
                if "_" not in package:
                    continue
                b, bv = package.split("_", 1)
                versions[b] = bv
            vs = list(filter(lambda x: x.startswith("gcc"), versions))
            if vs == []:
                continue
            vs = vs[0]
            gccversion = versions[vs]

    obj = fgcc.parse_file(
        StringIO(log),
        sut=sut,
        gccversion=gccversion,
        stats=stats
    )

    return obj
Esempio n. 4
0
 def test_identify_c(self, mock_parse_warning):
     lines = self.create_mock_file(
         ["unix/arlib.c: In function 'ar_scan':", "ignored by mock"])
     analysis = gcc.parse_file(lines, '4.7.2')
     self.assertEqual(len(analysis.results), 1)
     self.assertEqual(analysis.results[0], mock_parse_warning.return_value)
     self.assertEqual(mock_parse_warning.call_args[0][1], "ar_scan")
Esempio n. 5
0
 def test_identify_c(self, mock_parse_warning):
     lines = self.create_mock_file(["unix/arlib.c: In function 'ar_scan':", "ignored by mock"])
     analysis = gcc.parse_file(lines, '4.7.2')
     self.assertEqual(len(analysis.results), 1)
     self.assertEqual(analysis.results[0],
                      mock_parse_warning.return_value)
     self.assertEqual(mock_parse_warning.call_args[0][1], "ar_scan")
Esempio n. 6
0
 def test_identify_cpp(self, mock_parse_warning):
     lines = self.create_mock_file(
         ["/builddir/build/BUILD/libreoffice-3.5.7.2/icc/unxlngi6.pro/misc/build/SampleICC-1.3.2/IccProfLib/IccMpeACS.cpp: In member function 'virtual bool CIccMpeAcs::Read(icUInt32Number, CIccIO*)':",
         "ignored by mock"])
     ret = list(gcc.parse_file(lines))
     self.assertEqual(len(ret), 1)
     self.assertEqual(ret[0], mock_parse_warning.return_value)
     self.assertEqual(mock_parse_warning.call_args[0][1], "virtual bool CIccMpeAcs::Read(icUInt32Number, CIccIO*)")
Esempio n. 7
0
def parse_gcc_stderr(stderr, stats):
    from firehose.parsers.gcc import parse_file

    log('parse_gcc_stderr(stderr=%r)' % stderr)

    f = StringIO.StringIO(stderr)
    analysis = parse_file(f, stats=stats)
    write_analysis_as_xml(analysis)
Esempio n. 8
0
 def test_identify_global(self, mock_parse_warning):
     lines = self.create_mock_file(
         ["/builddir/build/BUILD/libreoffice-3.5.7.2/icc/unxlngi6.pro/misc/build/SampleICC-1.3.2/IccProfLib/IccMpeACS.cpp: At global scope:",
         "ignored by mock"])
     analysis = gcc.parse_file(lines, '4.7.2')
     self.assertEqual(len(analysis.results), 1)
     self.assertEqual(analysis.results[0],
                      mock_parse_warning.return_value)
     self.assertEqual(mock_parse_warning.call_args[0][1], gcc.GLOBAL_FUNC_NAME)
Esempio n. 9
0
 def test_identify_global(self, mock_parse_warning):
     lines = self.create_mock_file([
         "/builddir/build/BUILD/libreoffice-3.5.7.2/icc/unxlngi6.pro/misc/build/SampleICC-1.3.2/IccProfLib/IccMpeACS.cpp: At global scope:",
         "ignored by mock"
     ])
     analysis = gcc.parse_file(lines, '4.7.2')
     self.assertEqual(len(analysis.results), 1)
     self.assertEqual(analysis.results[0], mock_parse_warning.return_value)
     self.assertEqual(mock_parse_warning.call_args[0][1],
                      gcc.GLOBAL_FUNC_NAME)
Esempio n. 10
0
 def test_identify_cpp(self, mock_parse_warning):
     lines = self.create_mock_file([
         "/builddir/build/BUILD/libreoffice-3.5.7.2/icc/unxlngi6.pro/misc/build/SampleICC-1.3.2/IccProfLib/IccMpeACS.cpp: In member function 'virtual bool CIccMpeAcs::Read(icUInt32Number, CIccIO*)':",
         "ignored by mock"
     ])
     analysis = gcc.parse_file(lines, '4.7.2')
     self.assertEqual(len(analysis.results), 1)
     self.assertEqual(analysis.results[0], mock_parse_warning.return_value)
     self.assertEqual(
         mock_parse_warning.call_args[0][1],
         "virtual bool CIccMpeAcs::Read(icUInt32Number, CIccIO*)")
Esempio n. 11
0
 def test_multiple_warnings_per_func(self, mock_parse_warning):
     # we expect that upon reaching "None", it will stop looking for
     # warnings, and thus the last MagicMock won't be counted
     mock_parse_warning.side_effect = [
         mock.MagicMock(),
         mock.MagicMock(), None,
         mock.MagicMock()
     ]
     lines = self.create_mock_file(
         ["unix/arlib.c: In function 'ar_scan':", "", "", "", ""])
     analysis = gcc.parse_file(lines, '4.7.2')
     self.assertEqual(len(analysis.results), 2)
    def handle_output(self, result):
        from firehose.parsers.gcc import parse_file

        f = StringIO.StringIO(result.err)
        analysis = parse_file(f, stats=make_stats(result.timer))
        if result.sourcefile:
            analysis.metadata.file_ = File(givenpath=result.sourcefile,
                                           abspath=None)
        self.set_custom_fields(result, analysis)

        self.result = result

        return analysis
    def handle_output(self, result):
        from firehose.parsers.cppcheck import parse_file

        if result.returncode:
            analysis = self._make_failed_analysis(result.sourcefile, result.timer,
                                                  msgtext='Bad exit code running %s' % self.name,
                                                  failureid='bad-exit-code')
            self.set_custom_fields(result, analysis)
            return analysis

        # (there doesn't seem to be a way to have cppcheck directly
        # save its XML output to a given location)

        with tempfile.NamedTemporaryFile() as outfile:
            outfile.write(result.err)
            outfile.flush()

            with open(outfile.name) as infile:
                # Parse stderr into firehose XML format and save:
                analysis = parse_file(infile,
                                      file_=make_file(result.sourcefile),
                                      stats=make_stats(result.timer))
                self.set_custom_fields(result, analysis)
                return analysis
Esempio n. 14
0
 def test_identify_c(self, mock_parse_warning):
     lines = self.create_mock_file(["unix/arlib.c: In function 'ar_scan':", "ignored by mock"])
     ret = list(gcc.parse_file(lines))
     self.assertEqual(len(ret), 1)
     self.assertEqual(ret[0], mock_parse_warning.return_value)
     self.assertEqual(mock_parse_warning.call_args[0][1], "ar_scan")