diff options
author | Alexey Neyman <stilor@att.net> | 2018-04-17 22:47:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 22:47:39 -0700 |
commit | 90d14443d1ab1d650f7aef98df3d2948ba6dd605 (patch) | |
tree | 88a932353f8dc19342b674cc57dee4bae39dd3ee | |
parent | 5472517b31bde9b1ab71fd3369f3370e813e0351 (diff) | |
parent | 345dc4161d937c302248ea34ea55a9abc4bf343d (diff) | |
download | crosstool-ng-90d14443d1ab1d650f7aef98df3d2948ba6dd605.tar.gz crosstool-ng-90d14443d1ab1d650f7aef98df3d2948ba6dd605.tar.bz2 crosstool-ng-90d14443d1ab1d650f7aef98df3d2948ba6dd605.zip |
Merge pull request #947 from stilor/docker-testing
Docker-based testing for Linux distros
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | testing/docker/archlinux/Dockerfile | 3 | ||||
-rwxr-xr-x | testing/docker/common-scripts/ctng-install | 10 | ||||
-rwxr-xr-x | testing/docker/common-scripts/ctng-test-all | 12 | ||||
-rwxr-xr-x | testing/docker/common-scripts/su-as-user | 16 | ||||
-rwxr-xr-x | testing/docker/dmgr.sh | 106 |
7 files changed, 154 insertions, 1 deletions
@@ -18,6 +18,9 @@ config/versions/ verbatim-data.mk maintainer/package-versions +*.tar.xz +*.tar.bz2 + # Temporaries .*.swp build.log @@ -25,6 +28,9 @@ build.log temp.* stamp-h1 +# Testing +testing/docker/build-* + # This is the place where toolchains are built .build/ # .. and log for 'build-all' diff --git a/configure.ac b/configure.ac index 5cb82a8b..765eae17 100644 --- a/configure.ac +++ b/configure.ac @@ -167,7 +167,7 @@ CTNG_PROG_VERSION_REQ_ANY([MAKE], [make_3_81_or_newer]) # Check other companion tools that we may or may not build. -CTNG_PROG_VERSION([LIBTOOL], +CTNG_PROG_VERSION_REQ_STRICT([LIBTOOL], [GNU libtool >= 2.4], [libtool], [glibtool libtool], diff --git a/testing/docker/archlinux/Dockerfile b/testing/docker/archlinux/Dockerfile new file mode 100644 index 00000000..eee2f47b --- /dev/null +++ b/testing/docker/archlinux/Dockerfile @@ -0,0 +1,3 @@ +FROM hoverbear/archlinux +RUN pacman -Syu --noconfirm +RUN pacman -S --noconfirm base-devel git help2man python diff --git a/testing/docker/common-scripts/ctng-install b/testing/docker/common-scripts/ctng-install new file mode 100755 index 00000000..f29093a9 --- /dev/null +++ b/testing/docker/common-scripts/ctng-install @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e +cd +rm -rf bld-ctng +mkdir bld-ctng +cd bld-ctng +/crosstool-ng/configure --prefix=$HOME/inst-ctng +make +make install diff --git a/testing/docker/common-scripts/ctng-test-all b/testing/docker/common-scripts/ctng-test-all new file mode 100755 index 00000000..f0ba2663 --- /dev/null +++ b/testing/docker/common-scripts/ctng-test-all @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e +cd +rm -rf bld-samples +mkdir bld-samples +cd bld-samples +export PATH=$HOME/inst-ctng/bin:$PATH +ct-ng help +ct-ng list-samples +ct-ng list-steps +ct-ng build-all diff --git a/testing/docker/common-scripts/su-as-user b/testing/docker/common-scripts/su-as-user new file mode 100755 index 00000000..99246f23 --- /dev/null +++ b/testing/docker/common-scripts/su-as-user @@ -0,0 +1,16 @@ +#!/bin/bash + +usr=$1 +uid=$2 +grp=$3 +gid=$4 +shift 4 + +groupadd -g ${gid} ${grp} +useradd -d /home/${usr} -m -g ${gid} -u ${uid} ${usr} +ln -sf /src /home/${usr}/src +if [ -z "$*" ]; then + exec su -l ${usr} +else + exec su -l -c "/bin/bash -c '$*'" ${usr} +fi diff --git a/testing/docker/dmgr.sh b/testing/docker/dmgr.sh new file mode 100755 index 00000000..5dbb8b22 --- /dev/null +++ b/testing/docker/dmgr.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Run from the directory containing this script +cd `dirname $0` + +msg() +{ + echo "INFO :: $*" >&2 +} + +error() +{ + echo "ERROR :: $*" >&2 + exit 1 +} + +usage() +{ + cat >&2 <<EOF +${1:+ERROR :: $1 + +}Usage: $0 [action] [containters] + +Action is one of: + + build Build or rebuild the specified containers. + +If containers are not specified, the action is applied to all available containers. +EOF + exit 1 +} + +# Build a docker container, store its ID. +action_build() +{ + local cntr=$1 + + msg "Building Docker container for ${cntr}" + docker build -t "ctng-${cntr}" "${cntr}" +} + +# Common backend for enter/test +_dckr() +{ + local topdir=`cd ../.. && pwd` + local cntr=$1 + shift + + mkdir -p build-${cntr} + docker run --rm -i -t \ + -v `pwd`/common-scripts:/setup-scripts:ro \ + -v ${topdir}:/crosstool-ng:ro \ + -v `pwd`/build-${cntr}:/home \ + -v $HOME/src:/src:ro \ + ctng-${cntr} \ + /setup-scripts/su-as-user `id -un` `id -u` `id -gn` `id -g` "$@" +} + +# Run the test +action_test() +{ + local cntr=$1 + + # The test assumes the top directory is bootstrapped, but clean. + msg "Setting up crosstool-NG in ${cntr}" + _dckr "${cntr}" /setup-scripts/ctng-install + msg "Running build-all in ${cntr}" + _dckr "${cntr}" /setup-scripts/ctng-test-all +} + +# Enter the container using the same user account/environment as for testing. +action_enter() +{ + local cntr=$1 + + msg "Entering ${cntr}" + _dckr "${cntr}" +} + +# Clean up after test suite run +action_clean() +{ + local cntr=$1 + + msg "Cleaning up after ${cntr}" + rm -rf build-${cntr} +} + +action=$1 +shift +all_containers=`ls */Dockerfile | sed 's,/Dockerfile,,'` +selected_containers="${*:-${all_containers}}" + +case "${action}" in + build|test|enter|clean) + for c in ${selected_containers}; do + eval "action_${action} $c" + done + ;; + "") + usage "No action specified." + ;; + *) + usage "Unknown action ${action}." + ;; +esac |