From 3311145d703424dd346d3defa8ad4f0f892db2be Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Thu, 18 Oct 2018 12:27:37 +0200 Subject: [PATCH] Docker: Allow executing topotests while in subdir of FRR repo Signed-off-by: Christian Franke --- tests/topotests/Dockerfile | 10 ++++++---- tests/topotests/docker/{docker.sh => build.sh} | 10 +--------- tests/topotests/docker/frr-topotests.sh | 7 ++++++- tests/topotests/docker/{ => inner}/compile_frr.sh | 0 tests/topotests/docker/{ => inner}/entrypoint.sh | 0 tests/topotests/docker/{ => inner}/funcs.sh | 0 tests/topotests/docker/{ => inner}/motd.txt | 0 7 files changed, 13 insertions(+), 14 deletions(-) rename tests/topotests/docker/{docker.sh => build.sh} (89%) rename tests/topotests/docker/{ => inner}/compile_frr.sh (100%) rename tests/topotests/docker/{ => inner}/entrypoint.sh (100%) rename tests/topotests/docker/{ => inner}/funcs.sh (100%) rename tests/topotests/docker/{ => inner}/motd.txt (100%) diff --git a/tests/topotests/Dockerfile b/tests/topotests/Dockerfile index d7b2cae354..4f418b3acb 100644 --- a/tests/topotests/Dockerfile +++ b/tests/topotests/Dockerfile @@ -58,11 +58,13 @@ RUN echo "" >> /etc/security/limits.conf; \ echo "root hard core unlimited" >> /etc/security/limits.conf # Copy run scripts to facilitate users wanting to run the tests +COPY docker/inner /opt/topotests COPY . /root/topotests -WORKDIR /root -ENV PATH "$PATH:/root/topotests/docker" -RUN echo "cat /root/topotests/docker/motd.txt" >> /root/.profile && \ +WORKDIR /root/topotests +ENV PATH "$PATH:/opt/topotests" + +RUN echo "cat /opt/topotests/motd.txt" >> /root/.profile && \ echo "export PS1='(topotests) $PS1'" >> /root/.profile -ENTRYPOINT [ "bash", "/root/topotests/docker/entrypoint.sh" ] +ENTRYPOINT [ "bash", "/opt/topotests/entrypoint.sh" ] diff --git a/tests/topotests/docker/docker.sh b/tests/topotests/docker/build.sh similarity index 89% rename from tests/topotests/docker/docker.sh rename to tests/topotests/docker/build.sh index 4dcee218c9..47b14df0b0 100755 --- a/tests/topotests/docker/docker.sh +++ b/tests/topotests/docker/build.sh @@ -22,15 +22,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# Load shared functions -CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -. $CDIR/funcs.sh - -# -# Script begin -# - exec docker build --pull \ --compress \ - -t frrrouting/topotests \ + -t frrouting/topotests \ . diff --git a/tests/topotests/docker/frr-topotests.sh b/tests/topotests/docker/frr-topotests.sh index e5e91156a5..3df31c5d63 100755 --- a/tests/topotests/docker/frr-topotests.sh +++ b/tests/topotests/docker/frr-topotests.sh @@ -105,7 +105,12 @@ if [ -z "$TOPOTEST_LOGS" ]; then fi if [ -z "$TOPOTEST_FRR" ]; then - TOPOTEST_FRR="$(pwd)" + TOPOTEST_FRR="$(git rev-parse --show-toplevel || true)" + if [ -z "$TOPOTEST_FRR" ]; then + echo "Could not determine base of FRR tree." >&2 + echo "frr-topotests only works if you have your tree in git." >&2 + exit 1 + fi fi if [ -z "$TOPOTEST_BUILDCACHE" ]; then diff --git a/tests/topotests/docker/compile_frr.sh b/tests/topotests/docker/inner/compile_frr.sh similarity index 100% rename from tests/topotests/docker/compile_frr.sh rename to tests/topotests/docker/inner/compile_frr.sh diff --git a/tests/topotests/docker/entrypoint.sh b/tests/topotests/docker/inner/entrypoint.sh similarity index 100% rename from tests/topotests/docker/entrypoint.sh rename to tests/topotests/docker/inner/entrypoint.sh diff --git a/tests/topotests/docker/funcs.sh b/tests/topotests/docker/inner/funcs.sh similarity index 100% rename from tests/topotests/docker/funcs.sh rename to tests/topotests/docker/inner/funcs.sh diff --git a/tests/topotests/docker/motd.txt b/tests/topotests/docker/inner/motd.txt similarity index 100% rename from tests/topotests/docker/motd.txt rename to tests/topotests/docker/inner/motd.txt -- 2.39.5