From 5bc822935a451b9c72307d6613ce95046ec7784e Mon Sep 17 00:00:00 2001 From: Nick James Kirkby <20824939+driftregion@users.noreply.github.com> Date: Sun, 19 May 2024 15:49:29 -0700 Subject: [PATCH] try running vcan tests under docker --- .github/workflows/ci.yml | 5 +---- Dockerfile | 12 ++++++++++++ docker-entrypoint.sh | 13 +++++++++++++ src/tp.c | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-entrypoint.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fc72f1..01111ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,8 +20,5 @@ jobs: continue-on-error: true - name: run unit tests - run: ip link help dev && \ - sudo ip link add name vcan0 type vcan && \ - sudo ip link set vcan0 up && \ - bazel test //test:all + run: docker run -it --cap-add NET_ADMIN --rm -v $(pwd):$(pwd) -w $(pwd) iso14229 bazel test //test:all diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..49d2136 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:22.04 + +RUN apt update && apt install apt-transport-https curl gnupg -y && \ + curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg &&\ + mv bazel-archive-keyring.gpg /usr/share/keyrings && \ + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \ + apt update &&\ + apt install net-tools iproute2 can-utils bazel clang-15 -y + +ADD docker-entrypoint.sh . + +ENTRYPOINT ["sh", "docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..aefa2c6 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +# Display configuration +echo Using following configuration +echo VCAN_INTERFACE: "${VCAN_INTERFACE:=vcan0}" + +# Setting up vcan +ip link add "$VCAN_INTERFACE" type vcan +ip link set up "$VCAN_INTERFACE" +echo Created vcan + +$@ \ No newline at end of file diff --git a/src/tp.c b/src/tp.c index 63106d7..0cfc527 100644 --- a/src/tp.c +++ b/src/tp.c @@ -1,4 +1,5 @@ #include "tp.h" +#include /** * @brief