openpgp-card/tools/cargo-test-in-docker
Nora Widdecke dfb7f3275d
opgpcard: Replace flagfile with environment variable
- A flagfile requires manual management with touch and rm, replace it
    with an environment variable that can be set more conveniently.

  - Removing tools/tests/opgpcard.rs is not necessary, the file it links
    to is always generated in build.rs, either with subplot tests or
    without. But it is always there, so cargo test does not fail for
    that reason.
2022-10-27 15:46:42 +02:00

25 lines
851 B
Bash
Executable file

#!/usr/bin/env bash
#
# Run this to run opgpcard (tools directory) test suite inside a
# Docker container with a virtual smartcard running. The test suite
# contains tests that run the opgpcard binary and rely on a virtual
# smart card to be available.
#
# SPDX-FileCopyrightText: 2022 Lars Wirzenius <liw@liw.fi>
# SPDX-License-Identifier: MIT OR Apache-2.0
set -euo pipefail
docker run --rm -it \
-v root:/root \
-v cargo:/cargo \
-v $(pwd):/src \
-e CARD_BASED_TESTS=true \
registry.gitlab.com/openpgp-card/virtual-cards/smartpgp-builddeps sh -c '
sed -i "s/timeout=20/timeout=60/" /home/jcardsim/run-card.sh &&
/etc/init.d/pcscd start &&
su - -c "sh /home/jcardsim/run-card.sh >/dev/null" jcardsim &&
cd /src/tools &&
CARGO_TARGET_DIR=/cargo/ cargo update &&
CARGO_TARGET_DIR=/cargo/ cargo build -vv &&
CARGO_TARGET_DIR=/cargo/ cargo test'