[gnumeric] t8010: define corpus "full" and "random:N".



commit d89911449788a400feb0944adfa1d1aa05d8171f
Author: Morten Welinder <terra gnome org>
Date:   Fri Apr 10 22:34:47 2015 -0400

    t8010: define corpus "full" and "random:N".
    
    Full corpus runs for too long, so default is random:5.

 test/GnumericTest.pm       |   93 ++++++++++++++++++++++++++++++++++++++++++-
 test/t8010-valgrind-ods.pl |   60 +---------------------------
 2 files changed, 93 insertions(+), 60 deletions(-)
---
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index de872bd..789741c 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -12,10 +12,10 @@ $| = 1;
                            test_importer test_exporter test_roundtrip
                           test_ssindex sstest test_command message subtest
                           $ssconvert $sstest $ssdiff $topsrc $top_builddir
-                          $subtests $samples $PERL);
+                          $subtests $samples corpus $PERL);
 @GnumericTest::EXPORT_OK = qw(junkfile);
 
-use vars qw($topsrc $top_builddir $samples $default_subtests $subtests $PERL $verbose);
+use vars qw($topsrc $top_builddir $samples $default_subtests $default_corpus $PERL $verbose);
 use vars qw($ssconvert $ssindex $sstest $ssdiff);
 use vars qw($normalize_gnumeric);
 
@@ -35,7 +35,9 @@ $ssdiff = "$top_builddir/src/ssdiff";
 $normalize_gnumeric = "$PERL $topsrc/test/normalize-gnumeric";
 $verbose = 0;
 $default_subtests = '*';
-$subtests = undef;
+my $subtests = undef;
+$default_corpus = 'full';
+my $user_corpus = undef;
 
 # -----------------------------------------------------------------------------
 
