Skip to content

Instantly share code, notes, and snippets.

@terngkub
Created March 13, 2019 19:52
Show Gist options
  • Select an option

  • Save terngkub/7f177eb6faea48221670c0ef2f2efded to your computer and use it in GitHub Desktop.

Select an option

Save terngkub/7f177eb6faea48221670c0ef2f2efded to your computer and use it in GitHub Desktop.
fillit_compare

fillit_compare

A shellscript to compare the result of 2 fillit program

About the script

  • I used this script to test the result of my fillit project by comparing the result with other students project.
  • The script uses Tetriminos-generator to generate a random input.
  • Then, the script runs two fillit program and compare the results.
  • If there is a different, the script will stop running. You can then look at the input, outputs and the different file.

How to use the scipt

  • Download and install Tetriminos-generator. You can see the instruction in its project page.
  • Put this script in the Tetriminos-generator root directory.
  • Put two fillit programs each one in each folder at the Tetriminos-generator root directory.
  • So the structure will look like this:
     Tretriminos-generator/
     	compare.sh
     	first-fillit-folder/
     		fillit
     	second-fillit-folder/
     		fillit
    
  • Don't forget to use make command on each fillit.
  • Edit compare.sh
    • NUM is the number of times the test will run.
    • FIRST is your first fillit directory name.
    • SECOND is your second fillit derectory name.
  • Run:
     sh compare.sh
    
#!/bin/sh
NUM=10000
FIRST=first
SECOND=second
rm first_output.txt
rm second_output.txt
rm diff.txt
a=0
while [ $a -lt $NUM ]
do
echo $a
./tetri-gen -v -f 4
$(FIRST)/fillit sample.fillit > first_output.txt
$(SECOND)/fillit sample.fillit > second_output.txt
diff first_output.txt second_output.txt > diff.txt
if [ -s diff.txt ]
then
break
fi
rm first_output.txt
rm second_output.txt
rm diff.txt
a=`expr $a + 1`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment