2022-08-29 15:39:34 +03:00
|
|
|
#!/bin/bash
|
|
|
|
# Expects $1 to be a (speedtest1 --script) output file. Output is a
|
|
|
|
# series of SQL files extracted from that file.
|
|
|
|
infile=${1:?arg = speedtest1 --script output file}
|
|
|
|
testnums=$(grep -e '^-- begin test' "$infile" | cut -d' ' -f4)
|
2022-08-29 20:41:16 +03:00
|
|
|
if [ x = "x${testnums}" ]; then
|
|
|
|
echo "Could not parse any begin/end blocks out of $infile" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-30 13:04:08 +03:00
|
|
|
odir=${infile%%/*}
|
|
|
|
if [ "$odir" = "$infile" ]; then odir="."; fi
|
2022-08-29 15:39:34 +03:00
|
|
|
#echo testnums=$testnums
|
|
|
|
for n in $testnums; do
|
2022-08-30 13:04:08 +03:00
|
|
|
ofile=$odir/$(printf "speedtest1-%03d.sql" $n)
|
2022-08-29 20:41:16 +03:00
|
|
|
sed -n -e "/^-- begin test $n /,/^-- end test $n\$/p" $infile > $ofile
|
2022-08-29 15:39:34 +03:00
|
|
|
echo -e "$n\t$ofile"
|
|
|
|
done
|