Skip to content

Commit

Permalink
Merge pull request #3 from yomaytk/ci-test
Browse files Browse the repository at this point in the history
Create tests.yml
  • Loading branch information
yomaytk authored Jan 15, 2024
2 parents 05272ae + ccce4de commit 7fde064
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 14 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# ENTRYPOINT: `container-entry-point.sh` build and ctest
jobs:
build-and-test:
runs-on: ubuntu-22.04
name: Build-and-Run
steps:
- name: Checkout
uses: actions/checkout@v4

- name: build container image
run: |
docker build . -t elfconv-image
docker run --name elfconv-container elfconv-image
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
enable_testing()

cmake_minimum_required(VERSION 3.21)
project(elfconv)

Expand Down
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# Choose your LLVM version (16+)
ARG LLVM_VERSION=16
ARG ARCH=aarch64
ARG UBUNTU_VERSION=22.04
ARG DISTRO_NAME=jammy
ARG ROOT_DIR=/root/elfconv

# Run-time dependencies go here
FROM ubuntu:${UBUNTU_VERSION}
ARG LLVM_VERSION
ARG ARCH
ARG UBUNTU_VERSION
ARG DISTRO_NAME
ARG ROOT_DIR

RUN date
RUN dpkg --add-architecture armhf
RUN apt update

RUN apt install -qqy --no-install-recommends apt-transport-https software-properties-common gnupg ca-certificates wget && \
Expand All @@ -31,21 +28,32 @@ echo "deb-src http://apt.llvm.org/${DISTRO_NAME}/ llvm-toolchain-${DISTRO_NAME}-

# several install
RUN apt update
RUN apt install -qqy --no-install-recommends libtinfo-dev libzstd-dev python3-pip python3-setuptools python-setuptools python3 build-essential \
clang-${LLVM_VERSION} lld-${LLVM_VERSION} libstdc++-*-dev-armhf-cross ninja-build pixz xz-utils make rpm curl unzip tar git zip pkg-config vim \
RUN apt install -qqy --no-install-recommends file libtinfo-dev libzstd-dev python3-pip python3-setuptools python-setuptools python3 build-essential \
clang-${LLVM_VERSION} lld-${LLVM_VERSION} ninja-build pixz xz-utils make rpm curl unzip tar git zip pkg-config vim \
libc6-dev liblzma-dev zlib1g-dev libselinux1-dev libbsd-dev ccache binutils-dev libelf-dev && \
apt upgrade --yes && apt clean --yes && \
rm -rf /var/lib/apt/lists/*

# cross compile library
RUN apt update && \
if [ "$( uname -m )" = "x86_64" ]; then \
dpkg --add-architecture i386 && apt update && apt install -qqy zlib1g-dev:i386 gcc-multilib g++-multilib && apt update && apt install -qqy g++-*-aarch64-linux-gnu; \
elif [ "$( uname -m )" = "aarch64" ]; then \
dpkg --add-architecture armhf && apt update && apt install -qqy libstdc++-*-dev-armhf-cross; \
fi

# emscripten install
RUN cd /root && git clone https://github.com/emscripten-core/emsdk.git && cd emsdk && \
git pull && ./emsdk install latest && ./emsdk activate latest && . ./emsdk_env.sh && echo 'source "/root/emsdk/emsdk_env.sh"' >> /root/.bash_profile

# wasmedge install
# WASI Runtimes install
RUN curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash
RUN curl https://wasmtime.dev/install.sh -sSf | bash && echo 'export PATH=$PATH:/root/.wasmtime/bin' >> /root/.bash_profile

# git settings
RUN git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]"

WORKDIR ${ROOT_DIR}
COPY ./ ./
RUN chmod +x scripts/container-entry-point.sh
ENTRYPOINT [ "./scripts/container-entry-point.sh" ]
9 changes: 8 additions & 1 deletion examples/eratosthenes_sieve/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
CC=clang-16

eratosthenes_sieve: start.s cal.c
$(CC) -nostdlib -static start.s cal.c
@ARCH=$$( uname -m ); \
if [ "$$ARCH" = "x86_64" ]; then \
$(CC) -nostdlib -static --target=aarch64-linux-gnu --gcc-toolchain=/usr --sysroot=/usr/aarch64-linux-gnu start.s cal.c -fuse-ld=lld -pthread; \
elif [ "$$ARCH" = "aarch64" ]; then \
$(CC) -nostdlib -static start.s cal.c; \
else \
echo "Unknown architecture"; exit 1; \
fi

clean:
rm a.out
9 changes: 8 additions & 1 deletion examples/hello/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
CC=clang-16

hello: hello.c
$(CC) -static hello.c
@ARCH=$$( uname -m ); \
if [ "$$ARCH" = "x86_64" ]; then \
$(CC) -static --target=aarch64-linux-gnu --gcc-toolchain=/usr --sysroot=/usr/aarch64-linux-gnu hello.c -fuse-ld=lld -pthread; \
elif [ "$$ARCH" = "aarch64" ]; then \
$(CC) -static hello.c; \
else \
echo "Unknown architecture"; exit 1; \
fi

clean:
rm a.out
12 changes: 8 additions & 4 deletions examples/linpack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

CC=clang-16

linpack-soft-float: nostdin_linpack.c
$(CC) -static nostdin_linpack.c -o a.soft-float.out

linpack: nostdin_linpack.c
$(CC) -static nostdin_linpack.c -o a.out
@ARCH=$$(uname -m); \
if [ "$$ARCH" = "x86_64" ]; then \
$(CC) -static --target=aarch64-linux-gnu --gcc-toolchain=/usr --sysroot=/usr/aarch64-linux-gnu nostdin_linpack.c -fuse-ld=lld -pthread; \
elif [ "$$ARCH" = "aarch64" ]; then \
$(CC) -static nostdin_linpack.c; \
else \
echo "Unknown architecture"; exit 1; \
fi

clean:
rm *.out
9 changes: 8 additions & 1 deletion examples/print_hello/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
CC=clang-16

print_hello: print_hello.c start.s
$(CC) -nostdlib -static print_hello.c start.s
@ARCH=$$( uname -m ); \
if [ "$$ARCH" = "x86_64" ]; then \
$(CC) -nostdlib -static --target=aarch64-linux-gnu --gcc-toolchain=/usr --sysroot=/usr/aarch64-linux-gnu start.s print_hello.c -fuse-ld=lld -pthread; \
elif [ "$$ARCH" = "aarch64" ]; then \
$(CC) -nostdlib -static start.s print_hello.c; \
else \
echo "Unknown architecture"; exit 1; \
fi

clean:
rm a.out
2 changes: 1 addition & 1 deletion build.sh → scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# /path/to/home/remill
# /path/to/home/remill-build

ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )
REMILL_DIR=$( cd "$( realpath "${ROOT_DIR}/backend/remill" )" && pwd )
DOWNLOAD_DIR="$( cd "$( dirname "${REMILL_DIR}" )" && pwd )/lifting-bits-downloads"
BUILD_DIR="${ROOT_DIR}/build"
Expand Down
16 changes: 16 additions & 0 deletions scripts/container-entry-point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# entry directory: /root/elfconv

source ~/.bash_profile

# build elfconv
./scripts/build.sh

# elfconv integration test
cd ~/elfconv/examples/print_hello && make
cd ~/elfconv/examples/eratosthenes_sieve && make
cd ~/elfconv/examples/hello && make
cd ~/elfconv/build && ctest

# bash
exec bash && source ~/.bash_profile
File renamed without changes.

0 comments on commit 7fde064

Please sign in to comment.