H. Anthony Chan

116 papers B 18C 6Journal 45Unranked 46
YearRankTypeTitle / Venue / Authors
2025 J jnl
IEEE Trans. Consumer Electron.
Cheuk-Yiu Chan, Wan-Chi Siu, Yuk-Hee Chan, H. Anthony Chan
2025 conf
DSP
Hon-Man Hammond Lee, Wan-Chi Siu, Felix Ming-Fei Duan, Yi-Hao Cheng, H. Anthony Chan
2025 J jnl
IEEE Trans. Consumer Electron.
Ridwan Salahudeen, Wan-Chi Siu, H. Anthony Chan
2024 J jnl
IEEE Trans. Image Process.
Cheuk-Yiu Chan, Wan-Chi Siu, Yuk-Hee Chan, H. Anthony Chan
2024 conf
BigComp
C. Alisdair Lee, C. Francis Lau, H. Anthony Chan
2024 C conf
ICCE
Cheuk-Yiu Chan, Wan-Chi Siu, Yuk-Hee Chan, H. Anthony Chan
2024 conf
APSIPA
Wing-Ho Cheng, Wan-Chi Siu, H. Anthony Chan
2024 C conf
ISCAS
Li-Wen Wang, Wan-Chi Siu, Yi-Hao Cheng, H. Anthony Chan
2023 conf
TALE
H. Anthony Chan, LapLi Chan, Paul Hodgson, Hilman Tam, William Cheung, Keith Tsang
2023 conf
ICCE-Taiwan
Ridwan Salahudeen, Wan-Chi Siu, H. Anthony Chan
2023 J jnl
Frontiers Res. Metrics Anal.
C. Alisdair Lee, K. M. Chow, H. Anthony Chan, Daniel Pak-Kong Lun
2023 conf
DSP
Chun Chuen Hui, Wan-Chi Siu, Ngai-Fong Law, H. Anthony Chan
2023 B conf
ICIP
Wing-Fung Ku, Wan-Chi Siu, Xi Cheng, H. Anthony Chan
2022 J jnl
CoRR
Wing-Fung Ku, Wan-Chi Siu, Xi Cheng, H. Anthony Chan
2022 conf
MMSports@MM
Silvio Giancola, Anthony Cioppa, Adrien Deliège, Floriane Magera, Vladimir Somers, Le Kang, Xin Zhou, Olivier Barnich, Christophe De Vleeschouwer, Alexandre Alahi, Bernard Ghanem, Marc Van Droogenbroeck, Abdulrahman Darwish, Adrien Maglo, Albert Clapés, Andreas Luyts, Andrei Boiarov, Artur Xarles, Astrid Orcesi, Avijit Shah, Baoyu Fan, Bharath Comandur, Chen Chen, Chen Zhang, Chen Zhao, Chengzhi Lin, Cheuk-Yiu Chan, Chun Chuen Hui, Dengjie Li, Fan Yang, Fan Liang, Fang Da, Feng Yan, Fufu Yu, Guanshuo Wang, H. Anthony Chan, He Zhu, Hongwei Kan, Jiaming Chu, Jianming Hu, Jianyang Gu, Jin Chen, João V. B. Soares, Jonas Theiner, Jorge De Corte, José Henrique Brito, Jun Zhang, Junjie Li, Junwei Liang, Leqi Shen, Lin Ma, Lingchi Chen, Miguel Santos Marques, Mike Azatov, Nikita Kasatkin, Ning Wang, Qiong Jia, Quoc-Cuong Pham, Ralph Ewerth, Ran Song, Rengang Li, Rikke Gade, Ruben Debien, Runze Zhang, Sangrok Lee, Sergio Escalera, Shan Jiang, Shigeyuki Odashima, Shimin Chen, Shoichi Masui, Shouhong Ding, Sin-wai Chan, Siyu Chen, Tallal El Shabrawy, Tao He, Thomas B. Moeslund, Wan-Chi Siu, Wei Zhang, Wei Li, Xiangwei Wang, Xiao Tan, Xiaochuan Li, Xiaolin Wei, Xiaoqing Ye, Xing Liu, Xinying Wang, Yandong Guo, Yaqian Zhao, Yi Yu, Yingying Li, Yue He, Yujie Zhong, Zhenhua Guo, Zhiheng Li
2022 J jnl
CoRR
Silvio Giancola, Anthony Cioppa, Adrien Deliège, Floriane Magera, Vladimir Somers, Le Kang, Xin Zhou, Olivier Barnich, Christophe De Vleeschouwer, Alexandre Alahi, Bernard Ghanem, Marc Van Droogenbroeck, Abdulrahman Darwish, Adrien Maglo, Albert Clapés, Andreas Luyts, Andrei Boiarov, Artur Xarles, Astrid Orcesi, Avijit Shah, Baoyu Fan, Bharath Comandur, Chen Chen, Chen Zhang, Chen Zhao, Chengzhi Lin, Cheuk-Yiu Chan, Chun Chuen Hui, Dengjie Li, Fan Yang, Fan Liang, Fang Da, Feng Yan, Fufu Yu, Guanshuo Wang, H. Anthony Chan, He Zhu, Hongwei Kan, Jiaming Chu, Jianming Hu, Jianyang Gu, Jin Chen, João V. B. Soares, Jonas Theiner, Jorge De Corte, José Henrique Brito, Jun Zhang, Junjie Li, Junwei Liang, Leqi Shen, Lin Ma, Lingchi Chen, Miguel Santos Marques, Mike Azatov, Nikita Kasatkin, Ning Wang, Qiong Jia, Quoc-Cuong Pham, Ralph Ewerth, Ran Song, Rengang Li, Rikke Gade, Ruben Debien, Runze Zhang, Sangrok Lee, Sergio Escalera, Shan Jiang, Shigeyuki Odashima, Shimin Chen, Shoichi Masui, Shouhong Ding, Sin-wai Chan, Siyu Chen, Tallal El Shabrawy, Tao He, Thomas B. Moeslund, Wan-Chi Siu, Wei Zhang, Wei Li, Xiangwei Wang, Xiao Tan, Xiaochuan Li, Xiaolin Wei, Xiaoqing Ye, Xing Liu, Xinying Wang, Yandong Guo, Yaqian Zhao, Yi Yu, Yingying Li, Yue He, Yujie Zhong, Zhenhua Guo, Zhiheng Li
2021 conf
CSCI
C. Alisdair Lee, Shum Paul Kwok-ching, H. Anthony Chan
2021 conf
APSIPA ASC
Zhi-Song Liu, Wan-Chi Siu, H. Anthony Chan
2020 J jnl
RFC
H. Anthony Chan, Xinpeng Wei, Jong-Hyouk Lee, Seil Jeon, Carlos J. Bernardos
2019 J jnl
IEEE Wirel. Commun. Lett.
Wei Quan, Nan Cheng, Meng Qin, Hongke Zhang, H. Anthony Chan, Xuemin Shen
2019 J jnl
ACM Trans. Internet Techn.
Kai Wang, Wei Quan, Nan Cheng, Mingyuan Liu, Yu Liu, H. Anthony Chan
2019 J jnl
CoRR
Lav Gupta, Mohammed Samaka, Raj Jain, Aiman Erbad, Deval Bhamare, H. Anthony Chan
2019 J jnl
CoRR
Deval Bhamare, Mohammed Samaka, Aiman Erbad, Raj Jain, Lav Gupta, H. Anthony Chan
2017 J jnl
EURASIP J. Wirel. Commun. Netw.
Muhana Muslam, H. Anthony Chan, Neco Ventura
2017 B conf
ICCCN
Lav Gupta, Mohammed Samaka, Raj Jain, Aiman Erbad, Deval Bhamare, H. Anthony Chan
2017 J jnl
J. Reliab. Intell. Environ.
Lav Gupta, Mohammed Samaka, Raj Jain, Aiman Erbad, Deval Bhamare, H. Anthony Chan
2017 conf
ICC
Deval Bhamare, Mohammed Samaka, Aiman Erbad, Raj Jain, Lav Gupta, H. Anthony Chan
2017 J jnl
IEEE Internet Comput.
Xin Li, Mohammed Samaka, H. Anthony Chan, Deval Bhamare, Lav Gupta, Chengcheng Guo, Raj Jain
2017 J jnl
Comput. Commun.
Deval Bhamare, Mohammed Samaka, Aiman Erbad, Raj Jain, Lav Gupta, H. Anthony Chan
2016 conf
INFOCOM Workshops
H. Anthony Chan, Xinpeng Wei, Jong-Hyouk Lee, Fred L. Templin, Seil Jeon
2016 J jnl
J. Netw. Comput. Appl.
Petro P. Ernest, Olabisi E. Falowo, H. Anthony Chan
2015 J jnl
Wirel. Pers. Commun.
Petro Pesha Ernest, H. Anthony Chan, Olabisi Emmanuel Falowo, Linoh A. Magagula
2015 J jnl
RFC
Dapeng Liu, Juan Carlos Zúñiga, Pierrick Seite, H. Anthony Chan, Carlos Jesus Bernardos
2015 J jnl
Telecommun. Syst.
Petro Pesha Ernest, H. Anthony Chan, Jiang Xie, Olabisi Emmanuel Falowo
2014 conf
ICC Workshops
H. Anthony Chan, Hyunho Park, Hyeong Ho Lee, Charles Perkins, Dapeng Liu
2014 B conf
GLOBECOM
John Kaippallimalil, H. Anthony Chan
2014 conf
CCNC
Petro Pesha Ernest, H. Anthony Chan, Olabisi Emmanuel Falowo, Linoh A. Magagula, Sandra Céspedes Umaña
2014 J jnl
RFC
H. Anthony Chan, Dapeng Liu, Pierrick Seite, Hidetoshi Yokota, Jouni Korhonen
2013 J jnl
Secur. Commun. Networks
Bazara I. A. Barry, H. Anthony Chan
2013 conf
CCNC
Adeyemi Abel Ajibesin, Neco Ventura, Alexandru Murgu, H. Anthony Chan
2013 J jnl
IEEE Wirel. Commun.
Jong-Hyouk Lee, Jean-Marie Bonnin, Pierrick Seite, H. Anthony Chan
2013 conf
MILCOM
Allen L. Ramaboli, Olabisi E. Falowo, H. Anthony Chan
2013 conf
CCNC
Allen Lehopotseng Ramaboli, Olabisi Emmanuel Falowo, H. Anthony Chan
2013 B conf
WiMob
Petro P. Ernest, Olabisi Emmanuel Falowo, H. Anthony Chan
2013 B conf
AINA
Allen L. Ramaboli, Olabisi Emmanuel Falowo, H. Anthony Chan
2012 J jnl
J. Netw. Comput. Appl.
Allen L. Ramaboli, Olabisi Emmanuel Falowo, H. Anthony Chan
2012 B conf
GLOBECOM
Petro P. Ernest, H. Anthony Chan, Olabisi Emmanuel Falowo
2012 conf
ICC
H. Anthony Chan
2012 J jnl
Comput. Networks
Olabisi Emmanuel Falowo, H. Anthony Chan
2012 B conf
GLOBECOM
Olabisi Emmanuel Falowo, H. Anthony Chan
2012 J jnl
Wirel. Commun. Mob. Comput.
Linoh A. Magagula, H. Anthony Chan, Olabisi Emmanuel Falowo
2012 J jnl
Netw. Protoc. Algorithms
Oladayo Bello, Antoine B. Bagula, H. Anthony Chan
2012 J jnl
EURASIP J. Wirel. Commun. Netw.
Olabisi Emmanuel Falowo, H. Anthony Chan
2012 B conf
WCNC
Muhana Muslam, H. Anthony Chan, Linoh A. Magagula, Neco Ventura
2012 conf
UKSim
Adeyemi Abel Ajibesin, Neco Ventura, H. Anthony Chan, Alexandru Murgu, Olubola K. Egunsola
2011 J jnl
J. Commun.
H. Anthony Chan, Hidetoshi Yokota, Jiang Xie, Pierrick Seite, Dapeng Liu
2011 J jnl
Telecommun. Syst.
Olabisi Emmanuel Falowo, H. Anthony Chan
2011 conf
WPMC
Petro P. Ernest, H. Anthony Chan
2011 J jnl
Math. Comput. Model.
Oladayo Salami, Antoine B. Bagula, H. Anthony Chan
2011 conf
CCNC
Muhana Muslam, H. Anthony Chan, Neco Ventura
2011 J jnl
EURASIP J. Wirel. Commun. Netw.
Muhana Muslam, H. Anthony Chan, Neco Ventura
2011 conf
MILCOM
Olabisi E. Falowo, H. Anthony Chan
2011 B conf
PIMRC
Olabisi Emmanuel Falowo, H. Anthony Chan
2011 conf
GLOBECOM Workshops
Oladayo Salami, Antoine B. Bagula, H. Anthony Chan
2010 conf
NEW2AN
Oladayo Salami, Antoine B. Bagula, H. Anthony Chan
2010 conf
AST/UCMA/ISA/ACN
Oladayo Salami, Antoine B. Bagula, H. Anthony Chan
2010 B conf
PIMRC
Linoh A. Magagula, H. Anthony Chan, Olabisi Emmanuel Falowo
2010 J jnl
Int. J. Commun. Syst.
Olabisi Emmanuel Falowo, Sherali Zeadally, H. Anthony Chan
2010 J jnl
EURASIP J. Wirel. Commun. Netw.
Linoh A. Magagula, Olabisi Emmanuel Falowo, H. Anthony Chan
2010 conf
ICITST
Mohssen M. Z. E. Mohammed, H. Anthony Chan, Neco Ventura, Mohsin Hashim, Eihab Bashier
2010 B conf
WCNC
Linoh A. Magagula, H. Anthony Chan, Olabisi Emmanuel Falowo
2010 B conf
LCN
Linoh A. Magagula, H. Anthony Chan, Olabisi Emmanuel Falowo
2010 J jnl
Wirel. Commun. Mob. Comput.
Olabisi Emmanuel Falowo, H. Anthony Chan
2010 ch.
Handbook of Information and Communication Security
Bazara I. A. Barry, H. Anthony Chan
2010 conf
CCNC
Olabisi E. Falowo, H. Anthony Chan
2010 B conf
GLOBECOM
Linoh A. Magagula, H. Anthony Chan, Olabisi Emmanuel Falowo
2010 conf
Security and Management
Mohssen M. Z. E. Mohammed, H. Anthony Chan, Neco Ventura, Mohsin Hashim, Izzeldin Amin
2009 conf
Security and Management
Mohssen M. Z. E. Mohammed, H. Anthony Chan, Neco Ventura, Mohsin Hashim, Izzeldin Amin
2009 conf
CCECE
Olabisi Emmanuel Falowo, Neco Ventura, H. Anthony Chan
2009 conf
ICPP Workshops
Oladayo Salami, Antoine B. Bagula, H. Anthony Chan
2009 C conf
ICSEA
Mohssen M. Z. E. Mohammed, H. Anthony Chan, Neco Ventura, Mohsin Hashim, Izzeldin Amin
2009 conf
BroadBandCom
Mohssen Mohammed Zian Elaabdeen Mohammed, H. Anthony Chan, Neco Ventura, Mohsin Hashim, Ezzeldien Amin
2009 J jnl
Secur. Commun. Networks
Bazara I. A. Barry, H. Anthony Chan
2008 J jnl
EURASIP J. Wirel. Commun. Netw.
Deeya Shakti Nursimloo, George Kalaba Kalebaila, H. Anthony Chan
2008 conf
ADHOC-NOW
Tope R. Kareem, Karel Matthee, H. Anthony Chan, Ntsibane Ntlatlapa
2008 conf
CCNC
Indika W. G. Piyasena, H. Anthony Chan
2008 conf
BroadCom
Tope R. Kareem, H. Anthony Chan, Ntsibane Ntlatlapa
2008 conf
BroadCom
Linoh A. Magagula, H. Anthony Chan
2008 conf
CCNC
Dali Wei, H. Anthony Chan
2008 conf
BroadCom
Mohssen M. Z. E. Mohammed, H. Anthony Chan
2008 B conf
WiMob
Linoh A. Magagula, H. Anthony Chan
2008 J jnl
Comput. Commun.
Olabisi Emmanuel Falowo, H. Anthony Chan
2008 conf
BroadCom
Oladayo Salami, H. Anthony Chan, Antoine B. Bagula
2008 C conf
SecureComm
Bazara I. A. Barry, H. Anthony Chan
2008 conf
BroadCom
Adeyemi Abel Ajibesin, H. Anthony Chan, Mqhele E. Dlodlo
2008 C conf
BROADNETS
Olabisi E. Falowo, H. Anthony Chan
2007 B conf
PIMRC
Mohamed A. Abdelatif, George Kalaba Kalebaila, H. Anthony Chan
2007 conf
OTM Conferences (2)
Bazara I. A. Barry, H. Anthony Chan
2007 J jnl
EURASIP J. Wirel. Commun. Netw.
Olabisi Emmanuel Falowo, H. Anthony Chan
2007 C conf
ISCC
Olabisi Emmanuel Falowo, H. Anthony Chan
2006 B conf
IWCMC
Robert Achieng, H. Anthony Chan
2006 conf
Wireless and Optical Communications
Oladayo Salami, H. Anthony Chan, Mqhele E. Dlodlo
2006 B conf
PIMRC
George Kalaba Kalebaila, H. Anthony Chan
2006 J jnl
Afr. J. Inf. Commun. Technol.
Yang Li, Johnson I. Agbinya, H. Anthony Chan
2006 conf
ISWCS
Olabisi E. Falowo, H. Anthony Chan
2006 conf
CCNC
Oladayo Salami, H. Anthony Chan
2006 conf
CCECE
Olabisi Emmanuel Falowo, H. Anthony Chan
2006 B conf
IWCMC
Kamil H. Suleiman, H. Anthony Chan, Mqhele E. Dlodlo
2006 conf
ICON
S. M. Akramus Salehin, H. Anthony Chan, Neco Ventura
2006 J jnl
J. Adv. Comput. Intell. Intell. Informatics
Sandisiwe N. Ncemane, H. Anthony Chan, Tope R. Kareem
2006 J jnl
Afr. J. Inf. Commun. Technol.
Yang Li, H. Anthony Chan, Johnson I. Agbinya
2006 J jnl
Afr. J. Inf. Commun. Technol.
Johnson I. Agbinya, H. Anthony Chan, Donald A. Adjeroh
2006 J jnl
Afr. J. Inf. Commun. Technol.
Johnson I. Agbinya, Donald A. Adjeroh, H. Anthony Chan
2006 conf
ICN/ICONS/MCL
Oladayo Salami, H. Anthony Chan
2005 J jnl
Afr. J. Inf. Commun. Technol.
Deeya Shakti Nursimloo, H. Anthony Chan
2005 J jnl
Afr. J. Inf. Commun. Technol.
Johnson I. Agbinya, H. Anthony Chan, Donald A. Adjeroh
tests/conftest.py
← Index tests/conftest.py python
"""
Pytest configuration and shared fixtures for REDB unit tests.
"""
import os
import sys
import pytest
import logging
import tempfile
import hashlib
from unittest.mock import Mock, MagicMock, patch
from pathlib import Path

