File: allexamples.perl

package info (click to toggle)
gecode 6.1.0-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 26,372 kB
  • sloc: cpp: 328,292; perl: 2,048; makefile: 1,793; sh: 214
file content (60 lines) | stat: -rw-r--r-- 1,437 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl -w
use File::Basename;

$directory = $ARGV[0];

open (EXAMPLES, "find $directory/examples -maxdepth 1 -type f ! -name '*.*' |");

while (my $x = <EXAMPLES>) {
  chomp($x);
  my ($filename, $dummydir, $suffix) = fileparse($x);

  open (HELP, "$x -help 2>&1 |");
  my @prop;
  my @model;
  while (my $l = <HELP>) {
    if ($l =~ /-propagation \((.*)\)/) {
      $l1 = $1;
      $l1 =~ s/ //g;
      @prop = split(/,/, $l1);
    } elsif ($l =~ /-model \((.*)\)/) {
      $l1 = $1;
      $l1 =~ s/ //g;
      @model = split(/,/, $l1);
    }
  }
  if (scalar(@prop) == 0) {
    if (scalar(@model) == 0) {
      runexample($directory,$filename);
    } else {
      foreach $m (@model) {
        runexample($directory,"$filename -model $m");
      }
    }
  } else {
    foreach $p (@prop) {
      if (scalar(@model) == 0) {
        runexample($directory,"$filename -propagation $p");
      } else {
        foreach $m (@model) {
          runexample($directory,"$filename -propagation $p -model $m");
        }
      }
    }
  }
  close (HELP);
}
close (EXAMPLES);

sub runexample {
  $directory = $_[0];
  $filename = $_[1];
  print "------------------------------------------------------------\n";
  print "Running $filename\n";
  open (EX, "$directory/examples/$filename -time 120000 2>&1 |");
  while ($l = <EX>) {
    print $l;
  }
  close (EX);
  print "------------------------------------------------------------\n";
}