From 73622024781de8fdbaabd007bf7784e7d678511a Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Fri, 10 Mar 2017 21:11:36 +0000 Subject: [PATCH] tools: Add initial Linux Test Project container LTP is compiled in on debian container and the binaries then copied into another container, which is pushed to hub. LTP does not compile on Alpine as it uses glibc specific pthread extensions. I tried to link LTP statically to not require a glibc based base image but that failed too. Signed-off-by: Rolf Neugebauer --- tools/test-ltp/.gitignore | 2 ++ tools/test-ltp/Dockerfile.build | 19 +++++++++++++++ tools/test-ltp/Dockerfile.pkg | 4 ++++ tools/test-ltp/Makefile | 42 +++++++++++++++++++++++++++++++++ tools/test-ltp/README.md | 1 + 5 files changed, 68 insertions(+) create mode 100644 tools/test-ltp/.gitignore create mode 100644 tools/test-ltp/Dockerfile.build create mode 100644 tools/test-ltp/Dockerfile.pkg create mode 100644 tools/test-ltp/Makefile create mode 100644 tools/test-ltp/README.md diff --git a/tools/test-ltp/.gitignore b/tools/test-ltp/.gitignore new file mode 100644 index 000000000..bb3d04166 --- /dev/null +++ b/tools/test-ltp/.gitignore @@ -0,0 +1,2 @@ +/hash +/opt diff --git a/tools/test-ltp/Dockerfile.build b/tools/test-ltp/Dockerfile.build new file mode 100644 index 000000000..c9dd6b6e8 --- /dev/null +++ b/tools/test-ltp/Dockerfile.build @@ -0,0 +1,19 @@ +FROM debian:jessie + +ARG LTP_VERSION + +ENV LTP_SOURCE=https://github.com/linux-test-project/ltp/releases/download/${LTP_VERSION}/ltp-full-${LTP_VERSION}.tar.xz +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y curl xz-utils make gcc flex bison automake autoconf + +RUN curl -fsSL -o ltp-full-${LTP_VERSION}.tar.xz ${LTP_SOURCE} + +RUN cat ltp-full-${LTP_VERSION}.tar.xz | tar --absolute-names -xJ && mv /ltp-full-${LTP_VERSION} /ltp + +RUN cd /ltp \ + && make autotools \ + && ./configure \ + && make -j "$(getconf _NPROCESSORS_ONLN)" all \ + && make install diff --git a/tools/test-ltp/Dockerfile.pkg b/tools/test-ltp/Dockerfile.pkg new file mode 100644 index 000000000..d2c72b393 --- /dev/null +++ b/tools/test-ltp/Dockerfile.pkg @@ -0,0 +1,4 @@ +FROM debian:jessie-slim@sha256:2a14128195ab26b1c56c5773dda9def9b909c2e01596ef9108e2295d418210a3 +ADD . / +WORKDIR /opt/ltp +ENTRYPOINT ["./runltplite.sh"] diff --git a/tools/test-ltp/Makefile b/tools/test-ltp/Makefile new file mode 100644 index 000000000..df63b2eb8 --- /dev/null +++ b/tools/test-ltp/Makefile @@ -0,0 +1,42 @@ +LTP_VERSION=20170116 + +all: ltp.tar push + +# Build LTP and get the result as a tarball +DEPS=Dockerfile.build Makefile +ltp.tag: $(DEPS) + BUILD=$$(docker build -f $< -q . --build-arg LTP_VERSION=$(LTP_VERSION)) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && echo "$$BUILD" > $@ + +ltp.tar: ltp.tag + docker run --rm --net=none --log-driver=none $(shell cat ltp.tag) tar cf - opt/ltp > $@ + +SHASUM=alpine:3.5 +IMAGE=test-ltp-$(LTP_VERSION) + +# Note: We do not compute the hash from all the dependencies here +# because the ltp binaries will change everytime we build. Ideally, we +# would calculate the hash from the source and the apt-get cache, but +# it's not that critical. +hash: Dockerfile.pkg ltp.tar $(DEPS) + tar xf ltp.tar + tar cf - Dockerfile.pkg opt | docker build --no-cache -t $(IMAGE):build -f Dockerfile.pkg - + cat Dockerfile.pkg $(DEPS) | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@ + +push: hash + docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ + (docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \ + docker push mobylinux/$(IMAGE):$(shell cat hash)) + docker rmi $(IMAGE):build + rm -f hash + +tag: hash + docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ + docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) + docker rmi $(IMAGE):build + rm -f hash + +.PHONY: clean +clean: + rm -rf opt ltp.tar ltp.tag hash + +.DELETE_ON_ERROR: diff --git a/tools/test-ltp/README.md b/tools/test-ltp/README.md new file mode 100644 index 000000000..6889cd72e --- /dev/null +++ b/tools/test-ltp/README.md @@ -0,0 +1 @@ +This directory creates a container which runs the Linux Test Project test code