# Add the project root to the path
sys.path.insert(0, str(Path(__file__).parent.parent))

# Test files directory
TEST_FILES_DIR = Path(__file__).parent.parent / "test_files"


# ============================================================================
# Logger Fixtures
# ============================================================================

@pytest.fixture
def mock_logger():
    """Create a mock logger for testing."""
    logger = Mock()
    logger.debug = Mock()
    logger.info = Mock()
    logger.warning = Mock()
    logger.error = Mock()
    return logger


@pytest.fixture
def real_logger():
    """Create a real logger for testing with debug output."""
    logger = logging.getLogger("test_logger")
    logger.setLevel(logging.DEBUG)
    if not logger.handlers:
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        formatter = logging.Formatter('%(levelname)s - %(message)s')
        handler.setFormatter(formatter)
        logger.addHandler(handler)
    return logger


# ============================================================================
# Test Binary Files Fixtures
# ============================================================================

@pytest.fixture
def elf_binary_path():
    """Path to the ELF test binary."""
    path = TEST_FILES_DIR / "hello"
    if not path.exists():
        pytest.skip(f"Test file not found: {path}")
    return str(path)


@pytest.fixture
def elf_advanced_binary_path():
    """Path to the advanced ELF test binary."""
    path = TEST_FILES_DIR / "hello_advanced"
    if not path.exists():
        pytest.skip(f"Test file not found: {path}")
    return str(path)


@pytest.fixture
def pe_binary_path():
    """Path to the PE test binary (.NET PE)."""
    path = TEST_FILES_DIR / "d8637bdbcfc9112fcb1f0167b398e771"
    if not path.exists():
        pytest.skip(f"Test file not found: {path}")
    return str(path)


@pytest.fixture
def elf_binary_content(elf_binary_path):
    """Read the ELF test binary content."""
    with open(elf_binary_path, "rb") as f:
        return f.read()


@pytest.fixture
def pe_binary_content(pe_binary_path):
    """Read the PE test binary content."""
    with open(pe_binary_path, "rb") as f:
        return f.read()


# ============================================================================
# Temporary Files Fixtures
# ============================================================================

@pytest.fixture
def temp_binary_file():
    """Create a temporary binary file for testing."""
    with tempfile.NamedTemporaryFile(delete=False, suffix=".bin") as f:
        # Write some test data
        f.write(b"\x7fELF" + b"\x00" * 100 + b"test data")
        temp_path = f.name

    yield temp_path

    # Cleanup
    if os.path.exists(temp_path):
        os.unlink(temp_path)


@pytest.fixture
def temp_text_file():
    """Create a temporary text file for testing."""
    with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode="w") as f:
        f.write("This is a test file with some text content.")
        temp_path = f.name

    yield temp_path

    # Cleanup
    if os.path.exists(temp_path):
        os.unlink(temp_path)


