This commit is contained in:
seta75D
2021-10-11 19:38:01 -03:00
commit 7c4988eac0
12567 changed files with 3198619 additions and 0 deletions

51
cmd/patch/tests/testpatch Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
while (true)
do
generations=`random_numbers 1 1 8`
lines=`random_numbers 1 10 5000`
max_mutation=`expr 1 \* $lines`
max_mutation=`expr $max_mutation \/ 5`
mutations=`random_numbers 1 1 $max_mutation`
genfile $lines > original
cp original save_orig
echo testing lines=$lines mutations=$max_mutation generations=$generations
rm -f patch_file
while [ $generations -ne 0 ]; do
ptype=`random_numbers 1 0 99999`
ptype=`expr $ptype \% 3`
if [ $ptype -eq 0 ]; then
ptype="-c"
elif [ $ptype -eq 1 ]; then
ptype=" "
else
ptype="-e"
fi
echo "Creating generation $generations of type ($ptype)..."
mutatefile $max_mutation $lines original > mutant
echo "Index:original" >> patch_file
diff $ptype original mutant >> patch_file
mv mutant original
generations=`expr $generations - 1`
done
cp original expected
cp save_orig original
echo Patching file...
../patch original < patch_file
if [ $? -ne 0 ]; then
echo Patch returned $?
diff original expected > failure
exit
fi
diff original expected > failure
if [ $? -ne 0 ]; then
echo diff returned $?
exit
fi
done