From f3f0370f1054f4e49aa8f5ea70485d673e8e94b6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Jul 2019 13:09:43 +0200 Subject: build: Alternative build system based on waf Update #3818. --- testsuites/build/.doorstop.skip | 0 testsuites/build/bad-integer.ini | 2 + testsuites/build/bin/fake-rtems5-ar | 31 +++++ testsuites/build/bin/fake-rtems5-gcc | 43 +++++++ testsuites/build/bin/fake-rtems5-ld | 31 +++++ testsuites/build/fake-good.ini | 1 + testsuites/build/fake-inherit-good.ini | 2 + testsuites/build/fake-inherit-loop.ini | 4 + testsuites/build/fake-inherit-none.ini | 2 + testsuites/build/fake-none.ini | 1 + testsuites/build/good-integer.ini | 2 + testsuites/build/not-power-of-two.ini | 2 + testsuites/build/spec/bsp.yml | 16 +++ testsuites/build/spec/config-file.yml | 19 +++ testsuites/build/spec/config-header.yml | 18 +++ testsuites/build/spec/gcc.yml | 41 ++++++ testsuites/build/spec/integer-option.yml | 25 ++++ testsuites/build/spec/string-option.yml | 24 ++++ testsuites/build/spec/top-level-group.yml | 17 +++ testsuites/build/spec2/config-file.yml | 16 +++ testsuites/build/spec2/gcc.yml | 41 ++++++ testsuites/build/spec2/top-level-group.yml | 16 +++ testsuites/build/test.py | 200 +++++++++++++++++++++++++++++ testsuites/build/too-big.ini | 2 + testsuites/build/too-small.ini | 2 + 25 files changed, 558 insertions(+) create mode 100644 testsuites/build/.doorstop.skip create mode 100644 testsuites/build/bad-integer.ini create mode 100755 testsuites/build/bin/fake-rtems5-ar create mode 100755 testsuites/build/bin/fake-rtems5-gcc create mode 100755 testsuites/build/bin/fake-rtems5-ld create mode 100644 testsuites/build/fake-good.ini create mode 100644 testsuites/build/fake-inherit-good.ini create mode 100644 testsuites/build/fake-inherit-loop.ini create mode 100644 testsuites/build/fake-inherit-none.ini create mode 100644 testsuites/build/fake-none.ini create mode 100644 testsuites/build/good-integer.ini create mode 100644 testsuites/build/not-power-of-two.ini create mode 100644 testsuites/build/spec/bsp.yml create mode 100644 testsuites/build/spec/config-file.yml create mode 100644 testsuites/build/spec/config-header.yml create mode 100644 testsuites/build/spec/gcc.yml create mode 100644 testsuites/build/spec/integer-option.yml create mode 100644 testsuites/build/spec/string-option.yml create mode 100644 testsuites/build/spec/top-level-group.yml create mode 100644 testsuites/build/spec2/config-file.yml create mode 100644 testsuites/build/spec2/gcc.yml create mode 100644 testsuites/build/spec2/top-level-group.yml create mode 100755 testsuites/build/test.py create mode 100644 testsuites/build/too-big.ini create mode 100644 testsuites/build/too-small.ini (limited to 'testsuites') diff --git a/testsuites/build/.doorstop.skip b/testsuites/build/.doorstop.skip new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testsuites/build/bad-integer.ini b/testsuites/build/bad-integer.ini new file mode 100644 index 0000000000..7bc5b72bc1 --- /dev/null +++ b/testsuites/build/bad-integer.ini @@ -0,0 +1,2 @@ +[fake/good] +INTEGER = bad diff --git a/testsuites/build/bin/fake-rtems5-ar b/testsuites/build/bin/fake-rtems5-ar new file mode 100755 index 0000000000..1561e69e27 --- /dev/null +++ b/testsuites/build/bin/fake-rtems5-ar @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (C) 2019 embedded brains GmbH +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import sys + +print(sys.argv) +exit(0) diff --git a/testsuites/build/bin/fake-rtems5-gcc b/testsuites/build/bin/fake-rtems5-gcc new file mode 100755 index 0000000000..f2ae2d92c5 --- /dev/null +++ b/testsuites/build/bin/fake-rtems5-gcc @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (C) 2019 embedded brains GmbH +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import argparse +import sys + +sys.argv = list(filter(lambda a: a != '-', sys.argv)) + +parser = argparse.ArgumentParser() +parser.add_argument('-E', action='count') +parser.add_argument('-dM', action='count') +args = parser.parse_args() + +if args.E > 0: + print("#define __GNUC__ 7") + print("#define __GNUC_MINOR__ 4") + print("#define __GNUC_PATCHLEVEL__ 0") + +exit(0) diff --git a/testsuites/build/bin/fake-rtems5-ld b/testsuites/build/bin/fake-rtems5-ld new file mode 100755 index 0000000000..1561e69e27 --- /dev/null +++ b/testsuites/build/bin/fake-rtems5-ld @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (C) 2019 embedded brains GmbH +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import sys + +print(sys.argv) +exit(0) diff --git a/testsuites/build/fake-good.ini b/testsuites/build/fake-good.ini new file mode 100644 index 0000000000..44c5aad131 --- /dev/null +++ b/testsuites/build/fake-good.ini @@ -0,0 +1 @@ +[fake/good] diff --git a/testsuites/build/fake-inherit-good.ini b/testsuites/build/fake-inherit-good.ini new file mode 100644 index 0000000000..c0e00ccc30 --- /dev/null +++ b/testsuites/build/fake-inherit-good.ini @@ -0,0 +1,2 @@ +[fake/very] +INHERIT = good diff --git a/testsuites/build/fake-inherit-loop.ini b/testsuites/build/fake-inherit-loop.ini new file mode 100644 index 0000000000..e995b527d4 --- /dev/null +++ b/testsuites/build/fake-inherit-loop.ini @@ -0,0 +1,4 @@ +[fake/one] +INHERIT = two +[fake/two] +INHERIT = one diff --git a/testsuites/build/fake-inherit-none.ini b/testsuites/build/fake-inherit-none.ini new file mode 100644 index 0000000000..aa7b0b5f38 --- /dev/null +++ b/testsuites/build/fake-inherit-none.ini @@ -0,0 +1,2 @@ +[fake/none] +INHERIT = none2 diff --git a/testsuites/build/fake-none.ini b/testsuites/build/fake-none.ini new file mode 100644 index 0000000000..fa9a6d7f5b --- /dev/null +++ b/testsuites/build/fake-none.ini @@ -0,0 +1 @@ +[fake/none] diff --git a/testsuites/build/good-integer.ini b/testsuites/build/good-integer.ini new file mode 100644 index 0000000000..470d498a10 --- /dev/null +++ b/testsuites/build/good-integer.ini @@ -0,0 +1,2 @@ +[fake/good] +INTEGER = 0x08 diff --git a/testsuites/build/not-power-of-two.ini b/testsuites/build/not-power-of-two.ini new file mode 100644 index 0000000000..dad6115be9 --- /dev/null +++ b/testsuites/build/not-power-of-two.ini @@ -0,0 +1,2 @@ +[fake/good] +INTEGER = 3 diff --git a/testsuites/build/spec/bsp.yml b/testsuites/build/spec/bsp.yml new file mode 100644 index 0000000000..5b37a84dbc --- /dev/null +++ b/testsuites/build/spec/bsp.yml @@ -0,0 +1,16 @@ +active: true +arch: fake +bsp: good +build-type: bsp +derived: true +enabled-by: [] +family: good +header: '' +level: 1.0 +links: [] +normative: true +order: 0 +ref: '' +reviewed: null +text: '' +type: build diff --git a/testsuites/build/spec/config-file.yml b/testsuites/build/spec/config-file.yml new file mode 100644 index 0000000000..48a5a0bc55 --- /dev/null +++ b/testsuites/build/spec/config-file.yml @@ -0,0 +1,19 @@ +active: true +build-type: config-file +content: | + $$ + a$$z + ${ABC} + 0$${NIX}1 +derived: false +enabled-by: [] +header: '' +level: 1.0 +links: [] +normative: true +order: 0 +ref: '' +reviewed: null +target: config-file.txt +text: '' +type: build diff --git a/testsuites/build/spec/config-header.yml b/testsuites/build/spec/config-header.yml new file mode 100644 index 0000000000..22971c127f --- /dev/null +++ b/testsuites/build/spec/config-header.yml @@ -0,0 +1,18 @@ +active: true +build-type: config-header +derived: false +enabled-by: [] +header: '' +level: 1.0 +links: +- string-option: null +- integer-option: null +normative: true +order: 0 +ref: '' +reviewed: null +target: config-header.h +guard: CONFIG_HEADER_H +include-headers: [] +text: '' +type: build diff --git a/testsuites/build/spec/gcc.yml b/testsuites/build/spec/gcc.yml new file mode 100644 index 0000000000..18bf857ee1 --- /dev/null +++ b/testsuites/build/spec/gcc.yml @@ -0,0 +1,41 @@ +actions: +- set-value: ${ARCH}-rtems5-gcc +- substitute: null +- find-program: null +- env-assign: AS +- env-assign: CC +- env-assign: LINK_CC +- set-value: ${ARCH}-rtems5-g++ +- substitute: null +- find-program: null +- env-assign: CXX +- env-assign: LINK_CXX +- set-value: ${ARCH}-rtems5-ar +- substitute: null +- find-program: null +- env-assign: AR +- set-value: ${ARCH}-rtems5-ld +- substitute: null +- find-program: null +- env-assign: LD +- script: | + load = "ar g++ gas gcc" + if not is_windows_host: + load += " gccdeps" + conf.load(load) +active: true +build-type: option +default: null +default-by-variant: [] +derived: false +enabled-by: [] +header: '' +level: 1.39 +links: [] +name: GCC +normative: true +order: -900 +ref: '' +reviewed: oRRzhna6a47p0_QjPWqYLful9JgHGbxMqy-q7mSiZiU= +text: '' +type: build diff --git a/testsuites/build/spec/integer-option.yml b/testsuites/build/spec/integer-option.yml new file mode 100644 index 0000000000..bacdb2a83f --- /dev/null +++ b/testsuites/build/spec/integer-option.yml @@ -0,0 +1,25 @@ +active: true +build-type: option +derived: false +enabled-by: [] +format: '{:#010x}' +header: '' +level: 1.0 +links: [] +name: INTEGER +normative: true +order: 0 +ref: '' +reviewed: null +text: '' +type: build +default: 1 +default-by-variant: [] +actions: +- get-integer: null +- assert-in-interval: + - 1 + - 16 +- assert-power-of-two: null +- env-assign: null +- format-and-define: null diff --git a/testsuites/build/spec/string-option.yml b/testsuites/build/spec/string-option.yml new file mode 100644 index 0000000000..c97c078868 --- /dev/null +++ b/testsuites/build/spec/string-option.yml @@ -0,0 +1,24 @@ +active: true +build-type: option +derived: false +enabled-by: [] +format: '{}' +header: '' +level: 1.0 +links: [] +name: ABC +normative: true +order: 0 +ref: '' +reviewed: null +text: '' +type: build +default: ZYZ +default-by-variant: +- value: DEF + variants: + - .*go.*d +actions: +- get-string: null +- env-assign: null +- define: null diff --git a/testsuites/build/spec/top-level-group.yml b/testsuites/build/spec/top-level-group.yml new file mode 100644 index 0000000000..89b6c457f2 --- /dev/null +++ b/testsuites/build/spec/top-level-group.yml @@ -0,0 +1,17 @@ +active: true +build-type: group +derived: false +enabled-by: [] +header: '' +level: 1.82 +links: +- config-header: null +- config-file: null +- gcc: null +normative: true +order: 0 +ref: '' +reviewed: null +text: '' +top-level: true +type: build diff --git a/testsuites/build/spec2/config-file.yml b/testsuites/build/spec2/config-file.yml new file mode 100644 index 0000000000..7aac892f2c --- /dev/null +++ b/testsuites/build/spec2/config-file.yml @@ -0,0 +1,16 @@ +active: true +build-type: config-file +content: | + ${OPEN +derived: false +enabled-by: [] +header: '' +level: 1.0 +links: [] +normative: true +order: 0 +ref: '' +reviewed: null +target: config-file.txt +text: '' +type: build diff --git a/testsuites/build/spec2/gcc.yml b/testsuites/build/spec2/gcc.yml new file mode 100644 index 0000000000..18bf857ee1 --- /dev/null +++ b/testsuites/build/spec2/gcc.yml @@ -0,0 +1,41 @@ +actions: +- set-value: ${ARCH}-rtems5-gcc +- substitute: null +- find-program: null +- env-assign: AS +- env-assign: CC +- env-assign: LINK_CC +- set-value: ${ARCH}-rtems5-g++ +- substitute: null +- find-program: null +- env-assign: CXX +- env-assign: LINK_CXX +- set-value: ${ARCH}-rtems5-ar +- substitute: null +- find-program: null +- env-assign: AR +- set-value: ${ARCH}-rtems5-ld +- substitute: null +- find-program: null +- env-assign: LD +- script: | + load = "ar g++ gas gcc" + if not is_windows_host: + load += " gccdeps" + conf.load(load) +active: true +build-type: option +default: null +default-by-variant: [] +derived: false +enabled-by: [] +header: '' +level: 1.39 +links: [] +name: GCC +normative: true +order: -900 +ref: '' +reviewed: oRRzhna6a47p0_QjPWqYLful9JgHGbxMqy-q7mSiZiU= +text: '' +type: build diff --git a/testsuites/build/spec2/top-level-group.yml b/testsuites/build/spec2/top-level-group.yml new file mode 100644 index 0000000000..3cefcbdfe9 --- /dev/null +++ b/testsuites/build/spec2/top-level-group.yml @@ -0,0 +1,16 @@ +active: true +build-type: group +derived: false +enabled-by: [] +header: '' +level: 1.82 +links: +- config-file: null +- gcc: null +normative: true +order: 0 +ref: '' +reviewed: null +text: '' +top-level: true +type: build diff --git a/testsuites/build/test.py b/testsuites/build/test.py new file mode 100755 index 0000000000..e8b50983dd --- /dev/null +++ b/testsuites/build/test.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python + +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (C) 2019 embedded brains GmbH +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import os +import subprocess +import unittest + +try: + os.symlink("../../wscript", "wscript") +except FileExistsError: + pass +try: + os.symlink("fake-rtems5-gcc", "bin/fake-rtems5-g++") +except FileExistsError: + pass +exec(open("../../wscript", "r").read()) + + +class TestWscript(unittest.TestCase): + def test_is_enabled(self): + self.assertTrue(_is_enabled([], None)) + self.assertTrue(_is_enabled([], [])) + self.assertFalse(_is_enabled([], ["A"])) + self.assertTrue(_is_enabled(["A"], "A")) + self.assertFalse(_is_enabled(["B"], "A")) + self.assertTrue(_is_enabled(["A"], ["A"])) + self.assertFalse(_is_enabled(["B"], ["A"])) + self.assertTrue(_is_enabled(["A"], ["A", "B"])) + self.assertTrue(_is_enabled(["B"], ["A", "B"])) + self.assertFalse(_is_enabled(["C"], ["A", "B"])) + self.assertFalse(_is_enabled(["A"], {"not": "A"})) + self.assertTrue(_is_enabled(["B"], {"not": "A"})) + self.assertFalse(_is_enabled(["A"], {"and": ["A", "B"]})) + self.assertTrue(_is_enabled(["A", "B"], {"and": ["A", "B"]})) + self.assertTrue(_is_enabled(["A", "B", "C"], {"and": ["A", "B"]})) + self.assertTrue( + _is_enabled(["A", "B"], {"and": ["A", "B", {"not": "C"}]}) + ) + self.assertFalse( + _is_enabled(["A", "B", "C"], {"and": ["A", "B", {"not": "C"}]}) + ) + self.assertFalse(_is_enabled(["A"], {"and": "A", "x": "y"})) + self.assertFalse(_is_enabled(["A"], {"x": "A"})) + self.assertTrue(_is_enabled([], {"not": {"and": ["A", {"not": "A"}]}})) + + +class TestWaf(unittest.TestCase): + @staticmethod + def waf(args, returncode): + cmd = f"../../waf {args}" + print(cmd) + cp = subprocess.run( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + if returncode != None and cp.returncode != returncode: + raise AssertionError(f"command failed: {cmd}") + return cp + + def setUp(self): + self.waf("distclean", None) + self.tools = f"--rtems-tools={os.getcwd()}" + self.specs = "--rtems-specs=spec" + + def test_specs_no_such_directory(self): + cp = self.waf("configure --rtems-specs=nix", 1) + self.assertIn(b"Cannot list build specification directory:", cp.stderr) + + def test_specs_not_a_directory(self): + cp = self.waf("configure --rtems-specs=test.py", 1) + self.assertIn(b"Cannot list build specification directory:", cp.stderr) + + def test_configure_no_bsp(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=fake-none.ini", + 1, + ) + self.assertIn(b"No such base BSP: 'fake/none'", cp.stderr) + + def test_configure_inherit_loop(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=fake-inherit-loop.ini", + 1, + ) + self.assertIn( + b"Recursion in BSP options inheritance: fake/one -> fake/two -> fake/one", + cp.stderr, + ) + + def test_configure_inherit_none(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=fake-inherit-none.ini", + 1, + ) + self.assertIn( + b"BSP variant 'fake/none' cannot inherit options from not existing variant 'fake/none2'", + cp.stderr, + ) + + def test_configure_inherit_good(self): + self.waf( + f"configure {self.tools} {self.specs} --rtems-config=fake-inherit-good.ini", + 0, + ) + + def test_configure_good(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=fake-good.ini", + 0, + ) + content = """$ +a$z +DEF +0${NIX}1 +""" + with open("build/fake/good/config-file.txt", "r") as f: + self.assertEqual(content, f.read()) + + def test_bad_config_file(self): + cp = self.waf( + f"configure {self.tools} {self.specs}2 --rtems-config=fake-good.ini", + 1, + ) + self.assertIn( + b"""In item 'config-file' substitution in '${OPEN +' failed: Invalid placeholder in string: line 1, col 1 +""", + cp.stderr, + ) + + def test_ini_bad_integer(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=bad-integer.ini", + 1, + ) + self.assertIn( + b"Value 'bad' for option 'INTEGER' is an invalid integer", cp.stderr + ) + + def test_ini_too_small(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=too-small.ini", + 1, + ) + self.assertIn( + b"Value '-1' for option 'INTEGER' is not in closed interval [1, 16]", + cp.stderr, + ) + + def test_ini_too_big(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=too-big.ini", + 1, + ) + self.assertIn( + b"Value '100' for option 'INTEGER' is not in closed interval [1, 16]", + cp.stderr, + ) + + def test_ini_not_power_of_two(self): + cp = self.waf( + f"configure {self.tools} {self.specs} --rtems-config=not-power-of-two.ini", + 1, + ) + self.assertIn( + b"Value '3' for option 'INTEGER' is not a power of two", cp.stderr + ) + + def test_good_integer(self): + self.waf( + f"configure {self.tools} {self.specs} --rtems-config=good-integer.ini", + 0, + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/testsuites/build/too-big.ini b/testsuites/build/too-big.ini new file mode 100644 index 0000000000..3d0fba4671 --- /dev/null +++ b/testsuites/build/too-big.ini @@ -0,0 +1,2 @@ +[fake/good] +INTEGER = 100 diff --git a/testsuites/build/too-small.ini b/testsuites/build/too-small.ini new file mode 100644 index 0000000000..55464db1cf --- /dev/null +++ b/testsuites/build/too-small.ini @@ -0,0 +1,2 @@ +[fake/good] +INTEGER = -1 -- cgit v1.2.3