From 2b01b2250dd265acd2317e076eb6511f8b27b2ab Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 8 Feb 2021 02:39:05 +0200 Subject: Add a script to run tests in isolated environment --- README.md | 12 +----------- start-unshare-impl.sh | 19 +++++++++++++++++++ start-unshare.sh | 9 +++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100755 start-unshare-impl.sh create mode 100755 start-unshare.sh diff --git a/README.md b/README.md index ce91c7c..f3e84b0 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,7 @@ All tests except the input and video module load tests can be run inside a conta This allows to run the tests in a regular development machine with convenient debugging and fast turnaround. The only prerequisite is root permissions. -The most convenient way to run the tests is doing the following as root: - -``` -$ unshare --ipc --mount --mount-proc --net --pid --fork /bin/bash - # then, in the newly opened shell session, perform the following -$ mkdir -p empty -$ mount --bind empty /dev -$ mount --bind empty /sys - # now the tests can be run -``` - +The most convenient way to run the tests is running `./start-unshare.sh` as root. This creates a bare-bones environment that shares the filesystem with the rest of the system, but is otherwise isolated from it. This allows running additional X servers without affecting the primary X server running on the machine. diff --git a/start-unshare-impl.sh b/start-unshare-impl.sh new file mode 100755 index 0000000..bb1bf8b --- /dev/null +++ b/start-unshare-impl.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [[ -z $IN_CONTAINER ]]; then + echo "Please use start-container.sh script" + exit +fi + +function cleanup { + rm -rf _xorg_integration_test_empty +} + +trap cleanup EXIT + +mkdir -p _xorg_integration_test_empty + +mount --bind _xorg_integration_test_empty /dev +mount --bind _xorg_integration_test_empty /sys + +/bin/bash diff --git a/start-unshare.sh b/start-unshare.sh new file mode 100755 index 0000000..f7d253a --- /dev/null +++ b/start-unshare.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if (( $EUID != 0 )); then + echo "Please run this script as root" + exit +fi + +unshare --ipc --mount --mount-proc --net --pid --fork \ + /bin/bash -c "IN_CONTAINER=1 ./start-unshare-impl.sh" -- cgit v1.2.3