xref: /rust-libc-0.2.174/ci/run-docker.sh (revision b46b6e2e)
1#!/usr/bin/env sh
2
3# Small script to run tests for a target (or all targets) inside all the
4# respective docker images.
5
6set -ex
7
8run() {
9    echo "Building docker container for target ${1}"
10    # use -f so we can use ci/ as build context
11    docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
12    mkdir -p target
13    if [ -w /dev/kvm ]; then
14        kvm="--volume /dev/kvm:/dev/kvm"
15    else
16        kvm=""
17    fi
18
19    docker run \
20      --user "$(id -u)":"$(id -g)" \
21      --rm \
22      --init \
23      --volume "${HOME}/.cargo":/cargo \
24      $kvm \
25      --env CARGO_HOME=/cargo \
26      --volume "$(rustc --print sysroot)":/rust:ro \
27      --volume "$(pwd)":/checkout:ro \
28      --volume "$(pwd)"/target:/checkout/target \
29      --env CARGO_TARGET_DIR=/checkout/target \
30      --workdir /checkout \
31      libc \
32      ci/run.sh "${1}"
33}
34
35if [ -z "${1}" ]; then
36  for d in ci/docker/*; do
37    run "${d}"
38  done
39else
40  run "${1}"
41fi
42