@pytest.fixture
def temp_pe_like_file():
    """Create a temporary file with PE-like header for testing."""
    with tempfile.NamedTemporaryFile(delete=False, suffix=".exe") as f:
        # MZ header
        f.write(b"MZ" + b"\x00" * 58)
        # e_lfanew pointing to PE header at offset 64
        f.write(b"\x40\x00\x00\x00")
        # PE signature at offset 64
        f.write(b"PE\x00\x00")
        # Minimal COFF header (20 bytes)
        f.write(b"\x4c\x01")  # Machine (i386)
        f.write(b"\x01\x00")  # NumberOfSections
        f.write(b"\x00" * 16)  # Rest of COFF header
        temp_path = f.name

    yield temp_path

    # Cleanup
    if os.path.exists(temp_path):
        os.unlink(temp_path)


# ============================================================================
# Mock Exporter Fixtures
# ============================================================================

@pytest.fixture
def mock_print_exporter(mock_logger):
    """Create a mock PrintExporter."""
    from redb.extractors.database_exporters import PrintExporter
    exporter = PrintExporter(mock_logger, "test_index")
    return exporter


@pytest.fixture
def mock_elasticsearch_exporter(mock_logger):
    """Create a mock ElasticsearchExporter with mocked client."""
    with patch('redb.settings.get_elasticsearch_client') as mock_client:
        mock_client.return_value = Mock()
        from redb.extractors.database_exporters import ElasticsearchExporter
        exporter = ElasticsearchExporter(mock_logger, "test_index")
        return exporter


