Skip to content

Commit

Permalink
Check if the VLE toolchain is available before installing and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Noalhyt committed Jun 27, 2023
1 parent b3c1af4 commit 538d5e2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
16 changes: 10 additions & 6 deletions ofrak_patch_maker/Dockerstub
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ fi;
#PPCVLE 4 NXP GCC Fork
# Download the toolchain into your OFRAK directory from here (requires sign up):
# https://www.nxp.com/design/software/development-software/s32-design-studio-ide/s32-design-studio-for-power-architecture:S32DS-PA
# if the file `gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zip` doesn't exist, the toolchain won't be installed, and corresponding tests will be skipped.
ARG OFRAK_DIR=.
COPY $OFRAK_DIR/gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zip /tmp
RUN cd /tmp && \
unzip gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zip && \
cd powerpc-eabivle-4_9 && \
for f in *; do test -d "${f}" && cp -r "${f}" /usr/; done && \
COPY $OFRAK_DIR/gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zi[p] /tmp
RUN test -f /tmp/gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zip && \
cd /tmp && \
unzip -q gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zip && \
cp -r powerpc-eabivle-4_9 /opt/rbs/toolchain/ && \
rm -rf powerpc-eabivle-4_9 && \
rm gcc-4.9.4-Ee200-eabivle-x86_64-linux-g2724867.zip && \
dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1
apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 \
|| true
10 changes: 5 additions & 5 deletions ofrak_patch_maker/ofrak_patch_maker/toolchain.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ LINKER = /usr/bin/powerpc-linux-gnu-ld
BIN_PARSER = /usr/bin/powerpc-linux-gnu-objdump

[GNU_PPCVLE_4]
PREPROCESSOR = /usr/bin/powerpc-eabivle-gcc
COMPILER = /usr/bin/powerpc-eabivle-gccbloop
LINKER = /usr/bin/powerpc-eabivle-ld
BIN_PARSER = /usr/bin/powerpc-eabivle-objdump
PREPROCESSOR = /opt/rbs/toolchain/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc
COMPILER = /opt/rbs/toolchain/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc
LINKER = /opt/rbs/toolchain/powerpc-eabivle-4_9/bin/powerpc-eabivle-ld
BIN_PARSER = /opt/rbs/toolchain/powerpc-eabivle-4_9/bin/powerpc-eabivle-objdump

[ASM]
ARM_ASM_PATH = /opt/rbs/toolchain/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-as
Expand All @@ -63,4 +63,4 @@ M68K_ASM_PATH = /usr/bin/m68k-linux-gnu-as
AARCH64_ASM_PATH = /usr/bin/aarch64-linux-gnu-as
AVR_ASM_PATH = /usr/bin/avr-as
PPC_ASM_PATH = /usr/bin/powerpc-linux-gnu-as
PPCVLE_ASM_PATH = /usr/bin/powerpc-eabivle-as
PPCVLE_ASM_PATH = /opt/rbs/toolchain/powerpc-eabivle-4_9/bin/powerpc-eabivle-as
35 changes: 35 additions & 0 deletions ofrak_patch_maker/ofrak_patch_maker_test/test_ppc_vle_toolchain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import tempfile
from warnings import warn

import pytest

Expand Down Expand Up @@ -36,6 +37,32 @@
PPC_EXTENSION = ".vle"


INSTALL_TOOLCHAIN_MESSAGE = f"""
The NXP PPC VLE toolchain was not installed as part af the container build, because it requires signing-up and manually downloading the toolchain.
Download the toolchain into your OFRAK directory from here:
https://www.nxp.com/design/software/development-software/s32-design-studio-ide/s32-design-studio-for-power-architecture:S32DS-PA
Then rebuild the docker container, or refer to the Dockerfile for installation instructions.
"""


def check_toolchain_installed(toolchain_under_test: ToolchainUnderTest) -> bool:
tc_config = ToolchainConfig(
file_format=BinFileType.ELF,
force_inlines=True,
relocatable=False,
no_std_lib=True,
no_jump_tables=True,
no_bss_section=True,
compiler_optimization_level=CompilerOptimizationLevel.FULL,
)
compiler_path_exist = os.path.exists(
toolchain_under_test.toolchain(toolchain_under_test.proc, tc_config)._compiler_path
)
if not compiler_path_exist:
warn(INSTALL_TOOLCHAIN_MESSAGE)
return compiler_path_exist


@pytest.fixture(
params=[
ToolchainUnderTest(
Expand All @@ -62,19 +89,27 @@ def toolchain_under_test(request) -> ToolchainUnderTest:


def test_monkey_patch(toolchain_under_test: ToolchainUnderTest):
if not check_toolchain_installed(toolchain_under_test):
pytest.skip(INSTALL_TOOLCHAIN_MESSAGE)
run_monkey_patch_test(toolchain_under_test)


# C Tests
def test_bounds_check(toolchain_under_test: ToolchainUnderTest):
if not check_toolchain_installed(toolchain_under_test):
pytest.skip(INSTALL_TOOLCHAIN_MESSAGE)
run_bounds_check_test(toolchain_under_test)


def test_hello_world(toolchain_under_test: ToolchainUnderTest):
if not check_toolchain_installed(toolchain_under_test):
pytest.skip(INSTALL_TOOLCHAIN_MESSAGE)
run_hello_world_test(toolchain_under_test)


def test_vle_alignment(toolchain_under_test: ToolchainUnderTest):
if not check_toolchain_installed(toolchain_under_test):
pytest.skip(INSTALL_TOOLCHAIN_MESSAGE)
tc_config = ToolchainConfig(
file_format=BinFileType.ELF,
force_inlines=True,
Expand Down

0 comments on commit 538d5e2

Please sign in to comment.