Skip to content

Commit

Permalink
Github test scripts mods to test why test-openpgp.sh sometimes fails
Browse files Browse the repository at this point in the history
 Changes to be committed:
	modified:   restart-pcscd.sh
	modified:   test-openpgp.sh
  • Loading branch information
dengert authored and frankmorgner committed Feb 28, 2024
1 parent 11b5ab8 commit 818f1da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/restart-pcscd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This file is made to be sourced into other test scripts and not executed
# manually because it sets trap to restore pcscd to working state

# Set PCSCD_DEBUG="-d -a" to debug APDUs before sourcing this file

# register cleanup handler
function pcscd_cleanup {
echo "Process terminated: resetting pcscd"
Expand All @@ -20,13 +22,14 @@ if which systemctl && systemctl is-system-running; then
else
sudo pkill pcscd || echo "no pcscd process was running"
fi
sudo /usr/sbin/pcscd -f 2>&1 | sed -e 's/^/pcscd: /;' &
sudo /usr/sbin/pcscd -f $PCSCD_DEBUG 2>&1 | sed -e 's/^/pcscd: /' &


# Try to wait up to 30 seconds for pcscd to come up and create PID file
for ((i=1;i<=30;i++)); do
echo "Waiting for pcscd to start: $i s"
if [ -f "/var/run/pcscd/pcscd.pid" ]; then
echo "PCSC PID: `cat /var/run/pcscd/pcscd.pid`"
break
fi
sleep 1
Expand Down
26 changes: 26 additions & 0 deletions .github/test-openpgp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -ex -o xtrace

uname -a

source .github/setup-valgrind.sh

# install the opensc
Expand All @@ -26,12 +28,35 @@ echo "com.licel.jcardsim.vsmartcard.port=35963" >> openpgp_jcardsim.cfg;


# prepare pcscd
PCSCD_DEBUG="-d -a"
. .github/restart-pcscd.sh

sleep 5
echo "Is pcscd running:"
ps -ef | grep pcscd

echo "Test for /var/run/pcscd/"
if [ -d /var/run/pcscd/ ] ; then
ls -la /var/run/pcscd/*
if [ -f /var/run/pcscd/pcscd.pid ] ; then
echo "/var/run/pcscd/pcscd.pid `cat /var/run/pcscd/pcscd.pid`"
fi
fi

echo "Test for /run/pcscd/"
if [ -d /run/pcscd/ ] ; then
ls -la /run/pcscd/*
if [ -f /run/pcscd/pcscd.pid ] ; then
echo "/run/pcscd/pcscd.pid `cat /run/pcscd/pcscd.pid`"
fi

fi
ps -ef | grep pcsc

# start the applet and run couple of commands against that
java -noverify -cp ykneo-openpgp/applet/bin:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard openpgp_jcardsim.cfg >/dev/null &
PID=$!;
echo java pid $PID
sleep 5;
$VALGRIND opensc-tool --card-driver default --send-apdu 80b800002210D276000124010200000000000001000010D276000124010200000000000001000000;
$VALGRIND opensc-tool -n;
Expand All @@ -52,3 +77,4 @@ diff -u3 src/tests/p11test/openpgp_s0{_ref,}.json
diff -u3 src/tests/p11test/openpgp_s1{_ref,}.json

kill -9 $PID
ps -ef | grep pcsc

0 comments on commit 818f1da

Please sign in to comment.