does-hunspell-works-under-valgrind: workaround the testcase

echo "NEWSX" | hunspell -a with and w/o valgrind differed in
lower case. This could be workarounded by running such a command
under --tool=none.

Jan Kratochvil suggested the better workaround finding out
spelling suggestions somehow were based on the processor time used by
the process. And so overriding clock to simply always return zero means
the process cannot observe the cpu time used.
This commit is contained in:
Alexandra Hájková 2021-07-16 11:35:20 +02:00
parent dc7d3866cc
commit 9a0a8de052

View File

@ -48,42 +48,17 @@ rlJournalStart
rlPhaseStartTest
out="$TmpDir/spell_check.out"
err="$TmpDir/spell_check.err"
vout="$TmpDir/spell_check.valgrind.out"
verr="$TmpDir/spell_check.valgrind.err"
rlRun "echo \"NEWSX\"|hunspell -a;echo -e '#include <time.h>\nclock_t clock(void) { return 0; }'|gcc -o libclock.so -Wall -g -shared -fPIC -x c -;echo "NEWSX"|LD_PRELOAD=./libclock.so hunspell -a > out"
spell_checker_command=""
spell_checker_command="echo \"hackerx\" | $SPELL_CHECKER -a > $out 2> $err"
rlRun "echo \"NEWSX\"|hunspell -a;echo -e '#include <time.h>\nclock_t clock(void) { return 0; }'|gcc -o libclock.so -Wall -g -shared -fPIC -x c -;echo \"NEWSX\"|LD_PRELOAD=./libclock.so valgrind -q hunspell -a > valgrind_out"
# Remove dictionary to avoid possibility of different results with
# already present dictionary. After this all commands start with
# the clean sheet.
rlRun "rm -f $HOME/.hunspell_en_US"
rlRun "$spell_checker_command" 0-255
if [ "$?" -eq "0" ]; then
spell_checker_command="${spell_checker_command/$out/$vout}"
spell_checker_command="${spell_checker_command/$err/$verr}"
rlRun "rm -f $HOME/.hunspell_en_US"
rlRun "valgrind $spell_checker_command" 0-255
if [ "$?" -ne 0 ]; then
rlLogWarning "Valgrind check failed"
rlLogWarning "$(cat $verr)"
else
rlAssertNotDiffer "$out" "$vout"
[ "$?" -ne 0 ] && rlLogWarning "$(diff $out $vout)"
fi
else
((skipped++))
rlLogWarning "Regular check failed"
rlLogWarning "$(cat $err)"
fi
rlRun "rm -f $out $err $vout $verr"
rlAssertNotDiffer "out" "valgrind_out"
[ "$?" -ne 0 ] && rlLogWarning "$(diff out valgrind_out)"
rlPhaseEnd
rlPhaseStartCleanup