Valtteri Lahtinen

12 papers Journal 10Unranked 2
YearRankTypeTitle / Venue / Authors
2025 J jnl
Autom. Softw. Eng.
Arif Ali Khan, Muhammad Azeem Akbar, Valtteri Lahtinen, Marko Paavola, Mahmood Khan Niazi, Mohammed Naif Alatawi, Shoayee Dlaim Alotaibi
2025 J jnl
ACM Trans. Quantum Comput.
Tejas Shinde, Ljubomir Budinski, Ossi Niemimäki, Valtteri Lahtinen, Helena Liebelt, Rui Li
2024 J jnl
CoRR
Arif Ali Khan, Muhammad Azeem Akbar, Valtteri Lahtinen, Marko Paavola
2024 J jnl
Autom. Softw. Eng.
Arif Ali Khan, Muhammad Azeem Akbar, Valtteri Lahtinen, Marko Paavola, Mahmood Khan Niazi, Mohammed Naif Alatawi, Shoayee Dlaim Alotaibi
2024 J jnl
Adv. Comput. Math.
P. Robert Kotiuga, Valtteri Lahtinen
2023 conf
QSW
Arif Ali Khan, Muhammad Azeem Akbar, Aakash Ahmad, Mahdi Fahmideh, Mohammad Shameem, Valtteri Lahtinen, Muhammad Waseem, Tommi Mikkonen
2022 J jnl
CoRR
Arif Ali Khan, Muhammad Azeem Akbar, Aakash Ahmad, Mahdi Fahmideh, Mohammad Shameem, Valtteri Lahtinen, Muhammad Waseem, Tommi Mikkonen
2022 conf
QP4SE@ESEC/SIGSOFT FSE
Arif Ali Khan, Mahdi Fahmideh, Aakash Ahmad, Muhammad Waseem, Mahmood Khan Niazi, Valtteri Lahtinen, Tommi Mikkonen
2021 J jnl
Pattern Anal. Appl.
Matti Pellikka, Valtteri Lahtinen
2020 J jnl
CoRR
Matti Pellikka, Valtteri Lahtinen
2019 J jnl
Comput. Math. Appl.
Alex Stockrahm, Valtteri Lahtinen, Jari J. J. Kangas, P. Robert Kotiuga
2017 J jnl
Synth.
Valtteri Lahtinen, Antti Stenvall
tests/unit/test_decompile_function_type.py
← Index tests/unit/test_decompile_function_type.py python
"""Unit tests for bninja/function_type.py."""
import sys
import pytest
from unittest.mock import MagicMock

# Install binaryninja stubs before importing
from tests.unit.conftest_binja_stubs import install_binja_stubs, SymbolType
install_binja_stubs()

from redb.extractors.decompiler.bninja.function_type import (
    FunctionType,
    FunctionTypeAnalysis,
)


# ============================================================================
# 4a. FunctionType / FunctionTypeAnalysis
# ============================================================================


class TestFunctionTypeEnum:
    def test_function_type_enum_values(self):
        assert FunctionType.USER.value == "USER"
        assert FunctionType.LIBRARY.value == "LIBRARY"
        assert FunctionType.EXTERNAL.value == "EXTERNAL"
        assert FunctionType.THUNK.value == "THUNK"
        assert FunctionType.UNKNOWN.value == "UNKNOWN"


class TestFunctionTypeAnalysis:
    def _make_function(self, symbol_type=None, is_thunk=False, raise_on_symbol=False):
        func = MagicMock()
        func.is_thunk = is_thunk
        if raise_on_symbol:
            type(func).symbol = property(lambda self: (_ for _ in ()).throw(Exception("no symbol")))
        else:
            func.symbol.type = symbol_type if symbol_type is not None else SymbolType.FunctionSymbol
        return func

    def test_user_function_type(self):
        func = self._make_function(symbol_type=SymbolType.FunctionSymbol)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.USER

    def test_external_function_type(self):
        func = self._make_function(symbol_type=SymbolType.ImportedFunctionSymbol)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.EXTERNAL

    def test_library_function_type(self):
        func = self._make_function(symbol_type=SymbolType.LibraryFunctionSymbol)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.LIBRARY

    def test_thunk_function_type(self):
        # Thunk overrides the symbol type
        func = self._make_function(
            symbol_type=SymbolType.FunctionSymbol, is_thunk=True
        )
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.THUNK

    def test_exception_returns_unknown(self):
        func = self._make_function(raise_on_symbol=True)
        analysis = FunctionTypeAnalysis(func)
        assert analysis.get_function_type() == FunctionType.UNKNOWN