Varun Dutt

109 papers B 10Misc 6Journal 29Unranked 63
YearRankTypeTitle / Venue / Authors
2026 J jnl
ACM Trans. Comput. Heal.
Ritik Sharma, Varun Dutt, Arnav Bhavsar, Ritu Kapur, Bhupender Kumar, Vikrant Kanwar
2025 conf
BIOSTEC (1)
Sakshi Chauhan, Gitanshu Choudhary, Arnav Bhavsar, Varun Dutt
2025 B conf
SMC
Ankit Singh, Ramajayam Govindaraji, Varun Dutt
2025 J jnl
Frontiers Robotics AI
Sakshi Chauhan, Shashank Kapoor, Malika Nagpal, Gitanshu Choudhary, Varun Dutt
2025 Misc conf
CogSIMA
Shubham Thakur, Shubham Sharma, Ranik Goyal, Megha Sharma, Shashank Uttrani, Varun Dutt
2025 J jnl
Comput. Intell.
Kirti Tripathi, Shashank Uttrani, Gitanshu Choudhary, Akash Singh, Priya Sharma, Varun Dutt
2025 conf
BIOSTEC (1)
Arjun Mehra, Arti Devi, Ananya Sharma, Sahil Rana, Shivam Kumar, Kala Venkata Uday, Varun Dutt
2025 Misc conf
CogSIMA
Ankit Singh, Varun Dutt
2025 conf
ISMAR-Adjunct
Ajoy Kumar, Shubham Thakur, Rahul Kumar, Varun Dutt
2025 conf
VR Workshops
Ajoy Kumar, Sahil Sankhyan, Akash Singh, Arnav Bhavsar, Varun Dutt
2025 conf
VR Workshops
Arjun Mehra, Arti Devi, Ajoy Kumar, Sahil Rana, Shivam Kumar, Kala Venkata Uday, Varun Dutt
2025 B conf
SMC
Arjun Mehra, Ajoy Kumar, Arti Devi, Kala Venkata Uday, Varun Dutt
2024 B conf
SMC
Akash K. Rao, Shashank Uttrani, Darshil Shah, Vishnu K. Menon, Arnav Bhavsar, Shubhajit Roy Chowdhury, Ramsingh Negi, Varun Dutt
2024 conf
CCGridW
Varun Dutt, Lucas Galan, Faiyaz Doctor, Lina Barakat, Kate Isaacs, Demetris Hadjigeorgiou, Aldo Fumagalli
2024 conf
PETRA
Arti Devi, Shashank Uttrani, Aryansh Singla, Sarthak Jha, Nataraj Dasgupta, Sayee Natarajan, Rajeshwari S. Punekar, Larry A. Pickett, Varun Dutt
2024 J jnl
CoRR
Akash K. Rao, Vishnu K. Menon, Arnav Bhavsar, Shubhajit Roy Chowdhury, Ramsingh Negi, Varun Dutt
2024 J jnl
CoRR
Akash K. Rao, Vishnu K. Menon, Shashank Uttrani, Ayushman Dixit, Dipanshu Verma, Varun Dutt
2024 B conf
SMC
Malika Nagpal, Sakshi Chauhan, Gitanshu Choudhary, Shivanshi Saini, Varun Dutt
2024 conf
ICCCNT
S. Mani, Varun Dutt
2024 conf
ICCCNT
Shashank Kapoor, Shashank Uttrani, Gunjan Paul, Varun Dutt
2024 J jnl
CoRR
Akash K. Rao, Arnav Bhavsar, Shubhajit Roy Chowdhury, Sushil Chandra, Ramsingh Negi, Prakash Duraisamy, Varun Dutt
2024 conf
SOSE
Varun Dutt, Demetris Hadjigeorgiou, Lucas Galan, Faiyaz Doctor, Lina Barakat, Kate Isaacs
2024 conf
ICSR + AI (3)
Sakshi Chauhan, Gitanshu Chaudhary, Arnav Bhavsar, Katja D. Mombaur, Varun Dutt
2024 conf
PETRA
Shashank Kapoor, Shashank Uttrani, Gunjan Paul, Varun Dutt
2024 conf
PETRA
Kirti Tripathi, Srishti Swaroop, Ankush Arya, Divyansh Pandey, Arnav Bhavsar, Varun Dutt
2024 J jnl
IEEE Access
Ritu Kapur, Yashwant Kumar, Ritik Sharma, Shivani Sharma, Eishkaran Singh, Dhruv Rohilla, Vikrant Kanwar, Bhupender Kumar, Arnav Bhavsar, Varun Dutt
2024 conf
ICCCNT
S. Mani, Varun Dutt
2024 conf
ICCCNT
Priyanka Priyanka, Praveen Kumar, Kala Venkata Uday, Varun Dutt
2024 conf
ICCCNT
Abhinav Choudhury, Prakash Duraisamy, James Van Haneghan, Fang Jiang, Varun Dutt
2024 conf
ICCCNT
Arti Devi, Shashank Uttrani, Aryansh Singla, Sarthak Jha, Preethi Ravula, Nataraj Dasgupta, Sayee Natarajan, Rajeshwari S. Punekar, Larry A. Pickett, Emilio Lapiello, Varun Dutt
2024 conf
ICCCNT
Abhinav Choudhury, Prakash Duraisamy, James Van Haneghan, Fang Jiang, Varun Dutt
2024 conf
ICCCNT
Praveen Kumar, Manika Gupta, Priyanka, Anuj Kumar Dubey, Varun Dutt
2024 conf
ICCCNT
Akash Singh, Kirti Tripathi, Priya Sharma, Gitanshu Choudhary, Arnav Bhavsar, Varun Dutt
2024 conf
PETRA
Sagnik Ghosh, Kirti Tripathi, Ankita Garg, Dinesh Singh, Amit Prasad, Arnav Bhavsar, Varun Dutt
2024 J jnl
CoRR
Akash K. Rao, Gunjan Y. Trivedi, Riri G. Trivedi, Anshika Bajpai, Gajraj Singh Chouhan, Vishnu K. Menon, Kathirvel Soundappan, Hemalatha Ramani, Neha Pandya, Varun Dutt
2024 conf
PETRA
Akash K. Rao, Vishnu K. Menon, Darshil Shah, Arnav Bhavsar, Varun Dutt
2024 J jnl
CoRR
Akash K. Rao, Shashank Uttrani, Vishnu K. Menon, Darshil Shah, Arnav Bhavsar, Shubhajit Roy Chowdhury, Varun Dutt
2024 conf
ICMHI
Arti Devi, Shashank Uttrani, Aryansh Singla, Sarthak Jha, Nataraj Dasgupta, Sayee Natarajan, Rajeshwari S. Punekar, Larry A. Pickett, Varun Dutt
2024 conf
PETRA
Sakshi Chauhan, Gitanshu Choudhary, Arnav Bhavsar, Varun Dutt
2024 conf
PETRA
Ritu Kapur, Ritik Sharma, Vikrant Kanwar, Arnav Bhavsar, Varun Dutt
2024 conf
ICCCNT
Kirti Tripathi, Vivian Carter, An'Darius Fergerson, Prakash Duraisamy, Varun Dutt
2024 B conf
SMC
Ankita Garg, Ajoy Kumar, Shubham Garg, Laxmidhar Behera, Varun Dutt
2024 B conf
SMC
Ajoy Kumar, Sahil Sankhyan, Kirti Tripathi, Sakshi Thakur, Arnav Bhavsar, Varun Dutt
2024 conf
ISMAR-Adjunct
Ajoy Kumar, Sahil Sankhyan, Kirti Tripathi, Akash K. Rao, Arnav Bhavsar, Varun Dutt
2023 J jnl
IEEE Access
Praveen Kumar, P. Priyanka, J. Dhanya, Kala Venkata Uday, Varun Dutt
2023 conf
PETRA
Anuj Nandanwar, Varun Dutt
2023 conf
PETRA
Darshil Shah, Akash K. Rao, Arnav Bhavsar, Shubhajit Roy Chowdhury, Sushil Chandra, Varun Dutt
2023 J jnl
Frontiers Big Data
Shashank Uttrani, Palvi Aggarwal, Varun Dutt
2023 conf
PETRA
Gitanshu Choudhary, Keshav Tadia, Varun Dutt
2023 conf
PETRA
Durgesh Ameta, Ankita Garg, Parveen Kumar, Laxmidhar Behera, Varun Dutt
2023 conf
EuroS&P Workshops
Megha Sharma, Kuldeep Singh, Palvi Aggarwal, Varun Dutt
2023 conf
PETRA
Shilpa Chandra, Kulbhushan Chand, Varun Dutt
2023 conf
ISMAR-Adjunct
Akash K. Rao, Gitanshu Choudhary, Ramsingh Negi, Varun Dutt
2023 conf
PETRA
Gaurav Jaswal, Geetanjali Sharma, Varun Dutt, Arnav Bhavsar
2023 conf
SBP-BRiMS
Aadhar Gupta, Mahavir Dabas, Shashank Uttrani, Sakshi Sharma, Varun Dutt
2023 conf
PETRA
Akash K. Rao, Gunjan Y. Trivedi, Anshika Bajpai, Gajraj Singh Chouhan, Riri G. Trivedi, Anita Kumar, Varun Dutt, Kathirvel Soundappan, Hemalatha Ramani
2023 conf
PETRA
Akash K. Rao, Zoha Fatma, Vishnu K. Menon, Arnav Bhavsar, Shubhajit Roy Chowdhury, Sushil Chandra, Varun Dutt, Kulbhushan Chand
2023 conf
PETRA
Ankita Garg, Kirti Tripathi, Shatakshi Goyal, Laxmidhar Behera, Varun Dutt
2022 conf
RICE
Aashima, Shashank Bhargav, Shruti Kaushik, Varun Dutt
2022 conf
ICONIP (5)
Megha Sharma, Mayank Kumar, Cleotilde Gonzalez, Varun Dutt
2022 J jnl
Hum. Factors
Palvi Aggarwal, Frédéric Moisan, Cleotilde Gonzalez, Varun Dutt
2022 J jnl
Top. Cogn. Sci.
Shashank Uttrani, Neha Sharma, Varun Dutt
2022 conf
ICONIP (5)
Aadhar Gupta, Shashank Uttrani, Gunjan Paul, Bhavik Kanekar, Varun Dutt
2021 J jnl
IEEE Access
Anmol Gupta, Partha Pratim Roy, Varun Dutt
2020 J jnl
Frontiers Big Data
Shruti Kaushik, Abhinav Choudhury, Pankaj Kumar Sheron, Nataraj Dasgupta, Sayee Natarajan, Larry A. Pickett, Varun Dutt
2020 Misc conf
ICDCIT
Rishi Sharma, Tushar Saini, Praveen Kumar, Ankush Pathania, Khyathi Chitineni, Pratik Chaturvedi, Varun Dutt
2020 conf
ICCCNT
Debashis Sahoo, Naveksha Sood, Usha Rani, George Abraham, Varun Dutt, Dileep D.
2020 conf
HCI (46)
Akash K. Rao, Sushil Chandra, Varun Dutt
2020 ch.
Handbook of Computer Networks and Cyber Security
Palvi Aggarwal, Cleotilde Gonzalez, Varun Dutt
2020 conf
FICTA (2)
Abhinav Choudhury, Shruti Kaushik, Varun Dutt
2020 J jnl
IEEE Access
Shruti Kaushik, Abhinav Choudhury, Sayee Natarajan, Larry A. Pickett, Varun Dutt
2020 conf
SBP-BRiMS
Neha Sharma, Varun Dutt
2020 J jnl
IEEE Trans. Cogn. Dev. Syst.
Medha Kumar, Varun Dutt
2019 conf
MLDM (2)
Naveksha Sood, Shruti Kaushik, Aditya Nigam, Sriram Kailasam, Dileep D., Varun Dutt
2019 J jnl
Int. J. Cyber Situational Aware.
Zahid Maqbool, V. S. Chandrasekhar Pammi, Varun Dutt
2019 conf
MLDM (2)
Shruti Kaushik, Abhinav Choudhury, Ashutosh Kumar Jatav, Nataraj Dasgupta, Sayee Natarajan, Larry A. Pickett, Varun Dutt
2019 conf
AHFE (9)
Palvi Aggarwal, Aksh Gautam, Vaibhav Agarwal, Cleotilde Gonzalez, Varun Dutt
2019 conf
AHFE (7)
Pratik Chaturvedi, Varun Dutt
2019 Misc conf
CogSIMA
Medha Kumar, Kapil Agrawal, Varun Dutt
2019 conf
SocProS (2)
Praveen Kumar, Priyanka, Ankush Pathania, Shubham Agarwal, Naresh Mali, Ravinder Singh, Pratik Chaturvedi, Kala Venkata Uday, Varun Dutt
2019 conf
IHCI
Akash K. Rao, Jibraan Singh Chahal, Sushil Chandra, Varun Dutt
2018 conf
CyberSA
Zahid Maqbool, V. S. Chandrasekhar Pammi, Varun Dutt
2018 conf
MLDM (1)
Shruti Kaushik, Abhinav Choudhury, Nataraj Dasgupta, Sayee Natarajan, Larry A. Pickett, Varun Dutt
2018 B conf
SMC
Akash K. Rao, Chandan Satyarthi, Utkrisht Dhankar, Sushil Chandra, Varun Dutt
2018 conf
IHCI
Pratik Chaturvedi, Varun Dutt
2018 J jnl
Netw. Model. Anal. Health Informatics Bioinform.
Abhinav Choudhury, Shruti Kaushik, Varun Dutt
2018 J jnl
Int. J. Cyber Situational Aware.
Palvi Aggarwal, Frédéric Moisan, Cleotilde Gonzalez, Varun Dutt
2017 conf
ICC
Abhinav Choudhury, Shruti Kaushik, Varun Dutt
2017 J jnl
Hum. Factors
Zahid Maqbool, Nidhi Makhijani, V. S. Chandrasekhar Pammi, Varun Dutt
2017 conf
CyberSA
Palvi Aggarwal, Cleotilde Gonzalez, Varun Dutt
2017 B conf
ASONAM
Abhinav Choudhury, Shruti Kaushik, Varun Dutt
2016 conf
MLDM
Shruti Kaushik, Abhinav Choudhury, Kaustubh Mallik, Anzer Moid, Varun Dutt
2016 J jnl
Int. J. Hum. Comput. Interact.
Pradipta Biswas, Varun Dutt, Pat Langdon
2016 conf
CyberSA
Zahid Maqbool, V. S. Chandrasekhar Pammi, Varun Dutt
2016 conf
CyberSA
Palvi Aggarwal, Cleotilde Gonzalez, Varun Dutt
2015 J jnl
Cogn. Sci.
Cleotilde Gonzalez, Noam Ben-Asher, Jolie M. Martin, Varun Dutt
2015 conf
CyberSA
Palvi Aggarwal, Zahid Maqbool, Antra Grover, V. S. Chandrasekhar Pammi, Saumya Singh, Varun Dutt
2015 conf
HCI (10)
Pradipta Biswas, Varun Dutt
2014 Misc conf
KI
Shoubhik Debnath, Shiv Sankar Baishya, Rudolph Triebel, Varun Dutt, Daniel Cremers
2014 conf
IOV
Ajay Kumar, Jai Prakash, Varun Dutt
2013 J jnl
Hum. Factors
Varun Dutt, Young-Suk Ahn, Cleotilde Gonzalez
2013 J jnl
Int. J. Trust. Manag. Comput. Commun.
Varun Dutt, Amanjot Kaur
2013 J jnl
J. Comput. Sci.
Cleotilde Gonzalez, Varun Dutt, Christian Lebiere
2012 J jnl
Comput. Hum. Behav.
Varun Dutt, Cleotilde Gonzalez
2011 J jnl
Games
Cleotilde Gonzalez, Varun Dutt, Tomás Lejarraga
2011 J jnl
Comput. Hum. Behav.
Cleotilde Gonzalez, Varun Dutt
2011 B conf
DBSec
Varun Dutt, Young-Suk Ahn, Cleotilde Gonzalez
2011 B conf
CogSci
Varun Dutt, Jolie M. Martin, Cleotilde Gonzalez
2011 Misc conf
CogSIMA
Varun Dutt, Daniel N. Cassenti, Cleotilde Gonzalez
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 != ""