File: run_tests

package info (click to toggle)
creduce 2.6.0-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 4,328 kB
  • ctags: 4,312
  • sloc: cpp: 23,740; ansic: 6,970; sh: 4,827; perl: 2,680; lex: 441; makefile: 426
file content (90 lines) | stat: -rwxr-xr-x 2,049 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env perl
##
## Copyright (c) 2012, 2015 The University of Utah
## All rights reserved.
##
## This file is distributed under the University of Illinois Open Source
## License.  See the file COPYING for details.

###############################################################################

use strict;
use warnings;

use File::Temp qw/ tempfile tempdir /;
use Cwd;

my @tests = (
    { "name" => "test0",
      "unreduced" => "file1.c",
      "test_script" => "test0.sh",
    },
    { "name" => "test1",
      "unreduced" => "file2.c",
      "test_script" => "test1.sh",
    },
    { "name" => "test2",
      "unreduced" => "file1.c",
      "test_script" => "test2.sh",
    },
    { "name" => "test3",
      "unreduced" => "file2.c",
      "test_script" => "test3.sh",
    },
    { "name" => "test4",
      "unreduced" => "file2.c",
      "test_script" => "test4.sh",
    },
    { "name" => "test5",
      "unreduced" => "file2.c",
      "test_script" => "test5.sh",
    },
    { "name" => "test6",
      "unreduced" => "file3.c",
      "test_script" => "test6.sh",
    },
    { "name" => "test7",
      "unreduced" => "file3.c",
      "test_script" => "test7.sh",
    },
    );

sub run_test ($) {
    (my $num) = @_;

    my $tref = $tests[$num];
    my %test = %{$tref};
    
    my $name = $test{"name"};
    my $unreduced = $test{"unreduced"};
    my $test_script = $test{"test_script"};
    die unless (defined ($name) &&
		defined ($unreduced) &&
		defined ($test_script));

    my $test_dir = getcwd();
    my $temp_dir = tempdir( "tmp_${name}_XXXXX", 
		       DIR => $test_dir,
		       CLEANUP => 0 );

    print "\n\n===== running test $num in $temp_dir =====\n\n\n";

    chdir $temp_dir or die;

    system "cp ../$unreduced .";
    system "../../creduce/creduce --die-on-pass-bug ../${test_script} $unreduced";
    
    chdir $test_dir or die;
}

if (scalar(@ARGV)>0) {
    foreach my $i (@ARGV) {
	run_test ($i);
    }
} else {
    for (my $i=0; $i<scalar(@tests); $i++) {
	if ($i != 5) {
	    run_test ($i);
	}
    }
}