예제 #1
0
    def testBadToolchain(self):
        """Test that missing toolchains are detected"""
        self.setupToolchains()
        ret_code = self._RunControl('-b', TEST_BRANCH)
        lines = terminal.GetPrintTestLines()

        # Buildman always builds the upstream commit as well
        self.assertIn(
            'Building %d commits for %d boards' % (self._commits, len(boards)),
            lines[0].text)
        self.assertEqual(self._builder.count, self._total_builds)

        # Only sandbox should succeed, the others don't have toolchains
        self.assertEqual(self._builder.fail,
                         self._total_builds - self._commits)
        self.assertEqual(ret_code, 128)

        for commit in range(self._commits):
            for board in self._boards.GetList():
                if board.arch != 'sandbox':
                    errfile = self._builder.GetErrFile(commit, board.target)
                    fd = open(errfile)
                    self.assertEqual(fd.readlines(),
                                     ['No tool chain for %s\n' % board.arch])
                    fd.close()
예제 #2
0
 def testCurrentSource(self):
     """Very simple test to invoke buildman on the current source"""
     self.setupToolchains()
     self._RunControl()
     lines = terminal.GetPrintTestLines()
     self.assertIn('Building current source for %d boards' % len(boards),
                   lines[0].text)
예제 #3
0
    def setUp(self):
        self._base_dir = tempfile.mkdtemp()
        self._git_dir = os.path.join(self._base_dir, 'src')
        self._buildman_pathname = sys.argv[0]
        self._buildman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
        command.test_result = self._HandleCommand
        self.setupToolchains()
        self._toolchains.Add('arm-gcc', test=False)
        self._toolchains.Add('powerpc-gcc', test=False)
        bsettings.Setup(None)
        bsettings.AddFile(settings_data)
        self._boards = board.Boards()
        for brd in boards:
            self._boards.AddBoard(board.Board(*brd))

        # Directories where the source been cloned
        self._clone_dirs = []
        self._commits = len(commit_shortlog.splitlines()) + 1
        self._total_builds = self._commits * len(boards)

        # Number of calls to make
        self._make_calls = 0

        # Map of [board, commit] to error messages
        self._error = {}

        self._test_branch = TEST_BRANCH

        # Avoid sending any output and clear all terminal output
        terminal.SetPrintTestMode()
        terminal.GetPrintTestLines()
예제 #4
0
    def _SetupTest(self, echo_lines=False, **kwdisplay_args):
        """Set up the test by running a build and summary

        Args:
            echo_lines: True to echo lines to the terminal to aid test
                development
            kwdisplay_args: Dict of arguemnts to pass to
                Builder.SetDisplayOptions()

        Returns:
            Iterator containing the output lines, each a PrintLine() object
        """
        build = builder.Builder(self.toolchains,
                                self.base_dir,
                                None,
                                1,
                                2,
                                checkout=False,
                                show_unknown=False)
        build.do_make = self.Make
        board_selected = self.boards.GetSelectedDict()

        # Build the boards for the pre-defined commits and warnings/errors
        # associated with each. This calls our Make() to inject the fake output.
        build.BuildBoards(self.commits,
                          board_selected,
                          keep_outputs=False,
                          verbose=False)
        lines = terminal.GetPrintTestLines()
        count = 0
        for line in lines:
            if line.text.strip():
                count += 1

        # We should get two starting messages, an update for every commit built
        # and a summary message
        self.assertEqual(count, len(commits) * len(boards) + 3)
        build.SetDisplayOptions(**kwdisplay_args)
        build.ShowSummary(self.commits, board_selected)
        if echo_lines:
            terminal.EchoPrintTestLines()
        return iter(terminal.GetPrintTestLines())
