~percona-toolkit-dev/percona-toolkit/pt-table-sync-binlog-format-only-if-not-statement

« back to all changes in this revision

Viewing changes to util/test-bash-functions

MergeĀ lp:~percona-toolkit-dev/percona-toolkit/fix-945079-tmpdir-should-use-TEMP

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
# Paths
41
41
# ############################################################################
42
42
 
43
 
# Do not use TMPDIR because the tools use it for their own secure tmpdir.
44
 
TEST_TMPDIR="/tmp/percona-toolkit.test"
45
 
if [ ! -d $TEST_TMPDIR ]; then
46
 
   mkdir $TEST_TMPDIR
 
43
# Do not use PT_TMPDIR because the tools use it for their own secure tmpdir.
 
44
TEST_PT_TMPDIR="/tmp/percona-toolkit.test"
 
45
if [ ! -d $TEST_PT_TMPDIR ]; then
 
46
   mkdir $TEST_PT_TMPDIR
47
47
fi
48
48
 
49
49
# ############################################################################
79
79
# Source a test file to run whatever it contains (hopefully tests!).
80
80
run_test() {
81
81
   local t=$1  # test file name, e.g. "group-by-all-01" for pt-diskstats
82
 
   rm -rf $TEST_TMPDIR/* >/dev/null 2>&1
 
82
   rm -rf $TEST_PT_TMPDIR/* >/dev/null 2>&1
83
83
 
84
84
   # Tests assume that they're being ran from their own dir, so they access
85
85
   # sample files like "samples/foo.txt".  So cd to the dir of the test file
106
106
      echo "not ok $testno - $TEST_FILE $test_name"
107
107
      failed_tests=$(( failed_tests + 1))
108
108
      echo "#   Failed '$test_command'" >&2
109
 
      if [ -f $TEST_TMPDIR/failed_result ]; then
110
 
         cat $TEST_TMPDIR/failed_result | sed -e 's/^/#   /' -e '30q' >&2
 
109
      if [ -f $TEST_PT_TMPDIR/failed_result ]; then
 
110
         cat $TEST_PT_TMPDIR/failed_result | sed -e 's/^/#   /' -e '30q' >&2
111
111
      fi
112
112
   fi
113
113
   testno=$((testno + 1))
164
164
   local expected=$2
165
165
   local test_name=${3:-""}
166
166
   test_command="diff $got $expected"
167
 
   eval $test_command > $TEST_TMPDIR/failed_result 2>&1
 
167
   eval $test_command > $TEST_PT_TMPDIR/failed_result 2>&1
168
168
   result $? "$test_name"
169
169
}
170
170
 
235
235
   done
236
236
fi
237
237
 
238
 
rm -rf $TEST_TMPDIR
 
238
rm -rf $TEST_PT_TMPDIR
239
239
exit $failed_tests