# Sarus
#
# Copyright (c) 2018-2023, ETH Zurich. All rights reserved.
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

import unittest
import pytest

import common.util as util


class TestImageWithMaxPathLength(unittest.TestCase):
    """
    These tests simply pull and run an image with a very long path name inside.

    Ideally the very long path name should be 4096 bytes long (max path length on Linux).
    However, in practice it is shorter because it gets trunkated at container build time.
    """

    _IMAGE_NAME = "quay.io/ethcscs/sarus-integration-tests:image-with-max-path-length"

    @pytest.mark.xfail(reason="Incurs in 'no file descriptors available' errors in some CI host."
                              "Pending further investigation. Reference: CONTAINER-669")
    def test_image_with_max_path_length(self):
        util.pull_image_if_necessary(is_centralized_repository=False, image=self._IMAGE_NAME)
        prettyname = util.run_image_and_get_prettyname(is_centralized_repository=False, image=self._IMAGE_NAME)
        assert prettyname.startswith("Alpine Linux")
