Init
This commit is contained in:
51
cmd/patch/tests/testpatch
Executable file
51
cmd/patch/tests/testpatch
Executable 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
|
||||
Reference in New Issue
Block a user