Advertisement
Guest User

Untitled

a guest
Dec 20th, 2010
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. PREPARE=1
  4.  
  5. if [ $# -gt 0 ];then
  6.  echo Skipping test preparation.
  7.  PREPARE=0
  8. fi
  9.  
  10. if [ $PREPARE -eq 1 ]; then
  11.  echo Preparing tests for bgrep
  12.  
  13.  rm -f /tmp/bgrep*
  14.  
  15.  #
  16.  # create files with AAA...A BBBC AAA...A
  17.  # to find the sequence "BBB" == 0x424242
  18.  #
  19.  for index in `seq 0 1025`;do
  20.   fileIndex=`printf "%04i" ${index}`
  21.   perl -e 'print "A"x'"${index}"';print "BBBC";print "A"x20;' > /tmp/bgrepTest${fileIndex}.txt
  22.   printf "%08x\n" ${index} >> /tmp/bgrepExpectedResult.txt
  23.  done
  24.  
  25.  #
  26.  # create files with AAA...A BBB
  27.  # to find the sequence "BBB" == 0x424242
  28.  #
  29.  for index in `seq 1020 1025`;do
  30.   perl -e 'print "A"x'"${index}"';print "BBB"' > /tmp/bgrepTestSpecial${index}.txt
  31.   printf "%08x\n" ${index} >> /tmp/bgrepExpectedResult.txt
  32.  done
  33.  
  34. fi
  35.  
  36. #
  37. # Test execution
  38. #
  39. echo Testing bgrep
  40. echo "./bgrep 424242 /tmp/bgrepTest* | sed 's/^.*: //g' > /tmp/results.txt"
  41.  
  42. ./bgrep 424242 /tmp/bgrepTest* | sed 's/^.*: //g' > /tmp/results.txt
  43.  
  44. echo -e "\nDifferences between /tmp/results.txt and /tmp/bgrepExpectedResult.txt:"
  45.  
  46. diff -u /tmp/results.txt /tmp/bgrepExpectedResult.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement