-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathmkdot.pl
More file actions
executable file
·54 lines (42 loc) · 1.05 KB
/
mkdot.pl
File metadata and controls
executable file
·54 lines (42 loc) · 1.05 KB
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
#!/usr/bin/perl -w
# This currently won't parse the test output, as showIds isn't enabled.
use strict;
my %info;
sub add_info {
my $id = shift;
my $str = shift;
if (defined($info{$id})) {
if ($info{$id} ne $str) {
die "Mismatch";
}
} else {
$info{$id} = $str;
}
}
open OUT, "> cfg.dot" or die "open failed: $!";
print OUT "digraph G {\n";
open IN, "< cfg.expected" or die "open failed: $!";
while (<IN>) {
if (/^\| [0-9]+ \| [0-9]+ \| ([0-9]+) \| ([^|]+) \| ([0-9]+) \| ([^|]+) \|$/) {
my $srcid = $1;
my $srcstr = $2;
my $dstid = $3;
my $dststr = $4;
&add_info($srcid, $srcstr);
&add_info($dstid, $dststr);
print OUT "n$srcid -> n$dstid;\n";
} elsif (/^$/) {
# Nothing
} else {
die "Bad line: $_";
}
}
close IN;
for my $id (keys %info) {
my $str = $info{$id};
print OUT qq(n$id [label="$str"];\n);
}
print OUT "}\n";
close OUT;
system ("dot", "-Tpng", "cfg.dot", "-o", "cfg.png") == 0
or die "dot failed: $?";