Debian Codegraph @

mysql-test/suite/memcached/include/ibd2sdi_common.inc

raw
1 # This include file needs two variables to be set
2 # IBD_FILE The ibd file to be used by tool
3 # DUMP_FILE The output file generated from tool
4 # SKIP_LARGE_DATA_FILE The file prepended with ">" to redirect large output from SDI
5 # For example: --let SKIP_LARGE_DATA_FILE = > $MYSQLD_VARDIR/log/ibd2sdi-large.err
6
7 --echo # 1. Read SDI with long option
8 --exec $IBD2SDI --skip-pretty $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
9
10 --echo # 3. Read with specific id & type (long option)
11 --exec $IBD2SDI --skip-pretty --id=3 --type=3 $IBD_FILE 2>&1
12
13 --echo # 4. Read with specific id & type (short option)
14 --exec $IBD2SDI --skip-pretty -i 4 -t 4 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
15
16 --echo # 5. Read with skip data
17 --exec $IBD2SDI --skip-data $IBD_FILE $SKIP_LARGE_DATA_FILE
18 --exec $IBD2SDI -s $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
19
20 --echo # 6. Read SDI and dump into FILE
21 --exec $IBD2SDI --skip-pretty --dump-file=$DUMP_FILE $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
22 if (!$SKIP_LARGE_DATA_FILE) {
23 --cat_file $DUMP_FILE
24 }
25
26 --echo # 7. Read SDI and dump into FILE using short option
27 --exec $IBD2SDI --skip-pretty -s -d $DUMP_FILE $IBD_FILE 2>&1
28 if (!$SKIP_LARGE_DATA_FILE) {
29 --cat_file $DUMP_FILE
30 }
31
32 --echo # 8. Print all records matching type (short option)
33 --exec $IBD2SDI --skip-pretty -t 0 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
34
35 --echo # 9. Print all records matching id (long option)
36 --exec $IBD2SDI --skip-pretty --id=3 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
37
38 --echo # 10. Print version
39 --exec $IBD2SDI -v > $MYSQLTEST_VARDIR/tmp/ver_output
40
41 perl;
42 use strict;
43 use warnings;
44 use File::Copy;
45 my $dir = $ENV{'MYSQLTEST_VARDIR'};
46 my $in_file= $dir ."/tmp/ver_output";
47 # open file in write mode
48 open (IN_FILE, "<", $in_file) or die $!;
49
50 while(<IN_FILE>)
51 {
52 s/^(.*)ibd2sdi(\s+)(Ver\s\d\.\d\.\d+(-.*))(\s+for.*)$/IBD2SDI Ver #.#.#/;
53 print $_;
54 }
55 close(IN_FILE);
56 EOF
57 --remove_file $MYSQLTEST_VARDIR/tmp/ver_output
58
59 --echo # 11. Print help
60 --exec $IBD2SDI --help > $MYSQLTEST_VARDIR/tmp/help_output
61
62 perl;
63 use strict;
64 use warnings;
65 use File::Copy;
66 my $dir = $ENV{'MYSQLTEST_VARDIR'};
67 my $in_file= $dir ."/tmp/help_output";
68 # open file in write mode
69 open (IN_FILE, "<", $in_file) or die $!;
70
71 while(<IN_FILE>)
72 {
73 # Replacing path in Version output
74 s/^(.*)ibd2sdi(\s+)(Ver\s\d\.\d\.\d+(-.*))(\s+for.*)$/IBD2SDI Ver #.#.#/;
75 # Replacing path in Other lines
76 s/^Usage:(\s+.*)ibd2sdi(.*)$/IBD2SDI$2/;
77 s/(Copyright\s\(c\))\s([0-9]*),\s([0-9]*)(.*)/$1 YEAR, YEAR$4/g;
78
79 unless ($_=~ /^.*de?bug.*$/) {
80 print $_;
81 }
82 }
83 close(IN_FILE);
84 EOF
85 --remove_file $MYSQLTEST_VARDIR/tmp/help_output
86
87 --echo # 12. Print all records
88 --exec $IBD2SDI --skip-pretty $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
89
90 --echo # 13. Retrieve explicit id & type
91 --exec $IBD2SDI --skip-pretty --id=3 --type=3 $IBD_FILE 2>&1
92
93 --echo # 14. Skip data and retrieve
94 --exec $IBD2SDI --skip-pretty --skip-data $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
95
96 --echo # 15. Dump all records into outfile
97 --exec $IBD2SDI --skip-pretty --dump-file=$DUMP_FILE $IBD_FILE
98 if (!$SKIP_LARGE_DATA_FILE) {
99 --cat_file $DUMP_FILE
100 }
101
102 --echo # 16. Print all records matching type (short option)
103 --exec $IBD2SDI --skip-pretty -t 0 $IBD_FILE 2>&1
104
105 --echo # 17. Print all records matching id (long option)
106 --exec $IBD2SDI --skip-pretty --id=3 $IBD_FILE 2>&1
107
108 --echo # 18. Pass --no-check & --strict-check together
109 --error 1
110 --exec $IBD2SDI --skip-pretty --no-check --strict-check="crc32" $IBD_FILE 2>&1
111
112 --replace_result $IBD2SDI IBD2SDI
113 --error 1
114 --exec $IBD2SDI --type=@ $IBD_FILE 2>&1
115 --replace_result $IBD2SDI IBD2SDI
116 --error 1
117 #with $IBD_FILE argument to -t missing:
118 --exec $IBD2SDI -t 2>&1
119 --replace_result $IBD2SDI IBD2SDI
120 --error 1
121 --exec $IBD2SDI -t = $IBD_FILE 2>&1
122
123 --echo # 22. Test --type option with
124
125 --echo # 22.1 non numeric/Alphanumeric
126 --replace_result $IBD2SDI IBD2SDI
127 --error 1
128 --exec $IBD2SDI --type=a $IBD_FILE 2>&1
129 --replace_result $IBD2SDI IBD2SDI
130 --error 1
131 --exec $IBD2SDI -t b $IBD_FILE 2>&1
132
133 --echo # 22.2 numbers with +/-
134 --exec $IBD2SDI --skip-pretty --type=+0 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
135 --exec $IBD2SDI --skip-pretty --type=-0 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
136 --exec $IBD2SDI --skip-pretty --type=+1 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
137 --exec $IBD2SDI --skip-pretty --type=-1 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
138 --exec $IBD2SDI --skip-pretty --type=-15 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
139 --exec $IBD2SDI --skip-pretty --type=+16 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
140
141 --echo # 22.4 with no permitted values
142 --exec $IBD2SDI --skip-pretty --type=14 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
143 --exec $IBD2SDI --skip-pretty --type=-14 $IBD_FILE $SKIP_LARGE_DATA_FILE 2>&1
144
145 --echo # 22.5 with very long value
146 --replace_result $IBD2SDI IBD2SDI
147 --error 1
148 --exec $IBD2SDI --type=14324932470234893204293032 $IBD_FILE 2>&1
149
150 --echo # 22.6 with blank value
151 --replace_result $IBD2SDI IBD2SDI
152 --error 1
153 --exec $IBD2SDI --type= $IBD_FILE 2>&1
154
155 --echo # 22.7 value with spaces
156 --replace_result $IBD2SDI IBD2SDI
157 --error 1
158 --exec $IBD2SDI --type= 1 $IBD2SDI 2>&1
159
160 --echo # 23. Test for reading form more than type example (invalid): -t 0,1
161 --replace_result $IBD2SDI IBD2SDI
162 --error 1
163 --exec $IBD2SDI --type=0,1 $IBD_FILE 2>&1
164 --replace_result $IBD2SDI IBD2SDI
165 --error 1
166 --exec $IBD2SDI -t 2,3 $IBD_FILE 2>&1
167
168 --echo # 24. With misspelled --type
169 --replace_result $IBD2SDI IBD2SDI
170 --error 1
171 --exec $IBD2SDI --tpe=0 $IBD2SDI 2>&1
172
173 --echo # 25. With Invalid file types
174 --echo # 25.1 With non IBD file
175
176 --write_file $MYSQL_TMP_DIR/invalid_file.txt
177 test
178 EOF
179 --replace_result $IBD2SDI IBD2SDI
180 --error 1
181 --exec $IBD2SDI $MYSQL_TMP_DIR/invalid_file.txt 2>&1
182 --remove_file $MYSQL_TMP_DIR/invalid_file.txt
183
184 --echo # 25.2 with non existant file
185 --replace_result $IBD2SDI IBD2SDI
186 --error 1
187 --exec $IBD2SDI non_existant_file.txt 2>&1
188
189 --echo # 25.3 with empty file
190
191 --write_file $MYSQL_TMP_DIR/empty_file.txt
192 EOF
193 --replace_result $IBD2SDI IBD2SDI
194 --error 1
195 --exec $IBD2SDI $MYSQL_TMP_DIR/empty_file.txt 2>&1
196 --remove_file $MYSQL_TMP_DIR/empty_file.txt