~percona-toolkit-dev/percona-toolkit/fix-empty-table-bug-987393

« back to all changes in this revision

Viewing changes to t/lib/bash/summary_common.sh

  • Committer: Daniel Nichter
  • Date: 2012-04-03 16:14:55 UTC
  • mfrom: (217.6.22 2.0.3)
  • Revision ID: daniel@percona.com-20120403161455-ntv33vju9o6njtqv
Merge summary-tools-2.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env bash
 
2
 
 
3
plan 10
 
4
 
 
5
TMPDIR="$TEST_TMPDIR"
 
6
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
 
7
 
 
8
. "$LIB_DIR/summary_common.sh"
 
9
 
 
10
p="$TMPDIR/get_var_samples"
 
11
 
 
12
echo "test1    abcdef" > "$p"
 
13
is \
 
14
   "$(get_var test1 "$p")" \
 
15
   "abcdef"                \
 
16
   "Sanity check, get_var works"
 
17
 
 
18
echo "test2    abc def" > "$p"
 
19
is \
 
20
   "$(get_var test2 "$p")" \
 
21
   "abc def"                \
 
22
   "get_var works even if the value has spaces"
 
23
 
 
24
echo "test::1    abcdef" > "$p"
 
25
is \
 
26
   "$(get_var "test::1" "$p")" \
 
27
   "abcdef"                \
 
28
   "get_var works if the 'key' has colons"
 
29
 
 
30
 
 
31
echo "1234/567    qwerty" > "$p"
 
32
is \
 
33
   "$(get_var "1234/567" "$p")" \
 
34
   "qwerty"                \
 
35
   "get_var works if the 'key' has a dash in it"
 
36
 
 
37
 
 
38
echo ".*    some_new_value" >> "$p"
 
39
is \
 
40
   "$(get_var ".*" "$p")" \
 
41
   "some_new_value"                \
 
42
   "get_var treats the variable as a literal, not a regex"
 
43
 
 
44
if get_var "definitely_does_not_exist" "$p" 1>/dev/null ; then
 
45
   pass "get_var always returns true, even for variables that don't exist"
 
46
else
 
47
   fail "get_var should always return true"
 
48
fi
 
49
 
 
50
samples="$PERCONA_TOOLKIT_BRANCH/t/pt-mysql-summary/samples"
 
51
 
 
52
is \
 
53
   "$(get_var "table_open_cache" "$samples/temp002/mysql-variables")" \
 
54
   "400"                \
 
55
   "get_var works on a variables dump"
 
56
 
 
57
is \
 
58
   "$(get_var "Open_tables" "$samples/temp002/mysql-status")" \
 
59
   "40"                \
 
60
   "get_var works on a status dump"
 
61
 
 
62
cat <<EOF > "$p"
 
63
internal::nice_of_2750    0
 
64
internal::nice_of_2571    0
 
65
internal::nice_of_2406    0
 
66
 
 
67
EOF
 
68
 
 
69
is \
 
70
   "$(get_var "internal::nice_of_2750" "$p")" \
 
71
   "0"                \
 
72
   "get_var doesn't get confused if \$2 is also found inside \$1"
 
73
 
 
74
# setup_data_dir
 
75
 
 
76
dies_ok \
 
77
   "setup_data_dir $PERCONA_TOOLKIT_BRANCH" \
 
78
   "setup_data_dir dies if passed a populated directory" 2>/dev/null
 
79