Kan Yu

69 papers B 5Journal 54Unranked 10
YearRankTypeTitle / Venue / Authors
2026 J jnl
Signal Process.
Xinyu Tian, Qinghe Zheng, Binglin Li, Dali Qiao, Kan Yu, Zhiqing Wei, Bin Li, Hao Jiang, Xingwang Li, Yun Lin, Guan Gui
2026 J jnl
IEEE Trans. Mob. Comput.
Zhiyong Feng, Yun Wang, Xiaowu Liu, Kan Yu, Dingyou Ma, Qixun Zhang, Dong Li
2026 J jnl
IEEE J. Sel. Areas Commun.
Shuo Chang, Rui Sun, Jiashuo He, Sai Huang, Kan Yu, Zhiyong Feng
2026 J jnl
IEEE Trans. Mob. Comput.
Kaixuan Li, Kan Yu, Dingyou Ma, Yujia Zhao, Xiaowu Liu, Qixun Zhang, Zhiyong Feng
2026 J jnl
IEEE Trans. Commun.
Ruotong Li, Dingyou Ma, Zheng Jiang, Kan Yu, Huanran Zhang, Jiajun Hou, Qixun Zhang
2026 J jnl
IEEE Trans. Commun.
Luyang Sun, Zhiqing Wei, Haotian Liu, Kan Yu, Zhendong Li, Zhiyong Feng
2026 J jnl
IEEE Trans. Commun.
Wenxu Wang, Xiaowu Liu, Wei Gong, Yujia Zhao, Zheng Jiang, Kaixuan Li, Qixun Zhang, Zhiyong Feng, Kan Yu
2026 J jnl
IEEE J. Sel. Areas Commun.
Kan Yu, Ruinian Wang, Kaixuan Li, Qixun Zhang, Zhiyong Feng, Dong Li
2026 J jnl
IEEE Trans. Mob. Comput.
Zheng Jiang, Dingyou Ma, Bowen Wang, Ningyan Guo, Kan Yu, Qixun Zhang
2026 J jnl
CoRR
Kan Yu, Kaixuan Li, Yujia Zhao, Dingyou Ma, Qixun Zhang, Zhiyong Feng
2025 J jnl
IEEE Trans. Veh. Technol.
Ruinian Wang, Kan Yu, Kaixuan Li, Xiaowu Liu, Zhiyong Feng, Dingyou Ma, Dong Li
2025 J jnl
CoRR
Wenli Yuan, Kan Yu, Xiaowu Liu, Kaixuan Li, Qixun Zhang, Zhiyong Feng
2025 J jnl
CoRR
Yujia Zhao, Zhiyong Feng, Kan Yu, Qixun Zhang, Dong Li
2025 J jnl
CoRR
Kaixuan Li, Kan Yu, Dingyou Ma, Yujia Zhao, Xiaowu Liu, Qixun Zhang, Zhiyong Feng
2025 J jnl
IEEE Trans. Commun.
Fuze Zhu, Xiaowu Liu, Kan Yu, Qixun Zhang, Zhiyong Feng, Dong Li
2025 J jnl
CoRR
Kan Yu, Wenxu Wang, Xiaowu Liu, Yujia Zhao, Qixun Zhang, Zhiyong Feng, Dong Li
2025 J jnl
IEEE Trans. Cogn. Commun. Netw.
Bowen Gu, Dong Li, Hao Xie, Kan Yu, Quansheng Guan, Yongjun Xu
2025 B conf
GLOBECOM
Jiachen Wei, Dingyou Ma, Zongqi Mo, Zhiqing Wei, Ningyan Guo, Kan Yu, Qixun Zhang
2025 J jnl
IEEE Trans. Commun.
Kaixuan Li, Kan Yu, Xiaowu Liu, Dingyou Ma, Qixun Zhang, Zhiyong Feng, Dong Li
2025 J jnl
CoRR
Kaixuan Li, Kan Yu, Xiaowu Liu, Qixun Zhang, Zhiyong Feng, Dong Li
2025 J jnl
IEEE Trans. Veh. Technol.
Ruotong Li, Qixun Zhang, Dingyou Ma, Kan Yu, Yuzhen Huang
2025 B conf
GLOBECOM
Xianhua Yu, Dong Li, Bowen Gu, Xiaoye Jing, Wen Wu, Tuo Wu, Kan Yu
2025 J jnl
IEEE Trans. Commun.
Zhiyong Feng, Yujia Zhao, Kan Yu, Dong Li
2025 J jnl
IEEE Wirel. Commun.
Kan Yu, Kaixuan Li, Yujia Zhao, Zhiyong Feng, Dong Li, Qixun Zhang, Jiguo Yu
2025 J jnl
CoRR
Wenxu Wang, Xiaowu Liu, Wei Gong, Yujia Zhao, Kaixuan Li, Qixun Zhang, Zhiyong Feng, Kan Yu
2025 J jnl
CoRR
Kan Yu, Kaixuan Li, Xiaowu Liu, Qixun Zhang, Zhiyong Feng
2025 J jnl
IEEE Trans. Veh. Technol.
Kan Yu, Xiao Zhao, Zhiyong Feng, Dianxia Chen, Xiaowu Liu, Xiaoshan Ma, Dong Li
2025 J jnl
IEEE Trans. Commun.
Jing Qiu, Jiguo Yu, Anming Dong, Kan Yu, Honglong Chen
2024 J jnl
IEEE Trans. Ind. Informatics
Wenshuo Ma, Xiaowu Liu, Jiguo Yu, Kan Yu, Xinyu Wang
2024 J jnl
IEEE/ACM Trans. Netw.
Kan Yu, Jiguo Yu, Zhiyong Feng, Honglong Chen
2024 conf
WASA (2)
Wenshuo Ma, Xinru Liu, Kan Yu, Chuanwen Luo, Guopeng Wang, Xiaowu Liu
2024 J jnl
IEEE Trans. Wirel. Commun.
Jiashuo He, Sai Huang, Zheng Yang, Kan Yu, Hao Huan, Zhiyong Feng
2024 J jnl
IEEE Wirel. Commun. Lett.
Hao Xie, Dong Li, Kan Yu, Guangchi Zhang
2024 J jnl
CoRR
Kan Yu, Fuze Zhu, Xiaowu Liu, Zhiyong Feng, Dong Li
2024 B conf
WCNC
Bowen Wang, Chao Jiao, Qixun Zhang, Kan Yu, Dingyou Ma
2024 conf
MSN
Wenhao Zhang, Wenshuo Ma, Chunmei Yang, Kan Yu, Chuanwen Luo, Guangsheng Feng
2024 J jnl
CoRR
Zhiyong Feng, Yujia Zhao, Kan Yu, Dong Li
2024 J jnl
IEEE Trans. Veh. Technol.
Kan Yu, Zhiyong Feng, Jiguo Yu, Ting Chen, Jinlin Peng, Dong Li
2024 B conf
WCNC
Qianyi Hao, Qixun Zhang, Yanpeng Cui, Fan Liu, Kan Yu, Dingyou Ma
2024 J jnl
IEEE Trans. Wirel. Commun.
Kan Yu, Dong Li, Jiguo Yu, Qixun Zhang, Zhiyong Feng
2023 conf
ICDM (Workshops)
Shijie Li, Xiaowu Liu, Wenshuo Ma, Kan Yu, Yangyang Liu
2023 J jnl
Comput. Networks
Kan Yu, Jiguo Yu, Zhiyong Feng, Min Guo
2023 J jnl
IEEE Trans. Veh. Technol.
Yahui Ji, Kan Yu, Jing Qiu, Jiguo Yu
2023 conf
iThings/GreenCom/CPSCom/SmartData/Cybermatics
Kan Yu, Kaixuan Li, Zhiyong Feng, Xiao Zhao, Chuanwen Luo, Ting Chen, Dong Li
2023 conf
MSN
Xiao Zhao, Kan Yu, Dong Li, Xiaowu Liu, Chuanwen Luo
2023 J jnl
CoRR
Kan Yu, Zhiyong Feng, Dong Li, Jiguo Yu
2023 J jnl
IEEE/ACM Trans. Netw.
Kan Yu, Jiguo Yu, Chuanwen Luo
2022 J jnl
J. Circuits Syst. Comput.
Guangshun Li, Guopeng Liang, Junhua Wu, Zhenyu Jin, Wenzhen Feng, Kan Yu
2022 J jnl
IEEE Trans. Veh. Technol.
Kan Yu, Jiguo Yu, Anming Dong
2022 J jnl
Ad Hoc Networks
Xiaowu Liu, Xue Yang, Jiguo Yu, Kan Yu
2022 conf
WASA (1)
Junhua Wu, Huiru Zhang, Guangshun Li, Kan Yu
2022 J jnl
IEEE Trans. Wirel. Commun.
Jing Qiu, Jiguo Yu, Anming Dong, Kan Yu
2022 J jnl
Int. J. Intell. Syst.
Junhua Wu, Tiantian Wang, Guangshun Li, Kan Yu, Chuanwen Luo
2022 conf
iThings/GreenCom/CPSCom/SmartData/Cybermatics
Shanchao Zheng, Kan Yu, Guangshun Li, Xiaowu Liu
2022 J jnl
Internet Things
Yahui Ji, Jiguo Yu, Yan Yao, Kan Yu, Honglong Chen, Shanchao Zheng
2022 J jnl
Int. J. Intell. Syst.
Kan Yu, Shanchao Zheng, Guangshun Li, Xiaowu Liu, Xue Yang, Xiao Zhao
2022 J jnl
Ad Hoc Networks
Xiaowu Liu, Jiguo Yu, Kan Yu, Guijuan Wang, Xingjian Feng
2021 conf
WASA (2)
Xiaowu Liu, Wenshuo Ma, Jiguo Yu, Kan Yu, Jiaqi Xiang
2021 J jnl
IEEE/ACM Trans. Netw.
Kan Yu, Jiguo Yu, Xiuzhen Cheng, Dongxiao Yu, Anming Dong
2021 J jnl
Ad Hoc Networks
Kan Yu, Biwei Yan, Jiguo Yu, Honglong Chen, Anming Dong
2020 J jnl
IEEE Access
Kan Yu, Jiguo Yu, Anming Dong, Guangshun Li
2020 J jnl
IEEE Trans. Wirel. Commun.
Jiguo Yu, Kan Yu, Dongxiao Yu, Weifeng Lv, Xiuzhen Cheng, Honglong Chen, Wei Cheng
2019 J jnl
Comput. Networks
Kan Yu, Yinglong Wang, Jiguo Yu, Dongxiao Yu, Xiuzhen Cheng, Zhiguang Shan
2018 J jnl
EURASIP J. Wirel. Commun. Netw.
Kan Yu, Guangshun Li, Jiguo Yu, Lina Ni
2017 J jnl
EURASIP J. Wirel. Commun. Netw.
Kan Yu, Meng Gao, Honglu Jiang, Guangshun Li
2017 J jnl
IEEE Internet Things J.
Lina Ni, Jinquan Zhang, Changjun Jiang, Chungang Yan, Kan Yu
2017 B conf
WCNC
Kan Yu, Jiguo Yu, Xiuzhen Cheng, Tianyi Song
2016 conf
IIKI
Meng Gao, Jiguo Yu, Kan Yu
2015 conf
WASA
Kan Yu, Zhi Li, Qiang Li, Jiguo Yu
tests/integration/test_elf_extractor.py
← Index tests/integration/test_elf_extractor.py python
"""
Integration tests for the ELFExtractor base class.
"""
import pytest
from unittest.mock import Mock, patch, MagicMock

