Malcolm Munro

147 papers A* 1B 9C 12Misc 3Journal 45Unranked 76
YearRankTypeTitle / Venue / Authors
2019 conf
CSCloud/EdgeCom
Abdullah Sheikh, Malcolm Munro, David Budgen
2018 conf
ICCBDC
Abdullah Sheikh, Malcolm Munro, David Budgen
2018 J jnl
Int. J. Web Eng. Technol.
Samer Hanna, Malcolm Munro
2014 C conf
FIE
Mohammed Basheri, Malcolm Munro
2013 conf
CSCL (2)
Mohammed Basheri, Liz Burd, Malcolm Munro, Nilufar Baghaei
2012 J jnl
Decis. Support Syst.
Ling Liu, Malcolm Munro
2011 J jnl
Int. J. Inf. Syst. Model. Des.
Xiaofeng Du, Malcolm Munro, William Song
2011 J jnl
J. Softw. Maintenance Res. Pract.
Gerardo Canfora, Darren Dalcher, David Raffo, Victor R. Basili, Juan Fernández-Ramil, Václav Rajlich, Keith H. Bennett, Liz Burd, Malcolm Munro, Sophia Drossopoulou, Barry W. Boehm, Susan Eisenbach, Greg Michaelson, Peter Ross, Paul Wernick, Dewayne E. Perry
2011 Misc conf
TASE
Shengchao Qin, Aziem Chawdhary, Wei Xiong, Malcolm Munro, Zongyan Qiu, Huibiao Zhu
2010 J jnl
Int. J. Knowl. Eng. Data Min.
William Song, Xiaofeng Du, Malcolm Munro
2010 conf
ICSS
Deren Chen, S. Han, Malcolm Munro, Aijaz Soomro, William Song
2010 conf
ICSM
Mohammad Abdallah, Malcolm Munro, Keith B. Gallagher
2010 conf
WEBIST (2)
Ling Liu, Malcolm Munro, William Song
2009 conf
ITNG
Abdullah M. Alnajim, Malcolm Munro
2009 conf
INCoS
Abdullah M. Alnajim, Malcolm Munro
2009 conf
ISD
Xiaofeng Du, William Wei Song, Malcolm Munro
2009 J jnl
J. Digit. Inf. Manag.
Abdullah M. Alnajim, Malcolm Munro
2008 conf
ISD
Xiaofeng Du, William Song, Malcolm Munro
2008 B conf
SAFECOMP
Abdullah M. S. Alaraj, Malcolm Munro
2008 conf
ICDIM
Abdullah M. Alnajim, Malcolm Munro
2008 conf
ITNG
Samer Hanna, Malcolm Munro
2008 J jnl
IEEE Trans. Software Eng.
Keith B. Gallagher, Andrew Hatch, Malcolm Munro
2007 C conf
AICCSA
Samer Hanna, Malcolm Munro
2007 conf
ISD (2)
Samer Hanna, Malcolm Munro
2007 conf
ICDIM
Abdullah M. S. Alaraj, Malcolm Munro
2007 C conf
CollaborateCom
Abdullah M. S. Alaraj, Malcolm Munro
2007 J jnl
Int. J. Simul. Process. Model.
Nik Looker, Jie Xu, Malcolm Munro
2007 conf
ISD (2)
Xiaofeng Du, William Song, Malcolm Munro
2006 conf
Software Engineering Research and Practice
Suhaimi Ibrahim, Norbik Bashah Idris, Malcolm Munro, Aziz Deraman
2006 J jnl
MIS Q. Executive
Sid L. Huff, P. Michael Maher, Malcolm Munro
2006 conf
IAT Workshops
Xiaofeng Du, William Song, Malcolm Munro
2005 conf
COMPSAC (1)
Nik Looker, Malcolm Munro, Jie Xu
2005 B conf
VISSOFT
Keith B. Gallagher, Andrew Hatch, Malcolm Munro
2005 conf
WORDS
Nik Looker, Malcolm Munro, Binka Gwynne, Jie Xu
2005 B conf
VISSOFT
Michael Philip Smith, Malcolm Munro
2005 conf
IASTED Conf. on Software Engineering
Suhaimi Ibrahim, Norbik Bashah Idris, Malcolm Munro, Aziz Deraman
2005 conf
COMPSAC (2)
Nik Looker, Malcolm Munro, Jie Xu
2005 J jnl
Int. Arab J. Inf. Technol.
Suhaimi Ibrahim, Norbik Bashah Idris, Malcolm Munro, Aziz Deraman
2005 conf
SOSE
Nik Looker, Liz Burd, S. Drummond, Jie Xu, Malcolm Munro
2004 J jnl
Commun. Assoc. Inf. Syst.
Robert M. Davison, Malcolm Munro, Detmar W. Straub
2004 J jnl
Autom. Softw. Eng.
Mark Harman, Lin Hu, Malcolm Munro, Xingyuan Zhang, David W. Binkley, Sebastian Danicic, Mohammed Daoudi, Lahcen Ouarbya
2004 J jnl
IEEE Softw.
Nicolas Gold, Claire Knight, Andrew Mohan, Malcolm Munro
2004 conf
COMPSAC Workshops
Nik Looker, Malcolm Munro, Jie Xu
2003 J jnl
IEEE Trans. Software Eng.
Simon C. Shaw, Michael Goldstein, Malcolm Munro, Elizabeth Burd
2003 J jnl
Commun. Assoc. Inf. Syst.
Joey F. George, Robert M. Davison, Jon Heales, Malcolm Munro
2003 B conf
VISSOFT
Stuart M. Charters, Nigel Thomas, Malcolm Munro
2002 conf
ICSM
Mark Harman, Lin Hu, Robert M. Hierons, Malcolm Munro, Xingyuan Zhang, José Javier Dolado, Mari Carmen Otero, Joachim Wegener
2002 C conf
SCAM
Mark Harman, Lin Hu, Malcolm Munro, Xingyuan Zhang, Sebastian Danicic, Mohammed Daoudi, Lahcen Ouarbya
2002 conf
DIPES
Paul Townend, Jie Xu, Malcolm Munro
2002 C conf
SCAM
Xingyuan Zhang, Malcolm Munro, Mark Harman, Lin Hu
2002 conf
IWPC
Claire Knight, Malcolm Munro
2002 conf
HICSS
Keith H. Bennett, Malcolm Munro, Jie Xu, Nicolas Gold, Paul J. Layzell, Nikolay Mehandjiev, David Budgen, Pearl Brereton
2002 B conf
VISSOFT
Christopher M. B. Taylor, Malcolm Munro
2002 B conf
VISSOFT
Michael Philip Smith, Malcolm Munro
2002 J jnl
Inf. Softw. Technol.
Mark Harman, Malcolm Munro, Lin Hu, Xingyuan Zhang
2002 C conf
SEKE
Stuart M. Charters, Claire Knight, Nigel Thomas, Malcolm Munro
2002 conf
TPHOLs
Xingyuan Zhang, Malcolm Munro, Mark Harman, Lin Hu
2001 B conf
COMPSAC
Keith H. Bennett, Jie Xu, Malcolm Munro, Zhuang Hong, Paul J. Layzell, Nicolas Gold, David Budgen, Pearl Brereton
2001 conf
ICSM
Keith H. Bennett, Malcolm Munro, Nicolas Gold, Paul J. Layzell, David Budgen, Pearl Brereton
2001 J jnl
J. Softw. Maintenance Res. Pract.
Yoon Kyu Jang, Malcolm Munro, Yong Rae Kwon
2001 conf
WORDS
Paul Townend, Jie Xu, Malcolm Munro
2001 conf
WCRE
Mark Harman, Lin Hu, Malcolm Munro, Xingyuan Zhang
2001 J jnl
Inf. Softw. Technol.
Frank P. A. Coolen, Michael Goldstein, Malcolm Munro
2001 conf
IWPC
Claire Knight, Malcolm Munro
2001 conf
IWPSE
Claire Knight, Malcolm Munro
2001 conf
IWPC
Mark Harman, Malcolm Munro, Lin Hu, Xingyuan Zhang
2001 Misc conf
HCI
Claire Knight, Malcolm Munro
2001 Misc conf
International Conference on Computational Science (2)
Claire Knight, Malcolm Munro
2000 J jnl
Inf. Syst. Res.
Barbara L. Marcolin, Deborah Compeau, Malcolm Munro, Sid L. Huff
2000 C conf
APSEC
Keith H. Bennett, Paul J. Layzell, David Budgen, Pearl Brereton, Linda A. Macaulay, Malcolm Munro
2000 C conf
WETICE
Claire Knight, Malcolm Munro
2000 J jnl
Ann. Softw. Eng.
Elizabeth Burd, Malcolm Munro
2000 J jnl
J. Syst. Softw.
Elizabeth Burd, Malcolm Munro
2000 C conf
IV
Claire Knight, Malcolm Munro
2000 conf
Workshop on Software and Performance
Nigel Thomas, Malcolm Munro, Peter J. B. King, Rob Pooley
1999 ch.
Visual Representations and Interpretations
Peter Young, Malcolm Munro
1999 conf
WCRE
Elizabeth Burd, Malcolm Munro
1999 conf
IWPC
Claire Knight, Malcolm Munro
1999 J jnl
IEE Proc. Softw.
Keith H. Bennett, Magnus Ramage, Malcolm Munro
1999 conf
ICSM
Elizabeth Burd, Malcolm Munro
1999 C conf
APSEC
Oh-Cheon Kwon, Gyu-Sang Shin, Cornelia Boldyreff, Malcolm Munro
1999 J jnl
J. Object Oriented Program.
Ishbel Duncan, Dave Robson, Malcolm Munro
1999 conf
IWPC
Paul Warren, Cornelia Boldyreff, Malcolm Munro
1999 J jnl
Commun. ACM
Pearl Brereton, David Budgen, Keith H. Bennett, Malcolm Munro, Paul J. Layzell, Linda A. Macaulay, David Griffiths, Charles Stannett
1998 J jnl
J. Syst. Softw.
Elizabeth Burd, Malcolm Munro
1998 J jnl
J. Syst. Softw.
Gerardo Canfora, Andrea De Lucia, Malcolm Munro
1998 conf
ECOOP Workshops
James Ingham, Malcolm Munro
1998 conf
WCRE
Elizabeth Burd, Malcolm Munro
1998 conf
ICSM
Elizabeth Burd, Malcolm Munro
1998 B conf
COMPSAC
Elizabeth Burd, Malcolm Munro
1998 J jnl
Int. J. Softw. Eng. Knowl. Eng.
Oh-Cheon Kwon, Cornelia Boldyreff, Malcolm Munro
1998 J jnl
MIS Q.
Peter R. Newsted, Sid L. Huff, Malcolm Munro
1998 conf
IWPC
Peter Young, Malcolm Munro
1997 conf
WPC
Elizabeth Burd, Malcolm Munro
1997 conf
ICSM
Elizabeth Burd, Malcolm Munro
1997 conf
WPC
Pui-Shan Chan, Malcolm Munro
1997 conf
WCRE
Elizabeth Burd, Malcolm Munro
1997 J jnl
Inf. Manag.
Malcolm Munro, Sid L. Huff, Barbara L. Marcolin, Deborah Compeau
1996 J jnl
J. Softw. Maintenance Res. Pract.
Aniello Cimitile, Andrea De Lucia, Malcolm Munro
1996 J jnl
Softw. Pract. Exp.
Aniello Cimitile, Malcolm Munro
1996 C conf
SEKE
Gerardo Canfora, Andrea De Lucia, Malcolm Munro
1996 conf
ICSM
Elizabeth Burd, Malcolm Munro, Clazien D. Wezeman
1996 B conf
COMPSAC
In Sang Chung, Malcolm Munro, Wan Kwon Lee, Yong Rae Kwon
1996 conf
WCRE
Elizabeth Burd, Malcolm Munro, Clazien D. Wezeman
1996 conf
WPC
Cornelia Boldyreff, Elizabeth Burd, R. M. Hather, Malcolm Munro, E. J. Younger
1996 conf
ICSM
Malcolm Munro, Paul J. Layzell, David Griffiths, Pearl Brereton
1996 conf
WPC
Andrea De Lucia, Anna Rita Fasolino, Malcolm Munro
1995 conf
WCRE
Helen M. Edwards, Malcolm Munro
1995 conf
ICSM
Aniello Cimitile, Andrea De Lucia, Malcolm Munro
1995 conf
WCRE
Aniello Cimitile, Andrea De Lucia, Malcolm Munro
1995 conf
ICSM
Cornelia Boldyreff, Elizabeth Burd, R. M. Hather, Richard Eric Mortimer, Malcolm Munro, E. J. Younger
1994 conf
ICSM
Gerardo Canfora, Aniello Cimitile, Maria Tortorella, Malcolm Munro
1994 J jnl
J. Softw. Maintenance Res. Pract.
Richard J. Turver, Malcolm Munro
1994 C ed.
ICIS
Janice I. DeGross, Sid L. Huff, Malcolm Munro
1994 conf
WPC
Aniello Cimitile, Maria Tortorella, Malcolm Munro
1994 J jnl
J. Softw. Maintenance Res. Pract.
Gerardo Canfora, Aniello Cimitile, Malcolm Munro
1994 J jnl
J. Softw. Maintenance Res. Pract.
Miriam A. M. Capretz, Malcolm Munro
1994 conf
ICSM
Jean-Pierre Queille, Jean-Francois Voidrot, Norman Wilde, Malcolm Munro
1994 conf
ICSM
David A. Kinloch, Malcolm Munro
1993 conf
WCRE
Gerardo Canfora, Aniello Cimitile, Malcolm Munro
1993 conf
WPC
David A. Kinloch, Malcolm Munro
1993 conf
ICSM
Helen M. Edwards, Malcolm Munro
1993 conf
WPC
Gerardo Canfora, Aniello Cimitile, Malcolm Munro, Maria Tortorella
1993 conf
ICSM
Gerardo Canfora, Aniello Cimitile, Malcolm Munro, C. J. Taylor
1993 A* conf
ICSE
Helen M. Edwards, Malcolm Munro
1993 conf
WCRE
Helen M. Edwards, Malcolm Munro
1992 conf
ICSM
Miriam A. M. Capretz, Malcolm Munro
1992 conf
SIGCPR
Sid L. Huff, Malcolm Munro, Barbara L. Marcolin
1992 conf
ACM Southeast Regional Conference
Robert M. Freeman, Malcolm Munro
1991 J jnl
J. Syst. Softw.
D. J. Robson, Keith H. Bennett, Barry J. Cornelius, Malcolm Munro
1991 J jnl
J. Softw. Maintenance Res. Pract.
Rachel J. Kenning, Simon D. Cooper, Robert M. Freeman, David S. Hinley, Malcolm Munro
1990 conf
ICSM
Rachel J. Kenning, Malcolm Munro
1989 J jnl
Softw. Eng. J.
Barry J. Cornelius, Malcolm Munro, D. J. Robson
1989 conf
CSEE
Barry J. Cornelius, Malcolm Munro, D. J. Robson
1989 J jnl
ACM SIGSOFT Softw. Eng. Notes
Simon D. Cooper, Rachel J. Kenning, Frank W. Calliss, Malcolm Munro
1989 conf
ICSM
Simon D. Cooper, Malcolm Munro
1989 conf
ICSM
Martin Ward, Frank W. Calliss, Malcolm Munro
1988 conf
ICSM
Frank W. Calliss, M. Khalil, Malcolm Munro, Martin Ward
1988 J jnl
J. Manag. Inf. Syst.
Malcolm Munro, Sid L. Huff, Gary Moore
1988 J jnl
Commun. ACM
Sid L. Huff, Malcolm Munro, Barbara H. Martin
1988 conf
ICSM
Nigel T. Fletton, Malcolm Munro
1988 J jnl
ACM SIGSOFT Softw. Eng. Notes
Frank W. Calliss, Malcolm Munro
1985 J jnl
MIS Q.
Sid L. Huff, Malcolm Munro
1985 conf
SIGCPR
Malcolm Munro, Sid L. Huff
1981 J jnl
Inf. Manag.
Niv Ahituv, Malcolm Munro, Yair Wand
1980 J jnl
MIS Q.
Malcolm Munro, Basil R. Wheeler
1977 J jnl
MIS Q.
Malcolm Munro, Gordon B. Davis
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 != ""