예제 #5
0
    def testOutput(self):
        """Test basic builder operation and output

        This does a line-by-line verification of the summary output.
        """
        global base_dir

        base_dir = tempfile.mkdtemp()
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        build = builder.Builder(self.toolchains,
                                base_dir,
                                None,
                                1,
                                2,
                                checkout=False,
                                show_unknown=False)
        build.do_make = self.Make
        board_selected = self.boards.GetSelectedDict()

        # Build the boards for the pre-defined commits and warnings/errors
        # associated with each. This calls our Make() to inject the fake output.
        build.BuildBoards(self.commits,
                          board_selected,
                          keep_outputs=False,
                          verbose=False)
        lines = terminal.GetPrintTestLines()
        count = 0
        for line in lines:
            if line.text.strip():
                count += 1

        # We should get two starting messages, then an update for every commit
        # built.
        self.assertEqual(count, len(commits) * len(boards) + 2)
        build.SetDisplayOptions(show_errors=True)
        build.ShowSummary(self.commits, board_selected)
        #terminal.EchoPrintTestLines()
        lines = terminal.GetPrintTestLines()

        # Upstream commit: no errors
        self.assertEqual(lines[0].text, '01: %s' % commits[0][1])

        # Second commit: all archs should fail with warnings
        self.assertEqual(lines[1].text, '02: %s' % commits[1][1])

        col = terminal.Color()
        self.assertSummary(lines[2].text,
                           'arm',
                           'w+', ['board1'],
                           outcome=OUTCOME_WARN)
        self.assertSummary(lines[3].text,
                           'powerpc',
                           'w+', ['board2', 'board3'],
                           outcome=OUTCOME_WARN)
        self.assertSummary(lines[4].text,
                           'sandbox',
                           'w+', ['board4'],
                           outcome=OUTCOME_WARN)

        # Second commit: The warnings should be listed
        self.assertEqual(lines[5].text,
                         'w+%s' % errors[0].rstrip().replace('\n', '\nw+'))
        self.assertEqual(lines[5].colour, col.MAGENTA)

        # Third commit: Still fails
        self.assertEqual(lines[6].text, '03: %s' % commits[2][1])
        self.assertSummary(lines[7].text,
                           'arm',
                           '', ['board1'],
                           outcome=OUTCOME_OK)
        self.assertSummary(lines[8].text, 'powerpc', '+', ['board2', 'board3'])
        self.assertSummary(lines[9].text, 'sandbox', '+', ['board4'])

        # Expect a compiler error
        self.assertEqual(lines[10].text,
                         '+%s' % errors[1].rstrip().replace('\n', '\n+'))

        # Fourth commit: Compile errors are fixed, just have warning for board3
        self.assertEqual(lines[11].text, '04: %s' % commits[3][1])
        expect = '%10s: ' % 'powerpc'
        expect += ' ' + col.Color(col.GREEN, '')
        expect += '  '
        expect += col.Color(col.GREEN, ' %s' % 'board2')
        expect += ' ' + col.Color(col.YELLOW, 'w+')
        expect += '  '
        expect += col.Color(col.YELLOW, ' %s' % 'board3')
        self.assertEqual(lines[12].text, expect)
        self.assertSummary(lines[13].text,
                           'sandbox',
                           'w+', ['board4'],
                           outcome=OUTCOME_WARN)

        # Compile error fixed
        self.assertEqual(lines[14].text,
                         '-%s' % errors[1].rstrip().replace('\n', '\n-'))
        self.assertEqual(lines[14].colour, col.GREEN)

        self.assertEqual(lines[15].text,
                         'w+%s' % errors[2].rstrip().replace('\n', '\nw+'))
        self.assertEqual(lines[15].colour, col.MAGENTA)

        # Fifth commit
        self.assertEqual(lines[16].text, '05: %s' % commits[4][1])
        self.assertSummary(lines[17].text,
                           'powerpc',
                           '', ['board3'],
                           outcome=OUTCOME_OK)
        self.assertSummary(lines[18].text, 'sandbox', '+', ['board4'])

        # The second line of errors[3] is a duplicate, so buildman will drop it
        expect = errors[3].rstrip().split('\n')
        expect = [expect[0]] + expect[2:]
        self.assertEqual(lines[19].text,
                         '+%s' % '\n'.join(expect).replace('\n', '\n+'))

        self.assertEqual(lines[20].text,
                         'w-%s' % errors[2].rstrip().replace('\n', '\nw-'))

        # Sixth commit
        self.assertEqual(lines[21].text, '06: %s' % commits[5][1])
        self.assertSummary(lines[22].text,
                           'sandbox',
                           '', ['board4'],
                           outcome=OUTCOME_OK)

        # The second line of errors[3] is a duplicate, so buildman will drop it
        expect = errors[3].rstrip().split('\n')
        expect = [expect[0]] + expect[2:]
        self.assertEqual(lines[23].text,
                         '-%s' % '\n'.join(expect).replace('\n', '\n-'))

        self.assertEqual(lines[24].text,
                         'w-%s' % errors[0].rstrip().replace('\n', '\nw-'))

        # Seventh commit
        self.assertEqual(lines[25].text, '07: %s' % commits[6][1])
        self.assertSummary(lines[26].text, 'sandbox', '+', ['board4'])

        # Pick out the correct error lines
        expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n')
        expect = expect_str[3:8] + [expect_str[-1]]
        self.assertEqual(lines[27].text,
                         '+%s' % '\n'.join(expect).replace('\n', '\n+'))

        # Now the warnings lines
        expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]]
        self.assertEqual(lines[28].text,
                         'w+%s' % '\n'.join(expect).replace('\n', '\nw+'))

        self.assertEqual(len(lines), 29)
        shutil.rmtree(base_dir)