pytestmark = [pytest.mark.integration, pytest.mark.elf]


class TestELFExtractorInitialization:
    """Tests for ELFExtractor initialization."""

    def test_elf_extractor_with_valid_elf(self, elf_binary_path, mock_logger):
        """Test ELFExtractor initialization with valid ELF file."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            assert extractor.filepath == elf_binary_path
            assert extractor._is_elf_file() is True

    def test_elf_extractor_with_invalid_file(self, pe_binary_path, mock_logger):
        """Test ELFExtractor initialization with non-ELF file."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(pe_binary_path, mock_logger)

            # Should not be a valid ELF
            assert extractor._is_elf_file() is False

    def test_elf_extractor_with_text_file(self, temp_text_file, mock_logger):
        """Test ELFExtractor initialization with text file."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(temp_text_file, mock_logger)

            # Should not be a valid ELF
            assert extractor._is_elf_file() is False


class TestELFExtractorMethods:
    """Tests for ELFExtractor helper methods."""

    def test_is_elf_file_true(self, elf_binary_path, mock_logger):
        """Test _is_elf_file returns True for valid ELF."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            assert extractor._is_elf_file() is True

    def test_is_elf_file_cached(self, elf_binary_path, mock_logger):
        """Test _is_elf_file result is cached."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            # First call
            result1 = extractor._is_elf_file()
            # Second call should use cached value
            result2 = extractor._is_elf_file()

            assert result1 == result2
            # Cache should be set
            assert extractor._elf_file_valid is not None

    def test_is_64bit(self, elf_binary_path, mock_logger):
        """Test _is_64bit method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._is_64bit()
            # Result depends on the test binary
            assert isinstance(result, bool)

    def test_is_stripped(self, elf_binary_path, mock_logger):
        """Test _is_stripped method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._is_stripped()
            assert isinstance(result, bool)

    def test_has_debug_info(self, elf_binary_path, mock_logger):
        """Test _has_debug_info method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._has_debug_info()
            assert isinstance(result, bool)

    def test_get_architecture(self, elf_binary_path, mock_logger):
        """Test _get_architecture method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._get_architecture()
            # Should return a string (architecture name)
            assert isinstance(result, str)
            assert result != ""

    def test_get_endianness(self, elf_binary_path, mock_logger):
        """Test _get_endianness method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._get_endianness()
            # Should be one of: "little", "big", or "unknown"
            assert result in ["little", "big", "unknown"]

    def test_get_file_type(self, elf_binary_path, mock_logger):
        """Test _get_file_type method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._get_file_type()
            # Should return a file type string
            assert isinstance(result, str)
            # Common values: "executable", "shared_object", "relocatable", etc.
            expected_types = ["none", "relocatable", "executable", "shared_object", "core_dump", "unknown"]
            assert result in expected_types or result.startswith("ET_")

    def test_is_pie(self, elf_binary_path, mock_logger):
        """Test _is_pie method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._is_pie()
            assert isinstance(result, bool)

    def test_has_stack_protection(self, elf_binary_path, mock_logger):
        """Test _has_stack_protection method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._has_stack_protection()
            assert isinstance(result, bool)

    def test_has_nx_bit(self, elf_binary_path, mock_logger):
        """Test _has_nx_bit method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._has_nx_bit()
            assert isinstance(result, bool)

    def test_has_relro(self, elf_binary_path, mock_logger):
        """Test _has_relro method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._has_relro()
            assert isinstance(result, bool)

    def test_get_build_id(self, elf_binary_path, mock_logger):
        """Test _get_build_id method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._get_build_id()
            # Could be None if no build ID, or a hex string
            assert result is None or isinstance(result, str)

    def test_count_sections(self, elf_binary_path, mock_logger):
        """Test _count_sections method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._count_sections()
            assert isinstance(result, int)
            assert result >= 0

    def test_count_segments(self, elf_binary_path, mock_logger):
        """Test _count_segments method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._count_segments()
            assert isinstance(result, int)
            assert result >= 0

    def test_count_symbols(self, elf_binary_path, mock_logger):
        """Test _count_symbols method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._count_symbols()
            assert isinstance(result, int)
            assert result >= 0

    def test_get_dependencies(self, elf_binary_path, mock_logger):
        """Test _get_dependencies method."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor._get_dependencies()
            assert isinstance(result, list)


