summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Dockerfile8
-rw-r--r--Makefile47
-rw-r--r--README.md15
-rwxr-xr-xkokoro/run_tests.sh11
-rw-r--r--test/syscalls/linux/pty.cc2
5 files changed, 83 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..32ac76f1b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,8 @@
+FROM ubuntu:bionic
+
+RUN apt-get update && apt-get install -y curl gnupg2 git
+RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
+ curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
+RUN apt-get update && apt-get install -y bazel && apt-get clean
+
+WORKDIR /gvisor
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..c70f76504
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+UID := $(shell id -u ${USER})
+GID := $(shell id -g ${USER})
+GVISOR_BAZEL_CACHE := $(shell readlink -f ~/.cache/bazel/)
+
+all: runsc
+
+docker-build:
+ docker build -t gvisor-bazel .
+
+bazel-shutdown:
+ docker exec -i gvisor-bazel bazel shutdown && \
+ docker kill gvisor-bazel
+
+bazel-server-start: docker-build
+ mkdir -p "$(GVISOR_BAZEL_CACHE)" && \
+ docker run -d --rm --name gvisor-bazel \
+ --user 0:0 \
+ -v "$(GVISOR_BAZEL_CACHE):$(HOME)/.cache/bazel/" \
+ -v "$(CURDIR):$(CURDIR)" \
+ --workdir "$(CURDIR)" \
+ --tmpfs /tmp \
+ --privileged \
+ gvisor-bazel \
+ sh -c "while :; do sleep 100; done" && \
+ docker exec --user 0:0 -i gvisor-bazel sh -c "groupadd --gid $(GID) gvisor && useradd --uid $(UID) --gid $(GID) -d $(HOME) gvisor"
+
+bazel-server:
+ docker exec gvisor-bazel true || \
+ $(MAKE) bazel-server-start
+
+BAZEL_OPTIONS := build runsc
+bazel: bazel-server
+ docker exec -u $(UID):$(GID) -i gvisor-bazel bazel $(BAZEL_OPTIONS)
+
+bazel-alias:
+ @echo "alias bazel='docker exec -u $(UID):$(GID) -i gvisor-bazel bazel'"
+
+runsc:
+ $(MAKE) BAZEL_OPTIONS="build runsc" bazel
+
+tests:
+ $(MAKE) BAZEL_OPTIONS="test --test_tag_filters runsc_ptrace //test/syscalls/..." bazel
+
+unit-tests:
+ $(MAKE) BAZEL_OPTIONS="test //pkg/... //runsc/... //tools/..." bazel
+
+.PHONY: docker-build bazel-shutdown bazel-server-start bazel-server bazel runsc tests
diff --git a/README.md b/README.md
index 245aabf84..f0252025c 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,14 @@ bazel build runsc
sudo cp ./bazel-bin/runsc/linux_amd64_pure_stripped/runsc /usr/local/bin
```
+If you don't want to install bazel on your system, you can build runsc in a
+Docker container:
+
+```
+make runsc
+sudo cp ./bazel-bin/runsc/linux_amd64_pure_stripped/runsc /usr/local/bin
+```
+
### Testing
The test suite can be run with Bazel:
@@ -78,6 +86,13 @@ The test suite can be run with Bazel:
bazel test ...
```
+or in a Docker container:
+
+```
+make unit-tests
+make tests
+```
+
### Using remote execution
If you have a [Remote Build Execution][rbe] environment, you can use it to speed
diff --git a/kokoro/run_tests.sh b/kokoro/run_tests.sh
index c5c6a7780..fbe353a1e 100755
--- a/kokoro/run_tests.sh
+++ b/kokoro/run_tests.sh
@@ -197,6 +197,16 @@ finish() {
exit ${exit_code}
}
+# Run bazel in a docker container
+build_in_docker() {
+ cd ${WORKSPACE_DIR}
+ bazel clean
+ bazel shutdown
+ make
+ make runsc
+ make bazel-shutdown
+}
+
########
# MAIN #
########
@@ -220,6 +230,7 @@ main() {
# Build other flavors too.
build_everything dbg
+ build_in_docker
# No need to call "finish" here, it will happen at exit.
}
diff --git a/test/syscalls/linux/pty.cc b/test/syscalls/linux/pty.cc
index 0485d187c..f926ac0f9 100644
--- a/test/syscalls/linux/pty.cc
+++ b/test/syscalls/linux/pty.cc
@@ -18,9 +18,11 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
+
#include <iostream>
#include "gtest/gtest.h"