diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 46a2962..d6d7515 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,9 @@ jobs: test: runs-on: ubuntu-latest needs: build + strategy: + matrix: + suite: ["pkcs11", "pytest"] steps: - name: Checkout repository and submodules uses: actions/checkout@v3 @@ -59,24 +62,5 @@ jobs: run: | cd artifacts docker load -q -i docker-image.tar - - name: Test PCSC (pytest) - run: ./tests/run-test-in-docker.sh - test_pkcs11: - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout repository and submodules - uses: actions/checkout@v3 - with: - submodules: recursive - - name: Retrieve saved image - uses: actions/download-artifact@v2 - with: - name: docker-artifact - path: artifacts - - name: Load image - run: | - cd artifacts - docker load -q -i docker-image.tar - - name: Test PKCS11 - run: ./tests/run-test-pkcs11-in-docker.sh + - name: Test ${{ matrix.suite }} + run: ./tests/run-test-in-docker.sh ${{ matrix.suite }} diff --git a/tests/docker/bullseye/Dockerfile b/tests/docker/bullseye/Dockerfile index 94ade74..14b7c48 100644 --- a/tests/docker/bullseye/Dockerfile +++ b/tests/docker/bullseye/Dockerfile @@ -28,11 +28,13 @@ RUN pip3 install pytest pycvc cryptography pyscard base58 WORKDIR / RUN git clone https://github.com/OpenSC/OpenSC WORKDIR /OpenSC -RUN git checkout tags/0.22.0 +RUN git checkout tags/0.23.0 RUN ./bootstrap RUN ./configure --enable-openssl RUN make -j `nproc` RUN make install RUN make clean RUN ldconfig +RUN git clone https://github.com/polhenarejos/pypicohsm.git +RUN pip3 install -e pypicohsm WORKDIR / diff --git a/tests/run-test-in-docker.sh b/tests/run-test-in-docker.sh index ca3486e..3589acc 100755 --- a/tests/run-test-in-docker.sh +++ b/tests/run-test-in-docker.sh @@ -1,5 +1,14 @@ #!/bin/bash -eu source tests/docker_env.sh -run_in_docker ./tests/start-up-and-test.sh + +if [[ "$#" -gt 1 ]]; then + if [[ $1 == "pkcs11" ]]; then + run_in_docker ./tests/start-up-and-test-pkcs11.sh + elif [[ $1 == "pytest" ]]; then + run_in_docker ./tests/start-up-and-test.sh + fi +else + run_in_docker ./tests/start-up-and-test.sh +fi diff --git a/tests/start-up-and-test-pkcs11.sh b/tests/start-up-and-test-pkcs11.sh index 8f0834e..25363be 100755 --- a/tests/start-up-and-test-pkcs11.sh +++ b/tests/start-up-and-test-pkcs11.sh @@ -1,13 +1,6 @@ #!/bin/bash -rm -rf pypicohsm -git clone https://github.com/polhenarejos/pypicohsm.git -pip3 install -e pypicohsm -/usr/sbin/pcscd & -sleep 2 -rm -f memory.flash -tar -xf tests/memory.tar.gz -./build_in_docker/pico_hsm > /dev/null 2>&1 & +source ./tests/startup.sh chmod a+x tests/scripts/*.sh diff --git a/tests/start-up-and-test.sh b/tests/start-up-and-test.sh index 4825b6b..de0a302 100755 --- a/tests/start-up-and-test.sh +++ b/tests/start-up-and-test.sh @@ -1,11 +1,5 @@ #!/bin/bash -rm -rf pypicohsm -git clone https://github.com/polhenarejos/pypicohsm.git -pip3 install -e pypicohsm -/usr/sbin/pcscd & -sleep 2 -rm -f memory.flash -tar -xf tests/memory.tar.gz -./build_in_docker/pico_hsm > /dev/null 2>&1 & +source ./tests/startup.sh + pytest tests -W ignore::DeprecationWarning diff --git a/tests/startup.sh b/tests/startup.sh new file mode 100644 index 0000000..8cc289f --- /dev/null +++ b/tests/startup.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +OK="\033[32mok\033[0m" +FAIL="\033[31mfail\033[0m" + +echo -n "Start PCSC... " +/usr/sbin/pcscd & +test $? -eq 0 && echo -e "${OK}" || { + echo -e "${FAIL}" + exit 1 +} +sleep 2 +rm -f memory.flash +tar -xf tests/memory.tar.gz +echo -n "Start Pico HSM... " +./build_in_docker/pico_hsm > /dev/null 2>&1 & +test $? -eq 0 && echo -e "${OK}" || { + echo -e "${FAIL}" + exit 1 +}