#! /usr/bin/perl # Generate variants of parallel_schedule file to verify that there are # no order dependencies between tests executed in parallel. # Usage: sched_variants input_file output_prefix # Output files are named with 'output_prefix' suffixed .1, .2, etc. die "Usage: sched_variants input_file output_prefix\n" if ($#ARGV != 1); $infile = $ARGV[0]; $outprefix = $ARGV[1]; $outcount = 0; # number of output files created # We scan the input file repeatedly. On each pass we generate two # output files, one where the k'th entry of each parallel test set # has been extracted and forced to run first, and one where it's been # forced to run last. The number of passes needed is the same as the # largest number of tests in a parallel test set. $k = 1; # test index we are currently hacking $more = 1; # true if we need another pass while ($more) { $more = 0; # until proven differently open(INFILE, $infile) || die "$infile: $!\n"; $outcount++; $outbefore = $outprefix . "." . $outcount; open(OUTBEFORE, "> $outbefore") || die "$outbefore: $!\n"; $outcount++; $outafter = $outprefix . "." . $outcount; open(OUTAFTER, "> $outafter") || die "$outafter: $!\n"; while () { if (! /^test:/) { # comment line print OUTBEFORE $_; print OUTAFTER $_; next; } @tests = split; shift(@tests); # remove test: if ($#tests < $k-1 || $#tests == 0) { # too few tests in this set, just repeat as-is print OUTBEFORE $_; print OUTAFTER $_; next; } if ($#tests >= $k) { $more = 1; # need more passes to process this set } @thistest = splice(@tests, $k-1, 1); print OUTBEFORE "test: @thistest\n"; print OUTBEFORE "test: @tests\n"; print OUTAFTER "test: @tests\n"; print OUTAFTER "test: @thistest\n"; } close OUTBEFORE; close OUTAFTER; close INFILE; $k++; } print "$outcount test files generated.\n"; exit 0;