1# SPDX-License-Identifier: GPL-2.0
2# Copyright 2022 Google LLC
3# Written by Simon Glass <sjg@chromium.org>
4
5import pytest
6
7import utils
8
9# This is needed for Azure, since the default '..' directory is not writeable
10TMPDIR = '/tmp/test_kconfig'
11
12@pytest.mark.slow
13@pytest.mark.boardspec('sandbox')
14def test_kconfig(ubman):
15    """Test build failures when IF_ENABLED_INT() option is not enabled"""
16
17    # This detects build errors in test/lib/kconfig.c
18    out = utils.run_and_log(
19        ubman, ['./tools/buildman/buildman', '-m', '--board', 'sandbox',
20               '-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True)
21    assert 'invalid_use_of_IF_ENABLED_INT' in out
22    assert 'invalid_use_of_CONFIG_IF_ENABLED_INT' in out
23
24@pytest.mark.slow
25@pytest.mark.boardspec('sandbox_spl')
26def test_kconfig_spl(ubman):
27    """Test build failures when IF_ENABLED_INT() option is not enabled"""
28
29    # This detects build errors in test/lib/kconfig_spl.c
30    out = utils.run_and_log(
31        ubman, ['./tools/buildman/buildman', '-m', '--board', 'sandbox_spl',
32               '-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True)
33    assert 'invalid_use_of_IF_ENABLED_INT' in out
34
35    # There is no CONFIG_SPL_TEST_KCONFIG, so the CONFIG_IF_ENABLED_INT()
36    # line should not generate an error
37    assert 'invalid_use_of_CONFIG_IF_ENABLED_INT' not in out
38