@@ -165,6 +167,84 @@ sub subtest {
 
 # -----------------------------------------------------------------------------
 
+my @full_corpus =
+    ("$samples/excel/address.xls",
+     "$samples/excel/bitwise.xls",
+     "$samples/excel/chart-tests-excel.xls",
+     "$samples/excel/datefuns.xls",
+     "$samples/excel/dbfuns.xls",
+     "$samples/excel/engfuns.xls",
+     "$samples/excel/finfuns.xls",
+     "$samples/excel/functions.xls",
+     "$samples/excel/infofuns.xls",
+     "$samples/excel/logfuns.xls",
+     "$samples/excel/lookfuns2.xls",
+     "$samples/excel/lookfuns.xls",
+     "$samples/excel/mathfuns.xls",
+     "$samples/excel/objs.xls",
+     "$samples/excel/operator.xls",
+     "$samples/excel/sort.xls",
+     "$samples/excel/statfuns.xls",
+     "$samples/excel/textfuns.xls",
+     "$samples/excel/yalta2008.xls",
+     "$samples/excel12/cellstyle.xlsx",
+     "$samples/crlibm.gnumeric",
+     "$samples/amath.gnumeric",
+     "$samples/gamma.gnumeric",
+     "$samples/linest.xls",
+     "$samples/vba-725220.xls",
+     "$samples/sumif.xls",
+     "$samples/array-intersection.xls",
+     "$samples/arrays.xls",
+     "$samples/docs-samples.gnumeric",
+     "$samples/ftest.xls",
+     "$samples/ttest.xls",
+     "$samples/chitest.xls",
+     "$samples/numbermatch.gnumeric",
+     "$samples/solver/afiro.mps",
+     "$samples/solver/blend.mps",
+     "$samples/auto-filter-tests.gnumeric",
+     "$samples/cell-comment-tests.gnumeric",
+     "$samples/colrow-tests.gnumeric",
+     "$samples/cond-format-tests.gnumeric",
+     "$samples/formula-tests.gnumeric",
+     "$samples/graph-tests.gnumeric",
+     "$samples/merge-tests.gnumeric",
+     "$samples/names-tests.gnumeric",
+     "$samples/number-tests.gnumeric",
+     "$samples/object-tests.gnumeric",
+     "$samples/page-setup-tests.gnumeric",
+     "$samples/rich-text-tests.gnumeric",
+     "$samples/sheet-formatting-tests.gnumeric",
+     "$samples/solver-tests.gnumeric",
+     "$samples/split-panes-tests.gnumeric",
+     "$samples/string-tests.gnumeric",
+     "$samples/merge-tests.gnumeric",
+     "$samples/style-tests.gnumeric",
+     "$samples/validation-tests.gnumeric",
+    );
+
+sub corpus {
+    my ($q) = @_;
+
+    my $corpus = ($user_corpus || $default_corpus);
+    if ($corpus eq 'full') {
+       return @full_corpus;
+    } elsif ($corpus =~ /^random:(\d+)$/) {
+       my $n = $1;
+       my @corpus = grep { -r $_; } @full_corpus;
+       while ($n < @corpus) {
+           my $i = int (rand() * @corpus);
+           splice @corpus, $i, 1;
+       }
+       return @corpus;
+    } else {
+       die "Invalid corpus specification\n";
+    }
+}
+
+# -----------------------------------------------------------------------------
+
 sub test_command {
     my ($cmd,$test) = @_;
 
@@ -715,6 +795,8 @@ $ENV{'LC_ALL'} = 'C';
 # libgsf listens for this
 delete $ENV{'WINDOWS_LANGUAGE'};
 
+my $seed = time();
+
 while (1) {
     if (@ARGV && $ARGV[0] eq '--verbose') {
        $verbose = 1;
@@ -723,9 +805,14 @@ while (1) {
     } elsif (@ARGV > 1 && $ARGV[0] eq '--subtests') {
        scalar shift @ARGV;
        $subtests = shift @ARGV;
+    } elsif (@ARGV > 1 && $ARGV[0] eq '--corpus') {
+       scalar shift @ARGV;
+       $user_corpus = shift @ARGV;
     } else {
        last;
     }
 }
 
+srand ($seed);
+
 1;
diff --git a/test/t8010-valgrind-ods.pl b/test/t8010-valgrind-ods.pl
index b61f247..a1b8089 100755
--- a/test/t8010-valgrind-ods.pl
+++ b/test/t8010-valgrind-ods.pl
@@ -5,6 +5,8 @@ use strict;
 use lib ($0 =~ m|^(.*/)| ? $1 : ".");
 use GnumericTest;
 
+$GnumericTest::default_corpus = 'random:5';
+
 &message ("Check the ods importer/exporter with valgrind.");
 
 my $xmllint = &GnumericTest::find_program ("xmllint");
@@ -12,63 +14,7 @@ my $unzip = &GnumericTest::find_program ("unzip");
 
 my $format = "Gnumeric_OpenCalc:odf";
 
-my @sources =
-    ("$samples/graph-tests.gnumeric",
-     "$samples/excel/address.xls",
-     "$samples/excel/bitwise.xls",
-     "$samples/excel/chart-tests-excel.xls",
-     "$samples/excel/datefuns.xls",
-     "$samples/excel/dbfuns.xls",
-     "$samples/excel/engfuns.xls",
-     "$samples/excel/finfuns.xls",
-     "$samples/excel/functions.xls",
-     "$samples/excel/infofuns.xls",
-     "$samples/excel/logfuns.xls",
-     "$samples/excel/lookfuns2.xls",
-     "$samples/excel/lookfuns.xls",
-     "$samples/excel/mathfuns.xls",
-     "$samples/excel/objs.xls",
-     "$samples/excel/operator.xls",
-     "$samples/excel/sort.xls",
-     "$samples/excel/statfuns.xls",
-     "$samples/excel/textfuns.xls",
-     "$samples/excel/yalta2008.xls",
-     "$samples/excel12/cellstyle.xlsx",
-     "$samples/crlibm.gnumeric",
-     "$samples/amath.gnumeric",
-     "$samples/gamma.gnumeric",
-     "$samples/linest.xls",
-     "$samples/vba-725220.xls",
-     "$samples/sumif.xls",
-     "$samples/array-intersection.xls",
-     "$samples/arrays.xls",
-     "$samples/docs-samples.gnumeric",
-     "$samples/ftest.xls",
-     "$samples/ttest.xls",
-     "$samples/chitest.xls",
-     "$samples/numbermatch.gnumeric",
-     "$samples/solver/afiro.mps",
-     "$samples/solver/blend.mps",
-     "$samples/auto-filter-tests.gnumeric",
-     "$samples/cell-comment-tests.gnumeric",
-     "$samples/colrow-tests.gnumeric",
-     "$samples/cond-format-tests.gnumeric",
-     "$samples/formula-tests.gnumeric",
-     "$samples/graph-tests.gnumeric",
-     "$samples/merge-tests.gnumeric",
-     "$samples/names-tests.gnumeric",
-     "$samples/number-tests.gnumeric",
-     "$samples/object-tests.gnumeric",
-     "$samples/page-setup-tests.gnumeric",
-     "$samples/rich-text-tests.gnumeric",
-     "$samples/sheet-formatting-tests.gnumeric",
-     "$samples/solver-tests.gnumeric",
-     "$samples/split-panes-tests.gnumeric",
-     "$samples/string-tests.gnumeric",
-     "$samples/merge-tests.gnumeric",
-     "$samples/style-tests.gnumeric",
-     "$samples/validation-tests.gnumeric",
-    );
+my @sources = &GnumericTest::corpus ();
 my $nskipped = 0;
 my $ngood = 0;
 my $nbad = 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]