@pytest.fixture
def mock_clickhouse_exporter(mock_logger):
    """Create a mock ClickHouseExporter with mocked client."""
    with patch('redb.settings.create_clickhouse_client') as mock_client:
        mock_client.return_value = Mock()
        from redb.extractors.database_exporters import ClickHouseExporter
        exporter = ClickHouseExporter(mock_logger, "test_index", client=Mock())
        return exporter


# ============================================================================
# Mock Settings Fixtures
# ============================================================================

@pytest.fixture
def mock_settings():
    """Mock the redb.settings module."""
    with patch.multiple(
        'redb.settings',
        ELASTIC_BINARIES_COLLECTION="test_collection",
        get_elasticsearch_client=Mock(return_value=Mock()),
        create_clickhouse_client=Mock(return_value=Mock()),
    ):
        yield


# ============================================================================
# Hash Fixtures
# ============================================================================

@pytest.fixture
def known_hashes(elf_binary_content):
    """Compute known hashes for the ELF test binary."""
    return {
        'md5': hashlib.md5(elf_binary_content).hexdigest(),
        'sha1': hashlib.sha1(elf_binary_content).hexdigest(),
        'sha256': hashlib.sha256(elf_binary_content).hexdigest(),
    }


@pytest.fixture
def pe_known_hashes(pe_binary_content):
    """Compute known hashes for the PE test binary."""
    return {
        'md5': hashlib.md5(pe_binary_content).hexdigest(),
        'sha1': hashlib.sha1(pe_binary_content).hexdigest(),
        'sha256': hashlib.sha256(pe_binary_content).hexdigest(),
    }


