xref: /rust-libc-0.2.174/ci/run-docker.sh (revision a01c32d6)
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
11    # use -f so we can use ci/ as build context
12    docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
13    mkdir -p target
14    if [ -w /dev/kvm ]; then
15        kvm="--volume /dev/kvm:/dev/kvm"
16    else
17        kvm=""
18    fi
19
20    docker run \
21      --user "$(id -u)":"$(id -g)" \
22      --rm \
23      --init \
24      --volume "${HOME}/.cargo":/cargo \
25      $kvm \
26      --env CARGO_HOME=/cargo \
27      --volume "$(rustc --print sysroot)":/rust:ro \
28      --volume "$(pwd)":/checkout:ro \
29      --volume "$(pwd)"/target:/checkout/target \
30      --env CARGO_TARGET_DIR=/checkout/target \
31      --workdir /checkout \
32      libc \
33      ci/run.sh "${1}"
34}
35
36if [ -z "${1}" ]; then
37  for d in ci/docker/*; do
38    run "${d}"
39  done
40else
41  run "${1}"
42fi
43