From a87bc12f8602686691d340bf6c60413dc9d0ad68 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Fri, 26 Jun 2015 13:06:17 -0700 Subject: [PATCH] Add makefile targets for basic lint and testing Signed-off-by: Alexander Morozov --- Makefile | 23 ++++++++++++++++++++--- libcontainer/Makefile | 33 --------------------------------- test_Dockerfile | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 36 deletions(-) delete mode 100644 libcontainer/Makefile create mode 100644 test_Dockerfile diff --git a/Makefile b/Makefile index 0a8de761..0a2230b3 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,27 @@ +RUNC_TEST_IMAGE=runc_test +PROJECT=github.com/opencontainers/runc +TEST_DOCKERFILE=test_Dockerfile +export GOPATH:=$(GOPATH):$(CURDIR)/Godeps/_workspace + all: - go get github.com/tools/godep - godep go build -o runc . + go build -o runc . + +lint: + go get golang.org/x/tools/cmd/vet + go vet ./... + go fmt ./... + +runctestimage: + docker build -t $(RUNC_TEST_IMAGE) -f $(TEST_DOCKERFILE) . + +test: runctestimage + docker run --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localtest + +localtest: + go test -v ./... install: cp runc /usr/local/bin/runc - rm runc clean: rm runc diff --git a/libcontainer/Makefile b/libcontainer/Makefile deleted file mode 100644 index 1a2e23e0..00000000 --- a/libcontainer/Makefile +++ /dev/null @@ -1,33 +0,0 @@ - -all: - docker build -t dockercore/libcontainer . - -test: - # we need NET_ADMIN for the netlink tests and SYS_ADMIN for mounting - docker run --rm -it --privileged dockercore/libcontainer - -sh: - docker run --rm -it --privileged -w /busybox dockercore/libcontainer nsinit exec sh - -GO_PACKAGES = $(shell find . -not \( -wholename ./vendor -prune -o -wholename ./.git -prune \) -name '*.go' -print0 | xargs -0n1 dirname | sort -u) - -direct-test: - go test $(TEST_TAGS) -cover -v $(GO_PACKAGES) - -direct-test-short: - go test $(TEST_TAGS) -cover -test.short -v $(GO_PACKAGES) - -direct-build: - go build -v $(GO_PACKAGES) - -direct-install: - go install -v $(GO_PACKAGES) - -local: - go test -v - -validate: - hack/validate.sh - -binary: all - docker run --rm --privileged -v $(CURDIR)/bundles:/go/bin dockercore/libcontainer make direct-install diff --git a/test_Dockerfile b/test_Dockerfile new file mode 100644 index 00000000..86a61fb5 --- /dev/null +++ b/test_Dockerfile @@ -0,0 +1,15 @@ +FROM golang:1.4 + +RUN echo "deb http://ftp.us.debian.org/debian testing main contrib" >> /etc/apt/sources.list +RUN apt-get update && apt-get install -y iptables criu=1.5.2-1 && rm -rf /var/lib/apt/lists/* + +# setup a playground for us to spawn containers in +RUN mkdir /busybox && \ + curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -xC /busybox + +RUN curl -sSL https://raw.githubusercontent.com/docker/docker/master/hack/dind -o /dind && \ + chmod +x /dind + +WORKDIR /go/src/github.com/opencontainers/runc +COPY libcontainer/sample_configs/minimal.json /busybox/container.json +ENTRYPOINT ["/dind"]