class TestWithELFFile:
    """Tests for the _with_elf_file context manager method."""

    def test_with_elf_file_success(self, elf_binary_path, mock_logger):
        """Test _with_elf_file executes operation successfully."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            # Define a simple operation
            def get_header(elf):
                return elf.header is not None

            result = extractor._with_elf_file(get_header)
            assert result is True

    def test_with_elf_file_error_handling(self, temp_text_file, mock_logger):
        """Test _with_elf_file handles errors gracefully."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(temp_text_file, mock_logger)

            # Define an operation that would fail
            def get_header(elf):
                return elf.header

            result = extractor._with_elf_file(get_header)
            # Should return None on error
            assert result is None


class TestELFExtractorTag:
    """Tests for tag method in ELF extractors."""

    def test_elf_features_tag(self, elf_binary_path, mock_logger):
        """Test that ELFFeaturesExtractor returns correct tag."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)
            tag = extractor.tag()
            # Should return the tag string
            assert isinstance(tag, str)
            assert "elf" in tag.lower() or "features" in tag.lower()


class TestELFExtractorClickHouseTable:
    """Tests for get_clickhouse_table method in ELF extractors."""

    def test_elf_features_clickhouse_table(self, elf_binary_path, mock_logger):
        """Test that ELFFeaturesExtractor returns correct ClickHouse table name."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)
            assert extractor.get_clickhouse_table() == "redb_elf_features"