예제 #6
0
    def testOutput(self):
        """Test basic builder operation and output

        This does a line-by-line verification of the summary output.
        """
        global base_dir

        base_dir = tempfile.mkdtemp()
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        build = builder.Builder(self.toolchains,
                                base_dir,
                                None,
                                1,
                                2,
                                checkout=False,
                                show_unknown=False)
        build.do_make = self.Make
        board_selected = self.boards.GetSelectedDict()

        build.BuildBoards(self.commits,
                          board_selected,
                          keep_outputs=False,
                          verbose=False)
        lines = terminal.GetPrintTestLines()
        count = 0
        for line in lines:
            if line.text.strip():
                count += 1

        # We should get one starting message, then an update for every commit
        # built.
        self.assertEqual(count, len(commits) * len(boards) + 1)
        build.SetDisplayOptions(show_errors=True)
        build.ShowSummary(self.commits, board_selected)
        #terminal.EchoPrintTestLines()
        lines = terminal.GetPrintTestLines()
        self.assertEqual(lines[0].text, '01: %s' % commits[0][1])
        self.assertEqual(lines[1].text, '02: %s' % commits[1][1])

        # We expect all archs to fail
        col = terminal.Color()
        self.assertSummary(lines[2].text, 'sandbox', '+', ['board4'])
        self.assertSummary(lines[3].text, 'arm', '+', ['board1'])
        self.assertSummary(lines[4].text, 'powerpc', '+', ['board2', 'board3'])

        # Now we should have the compiler warning
        self.assertEqual(lines[5].text,
                         'w+%s' % errors[0].rstrip().replace('\n', '\nw+'))
        self.assertEqual(lines[5].colour, col.MAGENTA)

        self.assertEqual(lines[6].text, '03: %s' % commits[2][1])
        self.assertSummary(lines[7].text, 'sandbox', '+', ['board4'])
        self.assertSummary(lines[8].text, 'arm', '', ['board1'], ok=True)
        self.assertSummary(lines[9].text, 'powerpc', '+', ['board2', 'board3'])

        # Compiler error
        self.assertEqual(lines[10].text,
                         '+%s' % errors[1].rstrip().replace('\n', '\n+'))

        self.assertEqual(lines[11].text, '04: %s' % commits[3][1])
        self.assertSummary(lines[12].text, 'sandbox', '', ['board4'], ok=True)
        self.assertSummary(lines[13].text,
                           'powerpc',
                           '', ['board2', 'board3'],
                           ok=True)

        # Compile error fixed
        self.assertEqual(lines[14].text,
                         '-%s' % errors[1].rstrip().replace('\n', '\n-'))
        self.assertEqual(lines[14].colour, col.GREEN)

        self.assertEqual(lines[15].text,
                         'w+%s' % errors[2].rstrip().replace('\n', '\nw+'))
        self.assertEqual(lines[15].colour, col.MAGENTA)

        self.assertEqual(lines[16].text, '05: %s' % commits[4][1])
        self.assertSummary(lines[17].text, 'sandbox', '+', ['board4'])
        self.assertSummary(lines[18].text, 'powerpc', '', ['board3'], ok=True)

        # The second line of errors[3] is a duplicate, so buildman will drop it
        expect = errors[3].rstrip().split('\n')
        expect = [expect[0]] + expect[2:]
        self.assertEqual(lines[19].text,
                         '+%s' % '\n'.join(expect).replace('\n', '\n+'))

        self.assertEqual(lines[20].text,
                         'w-%s' % errors[2].rstrip().replace('\n', '\nw-'))

        self.assertEqual(lines[21].text, '06: %s' % commits[5][1])
        self.assertSummary(lines[22].text, 'sandbox', '', ['board4'], ok=True)

        # The second line of errors[3] is a duplicate, so buildman will drop it
        expect = errors[3].rstrip().split('\n')
        expect = [expect[0]] + expect[2:]
        self.assertEqual(lines[23].text,
                         '-%s' % '\n'.join(expect).replace('\n', '\n-'))

        self.assertEqual(lines[24].text,
                         'w-%s' % errors[0].rstrip().replace('\n', '\nw-'))

        self.assertEqual(lines[25].text, '07: %s' % commits[6][1])
        self.assertSummary(lines[26].text, 'sandbox', '+', ['board4'])

        # Pick out the correct error lines
        expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n')
        expect = expect_str[3:8] + [expect_str[-1]]
        self.assertEqual(lines[27].text,
                         '+%s' % '\n'.join(expect).replace('\n', '\n+'))

        # Now the warnings lines
        expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]]
        self.assertEqual(lines[28].text,
                         'w+%s' % '\n'.join(expect).replace('\n', '\nw+'))

        self.assertEqual(len(lines), 29)
        shutil.rmtree(base_dir)