summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
authorBjorn Munch <bjorn.munch@oracle.com>2011-05-25 10:58:33 +0200
committerBjorn Munch <bjorn.munch@oracle.com>2011-05-25 10:58:33 +0200
commitd7334d8d859b787bfb4a3dd508618675dd2d85d9 (patch)
tree1a5fcf40567c27b0f390c79dd3d48511c8943f21 /mysql-test/lib
parent829a418a5301ae3c90eab1c69ddbd4d6646ea69a (diff)
downloadmariadb-git-d7334d8d859b787bfb4a3dd508618675dd2d85d9.tar.gz
Bug #11750043 40340: USE GZIPPED CORE FILES TO SAVE SPACE
Use [g]zip on core file if available, ignore if not Skip if running named test, and print a line saying what it compressed.
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/mtr_misc.pl35
1 files changed, 35 insertions, 0 deletions
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index a7b5afd9fd7..e50e8cc77df 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -31,6 +31,7 @@ sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@);
sub mtr_exe_maybe_exists(@);
+sub mtr_compress_file($);
sub mtr_milli_sleep($);
sub start_timer($);
sub has_expired($);
@@ -199,6 +200,40 @@ sub mtr_exe_exists (@) {
}
}
+#
+# Try to compress file using tools that might be available.
+# If zip/gzip is not available, just silently ignore.
+#
+
+sub mtr_compress_file ($) {
+ my ($filename)= @_;
+
+ mtr_error ("File to compress not found: $filename") unless -f $filename;
+
+ my $did_compress= 0;
+
+ if (IS_WINDOWS)
+ {
+ # Capture stderr
+ my $ziperr= `zip $filename.zip $filename 2>&1`;
+ if ($?) {
+ print "$ziperr\n" if $ziperr !~ /recognized as an internal or external/;
+ } else {
+ unlink($filename);
+ $did_compress=1;
+ }
+ }
+ else
+ {
+ my $gzres= system("gzip $filename");
+ $did_compress= ! $gzres;
+ if ($gzres && $gzres != -1) {
+ mtr_error ("Error: have gzip but it fails to compress core file");
+ }
+ }
+ mtr_print("Compressed file $filename") if $did_compress;
+}
+
sub mtr_milli_sleep ($) {
die "usage: mtr_milli_sleep(milliseconds)" unless @_ == 1;