diff --git a/Makefile b/Makefile index a237f255..f51abfd6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: dbuild man +.PHONY: dbuild man \ + localtest localunittest localintegration \ + test unittest integration RUNC_IMAGE := runc_dev RUNC_TEST_IMAGE := runc_test @@ -25,6 +27,12 @@ static: $(RUNC_LINK) $(RUNC_LINK): ln -sfn $(CURDIR) $(RUNC_LINK) +dbuild: runctestimage + docker build -t $(RUNC_IMAGE) . + docker create --name=$(RUNC_INSTANCE) $(RUNC_IMAGE) + docker cp $(RUNC_INSTANCE):$(RUNC_BUILD_PATH) . + docker rm $(RUNC_INSTANCE) + lint: go vet ./... go fmt ./... @@ -35,24 +43,24 @@ man: runctestimage: docker build -t $(RUNC_TEST_IMAGE) -f $(TEST_DOCKERFILE) . -test: runctestimage - docker run -e TESTFLAGS -ti --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localtest +test: + make unittest integration -localtest: all +localtest: + make localunittest localintegration + +unittest: runctestimage + docker run -e TESTFLAGS -ti --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localunittest + +localunittest: all go test -tags "$(BUILDTAGS)" ${TESTFLAGS} -v ./... -dbuild: runctestimage - docker build -t $(RUNC_IMAGE) . - docker create --name=$(RUNC_INSTANCE) $(RUNC_IMAGE) - docker cp $(RUNC_INSTANCE):$(RUNC_BUILD_PATH) . - docker rm $(RUNC_INSTANCE) - integration: runctestimage docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localintegration -localintegration: - bats tests/integration${TESTFLAGS} - +localintegration: all + bats -t tests/integration${TESTFLAGS} + install: install -D -m0755 runc /usr/local/sbin/runc diff --git a/script/test_Dockerfile b/script/test_Dockerfile index 19f9a723..bbb8af45 100644 --- a/script/test_Dockerfile +++ b/script/test_Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y \ python-minimal \ --no-install-recommends -# install bats +# install bats RUN cd /tmp \ && git clone https://github.com/sstephenson/bats.git \ && cd bats \ @@ -33,10 +33,9 @@ RUN mkdir -p /usr/src/criu \ && make install-criu # setup a playground for us to spawn containers in -RUN mkdir /busybox \ - && mkdir /testdata \ - && curl -o /testdata/busybox.tar -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' \ - && tar -C /busybox -xf /testdata/busybox.tar +ENV ROOTFS /busybox +RUN mkdir -p ${ROOTFS} \ + && curl -o- -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -C ${ROOTFS} -xf - COPY script/tmpmount / WORKDIR /go/src/github.com/opencontainers/runc