#!/bin/sh # run.sh — build and run the run-guix-container unit tests. # # Usage: ./run.sh set -e here=$(cd "$(dirname "$0")" && pwd) tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT # Find a real generated container script in the store, if any. container=$(ls /gnu/store | grep -E '^[0-9a-z]{32}-run-container$' | head -1) if [ -n "$container" ]; then container="/gnu/store/$container" fi cc -O2 -Wall -o "$tmp/test" "$here/test.c" cc -O2 -Wall -o "$tmp/daemon" "$here/../bin/run-guix-system-container.c" # The daemon's own switches: --log-dir must stay advertised (it is how a host # with a read-only /var keeps container logs), and anything unknown must # print the usage rather than start a half-configured daemon. echo "daemon switches:" if "$tmp/daemon" --help 2>&1 | grep -q -- "--log-dir"; then echo " ok --log-dir advertised" else echo " FAIL --log-dir missing from --help"; exit 1 fi # ... and the chosen directory must actually reach the daemon: it names it at # startup, which is observable without root. if "$tmp/daemon" --log-dir /tmp/rgsc-test-logs --port 8994 2>&1 \ | grep -q "container logs: /tmp/rgsc-test-logs"; then echo " ok --log-dir reaches the daemon" else echo " FAIL --log-dir did not reach the daemon"; exit 1 fi if GUIX_CONTAINER_LOG_DIR=/tmp/rgsc-env-logs "$tmp/daemon" --port 8994 2>&1 \ | grep -q "container logs: /tmp/rgsc-env-logs"; then echo " ok GUIX_CONTAINER_LOG_DIR reaches the daemon" else echo " FAIL GUIX_CONTAINER_LOG_DIR did not reach the daemon"; exit 1 fi if "$tmp/daemon" --no-such-option >/dev/null 2>&1; then echo " FAIL unknown option accepted"; exit 1 else echo " ok unknown option refused" fi "$tmp/test" "$container" "$tmp"