# ============================================================================
# Sample Data Fixtures
# ============================================================================

@pytest.fixture
def sample_binary_data():
    """Sample binary data for entropy and hash testing."""
    return b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" * 16


@pytest.fixture
def high_entropy_data():
    """High entropy random-like data for testing."""
    import random
    random.seed(42)  # Reproducible
    return bytes(random.randint(0, 255) for _ in range(256))


@pytest.fixture
def low_entropy_data():
    """Low entropy repetitive data for testing."""
    return b"\x00" * 256


# ============================================================================
# PE Object Fixtures
# ============================================================================

@pytest.fixture
def pe_object(pe_binary_path):
    """Create a pefile PE object for testing."""
    import pefile
    try:
        pe = pefile.PE(pe_binary_path)
        yield pe
        pe.close()
    except Exception as e:
        pytest.skip(f"Failed to parse PE file: {e}")


# ============================================================================
# ELF Object Fixtures
# ============================================================================

@pytest.fixture
def elf_object(elf_binary_path):
    """Create an ELFFile object for testing."""
    from elftools.elf.elffile import ELFFile
    try:
        with open(elf_binary_path, 'rb') as f:
            elf = ELFFile(f)
            # We need to keep the file open for ELFFile to work
            yield elf
    except Exception as e:
        pytest.skip(f"Failed to parse ELF file: {e}")


