コード例 #1
0
ファイル: ctools.py プロジェクト: pombredanne/trachacks
    def test_single_file(self):
        self._create_file('foo.c')
        self._create_file('foo.o')
        self._create_file('foo.gcno')
        self._create_file('foo.gcda')

        ctools.CommandLine = dummy.CommandLine(stdout="""
File `foo.c'
Lines executed:45.81% of 884
Branches executed:54.27% of 398
Taken at least once:36.68% of 398
Calls executed:48.19% of 249

File `foo.h'
Lines executed:50.00% of 4
No branches
Calls executed:100.00% of 1
""")
        ctools.gcov(self.ctxt)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('log', type)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        elem = xml.children[0]
        self.assertEqual('coverage', elem.name)
        self.assertEqual('foo.c', elem.attr['file'])
        self.assertEqual('foo.c', elem.attr['name'])
        self.assertEqual(888, elem.attr['lines'])
        self.assertEqual(45, elem.attr['percentage'])
コード例 #2
0
ファイル: ctools.py プロジェクト: kroman0/bitten
    def test_single_file(self):
        self._create_file('foo.c')
        self._create_file('foo.o')
        self._create_file('foo.gcno')
        self._create_file('foo.gcda')

        ctools.CommandLine = dummy.CommandLine(stdout="""
File `foo.c'
Lines executed:45.81% of 884
Branches executed:54.27% of 398
Taken at least once:36.68% of 398
Calls executed:48.19% of 249

File `foo.h'
Lines executed:50.00% of 4
No branches
Calls executed:100.00% of 1
""")
        ctools.gcov(self.ctxt)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('log', type)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        elem = xml.children[0]
        self.assertEqual('coverage', elem.name)
        self.assertEqual('foo.c', elem.attr['file'])
        self.assertEqual('foo.c', elem.attr['name'])
        self.assertEqual(888, elem.attr['lines'])
        self.assertEqual(45, elem.attr['percentage'])
コード例 #3
0
ファイル: ctools.py プロジェクト: pombredanne/trachacks
 def test_no_file(self):
     ctools.CommandLine = dummy.CommandLine()
     ctools.gcov(self.ctxt)
     type, category, generator, xml = self.ctxt.output.pop()
     self.assertEqual('log', type)
     type, category, generator, xml = self.ctxt.output.pop()
     self.assertEqual('report', type)
     self.assertEqual('coverage', category)
     self.assertEqual(0, len(xml.children))
コード例 #4
0
    def test_mark_unknown_lines(self):
        self._create_file('foo.cpp')
        self._create_file('foo.o')
        self._create_file('foo.gcno')
        self._create_file('foo.gcda')
        # changed line 2 to include unknown text
        self._create_file('foo.cpp.gcov',
                          content="""        -:    0:Source:foo.cpp
        -:    0:Graph:./foo.gcno
        -:    0:Data:./foo.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:#include <iostream>
        x:    2:
        1:    3:int main() {
        -:    4:    try {
        1:    5:        std::cout << "No exception!";
    =====:    6:    } catch(const std::exception &) {
    =====:    7:        std::cout << "Exception!";
        -:    8:    }
        4:    9:}
""")
        ctools.CommandLine = dummy.CommandLine(stdout="""
File 'foo.cpp'
Lines executed:60.00% of 5
Creating 'foo.cpp.gcov'

File '/usr/include/c++/4.9.1/iostream'
Lines executed:100.00% of 1
Creating 'iostream.gcov'

File '/usr/include/c++/4.9.1/bits/basic_ios.h'
No executable lines
Removing 'basic_ios.h.gcov'

File '/usr/include/c++/4.9.1/ostream'
No executable lines
Removing 'ostream.gcov'

File '/usr/include/c++/4.9.1/bits/ios_base.h'
Lines executed:0.00% of 2
Creating 'ios_base.h.gcov'

File '/usr/include/c++/4.9.1/bits/char_traits.h'
Lines executed:0.00% of 2
Creating 'char_traits.h.gcov'
""")
        ctools.gcov(self.ctxt)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('log', type)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        elem = xml.children[0]
        self.assertEqual('coverage', elem.name)
        self.assertEqual('- ??? 1 - 1 0 0 - 4', elem.attr['line_hits'])
コード例 #5
0
ファイル: ctools.py プロジェクト: kroman0/bitten
 def test_no_file(self):
     ctools.CommandLine = dummy.CommandLine()
     ctools.gcov(self.ctxt)
     type, category, generator, xml = self.ctxt.output.pop()
     self.assertEqual('log', type)
     type, category, generator, xml = self.ctxt.output.pop()
     self.assertEqual('report', type)
     self.assertEqual('coverage', category)
     self.assertEqual(0, len(xml.children))
コード例 #6
0
ファイル: ctools.py プロジェクト: hefloryd/bitten
    def test_mark_unknown_lines(self):
        self._create_file('foo.cpp')
        self._create_file('foo.o')
        self._create_file('foo.gcno')
        self._create_file('foo.gcda')
        # changed line 2 to include unknown text
        self._create_file('foo.cpp.gcov', content="""        -:    0:Source:foo.cpp
        -:    0:Graph:./foo.gcno
        -:    0:Data:./foo.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:#include <iostream>
        x:    2:
        1:    3:int main() {
        -:    4:    try {
        1:    5:        std::cout << "No exception!";
    =====:    6:    } catch(const std::exception &) {
    =====:    7:        std::cout << "Exception!";
        -:    8:    }
        4:    9:}
""")
        ctools.CommandLine = dummy.CommandLine(stdout="""
File 'foo.cpp'
Lines executed:60.00% of 5
Creating 'foo.cpp.gcov'

File '/usr/include/c++/4.9.1/iostream'
Lines executed:100.00% of 1
Creating 'iostream.gcov'

File '/usr/include/c++/4.9.1/bits/basic_ios.h'
No executable lines
Removing 'basic_ios.h.gcov'

File '/usr/include/c++/4.9.1/ostream'
No executable lines
Removing 'ostream.gcov'

File '/usr/include/c++/4.9.1/bits/ios_base.h'
Lines executed:0.00% of 2
Creating 'ios_base.h.gcov'

File '/usr/include/c++/4.9.1/bits/char_traits.h'
Lines executed:0.00% of 2
Creating 'char_traits.h.gcov'
""")
        ctools.gcov(self.ctxt)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('log', type)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        elem = xml.children[0]
        self.assertEqual('coverage', elem.name)
        self.assertEqual('- ??? 1 - 1 0 0 - 4', elem.attr['line_hits'])