|
Dmitry Belyavskiy |
089d79 |
#!/usr/bin/bash
|
|
Dmitry Belyavskiy |
089d79 |
set -uexo pipefail
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# The custom %check script to run the OpenSSH upstream testsuite in parallel.
|
|
Dmitry Belyavskiy |
089d79 |
#
|
|
Dmitry Belyavskiy |
089d79 |
# The upstream testsuite is serial,
|
|
Dmitry Belyavskiy |
089d79 |
# so the idea here is to split the testsuite into several $PARTS:
|
|
Dmitry Belyavskiy |
089d79 |
# * file-tests
|
|
Dmitry Belyavskiy |
089d79 |
# * interop-tests
|
|
Dmitry Belyavskiy |
089d79 |
# * unit
|
|
Dmitry Belyavskiy |
089d79 |
# * ltests-00
|
|
Dmitry Belyavskiy |
089d79 |
# * ltests-01
|
|
Dmitry Belyavskiy |
089d79 |
# * ...
|
|
Dmitry Belyavskiy |
089d79 |
# * ltests-23
|
|
Dmitry Belyavskiy |
089d79 |
# and run them in parallel, using make, each in its own build subtree.
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
PARALLEL_MAKEFILE=$1
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
SPLIT=24
|
|
Dmitry Belyavskiy |
089d79 |
PARTS='file-tests interop-tests unit '
|
|
Dmitry Belyavskiy |
089d79 |
for ((i = 1; i < SPLIT; i++)); do ii=$(printf %02d $i);
|
|
Dmitry Belyavskiy |
089d79 |
PARTS+="t-exec-$ii "
|
|
Dmitry Belyavskiy |
089d79 |
done
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# work around a selinux restriction:
|
|
Dmitry Belyavskiy |
089d79 |
chcon -t unconfined_exec_t ssh-sk-helper || :
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# work around something else that only crops up in brew
|
|
Dmitry Belyavskiy |
089d79 |
export TEST_SSH_UNSAFE_PERMISSIONS=1
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# create a .test directory to store all our files in:
|
|
Dmitry Belyavskiy |
089d79 |
mkdir -p .t .ltests/{in,not-in}
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# patch testsuite: use different ports to avoid port collisions
|
|
Dmitry Belyavskiy |
089d79 |
grep -REi 'port=[2-9][0-9]*' regress
|
|
Dmitry Belyavskiy |
089d79 |
sed -i 's|PORT=4242|PORT=$(expr $TEST_SSH_PORT + 1)|' \
|
|
Dmitry Belyavskiy |
089d79 |
regress/test-exec.sh*
|
|
Dmitry Belyavskiy |
089d79 |
sed -i 's|^P=3301 # test port|P=$(expr $TEST_SSH_PORT + 1)|' \
|
|
Dmitry Belyavskiy |
089d79 |
regress/multiplex.sh*
|
|
Dmitry Belyavskiy |
089d79 |
sed -i 's|^fwdport=3301|fwdport=$(expr $TEST_SSH_PORT + 1)|' \
|
|
Dmitry Belyavskiy |
089d79 |
regress/cfgmatch.sh* regress/cfgmatchlisten.sh*
|
|
Dmitry Belyavskiy |
089d79 |
sed -i 's|^LFWD_PORT=.*|LFWD_PORT=$(expr $TEST_SSH_PORT + 1)|' \
|
|
Dmitry Belyavskiy |
089d79 |
regress/forward-control.sh*
|
|
Dmitry Belyavskiy |
089d79 |
sed -i 's|^RFWD_PORT=.*|RFWD_PORT=$(expr $TEST_SSH_PORT + 2)|' \
|
|
Dmitry Belyavskiy |
089d79 |
regress/forward-control.sh*
|
|
Dmitry Belyavskiy |
089d79 |
( ! grep -REi 'port=[2-9][0-9]*' regress) # try to find more of those
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# patch testsuite: speed up
|
|
Dmitry Belyavskiy |
089d79 |
sed -i 's|sleep 1$|sleep .25|' regress/forward-control.sh
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# extract LTESTS list to .tests/ltests/all:
|
|
Dmitry Belyavskiy |
089d79 |
grep -Ex 'tests:[[:space:]]*file-tests t-exec interop-tests extra-tests unit' Makefile
|
|
Dmitry Belyavskiy |
089d79 |
echo -ne '\necho-ltests:\n\techo ${LTESTS}' >> regress/Makefile
|
|
Dmitry Belyavskiy |
089d79 |
make -s -C regress echo-ltests | tr ' ' '\n' > .ltests/all
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# separate ltests into $SPLIT roughly equal .tests/ltests/in/$ii parts:
|
|
Dmitry Belyavskiy |
089d79 |
grep -qFx connect .ltests/all
|
|
Dmitry Belyavskiy |
089d79 |
( ! grep -qFx nonex .ltests/all )
|
|
Dmitry Belyavskiy |
089d79 |
split -d -a2 --number=l/$SPLIT .ltests/all .ltests/in/
|
|
Dmitry Belyavskiy |
089d79 |
wc -l .ltests/in/*
|
|
Dmitry Belyavskiy |
089d79 |
grep -qFx connect .ltests/in/*
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# generate the inverses of them --- .ltests/not-in/$ii:
|
|
Dmitry Belyavskiy |
089d79 |
( ! grep -qFx nonex .ltests/in/* )
|
|
Dmitry Belyavskiy |
089d79 |
for ((i = 0; i < SPLIT; i++)); do ii=$(printf %02d $i);
|
|
Dmitry Belyavskiy |
089d79 |
while read -r tname; do
|
|
Dmitry Belyavskiy |
089d79 |
if ! grep -qFx "$tname" ".ltests/in/$ii"; then
|
|
Dmitry Belyavskiy |
089d79 |
echo -n "$tname " >> ".ltests/not-in/$ii"
|
|
Dmitry Belyavskiy |
089d79 |
fi
|
|
Dmitry Belyavskiy |
089d79 |
done < .ltests/all
|
|
Dmitry Belyavskiy |
089d79 |
done
|
|
Dmitry Belyavskiy |
089d79 |
grep . .ltests/not-in/*
|
|
Dmitry Belyavskiy |
089d79 |
( ! grep -q ^connect .ltests/not-in/0 )
|
|
Dmitry Belyavskiy |
089d79 |
for ((i = 1; i < SPLIT; i++)); do ii=$(printf %02d $i);
|
|
Dmitry Belyavskiy |
089d79 |
grep -q ^connect .ltests/not-in/$ii
|
|
Dmitry Belyavskiy |
089d79 |
done
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# prepare several test directories:
|
|
Dmitry Belyavskiy |
089d79 |
for PART in $PARTS; do
|
|
Dmitry Belyavskiy |
089d79 |
mkdir .t/${PART}
|
|
Dmitry Belyavskiy |
089d79 |
cp -ra * .t/${PART}/
|
|
Dmitry Belyavskiy |
089d79 |
sed -i "s|abs_top_srcdir=.*|abs_top_srcdir=$(pwd)/.t/${PART}|" \
|
|
Dmitry Belyavskiy |
089d79 |
.t/${PART}/Makefile
|
|
Dmitry Belyavskiy |
089d79 |
sed -i "s|abs_top_builddir=.*|abs_top_builddir=$(pwd)/.t/${PART}|" \
|
|
Dmitry Belyavskiy |
089d79 |
.t/${PART}/Makefile
|
|
Dmitry Belyavskiy |
089d79 |
sed -i "s|^BUILDDIR=.*|BUILDDIR=$(pwd)/.t/${PART}|" \
|
|
Dmitry Belyavskiy |
089d79 |
.t/${PART}/Makefile
|
|
Dmitry Belyavskiy |
089d79 |
done
|
|
Dmitry Belyavskiy |
089d79 |
|
|
Dmitry Belyavskiy |
089d79 |
# finally, run tests $PARTS in parallel in their own subtrees:
|
|
Dmitry Belyavskiy |
089d79 |
time make -f "$PARALLEL_MAKEFILE" -j$(nproc) $PARTS
|