Skip to content
Snippets Groups Projects
Commit 372a702c authored by Martyn Welch's avatar Martyn Welch
Browse files

Simplify by using csplit and not looking in old locations for scripts

parent b0c142de
No related branches found
No related tags found
1 merge request!2T4802: Fix up issues with apparmor-dbus testing
......@@ -79,16 +79,8 @@ else
CMD=$*
fi
CMDLINE=""
for PREFIX in '' '/usr/lib/apertis-tests/'; do
TOOL="${PREFIX}common/run-test-in-systemd"
if [ -x ${TOOL} ]; then
CMDLINE=${TOOL}
break
fi
done
if [ "$CMDLINE" = "" ]; then
CMDLINE="common/run-test-in-systemd"
if [ ! -x $CMDLINE ]; then
echo "common/run-test-in-systemd not found"
exit 1
fi
......@@ -140,24 +132,12 @@ echo "#---8<--- expected output from aa_log_extract_tokens.pl"
cat ${EXPECT_FILE} | sed 's/^/# /'
echo "#--->8---"
cp ${EXPECT_FILE} ${TMP_DIR}/REMAIN
EXPECT_COUNT=1
SEPARATOR=$( grep -m1 -x -n "${ALTERNATIVE_SEPARATOR}" ${TMP_DIR}/REMAIN | cut -d: -f1 )
while [ "${SEPARATOR}" != "" ]; do
echo "SEPARATOR=\"${SEPARATOR}\""
echo "REMAIN:"
cat ${TMP_DIR}/REMAIN
head -n $((${SEPARATOR}-1)) ${TMP_DIR}/REMAIN > ${TMP_DIR}/EXPECT${EXPECT_COUNT}
SEPARATOR=$((${SEPARATOR}+1))
tail -n +${SEPARATOR} ${TMP_DIR}/REMAIN > ${TMP_DIR}/REMAIN.new
mv ${TMP_DIR}/REMAIN.new ${TMP_DIR}/REMAIN
EXPECT_COUNT=$((${EXPECT_COUNT}+1))
SEPARATOR=$( grep -m1 -x -n "${ALTERNATIVE_SEPARATOR}" ${TMP_DIR}/REMAIN | cut -d: -f1 )
done
csplit ${EXPECT_FILE} -f ${TMP_DIR}/EXPECT -b "%d" "/^${ALTERNATIVE_SEPARATOR}$/" {*}
mv ${TMP_DIR}/REMAIN ${TMP_DIR}/EXPECT${EXPECT_COUNT}
# Old versions of csplit don't provide "--suppress-matched", strip separator separately
for FILE in ${TMP_DIR}/EXPECT*; do
sed -i "/^${ALTERNATIVE_SEPARATOR}$/d" ${FILE}
done
PARSE_FILE="${TMP_DIR}/PARSE"
......@@ -192,8 +172,8 @@ MATCH_EXPECTATION="False"
# We might have alternative expectations, take that into consideration.
OUTPUT_MD5=$( cat ${PARSE_FILE} | md5sum )
COUNT=$( ls -1 ${TMP_DIR}/EXPECT* | wc -l )
NUM=1
while [ $((${NUM} <= ${COUNT})) = 1 ]; do
NUM=0
while [ $((${NUM} < ${COUNT})) = 1 ]; do
EXPECTED_MD5=$( cat ${TMP_DIR}/EXPECT${NUM} | md5sum )
if [ "${OUTPUT_MD5}" = "${EXPECTED_MD5}" ]; then
echo "# audit log matches alternative expectation ${NUM}/${COUNT}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment