scripts: tests: Blackbox test expansion - device
Adds tests related to device flags: --seed Signed-off-by: Kamil Paszkiet <kamilx.paszkiet@intel.com>
This commit is contained in:
parent
6d8132c445
commit
717fccaa09
6 changed files with 119 additions and 0 deletions
|
@ -0,0 +1,8 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(integration)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -0,0 +1,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (c) 2024 Intel Corporation
|
||||
|
||||
config FAKE_ENTROPY_NATIVE_POSIX
|
||||
default y
|
||||
|
||||
source "Kconfig.zephyr"
|
|
@ -0,0 +1 @@
|
|||
CONFIG_ZTEST=y
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
|
||||
ZTEST_SUITE(a1_1_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/**
|
||||
* @brief Test Asserts
|
||||
*
|
||||
* This test verifies various assert macros provided by ztest.
|
||||
*
|
||||
*/
|
||||
ZTEST(a1_1_tests, test_assert)
|
||||
{
|
||||
zassert_true(0, "1 was false");
|
||||
zassert_false(1, "0 was true");
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
tests:
|
||||
seed_native_posix.dummy:
|
||||
platform_allow:
|
||||
- native_posix
|
||||
integration_platforms:
|
||||
- native_posix
|
75
scripts/tests/twister_blackbox/test_device.py
Normal file
75
scripts/tests/twister_blackbox/test_device.py
Normal file
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2024 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""
|
||||
Blackbox tests for twister's command line functions related to test filtering.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
import mock
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
import re
|
||||
|
||||
from conftest import ZEPHYR_BASE, TEST_DATA, testsuite_filename_mock
|
||||
from twisterlib.testplan import TestPlan
|
||||
|
||||
|
||||
class TestDevice:
|
||||
TESTDATA_1 = [
|
||||
(
|
||||
1234,
|
||||
),
|
||||
(
|
||||
4321,
|
||||
),
|
||||
(
|
||||
1324,
|
||||
)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
apath = os.path.join(ZEPHYR_BASE, 'scripts', 'twister')
|
||||
cls.loader = importlib.machinery.SourceFileLoader('__main__', apath)
|
||||
cls.spec = importlib.util.spec_from_loader(cls.loader.name, cls.loader)
|
||||
cls.twister_module = importlib.util.module_from_spec(cls.spec)
|
||||
|
||||
@classmethod
|
||||
def teardown_class(cls):
|
||||
pass
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'seed',
|
||||
TESTDATA_1,
|
||||
ids=[
|
||||
'seed 1234',
|
||||
'seed 4321',
|
||||
'seed 1324'
|
||||
],
|
||||
)
|
||||
|
||||
@mock.patch.object(TestPlan, 'TESTSUITE_FILENAME', testsuite_filename_mock)
|
||||
def test_seed(self, capfd, out_path, seed):
|
||||
test_platforms = ['native_posix']
|
||||
path = os.path.join(TEST_DATA, 'tests', 'seed_native_posix')
|
||||
args = ['--outdir', out_path, '-i', '-T', path, '-vv',] + \
|
||||
['--seed', f'{seed[0]}'] + \
|
||||
[val for pair in zip(
|
||||
['-p'] * len(test_platforms), test_platforms
|
||||
) for val in pair]
|
||||
|
||||
with mock.patch.object(sys, 'argv', [sys.argv[0]] + args), \
|
||||
pytest.raises(SystemExit) as sys_exit:
|
||||
self.loader.exec_module(self.twister_module)
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
sys.stdout.write(out)
|
||||
sys.stderr.write(err)
|
||||
|
||||
assert str(sys_exit.value) == '1'
|
||||
|
||||
expected_line = r'seed_native_posix.dummy FAILED Failed \(native (\d+\.\d+)s/seed: {}\)'.format(seed[0])
|
||||
assert re.search(expected_line, err)
|
Loading…
Add table
Add a link
Reference in a new issue