class TestELFExtractorExtract:
    """Tests for extract method in ELF extractors."""

    def test_elf_features_extract(self, elf_binary_path, mock_logger):
        """Test ELFFeaturesExtractor.extract() returns valid data."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor
        from redb.models.dataclasses import ELFFeatures

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            result = extractor.extract()
            assert result is not None
            assert isinstance(result, ELFFeatures)

            # Check some expected fields
            assert isinstance(result.ei_class, int)
            assert isinstance(result.ei_data, int)
            assert isinstance(result.e_entry, int)
            assert isinstance(result.number_of_sections, int)
            assert isinstance(result.number_of_segments, int)

    def test_elf_features_extract_invalid_file(self, pe_binary_path, mock_logger):
        """Test ELFFeaturesExtractor.extract() handles invalid ELF."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(pe_binary_path, mock_logger)

            result = extractor.extract()
            # Should return None for invalid ELF
            assert result is None


class TestELFExtractorPrepareExportData:
    """Tests for prepare_export_data method in ELF extractors."""

    def test_elf_features_prepare_export_elasticsearch(self, elf_binary_path, mock_logger):
        """Test prepare_export_data for Elasticsearch."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            # First extract
            extractor.extract()
            result = extractor.prepare_export_data("ElasticsearchExporter")
            # Should return the elf_features dataclass
            assert result is extractor.elf_features

    def test_elf_features_prepare_export_clickhouse(self, elf_binary_path, mock_logger):
        """Test prepare_export_data for ClickHouse."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_binary_path, mock_logger)

            # First extract
            extractor.extract()
            result = extractor.prepare_export_data("ClickHouseExporter")

            # Should return tuple of (data, column_names, column_type_names)
            assert isinstance(result, tuple)
            assert len(result) == 3
            data, column_names, column_type_names = result
            assert isinstance(data, list)
            assert isinstance(column_names, list)
            assert isinstance(column_type_names, list)
            # Column names and types should match in length
            assert len(column_names) == len(column_type_names)


class TestELFExtractorAdvanced:
    """Advanced tests for ELF extraction using hello_advanced binary."""

    def test_elf_advanced_features(self, elf_advanced_binary_path, mock_logger):
        """Test ELFFeaturesExtractor with more complex ELF binary."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_advanced_binary_path, mock_logger)

            result = extractor.extract()
            assert result is not None

            # Check that we can extract meaningful data
            assert result.number_of_sections > 0
            assert result.number_of_segments > 0

    def test_elf_advanced_architecture(self, elf_advanced_binary_path, mock_logger):
        """Test architecture detection for advanced ELF binary."""
        from redb.extractors.elf_extractors.elf_features import ELFFeaturesExtractor

        with patch('redb.settings.ELASTIC_BINARIES_COLLECTION', 'test'):
            extractor = ELFFeaturesExtractor(elf_advanced_binary_path, mock_logger)

            arch = extractor._get_architecture()
            # Should detect a valid architecture
            assert arch != "unknown"
            assert arch != ""