diff --git a/.gitignore b/.gitignore index 39408dd17..bda2340b8 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,10 @@ tests/.pytest_cache/ tests/binaries/*.o tests/binaries/*.out tests/binaries/gosample.x* +/tests/binaries/div_zero_binary/core +/tests/binaries/div_zero_binary/binary # VS Code files .vscode/ + +.zig/ diff --git a/setup-test-tools.sh b/setup-test-tools.sh index c02bdb0f4..ea7a829f5 100755 --- a/setup-test-tools.sh +++ b/setup-test-tools.sh @@ -23,10 +23,33 @@ install_apt() { sudo apt-get install -y \ nasm \ gcc \ - libc6-dev - test -f /usr/bin/go || sudo apt-get install -y golang + libc6-dev \ + curl \ + build-essential \ + gdb + test -f /usr/bin/go || sudo apt-ge\t install -y golang + + # Install zig to current directory # We use zig to compile some test binaries as it is much easier than with gcc - sudo snap install zig --classic --edge + if ! command -v zig &> /dev/null + then + ZIG_TAR_URL="https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3685+dae7aeb33.tar.xz" + ZIG_TAR_SHA256="dfc8f5ecb651342f1fc2b2828362b62f74fadac9931bda785b80bf7ecfcfabb2" + curl --output /tmp/zig.tar.xz "${ZIG_TAR_URL}" + ACTUAL_SHA256=$(sha256sum /tmp/zig.tar.xz | cut -d' ' -f1) + if [ "${ACTUAL_SHA256}" != "${ZIG_TAR_SHA256}" ]; then + echo "Zig binary checksum mismatch" + echo "Expected: ${ZIG_TAR_SHA256}" + echo "Actual: ${ACTUAL_SHA256}" + exit 1 + fi + + tar -C /tmp -xJf /tmp/zig.tar.xz + + mv /tmp/zig-linux-x86_64-* "$(pwd)/.zig" 2>/dev/null >/dev/null || true + echo "Zig installed to $(pwd)/.zig" + fi + } if linux; then diff --git a/tests/binaries/makefile b/tests/binaries/makefile index 9df0733f3..5ed330669 100644 --- a/tests/binaries/makefile +++ b/tests/binaries/makefile @@ -1,4 +1,4 @@ -ZIGCC = zig cc +ZIGCC = $(shell pwd)/../../.zig/zig cc CC = gcc DEBUG = 1