2 # Copyright (c) 2012 The Chromium OS Authors.
4 # See file CREDITS for list of people who contributed to this
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 # Bring in the patman libraries
31 our_path = os.path.dirname(os.path.realpath(__file__))
32 sys.path.append(os.path.join(our_path, '../patman'))
43 '''main.c: In function 'main_loop':
44 main.c:260:6: warning: unused variable 'joe' [-Wunused-variable]
46 '''main.c: In function 'main_loop':
47 main.c:295:2: error: 'fred' undeclared (first use in this function)
48 main.c:295:2: note: each undeclared identifier is reported only once for each function it appears in
49 make[1]: *** [main.o] Error 1
50 make: *** [common/libcommon.o] Error 2
53 '''main.c: In function 'main_loop':
54 main.c:280:6: warning: unused variable 'mary' [-Wunused-variable]
56 '''powerpc-linux-ld: warning: dot moved backwards before `.bss'
57 powerpc-linux-ld: warning: dot moved backwards before `.bss'
58 powerpc-linux-ld: u-boot: section .text lma 0xfffc0000 overlaps previous sections
59 powerpc-linux-ld: u-boot: section .rodata lma 0xfffef3ec overlaps previous sections
60 powerpc-linux-ld: u-boot: section .reloc lma 0xffffa400 overlaps previous sections
61 powerpc-linux-ld: u-boot: section .data lma 0xffffcd38 overlaps previous sections
62 powerpc-linux-ld: u-boot: section .u_boot_cmd lma 0xffffeb40 overlaps previous sections
63 powerpc-linux-ld: u-boot: section .bootpg lma 0xfffff198 overlaps previous sections
68 # hash, subject, return code, list of errors/warnings
70 ['1234', 'upstream/master, ok', 0, []],
71 ['5678', 'Second commit, a warning', 0, errors[0:1]],
72 ['9012', 'Third commit, error', 1, errors[0:2]],
73 ['3456', 'Fourth commit, warning', 0, [errors[0], errors[2]]],
74 ['7890', 'Fifth commit, link errors', 1, [errors[0], errors[3]]],
75 ['abcd', 'Sixth commit, fixes all errors', 0, []]
79 ['board0', 'arm', 'armv7', 'ARM Board 1', 'Tester', '', ''],
80 ['board1', 'arm', 'armv7', 'ARM Board 2', 'Tester', '', ''],
81 ['board2', 'powerpc', 'powerpc', 'PowerPC board 1', 'Tester', '', ''],
82 ['board3', 'powerpc', 'mpc5xx', 'PowerPC board 2', 'Tester', '', ''],
83 ['board4', 'sandbox', 'sandbox', 'Sandbox board', 'Tester', '', '']
87 """Class that holds build options"""
90 class TestBuild(unittest.TestCase):
93 TODO: Write tests for the rest of the functionality
96 # Set up commits to build
99 for commit_info in commits:
100 comm = commit.Commit(commit_info[0])
101 comm.subject = commit_info[1]
102 comm.return_code = commit_info[2]
103 comm.error_list = commit_info[3]
104 comm.sequence = sequence
106 self.commits.append(comm)
108 # Set up boards to build
109 self.boards = board.Boards()
111 self.boards.AddBoard(board.Board(*brd))
112 self.boards.SelectBoards([])
114 # Set up the toolchains
116 self.toolchains = toolchain.Toolchains()
117 self.toolchains.Add('arm-linux-gcc', test=False)
118 self.toolchains.Add('sparc-linux-gcc', test=False)
119 self.toolchains.Add('powerpc-linux-gcc', test=False)
120 self.toolchains.Add('gcc', test=False)
122 def Make(self, commit, brd, stage, *args, **kwargs):
123 result = command.CommandResult()
124 boardnum = int(brd.target[-1])
125 result.return_code = 0
127 result.stdout = ('This is the test output for board %s, commit %s' %
128 (brd.target, commit.hash))
129 if boardnum >= 1 and boardnum >= commit.sequence:
130 result.return_code = commit.return_code
131 result.stderr = ''.join(commit.error_list)
135 if arg.startswith('O='):
138 if not os.path.isdir(target_dir):
140 #time.sleep(.2 + boardnum * .2)
142 result.combined = result.stdout + result.stderr
146 """Test basic builder operation"""
147 output_dir = tempfile.mkdtemp()
148 if not os.path.isdir(output_dir):
150 build = builder.Builder(self.toolchains, output_dir, None, 1, 2,
151 checkout=False, show_unknown=False)
152 build.do_make = self.Make
153 board_selected = self.boards.GetSelectedDict()
155 #build.BuildCommits(self.commits, board_selected, False)
156 build.BuildBoards(self.commits, board_selected, False, False)
157 build.ShowSummary(self.commits, board_selected, True, False,
161 """Test basic builder operation by building a branch"""
162 base_dir = tempfile.mkdtemp()
163 if not os.path.isdir(base_dir):
166 options.git = os.getcwd()
167 options.summary = False
169 options.dry_run = False
170 #options.git = os.path.join(base_dir, 'repo')
171 options.branch = 'test-buildman'
172 options.force_build = False
173 options.list_tool_chains = False
175 options.git_dir = None
176 options.threads = None
177 options.show_unknown = False
178 options.quick = False
179 options.show_errors = False
180 options.keep_outputs = False
182 control.DoBuildman(options, args)
184 if __name__ == "__main__":