2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2013-04-03 11:07:16 +00:00
|
|
|
# Copyright (c) 2012 The Chromium OS Authors.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
import time
|
|
|
|
import unittest
|
|
|
|
|
2020-04-18 00:09:02 +00:00
|
|
|
from buildman import board
|
|
|
|
from buildman import bsettings
|
|
|
|
from buildman import builder
|
2022-01-22 12:07:31 +00:00
|
|
|
from buildman import cfgutil
|
2020-04-18 00:09:02 +00:00
|
|
|
from buildman import control
|
|
|
|
from buildman import toolchain
|
2020-04-18 00:09:04 +00:00
|
|
|
from patman import commit
|
|
|
|
from patman import command
|
|
|
|
from patman import terminal
|
|
|
|
from patman import test_util
|
|
|
|
from patman import tools
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2017-11-13 04:52:14 +00:00
|
|
|
use_network = True
|
|
|
|
|
2014-12-02 00:34:04 +00:00
|
|
|
settings_data = '''
|
|
|
|
# Buildman settings file
|
|
|
|
|
|
|
|
[toolchain]
|
|
|
|
main: /usr/sbin
|
|
|
|
|
|
|
|
[toolchain-alias]
|
|
|
|
x86: i386 x86_64
|
|
|
|
'''
|
|
|
|
|
2020-04-09 21:08:53 +00:00
|
|
|
migration = '''===================== WARNING ======================
|
|
|
|
This board does not use CONFIG_DM. CONFIG_DM will be
|
|
|
|
compulsory starting with the v2020.01 release.
|
|
|
|
Failure to update may result in board removal.
|
|
|
|
See doc/driver-model/migration.rst for more info.
|
|
|
|
====================================================
|
|
|
|
'''
|
|
|
|
|
2013-04-03 11:07:16 +00:00
|
|
|
errors = [
|
|
|
|
'''main.c: In function 'main_loop':
|
|
|
|
main.c:260:6: warning: unused variable 'joe' [-Wunused-variable]
|
|
|
|
''',
|
2014-09-06 01:00:08 +00:00
|
|
|
'''main.c: In function 'main_loop2':
|
2013-04-03 11:07:16 +00:00
|
|
|
main.c:295:2: error: 'fred' undeclared (first use in this function)
|
|
|
|
main.c:295:2: note: each undeclared identifier is reported only once for each function it appears in
|
|
|
|
make[1]: *** [main.o] Error 1
|
|
|
|
make: *** [common/libcommon.o] Error 2
|
|
|
|
Make failed
|
|
|
|
''',
|
2018-11-06 23:02:11 +00:00
|
|
|
'''arch/arm/dts/socfpga_arria10_socdk_sdmmc.dtb: Warning \
|
|
|
|
(avoid_unnecessary_addr_size): /clocks: unnecessary #address-cells/#size-cells \
|
|
|
|
without "ranges" or child "reg" property
|
2013-04-03 11:07:16 +00:00
|
|
|
''',
|
|
|
|
'''powerpc-linux-ld: warning: dot moved backwards before `.bss'
|
|
|
|
powerpc-linux-ld: warning: dot moved backwards before `.bss'
|
|
|
|
powerpc-linux-ld: u-boot: section .text lma 0xfffc0000 overlaps previous sections
|
|
|
|
powerpc-linux-ld: u-boot: section .rodata lma 0xfffef3ec overlaps previous sections
|
|
|
|
powerpc-linux-ld: u-boot: section .reloc lma 0xffffa400 overlaps previous sections
|
|
|
|
powerpc-linux-ld: u-boot: section .data lma 0xffffcd38 overlaps previous sections
|
|
|
|
powerpc-linux-ld: u-boot: section .u_boot_cmd lma 0xffffeb40 overlaps previous sections
|
|
|
|
powerpc-linux-ld: u-boot: section .bootpg lma 0xfffff198 overlaps previous sections
|
2014-09-06 01:00:21 +00:00
|
|
|
''',
|
|
|
|
'''In file included from %(basedir)sarch/sandbox/cpu/cpu.c:9:0:
|
|
|
|
%(basedir)sarch/sandbox/include/asm/state.h:44:0: warning: "xxxx" redefined [enabled by default]
|
|
|
|
%(basedir)sarch/sandbox/include/asm/state.h:43:0: note: this is the location of the previous definition
|
|
|
|
%(basedir)sarch/sandbox/cpu/cpu.c: In function 'do_reset':
|
|
|
|
%(basedir)sarch/sandbox/cpu/cpu.c:27:1: error: unknown type name 'blah'
|
|
|
|
%(basedir)sarch/sandbox/cpu/cpu.c:28:12: error: expected declaration specifiers or '...' before numeric constant
|
|
|
|
make[2]: *** [arch/sandbox/cpu/cpu.o] Error 1
|
|
|
|
make[1]: *** [arch/sandbox/cpu] Error 2
|
|
|
|
make[1]: *** Waiting for unfinished jobs....
|
|
|
|
In file included from %(basedir)scommon/board_f.c:55:0:
|
|
|
|
%(basedir)sarch/sandbox/include/asm/state.h:44:0: warning: "xxxx" redefined [enabled by default]
|
|
|
|
%(basedir)sarch/sandbox/include/asm/state.h:43:0: note: this is the location of the previous definition
|
|
|
|
make: *** [sub-make] Error 2
|
2013-04-03 11:07:16 +00:00
|
|
|
'''
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# hash, subject, return code, list of errors/warnings
|
|
|
|
commits = [
|
2020-04-09 21:08:53 +00:00
|
|
|
['1234', 'upstream/master, migration warning', 0, []],
|
2013-04-03 11:07:16 +00:00
|
|
|
['5678', 'Second commit, a warning', 0, errors[0:1]],
|
|
|
|
['9012', 'Third commit, error', 1, errors[0:2]],
|
|
|
|
['3456', 'Fourth commit, warning', 0, [errors[0], errors[2]]],
|
|
|
|
['7890', 'Fifth commit, link errors', 1, [errors[0], errors[3]]],
|
2014-09-06 01:00:21 +00:00
|
|
|
['abcd', 'Sixth commit, fixes all errors', 0, []],
|
2020-04-09 21:08:53 +00:00
|
|
|
['ef01', 'Seventh commit, fix migration, check directory suppression', 1,
|
|
|
|
[errors[4]]],
|
2013-04-03 11:07:16 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
boards = [
|
2013-09-23 23:35:16 +00:00
|
|
|
['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 1', 'board0', ''],
|
|
|
|
['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 2', 'board1', ''],
|
|
|
|
['Active', 'powerpc', 'powerpc', '', 'Tester', 'PowerPC board 1', 'board2', ''],
|
2017-11-13 04:52:15 +00:00
|
|
|
['Active', 'powerpc', 'mpc83xx', '', 'Tester', 'PowerPC board 2', 'board3', ''],
|
2013-09-23 23:35:16 +00:00
|
|
|
['Active', 'sandbox', 'sandbox', '', 'Tester', 'Sandbox board', 'board4', ''],
|
2013-04-03 11:07:16 +00:00
|
|
|
]
|
|
|
|
|
2014-12-02 00:33:51 +00:00
|
|
|
BASE_DIR = 'base'
|
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
OUTCOME_OK, OUTCOME_WARN, OUTCOME_ERR = range(3)
|
|
|
|
|
2013-04-03 11:07:16 +00:00
|
|
|
class Options:
|
|
|
|
"""Class that holds build options"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
class TestBuild(unittest.TestCase):
|
|
|
|
"""Test buildman
|
|
|
|
|
|
|
|
TODO: Write tests for the rest of the functionality
|
|
|
|
"""
|
|
|
|
def setUp(self):
|
|
|
|
# Set up commits to build
|
|
|
|
self.commits = []
|
|
|
|
sequence = 0
|
|
|
|
for commit_info in commits:
|
|
|
|
comm = commit.Commit(commit_info[0])
|
|
|
|
comm.subject = commit_info[1]
|
|
|
|
comm.return_code = commit_info[2]
|
|
|
|
comm.error_list = commit_info[3]
|
2020-04-09 21:08:53 +00:00
|
|
|
if sequence < 6:
|
|
|
|
comm.error_list += [migration]
|
2013-04-03 11:07:16 +00:00
|
|
|
comm.sequence = sequence
|
|
|
|
sequence += 1
|
|
|
|
self.commits.append(comm)
|
|
|
|
|
|
|
|
# Set up boards to build
|
|
|
|
self.boards = board.Boards()
|
|
|
|
for brd in boards:
|
|
|
|
self.boards.AddBoard(board.Board(*brd))
|
|
|
|
self.boards.SelectBoards([])
|
|
|
|
|
2014-12-02 00:34:04 +00:00
|
|
|
# Add some test settings
|
|
|
|
bsettings.Setup(None)
|
|
|
|
bsettings.AddFile(settings_data)
|
|
|
|
|
2013-04-03 11:07:16 +00:00
|
|
|
# Set up the toolchains
|
|
|
|
self.toolchains = toolchain.Toolchains()
|
|
|
|
self.toolchains.Add('arm-linux-gcc', test=False)
|
|
|
|
self.toolchains.Add('sparc-linux-gcc', test=False)
|
|
|
|
self.toolchains.Add('powerpc-linux-gcc', test=False)
|
|
|
|
self.toolchains.Add('gcc', test=False)
|
|
|
|
|
2014-09-06 01:00:08 +00:00
|
|
|
# Avoid sending any output
|
|
|
|
terminal.SetPrintTestMode()
|
|
|
|
self._col = terminal.Color()
|
|
|
|
|
2020-04-09 21:08:31 +00:00
|
|
|
self.base_dir = tempfile.mkdtemp()
|
|
|
|
if not os.path.isdir(self.base_dir):
|
|
|
|
os.mkdir(self.base_dir)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
shutil.rmtree(self.base_dir)
|
2014-09-06 01:00:21 +00:00
|
|
|
|
2020-04-09 21:08:31 +00:00
|
|
|
def Make(self, commit, brd, stage, *args, **kwargs):
|
2013-04-03 11:07:16 +00:00
|
|
|
result = command.CommandResult()
|
|
|
|
boardnum = int(brd.target[-1])
|
|
|
|
result.return_code = 0
|
|
|
|
result.stderr = ''
|
|
|
|
result.stdout = ('This is the test output for board %s, commit %s' %
|
|
|
|
(brd.target, commit.hash))
|
2014-09-06 01:00:21 +00:00
|
|
|
if ((boardnum >= 1 and boardnum >= commit.sequence) or
|
|
|
|
boardnum == 4 and commit.sequence == 6):
|
2013-04-03 11:07:16 +00:00
|
|
|
result.return_code = commit.return_code
|
2014-09-06 01:00:21 +00:00
|
|
|
result.stderr = (''.join(commit.error_list)
|
2020-04-09 21:08:31 +00:00
|
|
|
% {'basedir' : self.base_dir + '/.bm-work/00/'})
|
2020-04-09 21:08:53 +00:00
|
|
|
elif commit.sequence < 6:
|
|
|
|
result.stderr = migration
|
2013-04-03 11:07:16 +00:00
|
|
|
|
|
|
|
result.combined = result.stdout + result.stderr
|
|
|
|
return result
|
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
def assertSummary(self, text, arch, plus, boards, outcome=OUTCOME_ERR):
|
2014-09-06 01:00:08 +00:00
|
|
|
col = self._col
|
2018-11-06 23:02:13 +00:00
|
|
|
expected_colour = (col.GREEN if outcome == OUTCOME_OK else
|
|
|
|
col.YELLOW if outcome == OUTCOME_WARN else col.RED)
|
2014-09-06 01:00:08 +00:00
|
|
|
expect = '%10s: ' % arch
|
|
|
|
# TODO(sjg@chromium.org): If plus is '', we shouldn't need this
|
2022-01-29 21:14:17 +00:00
|
|
|
expect += ' ' + col.build(expected_colour, plus)
|
2014-09-06 01:00:08 +00:00
|
|
|
expect += ' '
|
|
|
|
for board in boards:
|
2022-01-29 21:14:17 +00:00
|
|
|
expect += col.build(expected_colour, ' %s' % board)
|
2014-09-06 01:00:08 +00:00
|
|
|
self.assertEqual(text, expect)
|
|
|
|
|
2021-01-31 05:17:46 +00:00
|
|
|
def _SetupTest(self, echo_lines=False, threads=1, **kwdisplay_args):
|
2020-04-09 21:08:32 +00:00
|
|
|
"""Set up the test by running a build and summary
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2020-04-09 21:08:32 +00:00
|
|
|
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
|
2014-09-06 01:00:08 +00:00
|
|
|
"""
|
2021-01-31 05:17:46 +00:00
|
|
|
build = builder.Builder(self.toolchains, self.base_dir, None, threads,
|
|
|
|
2, checkout=False, show_unknown=False)
|
2013-04-03 11:07:16 +00:00
|
|
|
build.do_make = self.Make
|
|
|
|
board_selected = self.boards.GetSelectedDict()
|
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Build the boards for the pre-defined commits and warnings/errors
|
|
|
|
# associated with each. This calls our Make() to inject the fake output.
|
2014-08-09 21:33:03 +00:00
|
|
|
build.BuildBoards(self.commits, board_selected, keep_outputs=False,
|
|
|
|
verbose=False)
|
2014-09-06 01:00:08 +00:00
|
|
|
lines = terminal.GetPrintTestLines()
|
|
|
|
count = 0
|
|
|
|
for line in lines:
|
|
|
|
if line.text.strip():
|
|
|
|
count += 1
|
|
|
|
|
2020-04-09 21:08:47 +00:00
|
|
|
# We should get two starting messages, an update for every commit built
|
|
|
|
# and a summary message
|
|
|
|
self.assertEqual(count, len(commits) * len(boards) + 3)
|
2020-04-09 21:08:32 +00:00
|
|
|
build.SetDisplayOptions(**kwdisplay_args);
|
2014-08-09 21:33:02 +00:00
|
|
|
build.ShowSummary(self.commits, board_selected)
|
2020-04-09 21:08:32 +00:00
|
|
|
if echo_lines:
|
|
|
|
terminal.EchoPrintTestLines()
|
|
|
|
return iter(terminal.GetPrintTestLines())
|
|
|
|
|
2020-04-09 21:08:53 +00:00
|
|
|
def _CheckOutput(self, lines, list_error_boards=False,
|
|
|
|
filter_dtb_warnings=False,
|
|
|
|
filter_migration_warnings=False):
|
2020-04-09 21:08:32 +00:00
|
|
|
"""Check for expected output from the build summary
|
2018-11-06 23:02:13 +00:00
|
|
|
|
2020-04-09 21:08:32 +00:00
|
|
|
Args:
|
|
|
|
lines: Iterator containing the lines returned from the summary
|
2020-04-09 21:08:34 +00:00
|
|
|
list_error_boards: Adjust the check for output produced with the
|
|
|
|
--list-error-boards flag
|
2020-04-09 21:08:52 +00:00
|
|
|
filter_dtb_warnings: Adjust the check for output produced with the
|
|
|
|
--filter-dtb-warnings flag
|
2020-04-09 21:08:32 +00:00
|
|
|
"""
|
2020-04-09 21:08:37 +00:00
|
|
|
def add_line_prefix(prefix, boards, error_str, colour):
|
2020-04-09 21:08:33 +00:00
|
|
|
"""Add a prefix to each line of a string
|
|
|
|
|
|
|
|
The training \n in error_str is removed before processing
|
|
|
|
|
|
|
|
Args:
|
|
|
|
prefix: String prefix to add
|
|
|
|
error_str: Error string containing the lines
|
2020-04-09 21:08:37 +00:00
|
|
|
colour: Expected colour for the line. Note that the board list,
|
|
|
|
if present, always appears in magenta
|
2020-04-09 21:08:33 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
New string where each line has the prefix added
|
|
|
|
"""
|
|
|
|
lines = error_str.strip().splitlines()
|
2020-04-09 21:08:37 +00:00
|
|
|
new_lines = []
|
|
|
|
for line in lines:
|
|
|
|
if boards:
|
2022-01-29 21:14:17 +00:00
|
|
|
expect = self._col.build(colour, prefix + '(')
|
|
|
|
expect += self._col.build(self._col.MAGENTA, boards,
|
2020-04-09 21:08:37 +00:00
|
|
|
bright=False)
|
2022-01-29 21:14:17 +00:00
|
|
|
expect += self._col.build(colour, ') %s' % line)
|
2020-04-09 21:08:37 +00:00
|
|
|
else:
|
2022-01-29 21:14:17 +00:00
|
|
|
expect = self._col.build(colour, prefix + line)
|
2020-04-09 21:08:37 +00:00
|
|
|
new_lines.append(expect)
|
2020-04-09 21:08:33 +00:00
|
|
|
return '\n'.join(new_lines)
|
|
|
|
|
2020-04-09 21:08:53 +00:00
|
|
|
col = terminal.Color()
|
|
|
|
boards01234 = ('board0 board1 board2 board3 board4'
|
|
|
|
if list_error_boards else '')
|
2020-04-09 21:08:38 +00:00
|
|
|
boards1234 = 'board1 board2 board3 board4' if list_error_boards else ''
|
|
|
|
boards234 = 'board2 board3 board4' if list_error_boards else ''
|
|
|
|
boards34 = 'board3 board4' if list_error_boards else ''
|
2020-04-09 21:08:34 +00:00
|
|
|
boards4 = 'board4' if list_error_boards else ''
|
|
|
|
|
2020-04-09 21:08:53 +00:00
|
|
|
# Upstream commit: migration warnings only
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '01: %s' % commits[0][1])
|
2018-11-06 23:02:13 +00:00
|
|
|
|
2020-04-09 21:08:53 +00:00
|
|
|
if not filter_migration_warnings:
|
|
|
|
self.assertSummary(next(lines).text, 'arm', 'w+',
|
|
|
|
['board0', 'board1'], outcome=OUTCOME_WARN)
|
|
|
|
self.assertSummary(next(lines).text, 'powerpc', 'w+',
|
|
|
|
['board2', 'board3'], outcome=OUTCOME_WARN)
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
|
|
|
|
outcome=OUTCOME_WARN)
|
|
|
|
|
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('+', boards01234, migration, col.RED))
|
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Second commit: all archs should fail with warnings
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '02: %s' % commits[1][1])
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2020-04-09 21:08:53 +00:00
|
|
|
if filter_migration_warnings:
|
|
|
|
self.assertSummary(next(lines).text, 'arm', 'w+',
|
|
|
|
['board1'], outcome=OUTCOME_WARN)
|
|
|
|
self.assertSummary(next(lines).text, 'powerpc', 'w+',
|
|
|
|
['board2', 'board3'], outcome=OUTCOME_WARN)
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
|
|
|
|
outcome=OUTCOME_WARN)
|
2018-11-06 23:02:13 +00:00
|
|
|
|
|
|
|
# Second commit: The warnings should be listed
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('w+', boards1234, errors[0], col.YELLOW))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Third commit: Still fails
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '03: %s' % commits[2][1])
|
2020-04-09 21:08:53 +00:00
|
|
|
if filter_migration_warnings:
|
|
|
|
self.assertSummary(next(lines).text, 'arm', '',
|
|
|
|
['board1'], outcome=OUTCOME_OK)
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertSummary(next(lines).text, 'powerpc', '+',
|
|
|
|
['board2', 'board3'])
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Expect a compiler error
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('+', boards234, errors[1], col.RED))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Fourth commit: Compile errors are fixed, just have warning for board3
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '04: %s' % commits[3][1])
|
2020-04-09 21:08:53 +00:00
|
|
|
if filter_migration_warnings:
|
|
|
|
expect = '%10s: ' % 'powerpc'
|
2022-01-29 21:14:17 +00:00
|
|
|
expect += ' ' + col.build(col.GREEN, '')
|
2020-04-09 21:08:53 +00:00
|
|
|
expect += ' '
|
2022-01-29 21:14:17 +00:00
|
|
|
expect += col.build(col.GREEN, ' %s' % 'board2')
|
|
|
|
expect += ' ' + col.build(col.YELLOW, 'w+')
|
2020-04-09 21:08:53 +00:00
|
|
|
expect += ' '
|
2022-01-29 21:14:17 +00:00
|
|
|
expect += col.build(col.YELLOW, ' %s' % 'board3')
|
2020-04-09 21:08:53 +00:00
|
|
|
self.assertEqual(next(lines).text, expect)
|
|
|
|
else:
|
|
|
|
self.assertSummary(next(lines).text, 'powerpc', 'w+',
|
|
|
|
['board2', 'board3'], outcome=OUTCOME_WARN)
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
|
2020-04-09 21:08:53 +00:00
|
|
|
outcome=OUTCOME_WARN)
|
2014-09-06 01:00:08 +00:00
|
|
|
|
|
|
|
# Compile error fixed
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('-', boards234, errors[1], col.GREEN))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2020-04-09 21:08:52 +00:00
|
|
|
if not filter_dtb_warnings:
|
|
|
|
self.assertEqual(
|
|
|
|
next(lines).text,
|
|
|
|
add_line_prefix('w+', boards34, errors[2], col.YELLOW))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Fifth commit
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '05: %s' % commits[4][1])
|
2020-04-09 21:08:53 +00:00
|
|
|
if filter_migration_warnings:
|
|
|
|
self.assertSummary(next(lines).text, 'powerpc', '', ['board3'],
|
|
|
|
outcome=OUTCOME_OK)
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
|
2014-09-06 01:00:08 +00:00
|
|
|
|
|
|
|
# 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:]
|
2020-04-09 21:08:33 +00:00
|
|
|
expect = '\n'.join(expect)
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('+', boards4, expect, col.RED))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2020-04-09 21:08:52 +00:00
|
|
|
if not filter_dtb_warnings:
|
|
|
|
self.assertEqual(
|
|
|
|
next(lines).text,
|
|
|
|
add_line_prefix('w-', boards34, errors[2], col.CYAN))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Sixth commit
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '06: %s' % commits[5][1])
|
2020-04-09 21:08:53 +00:00
|
|
|
if filter_migration_warnings:
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', '', ['board4'],
|
|
|
|
outcome=OUTCOME_OK)
|
|
|
|
else:
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
|
|
|
|
outcome=OUTCOME_WARN)
|
2014-09-06 01:00:08 +00:00
|
|
|
|
|
|
|
# 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:]
|
2020-04-09 21:08:33 +00:00
|
|
|
expect = '\n'.join(expect)
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('-', boards4, expect, col.GREEN))
|
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('w-', boards4, errors[0], col.CYAN))
|
2014-09-06 01:00:08 +00:00
|
|
|
|
2018-11-06 23:02:13 +00:00
|
|
|
# Seventh commit
|
2020-04-09 21:08:30 +00:00
|
|
|
self.assertEqual(next(lines).text, '07: %s' % commits[6][1])
|
2020-04-09 21:08:53 +00:00
|
|
|
if filter_migration_warnings:
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
|
|
|
|
else:
|
|
|
|
self.assertSummary(next(lines).text, 'arm', '', ['board0', 'board1'],
|
|
|
|
outcome=OUTCOME_OK)
|
|
|
|
self.assertSummary(next(lines).text, 'powerpc', '',
|
|
|
|
['board2', 'board3'], outcome=OUTCOME_OK)
|
|
|
|
self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
|
2014-09-06 01:00:21 +00:00
|
|
|
|
|
|
|
# Pick out the correct error lines
|
|
|
|
expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n')
|
|
|
|
expect = expect_str[3:8] + [expect_str[-1]]
|
2020-04-09 21:08:33 +00:00
|
|
|
expect = '\n'.join(expect)
|
2020-04-09 21:08:53 +00:00
|
|
|
if not filter_migration_warnings:
|
|
|
|
self.assertEqual(
|
|
|
|
next(lines).text,
|
|
|
|
add_line_prefix('-', boards01234, migration, col.GREEN))
|
|
|
|
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('+', boards4, expect, col.RED))
|
2014-09-06 01:00:21 +00:00
|
|
|
|
|
|
|
# Now the warnings lines
|
|
|
|
expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]]
|
2020-04-09 21:08:33 +00:00
|
|
|
expect = '\n'.join(expect)
|
2020-04-09 21:08:37 +00:00
|
|
|
self.assertEqual(next(lines).text,
|
|
|
|
add_line_prefix('w+', boards4, expect, col.YELLOW))
|
2014-09-06 01:00:21 +00:00
|
|
|
|
2020-04-09 21:08:32 +00:00
|
|
|
def testOutput(self):
|
|
|
|
"""Test basic builder operation and output
|
|
|
|
|
|
|
|
This does a line-by-line verification of the summary output.
|
|
|
|
"""
|
|
|
|
lines = self._SetupTest(show_errors=True)
|
2020-04-09 21:08:52 +00:00
|
|
|
self._CheckOutput(lines, list_error_boards=False,
|
|
|
|
filter_dtb_warnings=False)
|
2020-04-09 21:08:34 +00:00
|
|
|
|
|
|
|
def testErrorBoards(self):
|
|
|
|
"""Test output with --list-error-boards
|
|
|
|
|
|
|
|
This does a line-by-line verification of the summary output.
|
|
|
|
"""
|
|
|
|
lines = self._SetupTest(show_errors=True, list_error_boards=True)
|
2020-04-09 21:08:53 +00:00
|
|
|
self._CheckOutput(lines, list_error_boards=True)
|
2020-04-09 21:08:52 +00:00
|
|
|
|
|
|
|
def testFilterDtb(self):
|
|
|
|
"""Test output with --filter-dtb-warnings
|
|
|
|
|
|
|
|
This does a line-by-line verification of the summary output.
|
|
|
|
"""
|
|
|
|
lines = self._SetupTest(show_errors=True, filter_dtb_warnings=True)
|
2020-04-09 21:08:53 +00:00
|
|
|
self._CheckOutput(lines, filter_dtb_warnings=True)
|
|
|
|
|
|
|
|
def testFilterMigration(self):
|
|
|
|
"""Test output with --filter-migration-warnings
|
|
|
|
|
|
|
|
This does a line-by-line verification of the summary output.
|
|
|
|
"""
|
|
|
|
lines = self._SetupTest(show_errors=True,
|
|
|
|
filter_migration_warnings=True)
|
|
|
|
self._CheckOutput(lines, filter_migration_warnings=True)
|
2020-04-09 21:08:32 +00:00
|
|
|
|
2021-01-31 05:17:46 +00:00
|
|
|
def testSingleThread(self):
|
|
|
|
"""Test operation without threading"""
|
|
|
|
lines = self._SetupTest(show_errors=True, threads=0)
|
|
|
|
self._CheckOutput(lines, list_error_boards=False,
|
|
|
|
filter_dtb_warnings=False)
|
|
|
|
|
2013-04-03 11:07:16 +00:00
|
|
|
def _testGit(self):
|
|
|
|
"""Test basic builder operation by building a branch"""
|
|
|
|
options = Options()
|
|
|
|
options.git = os.getcwd()
|
|
|
|
options.summary = False
|
|
|
|
options.jobs = None
|
|
|
|
options.dry_run = False
|
2020-04-09 21:08:31 +00:00
|
|
|
#options.git = os.path.join(self.base_dir, 'repo')
|
2013-04-03 11:07:16 +00:00
|
|
|
options.branch = 'test-buildman'
|
|
|
|
options.force_build = False
|
|
|
|
options.list_tool_chains = False
|
|
|
|
options.count = -1
|
|
|
|
options.git_dir = None
|
|
|
|
options.threads = None
|
|
|
|
options.show_unknown = False
|
|
|
|
options.quick = False
|
|
|
|
options.show_errors = False
|
|
|
|
options.keep_outputs = False
|
|
|
|
args = ['tegra20']
|
|
|
|
control.DoBuildman(options, args)
|
|
|
|
|
2014-08-09 21:33:08 +00:00
|
|
|
def testBoardSingle(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['sandbox']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardArch(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['arm']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'all': ['board0', 'board1'],
|
|
|
|
'arm': ['board0', 'board1']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardArchSingle(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['arm sandbox']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'sandbox': ['board4'],
|
2017-11-13 04:52:15 +00:00
|
|
|
'all': ['board0', 'board1', 'board4'],
|
2018-06-12 05:26:46 +00:00
|
|
|
'arm': ['board0', 'board1']}, []))
|
2017-11-13 04:52:15 +00:00
|
|
|
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardArchSingleMultiWord(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['arm', 'sandbox']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'sandbox': ['board4'],
|
|
|
|
'all': ['board0', 'board1', 'board4'],
|
|
|
|
'arm': ['board0', 'board1']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardSingleAnd(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['Tester & arm']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'Tester&arm': ['board0', 'board1'],
|
|
|
|
'all': ['board0', 'board1']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardTwoAnd(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['Tester', '&', 'arm',
|
|
|
|
'Tester' '&', 'powerpc',
|
|
|
|
'sandbox']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'sandbox': ['board4'],
|
2017-11-13 04:52:15 +00:00
|
|
|
'all': ['board0', 'board1', 'board2', 'board3',
|
|
|
|
'board4'],
|
|
|
|
'Tester&powerpc': ['board2', 'board3'],
|
2018-06-12 05:26:46 +00:00
|
|
|
'Tester&arm': ['board0', 'board1']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardAll(self):
|
|
|
|
"""Test single board selection"""
|
2017-11-13 04:52:15 +00:00
|
|
|
self.assertEqual(self.boards.SelectBoards([]),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'all': ['board0', 'board1', 'board2', 'board3',
|
|
|
|
'board4']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardRegularExpression(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['T.*r&^Po']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'all': ['board2', 'board3'],
|
|
|
|
'T.*r&^Po': ['board2', 'board3']}, []))
|
2014-08-09 21:33:08 +00:00
|
|
|
|
|
|
|
def testBoardDuplicate(self):
|
|
|
|
"""Test single board selection"""
|
|
|
|
self.assertEqual(self.boards.SelectBoards(['sandbox sandbox',
|
|
|
|
'sandbox']),
|
2018-06-12 05:26:46 +00:00
|
|
|
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
2014-12-02 00:33:51 +00:00
|
|
|
def CheckDirs(self, build, dirname):
|
|
|
|
self.assertEqual('base%s' % dirname, build._GetOutputDir(1))
|
|
|
|
self.assertEqual('base%s/fred' % dirname,
|
|
|
|
build.GetBuildDir(1, 'fred'))
|
|
|
|
self.assertEqual('base%s/fred/done' % dirname,
|
|
|
|
build.GetDoneFile(1, 'fred'))
|
|
|
|
self.assertEqual('base%s/fred/u-boot.sizes' % dirname,
|
|
|
|
build.GetFuncSizesFile(1, 'fred', 'u-boot'))
|
|
|
|
self.assertEqual('base%s/fred/u-boot.objdump' % dirname,
|
|
|
|
build.GetObjdumpFile(1, 'fred', 'u-boot'))
|
|
|
|
self.assertEqual('base%s/fred/err' % dirname,
|
|
|
|
build.GetErrFile(1, 'fred'))
|
|
|
|
|
|
|
|
def testOutputDir(self):
|
|
|
|
build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2,
|
|
|
|
checkout=False, show_unknown=False)
|
|
|
|
build.commits = self.commits
|
|
|
|
build.commit_count = len(self.commits)
|
|
|
|
subject = self.commits[1].subject.translate(builder.trans_valid_chars)
|
2020-07-19 18:28:11 +00:00
|
|
|
dirname ='/%02d_g%s_%s' % (2, commits[1][0], subject[:20])
|
2014-12-02 00:33:51 +00:00
|
|
|
self.CheckDirs(build, dirname)
|
|
|
|
|
|
|
|
def testOutputDirCurrent(self):
|
|
|
|
build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2,
|
|
|
|
checkout=False, show_unknown=False)
|
|
|
|
build.commits = None
|
|
|
|
build.commit_count = 0
|
|
|
|
self.CheckDirs(build, '/current')
|
2014-08-09 21:33:08 +00:00
|
|
|
|
2014-12-02 00:33:55 +00:00
|
|
|
def testOutputDirNoSubdirs(self):
|
|
|
|
build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2,
|
|
|
|
checkout=False, show_unknown=False,
|
|
|
|
no_subdirs=True)
|
|
|
|
build.commits = None
|
|
|
|
build.commit_count = 0
|
|
|
|
self.CheckDirs(build, '')
|
|
|
|
|
2014-12-02 00:34:05 +00:00
|
|
|
def testToolchainAliases(self):
|
|
|
|
self.assertTrue(self.toolchains.Select('arm') != None)
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
self.toolchains.Select('no-arch')
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
self.toolchains.Select('x86')
|
|
|
|
|
|
|
|
self.toolchains = toolchain.Toolchains()
|
|
|
|
self.toolchains.Add('x86_64-linux-gcc', test=False)
|
|
|
|
self.assertTrue(self.toolchains.Select('x86') != None)
|
|
|
|
|
|
|
|
self.toolchains = toolchain.Toolchains()
|
|
|
|
self.toolchains.Add('i386-linux-gcc', test=False)
|
|
|
|
self.assertTrue(self.toolchains.Select('x86') != None)
|
|
|
|
|
2014-12-02 00:34:06 +00:00
|
|
|
def testToolchainDownload(self):
|
|
|
|
"""Test that we can download toolchains"""
|
2017-11-13 04:52:14 +00:00
|
|
|
if use_network:
|
2018-10-02 03:12:43 +00:00
|
|
|
with test_util.capture_sys_output() as (stdout, stderr):
|
|
|
|
url = self.toolchains.LocateArchUrl('arm')
|
2018-10-02 03:12:35 +00:00
|
|
|
self.assertRegexpMatches(url, 'https://www.kernel.org/pub/tools/'
|
|
|
|
'crosstool/files/bin/x86_64/.*/'
|
2020-04-17 23:51:30 +00:00
|
|
|
'x86_64-gcc-.*-nolibc[-_]arm-.*linux-gnueabi.tar.xz')
|
2014-12-02 00:34:06 +00:00
|
|
|
|
2019-12-05 22:59:14 +00:00
|
|
|
def testGetEnvArgs(self):
|
|
|
|
"""Test the GetEnvArgs() function"""
|
|
|
|
tc = self.toolchains.Select('arm')
|
|
|
|
self.assertEqual('arm-linux-',
|
|
|
|
tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
|
|
|
|
self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_PATH))
|
|
|
|
self.assertEqual('arm',
|
|
|
|
tc.GetEnvArgs(toolchain.VAR_ARCH))
|
|
|
|
self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS))
|
|
|
|
|
|
|
|
self.toolchains.Add('/path/to/x86_64-linux-gcc', test=False)
|
|
|
|
tc = self.toolchains.Select('x86')
|
|
|
|
self.assertEqual('/path/to',
|
|
|
|
tc.GetEnvArgs(toolchain.VAR_PATH))
|
|
|
|
tc.override_toolchain = 'clang'
|
|
|
|
self.assertEqual('HOSTCC=clang CC=clang',
|
|
|
|
tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS))
|
|
|
|
|
2020-03-18 15:42:45 +00:00
|
|
|
def testPrepareOutputSpace(self):
|
|
|
|
def _Touch(fname):
|
2022-01-29 21:14:04 +00:00
|
|
|
tools.write_file(os.path.join(base_dir, fname), b'')
|
2020-03-18 15:42:45 +00:00
|
|
|
|
|
|
|
base_dir = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
# Add various files that we want removed and left alone
|
2020-05-15 06:30:12 +00:00
|
|
|
to_remove = ['01_g0982734987_title', '102_g92bf_title',
|
|
|
|
'01_g2938abd8_title']
|
|
|
|
to_leave = ['something_else', '01-something.patch', '01_another']
|
2020-03-18 15:42:45 +00:00
|
|
|
for name in to_remove + to_leave:
|
|
|
|
_Touch(name)
|
|
|
|
|
|
|
|
build = builder.Builder(self.toolchains, base_dir, None, 1, 2)
|
|
|
|
build.commits = self.commits
|
|
|
|
build.commit_count = len(commits)
|
|
|
|
result = set(build._GetOutputSpaceRemovals())
|
|
|
|
expected = set([os.path.join(base_dir, f) for f in to_remove])
|
|
|
|
self.assertEqual(expected, result)
|
2014-12-02 00:34:06 +00:00
|
|
|
|
2022-01-22 12:07:31 +00:00
|
|
|
def test_adjust_cfg_nop(self):
|
|
|
|
"""check various adjustments of config that are nops"""
|
|
|
|
# enable an enabled CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'CONFIG_FRED=y',
|
|
|
|
cfgutil.adjust_cfg_line('CONFIG_FRED=y', {'FRED':'FRED'})[0])
|
|
|
|
|
|
|
|
# disable a disabled CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'# CONFIG_FRED is not set',
|
|
|
|
cfgutil.adjust_cfg_line(
|
|
|
|
'# CONFIG_FRED is not set', {'FRED':'~FRED'})[0])
|
|
|
|
|
|
|
|
# use the adjust_cfg_lines() function
|
|
|
|
self.assertEqual(
|
|
|
|
['CONFIG_FRED=y'],
|
|
|
|
cfgutil.adjust_cfg_lines(['CONFIG_FRED=y'], {'FRED':'FRED'}))
|
|
|
|
self.assertEqual(
|
|
|
|
['# CONFIG_FRED is not set'],
|
|
|
|
cfgutil.adjust_cfg_lines(['CONFIG_FRED=y'], {'FRED':'~FRED'}))
|
|
|
|
|
|
|
|
# handling an empty line
|
|
|
|
self.assertEqual('#', cfgutil.adjust_cfg_line('#', {'FRED':'~FRED'})[0])
|
|
|
|
|
|
|
|
def test_adjust_cfg(self):
|
|
|
|
"""check various adjustments of config"""
|
|
|
|
# disable a CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'# CONFIG_FRED is not set',
|
|
|
|
cfgutil.adjust_cfg_line('CONFIG_FRED=1' , {'FRED':'~FRED'})[0])
|
|
|
|
|
|
|
|
# enable a disabled CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'CONFIG_FRED=y',
|
|
|
|
cfgutil.adjust_cfg_line(
|
|
|
|
'# CONFIG_FRED is not set', {'FRED':'FRED'})[0])
|
|
|
|
|
|
|
|
# enable a CONFIG that doesn't exist
|
|
|
|
self.assertEqual(
|
|
|
|
['CONFIG_FRED=y'],
|
|
|
|
cfgutil.adjust_cfg_lines([], {'FRED':'FRED'}))
|
|
|
|
|
|
|
|
# disable a CONFIG that doesn't exist
|
|
|
|
self.assertEqual(
|
|
|
|
['# CONFIG_FRED is not set'],
|
|
|
|
cfgutil.adjust_cfg_lines([], {'FRED':'~FRED'}))
|
|
|
|
|
|
|
|
# disable a value CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'# CONFIG_FRED is not set',
|
|
|
|
cfgutil.adjust_cfg_line('CONFIG_FRED="fred"' , {'FRED':'~FRED'})[0])
|
|
|
|
|
|
|
|
# setting a value CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'CONFIG_FRED="fred"',
|
|
|
|
cfgutil.adjust_cfg_line('# CONFIG_FRED is not set' ,
|
|
|
|
{'FRED':'FRED="fred"'})[0])
|
|
|
|
|
|
|
|
# changing a value CONFIG
|
|
|
|
self.assertEqual(
|
|
|
|
'CONFIG_FRED="fred"',
|
|
|
|
cfgutil.adjust_cfg_line('CONFIG_FRED="ernie"' ,
|
|
|
|
{'FRED':'FRED="fred"'})[0])
|
|
|
|
|
|
|
|
# setting a value for a CONFIG that doesn't exist
|
|
|
|
self.assertEqual(
|
|
|
|
['CONFIG_FRED="fred"'],
|
|
|
|
cfgutil.adjust_cfg_lines([], {'FRED':'FRED="fred"'}))
|
|
|
|
|
|
|
|
def test_convert_adjust_cfg_list(self):
|
|
|
|
"""Check conversion of the list of changes into a dict"""
|
|
|
|
self.assertEqual({}, cfgutil.convert_list_to_dict(None))
|
|
|
|
|
|
|
|
expect = {
|
|
|
|
'FRED':'FRED',
|
|
|
|
'MARY':'~MARY',
|
|
|
|
'JOHN':'JOHN=0x123',
|
|
|
|
'ALICE':'ALICE="alice"',
|
|
|
|
'AMY':'AMY',
|
|
|
|
'ABE':'~ABE',
|
|
|
|
'MARK':'MARK=0x456',
|
|
|
|
'ANNA':'ANNA="anna"',
|
|
|
|
}
|
|
|
|
actual = cfgutil.convert_list_to_dict(
|
|
|
|
['FRED', '~MARY', 'JOHN=0x123', 'ALICE="alice"',
|
|
|
|
'CONFIG_AMY', '~CONFIG_ABE', 'CONFIG_MARK=0x456',
|
|
|
|
'CONFIG_ANNA="anna"'])
|
|
|
|
self.assertEqual(expect, actual)
|
|
|
|
|
|
|
|
def test_check_cfg_file(self):
|
|
|
|
"""Test check_cfg_file detects conflicts as expected"""
|
|
|
|
# Check failure to disable CONFIG
|
|
|
|
result = cfgutil.check_cfg_lines(['CONFIG_FRED=1'], {'FRED':'~FRED'})
|
|
|
|
self.assertEqual([['~FRED', 'CONFIG_FRED=1']], result)
|
|
|
|
|
|
|
|
result = cfgutil.check_cfg_lines(
|
|
|
|
['CONFIG_FRED=1', 'CONFIG_MARY="mary"'], {'FRED':'~FRED'})
|
|
|
|
self.assertEqual([['~FRED', 'CONFIG_FRED=1']], result)
|
|
|
|
|
|
|
|
result = cfgutil.check_cfg_lines(
|
|
|
|
['CONFIG_FRED=1', 'CONFIG_MARY="mary"'], {'MARY':'~MARY'})
|
|
|
|
self.assertEqual([['~MARY', 'CONFIG_MARY="mary"']], result)
|
|
|
|
|
|
|
|
# Check failure to enable CONFIG
|
|
|
|
result = cfgutil.check_cfg_lines(
|
|
|
|
['# CONFIG_FRED is not set'], {'FRED':'FRED'})
|
|
|
|
self.assertEqual([['FRED', '# CONFIG_FRED is not set']], result)
|
|
|
|
|
|
|
|
# Check failure to set CONFIG value
|
|
|
|
result = cfgutil.check_cfg_lines(
|
|
|
|
['# CONFIG_FRED is not set', 'CONFIG_MARY="not"'],
|
|
|
|
{'MARY':'MARY="mary"', 'FRED':'FRED'})
|
|
|
|
self.assertEqual([
|
|
|
|
['FRED', '# CONFIG_FRED is not set'],
|
|
|
|
['MARY="mary"', 'CONFIG_MARY="not"']], result)
|
|
|
|
|
|
|
|
# Check failure to add CONFIG value
|
|
|
|
result = cfgutil.check_cfg_lines([], {'MARY':'MARY="mary"'})
|
|
|
|
self.assertEqual([
|
|
|
|
['MARY="mary"', 'Missing expected line: CONFIG_MARY="mary"']], result)
|
|
|
|
|
|
|
|
|
2013-04-03 11:07:16 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|