# ============================================================================
# Dataclass Fixtures
# ============================================================================

@pytest.fixture
def sample_hash_dataclass():
    """Create a sample Hash dataclass."""
    from redb.models.dataclasses import Hash
    return Hash(
        md5="d41d8cd98f00b204e9800998ecf8427e",
        sha1="da39a3ee5e6b4b0d3255bfef95601890afd80709",
        sha256="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
    )


@pytest.fixture
def sample_hashes_dataclass():
    """Create a sample Hashes dataclass."""
    from redb.models.dataclasses import Hashes
    return Hashes(
        md5="d41d8cd98f00b204e9800998ecf8427e",
        sha1="da39a3ee5e6b4b0d3255bfef95601890afd80709",
        sha256="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        ssdeep_hash="3::",
        tlsh_hash=""
    )


@pytest.fixture
def sample_basic_properties():
    """Create a sample BasicProperties dataclass."""
    from redb.models.dataclasses import BasicProperties
    return BasicProperties(
        filename="test.exe",
        sample_name="test.exe",
        filesize=1024,
        filetype="PE32 executable",
        filetype_mime="application/x-dosexec",
        filetype_magika="pebin",
        file_entropy=6.5
    )


# ============================================================================
# Utility Functions for Tests
# ============================================================================

def compute_entropy(data):
    """Compute entropy of data for verification in tests."""
    import math
    from collections import Counter

    if not data:
        return 0.0

    if isinstance(data, str):
        counts = Counter(data)
        frequencies = (i / len(data) for i in counts.values())
        return -sum(f * math.log(f, 2) for f in frequencies)
    else:
        occurrences = Counter(bytearray(data))
        entropy = 0
        for x in occurrences.values():
            p_x = float(x) / len(data)
            entropy -= p_x * math.log(p_x, 2)
        return entropy


# Make the function available as a fixture
@pytest.fixture
def entropy_calculator():
    """Return the entropy calculation function."""
    return compute_entropy


# ============================================================================
# Skip Markers
# ============================================================================

# Mark tests that require external tools
requires_die = pytest.mark.skipif(
    not os.path.exists("/usr/bin/diec") and not os.path.exists("/usr/local/bin/diec"),
    reason="Detect It Easy (diec) not installed"
)

requires_capa = pytest.mark.skipif(
    not os.path.exists("/usr/bin/capa") and not os.path.exists("/usr/local/bin/capa"),
    reason="capa not installed"
)

requires_floss = pytest.mark.skipif(
    not os.path.exists("/usr/bin/floss") and not os.path.exists("/usr/local/bin/floss"),
    reason="floss not installed"
)