Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/test_part_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
# Copyright 2022 Northern.tech AS
# Copyright 2023 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -187,6 +187,7 @@ def test_partition_alignment(
assert parts_end[3] <= total_size
assert parts_end[3] >= total_size - part_overhead

@pytest.mark.cross_platform
def test_device_type(self, bitbake_path, bitbake_variables, latest_part_image):
"""Test that device type file is correctly embedded."""

Expand Down Expand Up @@ -218,6 +219,7 @@ def test_device_type(self, bitbake_path, bitbake_variables, latest_part_image):

fd.close()

@pytest.mark.cross_platform
def test_data_ownership(self, bitbake_path, bitbake_variables, latest_part_image):
"""Test that the owner of files on the data partition is root."""

Expand Down Expand Up @@ -312,6 +314,7 @@ def test_mender_grubenv(self, bitbake_path, bitbake_variables, latest_part_image
os.fchdir(old_cwd_fd)
os.close(old_cwd_fd)

@pytest.mark.cross_platform
@pytest.mark.min_yocto_version("warrior")
def test_split_mender_conf(
self, bitbake_path, bitbake_variables, latest_part_image
Expand Down Expand Up @@ -341,6 +344,7 @@ def test_split_mender_conf(
os.fchdir(old_cwd_fd)
os.close(old_cwd_fd)

@pytest.mark.cross_platform
@pytest.mark.min_mender_version("2.6.0")
def test_expected_data_dirs(
self, conversion, bitbake_path, bitbake_variables, latest_part_image
Expand Down
10 changes: 7 additions & 3 deletions tests/test_rootfs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
# Copyright 2020 Northern.tech AS
# Copyright 2023 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,13 +67,14 @@ def verify_file_executable(tmpdir, rootfs, path, filename):
)
assert os.access(os.path.join(tmpdir, filename), os.X_OK)

@pytest.mark.cross_platform
@pytest.mark.only_with_mender_feature("mender-client-install")
@pytest.mark.only_with_image("ext4", "ext3", "ext2")
@pytest.mark.min_mender_version("2.5.0")
def test_expected_files_ext234(
self, bitbake_path, bitbake_variables, latest_rootfs
):
"""Test mender client expected files"""
"""Test fstab contents and mender client expected files"""

with make_tempdir() as tmpdir:
subprocess.check_call(
Expand Down Expand Up @@ -139,6 +140,7 @@ def test_expected_files_ext234(
),
)

@pytest.mark.cross_platform
@pytest.mark.only_with_image("ext4", "ext3", "ext2")
@pytest.mark.min_mender_version("2.5.1")
def test_expected_files_ext234_mender_connect(
Expand Down Expand Up @@ -181,6 +183,7 @@ def test_expected_files_ext234_mender_connect(
assert "ShellCommand" in mender_connect_vars, mender_connect_vars
assert "User" in mender_connect_vars, mender_connect_vars

@pytest.mark.cross_platform
@pytest.mark.only_with_image("ext4", "ext3", "ext2")
@pytest.mark.min_mender_version("2.6.0")
def test_expected_files_ext234_mender_configure(
Expand Down Expand Up @@ -246,6 +249,7 @@ def test_expected_files_ext234_mender_configure(
assert "Type: symlink" in output
assert 'Fast link dest: "/data/mender-configure"' in output

@pytest.mark.cross_platform
@pytest.mark.only_with_image("ext4", "ext3", "ext2")
@pytest.mark.min_mender_version("3.1.0")
def test_expected_files_ext234_mender_monitor(
Expand Down Expand Up @@ -273,7 +277,7 @@ def test_expected_files_ext234_mender_monitor(
@pytest.mark.only_with_image("ubifs")
@pytest.mark.min_mender_version("1.2.0")
def test_expected_files_ubifs(self, bitbake_path, bitbake_variables, latest_ubifs):
"""Test that artifact_info file is correctly embedded."""
"""Test fstab contents on UBI File System."""

with make_tempdir() as tmpdir:
# NOTE: ubireader_extract_files can keep permissions only if
Expand Down
3 changes: 3 additions & 0 deletions tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def test_image_update_broken_kernel(
assert output.find(active_before) >= 0
assert output.find(passive_before) < 0

@pytest.mark.cross_platform
@pytest.mark.min_mender_version("1.0.0")
def test_too_big_image_update(self, bitbake_variables, connection):

Expand Down Expand Up @@ -586,6 +587,7 @@ def test_network_based_image_update(
),
],
)
@pytest.mark.cross_platform
@pytest.mark.min_mender_version("1.1.0")
def test_signed_updates(self, sig_case, bitbake_variables, connection):
"""Test various combinations of signed and unsigned, present and non-
Expand Down Expand Up @@ -985,6 +987,7 @@ def test_uboot_mender_saveenv_canary(self, bitbake_variables, connection):
)
connection.run("rm -f /data/old_env%d" % i)

@pytest.mark.cross_platform
@pytest.mark.min_mender_version("2.3.1")
def test_standalone_update_rollback(self, bitbake_variables, connection):
"""Test that the rollback state on the active partition does roll back to the
Expand Down
3 changes: 2 additions & 1 deletion tests/test_update_modules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
# Copyright 2022 Northern.tech AS
# Copyright 2023 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
from utils.common import put_no_sftp


@pytest.mark.cross_platform
@pytest.mark.min_yocto_version("kirkstone")
@pytest.mark.usefixtures("setup_board", "bitbake_path")
class TestUpdateModules:
Expand Down
11 changes: 11 additions & 0 deletions tests/utils/fixtures/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,14 @@ def commercial_test(request, bitbake_variables):
mark = request.node.get_closest_marker("commercial")
if mark is not None and not request.config.getoption("--commercial-tests"):
pytest.skip("Tests of commercial features are disabled.")


@pytest.fixture(scope="function", autouse=True)
def cross_platform_test(request):
mark = request.node.get_closest_marker("cross_platform")
option_no = request.config.getoption("--no-cross-platform-tests")
option_only = request.config.getoption("--only-cross-platform-tests")
if mark and option_no:
pytest.skip("Not running cross-platform tests.")
if not mark and option_only:
pytest.skip("Running only cross-platform tests.")
28 changes: 27 additions & 1 deletion tests/utils/parseropts/parseropts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import pytest

Expand Down Expand Up @@ -98,13 +112,24 @@ def pytest_addoption(parser):
action="store_true",
help="Enable tests of commercial features",
)

parser.addoption(
"--hardware-testing",
action="store_true",
default=False,
help="Run the test with real hardware",
)
parser.addoption(
"--no-cross-platform-tests",
action="store_true",
default=False,
help="Do not run platform agnostic tests",
)
parser.addoption(
"--only-cross-platform-tests",
action="store_true",
default=False,
help="Run platform agnostic tests only",
)


def pytest_configure(config):
Expand Down Expand Up @@ -146,3 +171,4 @@ def pytest_configure(config):
config.addinivalue_line(
"markers", "not_for_machine: exclude only for the given machine"
)
config.addinivalue_line("markers", "cross_platform: platform agnostic test")