Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 2 | # Copyright (c) 2012 The Chromium OS Authors. |
| 3 | # |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 4 | |
| 5 | import os |
| 6 | import shutil |
| 7 | import sys |
| 8 | import tempfile |
| 9 | import time |
| 10 | import unittest |
| 11 | |
| 12 | # Bring in the patman libraries |
| 13 | our_path = os.path.dirname(os.path.realpath(__file__)) |
| 14 | sys.path.append(os.path.join(our_path, '../patman')) |
| 15 | |
| 16 | import board |
| 17 | import bsettings |
| 18 | import builder |
| 19 | import control |
| 20 | import command |
| 21 | import commit |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 22 | import terminal |
Simon Glass | 4b4bc06 | 2018-10-01 21:12:43 -0600 | [diff] [blame] | 23 | import test_util |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 24 | import toolchain |
Simon Glass | 925f6ad | 2020-03-18 09:42:45 -0600 | [diff] [blame] | 25 | import tools |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 26 | |
Simon Glass | cb39a10 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 27 | use_network = True |
| 28 | |
Simon Glass | cc93529 | 2014-12-01 17:34:04 -0700 | [diff] [blame] | 29 | settings_data = ''' |
| 30 | # Buildman settings file |
| 31 | |
| 32 | [toolchain] |
| 33 | main: /usr/sbin |
| 34 | |
| 35 | [toolchain-alias] |
| 36 | x86: i386 x86_64 |
| 37 | ''' |
| 38 | |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 39 | migration = '''===================== WARNING ====================== |
| 40 | This board does not use CONFIG_DM. CONFIG_DM will be |
| 41 | compulsory starting with the v2020.01 release. |
| 42 | Failure to update may result in board removal. |
| 43 | See doc/driver-model/migration.rst for more info. |
| 44 | ==================================================== |
| 45 | ''' |
| 46 | |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 47 | errors = [ |
| 48 | '''main.c: In function 'main_loop': |
| 49 | main.c:260:6: warning: unused variable 'joe' [-Wunused-variable] |
| 50 | ''', |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 51 | '''main.c: In function 'main_loop2': |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 52 | main.c:295:2: error: 'fred' undeclared (first use in this function) |
| 53 | main.c:295:2: note: each undeclared identifier is reported only once for each function it appears in |
| 54 | make[1]: *** [main.o] Error 1 |
| 55 | make: *** [common/libcommon.o] Error 2 |
| 56 | Make failed |
| 57 | ''', |
Simon Glass | 2d48333 | 2018-11-06 16:02:11 -0700 | [diff] [blame] | 58 | '''arch/arm/dts/socfpga_arria10_socdk_sdmmc.dtb: Warning \ |
| 59 | (avoid_unnecessary_addr_size): /clocks: unnecessary #address-cells/#size-cells \ |
| 60 | without "ranges" or child "reg" property |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 61 | ''', |
| 62 | '''powerpc-linux-ld: warning: dot moved backwards before `.bss' |
| 63 | powerpc-linux-ld: warning: dot moved backwards before `.bss' |
| 64 | powerpc-linux-ld: u-boot: section .text lma 0xfffc0000 overlaps previous sections |
| 65 | powerpc-linux-ld: u-boot: section .rodata lma 0xfffef3ec overlaps previous sections |
| 66 | powerpc-linux-ld: u-boot: section .reloc lma 0xffffa400 overlaps previous sections |
| 67 | powerpc-linux-ld: u-boot: section .data lma 0xffffcd38 overlaps previous sections |
| 68 | powerpc-linux-ld: u-boot: section .u_boot_cmd lma 0xffffeb40 overlaps previous sections |
| 69 | powerpc-linux-ld: u-boot: section .bootpg lma 0xfffff198 overlaps previous sections |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 70 | ''', |
| 71 | '''In file included from %(basedir)sarch/sandbox/cpu/cpu.c:9:0: |
| 72 | %(basedir)sarch/sandbox/include/asm/state.h:44:0: warning: "xxxx" redefined [enabled by default] |
| 73 | %(basedir)sarch/sandbox/include/asm/state.h:43:0: note: this is the location of the previous definition |
| 74 | %(basedir)sarch/sandbox/cpu/cpu.c: In function 'do_reset': |
| 75 | %(basedir)sarch/sandbox/cpu/cpu.c:27:1: error: unknown type name 'blah' |
| 76 | %(basedir)sarch/sandbox/cpu/cpu.c:28:12: error: expected declaration specifiers or '...' before numeric constant |
| 77 | make[2]: *** [arch/sandbox/cpu/cpu.o] Error 1 |
| 78 | make[1]: *** [arch/sandbox/cpu] Error 2 |
| 79 | make[1]: *** Waiting for unfinished jobs.... |
| 80 | In file included from %(basedir)scommon/board_f.c:55:0: |
| 81 | %(basedir)sarch/sandbox/include/asm/state.h:44:0: warning: "xxxx" redefined [enabled by default] |
| 82 | %(basedir)sarch/sandbox/include/asm/state.h:43:0: note: this is the location of the previous definition |
| 83 | make: *** [sub-make] Error 2 |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 84 | ''' |
| 85 | ] |
| 86 | |
| 87 | |
| 88 | # hash, subject, return code, list of errors/warnings |
| 89 | commits = [ |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 90 | ['1234', 'upstream/master, migration warning', 0, []], |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 91 | ['5678', 'Second commit, a warning', 0, errors[0:1]], |
| 92 | ['9012', 'Third commit, error', 1, errors[0:2]], |
| 93 | ['3456', 'Fourth commit, warning', 0, [errors[0], errors[2]]], |
| 94 | ['7890', 'Fifth commit, link errors', 1, [errors[0], errors[3]]], |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 95 | ['abcd', 'Sixth commit, fixes all errors', 0, []], |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 96 | ['ef01', 'Seventh commit, fix migration, check directory suppression', 1, |
| 97 | [errors[4]]], |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 98 | ] |
| 99 | |
| 100 | boards = [ |
Simon Glass | e19d578 | 2013-09-23 17:35:16 -0600 | [diff] [blame] | 101 | ['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 1', 'board0', ''], |
| 102 | ['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 2', 'board1', ''], |
| 103 | ['Active', 'powerpc', 'powerpc', '', 'Tester', 'PowerPC board 1', 'board2', ''], |
Simon Glass | 251f586 | 2017-11-12 21:52:15 -0700 | [diff] [blame] | 104 | ['Active', 'powerpc', 'mpc83xx', '', 'Tester', 'PowerPC board 2', 'board3', ''], |
Simon Glass | e19d578 | 2013-09-23 17:35:16 -0600 | [diff] [blame] | 105 | ['Active', 'sandbox', 'sandbox', '', 'Tester', 'Sandbox board', 'board4', ''], |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 106 | ] |
| 107 | |
Simon Glass | 4466c1f | 2014-12-01 17:33:51 -0700 | [diff] [blame] | 108 | BASE_DIR = 'base' |
| 109 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 110 | OUTCOME_OK, OUTCOME_WARN, OUTCOME_ERR = range(3) |
| 111 | |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 112 | class Options: |
| 113 | """Class that holds build options""" |
| 114 | pass |
| 115 | |
| 116 | class TestBuild(unittest.TestCase): |
| 117 | """Test buildman |
| 118 | |
| 119 | TODO: Write tests for the rest of the functionality |
| 120 | """ |
| 121 | def setUp(self): |
| 122 | # Set up commits to build |
| 123 | self.commits = [] |
| 124 | sequence = 0 |
| 125 | for commit_info in commits: |
| 126 | comm = commit.Commit(commit_info[0]) |
| 127 | comm.subject = commit_info[1] |
| 128 | comm.return_code = commit_info[2] |
| 129 | comm.error_list = commit_info[3] |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 130 | if sequence < 6: |
| 131 | comm.error_list += [migration] |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 132 | comm.sequence = sequence |
| 133 | sequence += 1 |
| 134 | self.commits.append(comm) |
| 135 | |
| 136 | # Set up boards to build |
| 137 | self.boards = board.Boards() |
| 138 | for brd in boards: |
| 139 | self.boards.AddBoard(board.Board(*brd)) |
| 140 | self.boards.SelectBoards([]) |
| 141 | |
Simon Glass | cc93529 | 2014-12-01 17:34:04 -0700 | [diff] [blame] | 142 | # Add some test settings |
| 143 | bsettings.Setup(None) |
| 144 | bsettings.AddFile(settings_data) |
| 145 | |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 146 | # Set up the toolchains |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 147 | self.toolchains = toolchain.Toolchains() |
| 148 | self.toolchains.Add('arm-linux-gcc', test=False) |
| 149 | self.toolchains.Add('sparc-linux-gcc', test=False) |
| 150 | self.toolchains.Add('powerpc-linux-gcc', test=False) |
| 151 | self.toolchains.Add('gcc', test=False) |
| 152 | |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 153 | # Avoid sending any output |
| 154 | terminal.SetPrintTestMode() |
| 155 | self._col = terminal.Color() |
| 156 | |
Simon Glass | af43065 | 2020-04-09 15:08:31 -0600 | [diff] [blame] | 157 | self.base_dir = tempfile.mkdtemp() |
| 158 | if not os.path.isdir(self.base_dir): |
| 159 | os.mkdir(self.base_dir) |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 160 | |
Simon Glass | af43065 | 2020-04-09 15:08:31 -0600 | [diff] [blame] | 161 | def tearDown(self): |
| 162 | shutil.rmtree(self.base_dir) |
| 163 | |
| 164 | def Make(self, commit, brd, stage, *args, **kwargs): |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 165 | result = command.CommandResult() |
| 166 | boardnum = int(brd.target[-1]) |
| 167 | result.return_code = 0 |
| 168 | result.stderr = '' |
| 169 | result.stdout = ('This is the test output for board %s, commit %s' % |
| 170 | (brd.target, commit.hash)) |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 171 | if ((boardnum >= 1 and boardnum >= commit.sequence) or |
| 172 | boardnum == 4 and commit.sequence == 6): |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 173 | result.return_code = commit.return_code |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 174 | result.stderr = (''.join(commit.error_list) |
Simon Glass | af43065 | 2020-04-09 15:08:31 -0600 | [diff] [blame] | 175 | % {'basedir' : self.base_dir + '/.bm-work/00/'}) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 176 | elif commit.sequence < 6: |
| 177 | result.stderr = migration |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 178 | |
| 179 | result.combined = result.stdout + result.stderr |
| 180 | return result |
| 181 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 182 | def assertSummary(self, text, arch, plus, boards, outcome=OUTCOME_ERR): |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 183 | col = self._col |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 184 | expected_colour = (col.GREEN if outcome == OUTCOME_OK else |
| 185 | col.YELLOW if outcome == OUTCOME_WARN else col.RED) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 186 | expect = '%10s: ' % arch |
| 187 | # TODO(sjg@chromium.org): If plus is '', we shouldn't need this |
Simon Glass | 63c619e | 2015-02-05 22:06:11 -0700 | [diff] [blame] | 188 | expect += ' ' + col.Color(expected_colour, plus) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 189 | expect += ' ' |
| 190 | for board in boards: |
| 191 | expect += col.Color(expected_colour, ' %s' % board) |
| 192 | self.assertEqual(text, expect) |
| 193 | |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 194 | def _SetupTest(self, echo_lines=False, **kwdisplay_args): |
| 195 | """Set up the test by running a build and summary |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 196 | |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 197 | Args: |
| 198 | echo_lines: True to echo lines to the terminal to aid test |
| 199 | development |
| 200 | kwdisplay_args: Dict of arguemnts to pass to |
| 201 | Builder.SetDisplayOptions() |
| 202 | |
| 203 | Returns: |
| 204 | Iterator containing the output lines, each a PrintLine() object |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 205 | """ |
Simon Glass | af43065 | 2020-04-09 15:08:31 -0600 | [diff] [blame] | 206 | build = builder.Builder(self.toolchains, self.base_dir, None, 1, 2, |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 207 | checkout=False, show_unknown=False) |
| 208 | build.do_make = self.Make |
| 209 | board_selected = self.boards.GetSelectedDict() |
| 210 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 211 | # Build the boards for the pre-defined commits and warnings/errors |
| 212 | # associated with each. This calls our Make() to inject the fake output. |
Simon Glass | e5a0e5d | 2014-08-09 15:33:03 -0600 | [diff] [blame] | 213 | build.BuildBoards(self.commits, board_selected, keep_outputs=False, |
| 214 | verbose=False) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 215 | lines = terminal.GetPrintTestLines() |
| 216 | count = 0 |
| 217 | for line in lines: |
| 218 | if line.text.strip(): |
| 219 | count += 1 |
| 220 | |
Simon Glass | 7b33f21 | 2020-04-09 15:08:47 -0600 | [diff] [blame] | 221 | # We should get two starting messages, an update for every commit built |
| 222 | # and a summary message |
| 223 | self.assertEqual(count, len(commits) * len(boards) + 3) |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 224 | build.SetDisplayOptions(**kwdisplay_args); |
Simon Glass | b2ea7ab | 2014-08-09 15:33:02 -0600 | [diff] [blame] | 225 | build.ShowSummary(self.commits, board_selected) |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 226 | if echo_lines: |
| 227 | terminal.EchoPrintTestLines() |
| 228 | return iter(terminal.GetPrintTestLines()) |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 229 | |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 230 | def _CheckOutput(self, lines, list_error_boards=False, |
| 231 | filter_dtb_warnings=False, |
| 232 | filter_migration_warnings=False): |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 233 | """Check for expected output from the build summary |
| 234 | |
| 235 | Args: |
| 236 | lines: Iterator containing the lines returned from the summary |
Simon Glass | e631a2b | 2020-04-09 15:08:34 -0600 | [diff] [blame] | 237 | list_error_boards: Adjust the check for output produced with the |
| 238 | --list-error-boards flag |
Simon Glass | 174592b | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 239 | filter_dtb_warnings: Adjust the check for output produced with the |
| 240 | --filter-dtb-warnings flag |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 241 | """ |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 242 | def add_line_prefix(prefix, boards, error_str, colour): |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 243 | """Add a prefix to each line of a string |
| 244 | |
| 245 | The training \n in error_str is removed before processing |
| 246 | |
| 247 | Args: |
| 248 | prefix: String prefix to add |
| 249 | error_str: Error string containing the lines |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 250 | colour: Expected colour for the line. Note that the board list, |
| 251 | if present, always appears in magenta |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 252 | |
| 253 | Returns: |
| 254 | New string where each line has the prefix added |
| 255 | """ |
| 256 | lines = error_str.strip().splitlines() |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 257 | new_lines = [] |
| 258 | for line in lines: |
| 259 | if boards: |
| 260 | expect = self._col.Color(colour, prefix + '(') |
| 261 | expect += self._col.Color(self._col.MAGENTA, boards, |
| 262 | bright=False) |
| 263 | expect += self._col.Color(colour, ') %s' % line) |
| 264 | else: |
| 265 | expect = self._col.Color(colour, prefix + line) |
| 266 | new_lines.append(expect) |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 267 | return '\n'.join(new_lines) |
| 268 | |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 269 | col = terminal.Color() |
| 270 | boards01234 = ('board0 board1 board2 board3 board4' |
| 271 | if list_error_boards else '') |
Simon Glass | 9ef0ceb | 2020-04-09 15:08:38 -0600 | [diff] [blame] | 272 | boards1234 = 'board1 board2 board3 board4' if list_error_boards else '' |
| 273 | boards234 = 'board2 board3 board4' if list_error_boards else '' |
| 274 | boards34 = 'board3 board4' if list_error_boards else '' |
Simon Glass | e631a2b | 2020-04-09 15:08:34 -0600 | [diff] [blame] | 275 | boards4 = 'board4' if list_error_boards else '' |
| 276 | |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 277 | # Upstream commit: migration warnings only |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 278 | self.assertEqual(next(lines).text, '01: %s' % commits[0][1]) |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 279 | |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 280 | if not filter_migration_warnings: |
| 281 | self.assertSummary(next(lines).text, 'arm', 'w+', |
| 282 | ['board0', 'board1'], outcome=OUTCOME_WARN) |
| 283 | self.assertSummary(next(lines).text, 'powerpc', 'w+', |
| 284 | ['board2', 'board3'], outcome=OUTCOME_WARN) |
| 285 | self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'], |
| 286 | outcome=OUTCOME_WARN) |
| 287 | |
| 288 | self.assertEqual(next(lines).text, |
| 289 | add_line_prefix('+', boards01234, migration, col.RED)) |
| 290 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 291 | # Second commit: all archs should fail with warnings |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 292 | self.assertEqual(next(lines).text, '02: %s' % commits[1][1]) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 293 | |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 294 | if filter_migration_warnings: |
| 295 | self.assertSummary(next(lines).text, 'arm', 'w+', |
| 296 | ['board1'], outcome=OUTCOME_WARN) |
| 297 | self.assertSummary(next(lines).text, 'powerpc', 'w+', |
| 298 | ['board2', 'board3'], outcome=OUTCOME_WARN) |
| 299 | self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'], |
| 300 | outcome=OUTCOME_WARN) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 301 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 302 | # Second commit: The warnings should be listed |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 303 | self.assertEqual(next(lines).text, |
| 304 | add_line_prefix('w+', boards1234, errors[0], col.YELLOW)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 305 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 306 | # Third commit: Still fails |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 307 | self.assertEqual(next(lines).text, '03: %s' % commits[2][1]) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 308 | if filter_migration_warnings: |
| 309 | self.assertSummary(next(lines).text, 'arm', '', |
| 310 | ['board1'], outcome=OUTCOME_OK) |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 311 | self.assertSummary(next(lines).text, 'powerpc', '+', |
| 312 | ['board2', 'board3']) |
| 313 | self.assertSummary(next(lines).text, 'sandbox', '+', ['board4']) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 314 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 315 | # Expect a compiler error |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 316 | self.assertEqual(next(lines).text, |
| 317 | add_line_prefix('+', boards234, errors[1], col.RED)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 318 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 319 | # Fourth commit: Compile errors are fixed, just have warning for board3 |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 320 | self.assertEqual(next(lines).text, '04: %s' % commits[3][1]) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 321 | if filter_migration_warnings: |
| 322 | expect = '%10s: ' % 'powerpc' |
| 323 | expect += ' ' + col.Color(col.GREEN, '') |
| 324 | expect += ' ' |
| 325 | expect += col.Color(col.GREEN, ' %s' % 'board2') |
| 326 | expect += ' ' + col.Color(col.YELLOW, 'w+') |
| 327 | expect += ' ' |
| 328 | expect += col.Color(col.YELLOW, ' %s' % 'board3') |
| 329 | self.assertEqual(next(lines).text, expect) |
| 330 | else: |
| 331 | self.assertSummary(next(lines).text, 'powerpc', 'w+', |
| 332 | ['board2', 'board3'], outcome=OUTCOME_WARN) |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 333 | self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'], |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 334 | outcome=OUTCOME_WARN) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 335 | |
| 336 | # Compile error fixed |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 337 | self.assertEqual(next(lines).text, |
| 338 | add_line_prefix('-', boards234, errors[1], col.GREEN)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 339 | |
Simon Glass | 174592b | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 340 | if not filter_dtb_warnings: |
| 341 | self.assertEqual( |
| 342 | next(lines).text, |
| 343 | add_line_prefix('w+', boards34, errors[2], col.YELLOW)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 344 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 345 | # Fifth commit |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 346 | self.assertEqual(next(lines).text, '05: %s' % commits[4][1]) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 347 | if filter_migration_warnings: |
| 348 | self.assertSummary(next(lines).text, 'powerpc', '', ['board3'], |
| 349 | outcome=OUTCOME_OK) |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 350 | self.assertSummary(next(lines).text, 'sandbox', '+', ['board4']) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 351 | |
| 352 | # The second line of errors[3] is a duplicate, so buildman will drop it |
| 353 | expect = errors[3].rstrip().split('\n') |
| 354 | expect = [expect[0]] + expect[2:] |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 355 | expect = '\n'.join(expect) |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 356 | self.assertEqual(next(lines).text, |
| 357 | add_line_prefix('+', boards4, expect, col.RED)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 358 | |
Simon Glass | 174592b | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 359 | if not filter_dtb_warnings: |
| 360 | self.assertEqual( |
| 361 | next(lines).text, |
| 362 | add_line_prefix('w-', boards34, errors[2], col.CYAN)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 363 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 364 | # Sixth commit |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 365 | self.assertEqual(next(lines).text, '06: %s' % commits[5][1]) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 366 | if filter_migration_warnings: |
| 367 | self.assertSummary(next(lines).text, 'sandbox', '', ['board4'], |
| 368 | outcome=OUTCOME_OK) |
| 369 | else: |
| 370 | self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'], |
| 371 | outcome=OUTCOME_WARN) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 372 | |
| 373 | # The second line of errors[3] is a duplicate, so buildman will drop it |
| 374 | expect = errors[3].rstrip().split('\n') |
| 375 | expect = [expect[0]] + expect[2:] |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 376 | expect = '\n'.join(expect) |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 377 | self.assertEqual(next(lines).text, |
| 378 | add_line_prefix('-', boards4, expect, col.GREEN)) |
| 379 | self.assertEqual(next(lines).text, |
| 380 | add_line_prefix('w-', boards4, errors[0], col.CYAN)) |
Simon Glass | 6208fce | 2014-09-05 19:00:08 -0600 | [diff] [blame] | 381 | |
Simon Glass | 6af7101 | 2018-11-06 16:02:13 -0700 | [diff] [blame] | 382 | # Seventh commit |
Simon Glass | c3bc4f1 | 2020-04-09 15:08:30 -0600 | [diff] [blame] | 383 | self.assertEqual(next(lines).text, '07: %s' % commits[6][1]) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 384 | if filter_migration_warnings: |
| 385 | self.assertSummary(next(lines).text, 'sandbox', '+', ['board4']) |
| 386 | else: |
| 387 | self.assertSummary(next(lines).text, 'arm', '', ['board0', 'board1'], |
| 388 | outcome=OUTCOME_OK) |
| 389 | self.assertSummary(next(lines).text, 'powerpc', '', |
| 390 | ['board2', 'board3'], outcome=OUTCOME_OK) |
| 391 | self.assertSummary(next(lines).text, 'sandbox', '+', ['board4']) |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 392 | |
| 393 | # Pick out the correct error lines |
| 394 | expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n') |
| 395 | expect = expect_str[3:8] + [expect_str[-1]] |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 396 | expect = '\n'.join(expect) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 397 | if not filter_migration_warnings: |
| 398 | self.assertEqual( |
| 399 | next(lines).text, |
| 400 | add_line_prefix('-', boards01234, migration, col.GREEN)) |
| 401 | |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 402 | self.assertEqual(next(lines).text, |
| 403 | add_line_prefix('+', boards4, expect, col.RED)) |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 404 | |
| 405 | # Now the warnings lines |
| 406 | expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]] |
Simon Glass | c9dd80b | 2020-04-09 15:08:33 -0600 | [diff] [blame] | 407 | expect = '\n'.join(expect) |
Simon Glass | 8c9a267 | 2020-04-09 15:08:37 -0600 | [diff] [blame] | 408 | self.assertEqual(next(lines).text, |
| 409 | add_line_prefix('w+', boards4, expect, col.YELLOW)) |
Simon Glass | 930c8d4 | 2014-09-05 19:00:21 -0600 | [diff] [blame] | 410 | |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 411 | def testOutput(self): |
| 412 | """Test basic builder operation and output |
| 413 | |
| 414 | This does a line-by-line verification of the summary output. |
| 415 | """ |
| 416 | lines = self._SetupTest(show_errors=True) |
Simon Glass | 174592b | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 417 | self._CheckOutput(lines, list_error_boards=False, |
| 418 | filter_dtb_warnings=False) |
Simon Glass | e631a2b | 2020-04-09 15:08:34 -0600 | [diff] [blame] | 419 | |
| 420 | def testErrorBoards(self): |
| 421 | """Test output with --list-error-boards |
| 422 | |
| 423 | This does a line-by-line verification of the summary output. |
| 424 | """ |
| 425 | lines = self._SetupTest(show_errors=True, list_error_boards=True) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 426 | self._CheckOutput(lines, list_error_boards=True) |
Simon Glass | 174592b | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 427 | |
| 428 | def testFilterDtb(self): |
| 429 | """Test output with --filter-dtb-warnings |
| 430 | |
| 431 | This does a line-by-line verification of the summary output. |
| 432 | """ |
| 433 | lines = self._SetupTest(show_errors=True, filter_dtb_warnings=True) |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 434 | self._CheckOutput(lines, filter_dtb_warnings=True) |
| 435 | |
| 436 | def testFilterMigration(self): |
| 437 | """Test output with --filter-migration-warnings |
| 438 | |
| 439 | This does a line-by-line verification of the summary output. |
| 440 | """ |
| 441 | lines = self._SetupTest(show_errors=True, |
| 442 | filter_migration_warnings=True) |
| 443 | self._CheckOutput(lines, filter_migration_warnings=True) |
Simon Glass | ce558db | 2020-04-09 15:08:32 -0600 | [diff] [blame] | 444 | |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 445 | def _testGit(self): |
| 446 | """Test basic builder operation by building a branch""" |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 447 | options = Options() |
| 448 | options.git = os.getcwd() |
| 449 | options.summary = False |
| 450 | options.jobs = None |
| 451 | options.dry_run = False |
Simon Glass | af43065 | 2020-04-09 15:08:31 -0600 | [diff] [blame] | 452 | #options.git = os.path.join(self.base_dir, 'repo') |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 453 | options.branch = 'test-buildman' |
| 454 | options.force_build = False |
| 455 | options.list_tool_chains = False |
| 456 | options.count = -1 |
| 457 | options.git_dir = None |
| 458 | options.threads = None |
| 459 | options.show_unknown = False |
| 460 | options.quick = False |
| 461 | options.show_errors = False |
| 462 | options.keep_outputs = False |
| 463 | args = ['tegra20'] |
| 464 | control.DoBuildman(options, args) |
| 465 | |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 466 | def testBoardSingle(self): |
| 467 | """Test single board selection""" |
| 468 | self.assertEqual(self.boards.SelectBoards(['sandbox']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 469 | ({'all': ['board4'], 'sandbox': ['board4']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 470 | |
| 471 | def testBoardArch(self): |
| 472 | """Test single board selection""" |
| 473 | self.assertEqual(self.boards.SelectBoards(['arm']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 474 | ({'all': ['board0', 'board1'], |
| 475 | 'arm': ['board0', 'board1']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 476 | |
| 477 | def testBoardArchSingle(self): |
| 478 | """Test single board selection""" |
| 479 | self.assertEqual(self.boards.SelectBoards(['arm sandbox']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 480 | ({'sandbox': ['board4'], |
Simon Glass | 251f586 | 2017-11-12 21:52:15 -0700 | [diff] [blame] | 481 | 'all': ['board0', 'board1', 'board4'], |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 482 | 'arm': ['board0', 'board1']}, [])) |
Simon Glass | 251f586 | 2017-11-12 21:52:15 -0700 | [diff] [blame] | 483 | |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 484 | |
| 485 | def testBoardArchSingleMultiWord(self): |
| 486 | """Test single board selection""" |
| 487 | self.assertEqual(self.boards.SelectBoards(['arm', 'sandbox']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 488 | ({'sandbox': ['board4'], |
| 489 | 'all': ['board0', 'board1', 'board4'], |
| 490 | 'arm': ['board0', 'board1']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 491 | |
| 492 | def testBoardSingleAnd(self): |
| 493 | """Test single board selection""" |
| 494 | self.assertEqual(self.boards.SelectBoards(['Tester & arm']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 495 | ({'Tester&arm': ['board0', 'board1'], |
| 496 | 'all': ['board0', 'board1']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 497 | |
| 498 | def testBoardTwoAnd(self): |
| 499 | """Test single board selection""" |
| 500 | self.assertEqual(self.boards.SelectBoards(['Tester', '&', 'arm', |
| 501 | 'Tester' '&', 'powerpc', |
| 502 | 'sandbox']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 503 | ({'sandbox': ['board4'], |
Simon Glass | 251f586 | 2017-11-12 21:52:15 -0700 | [diff] [blame] | 504 | 'all': ['board0', 'board1', 'board2', 'board3', |
| 505 | 'board4'], |
| 506 | 'Tester&powerpc': ['board2', 'board3'], |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 507 | 'Tester&arm': ['board0', 'board1']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 508 | |
| 509 | def testBoardAll(self): |
| 510 | """Test single board selection""" |
Simon Glass | 251f586 | 2017-11-12 21:52:15 -0700 | [diff] [blame] | 511 | self.assertEqual(self.boards.SelectBoards([]), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 512 | ({'all': ['board0', 'board1', 'board2', 'board3', |
| 513 | 'board4']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 514 | |
| 515 | def testBoardRegularExpression(self): |
| 516 | """Test single board selection""" |
| 517 | self.assertEqual(self.boards.SelectBoards(['T.*r&^Po']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 518 | ({'all': ['board2', 'board3'], |
| 519 | 'T.*r&^Po': ['board2', 'board3']}, [])) |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 520 | |
| 521 | def testBoardDuplicate(self): |
| 522 | """Test single board selection""" |
| 523 | self.assertEqual(self.boards.SelectBoards(['sandbox sandbox', |
| 524 | 'sandbox']), |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 525 | ({'all': ['board4'], 'sandbox': ['board4']}, [])) |
Simon Glass | 4466c1f | 2014-12-01 17:33:51 -0700 | [diff] [blame] | 526 | def CheckDirs(self, build, dirname): |
| 527 | self.assertEqual('base%s' % dirname, build._GetOutputDir(1)) |
| 528 | self.assertEqual('base%s/fred' % dirname, |
| 529 | build.GetBuildDir(1, 'fred')) |
| 530 | self.assertEqual('base%s/fred/done' % dirname, |
| 531 | build.GetDoneFile(1, 'fred')) |
| 532 | self.assertEqual('base%s/fred/u-boot.sizes' % dirname, |
| 533 | build.GetFuncSizesFile(1, 'fred', 'u-boot')) |
| 534 | self.assertEqual('base%s/fred/u-boot.objdump' % dirname, |
| 535 | build.GetObjdumpFile(1, 'fred', 'u-boot')) |
| 536 | self.assertEqual('base%s/fred/err' % dirname, |
| 537 | build.GetErrFile(1, 'fred')) |
| 538 | |
| 539 | def testOutputDir(self): |
| 540 | build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2, |
| 541 | checkout=False, show_unknown=False) |
| 542 | build.commits = self.commits |
| 543 | build.commit_count = len(self.commits) |
| 544 | subject = self.commits[1].subject.translate(builder.trans_valid_chars) |
| 545 | dirname ='/%02d_of_%02d_g%s_%s' % (2, build.commit_count, commits[1][0], |
| 546 | subject[:20]) |
| 547 | self.CheckDirs(build, dirname) |
| 548 | |
| 549 | def testOutputDirCurrent(self): |
| 550 | build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2, |
| 551 | checkout=False, show_unknown=False) |
| 552 | build.commits = None |
| 553 | build.commit_count = 0 |
| 554 | self.CheckDirs(build, '/current') |
Simon Glass | 6131bea | 2014-08-09 15:33:08 -0600 | [diff] [blame] | 555 | |
Simon Glass | 5971ab5 | 2014-12-01 17:33:55 -0700 | [diff] [blame] | 556 | def testOutputDirNoSubdirs(self): |
| 557 | build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2, |
| 558 | checkout=False, show_unknown=False, |
| 559 | no_subdirs=True) |
| 560 | build.commits = None |
| 561 | build.commit_count = 0 |
| 562 | self.CheckDirs(build, '') |
| 563 | |
Simon Glass | 9b83bfd | 2014-12-01 17:34:05 -0700 | [diff] [blame] | 564 | def testToolchainAliases(self): |
| 565 | self.assertTrue(self.toolchains.Select('arm') != None) |
| 566 | with self.assertRaises(ValueError): |
| 567 | self.toolchains.Select('no-arch') |
| 568 | with self.assertRaises(ValueError): |
| 569 | self.toolchains.Select('x86') |
| 570 | |
| 571 | self.toolchains = toolchain.Toolchains() |
| 572 | self.toolchains.Add('x86_64-linux-gcc', test=False) |
| 573 | self.assertTrue(self.toolchains.Select('x86') != None) |
| 574 | |
| 575 | self.toolchains = toolchain.Toolchains() |
| 576 | self.toolchains.Add('i386-linux-gcc', test=False) |
| 577 | self.assertTrue(self.toolchains.Select('x86') != None) |
| 578 | |
Simon Glass | 827e37b | 2014-12-01 17:34:06 -0700 | [diff] [blame] | 579 | def testToolchainDownload(self): |
| 580 | """Test that we can download toolchains""" |
Simon Glass | cb39a10 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 581 | if use_network: |
Simon Glass | 4b4bc06 | 2018-10-01 21:12:43 -0600 | [diff] [blame] | 582 | with test_util.capture_sys_output() as (stdout, stderr): |
| 583 | url = self.toolchains.LocateArchUrl('arm') |
Simon Glass | da753e3 | 2018-10-01 21:12:35 -0600 | [diff] [blame] | 584 | self.assertRegexpMatches(url, 'https://www.kernel.org/pub/tools/' |
| 585 | 'crosstool/files/bin/x86_64/.*/' |
Simon Glass | 55a98d9 | 2020-04-17 17:51:30 -0600 | [diff] [blame] | 586 | 'x86_64-gcc-.*-nolibc[-_]arm-.*linux-gnueabi.tar.xz') |
Simon Glass | 827e37b | 2014-12-01 17:34:06 -0700 | [diff] [blame] | 587 | |
Simon Glass | 57cb9d5 | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 588 | def testGetEnvArgs(self): |
| 589 | """Test the GetEnvArgs() function""" |
| 590 | tc = self.toolchains.Select('arm') |
| 591 | self.assertEqual('arm-linux-', |
| 592 | tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) |
| 593 | self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_PATH)) |
| 594 | self.assertEqual('arm', |
| 595 | tc.GetEnvArgs(toolchain.VAR_ARCH)) |
| 596 | self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS)) |
| 597 | |
| 598 | self.toolchains.Add('/path/to/x86_64-linux-gcc', test=False) |
| 599 | tc = self.toolchains.Select('x86') |
| 600 | self.assertEqual('/path/to', |
| 601 | tc.GetEnvArgs(toolchain.VAR_PATH)) |
| 602 | tc.override_toolchain = 'clang' |
| 603 | self.assertEqual('HOSTCC=clang CC=clang', |
| 604 | tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS)) |
| 605 | |
Simon Glass | 925f6ad | 2020-03-18 09:42:45 -0600 | [diff] [blame] | 606 | def testPrepareOutputSpace(self): |
| 607 | def _Touch(fname): |
| 608 | tools.WriteFile(os.path.join(base_dir, fname), b'') |
| 609 | |
| 610 | base_dir = tempfile.mkdtemp() |
| 611 | |
| 612 | # Add various files that we want removed and left alone |
| 613 | to_remove = ['01_of_22_g0982734987_title', '102_of_222_g92bf_title', |
| 614 | '01_of_22_g2938abd8_title'] |
| 615 | to_leave = ['something_else', '01-something.patch', '01_of_22_another'] |
| 616 | for name in to_remove + to_leave: |
| 617 | _Touch(name) |
| 618 | |
| 619 | build = builder.Builder(self.toolchains, base_dir, None, 1, 2) |
| 620 | build.commits = self.commits |
| 621 | build.commit_count = len(commits) |
| 622 | result = set(build._GetOutputSpaceRemovals()) |
| 623 | expected = set([os.path.join(base_dir, f) for f in to_remove]) |
| 624 | self.assertEqual(expected, result) |
Simon Glass | 827e37b | 2014-12-01 17:34:06 -0700 | [diff] [blame] | 625 | |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 626 | if __name__ == "__main__": |
| 627 | unittest.main() |