-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
01_compile_all_test_targets.t
103 lines (93 loc) · 3.44 KB
/
01_compile_all_test_targets.t
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
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl -w
use Test::More;
use lib "$ENV{'PAPARAZZI_SRC'}/tests/lib";
use XML::Simple;
use Program;
use Data::Dumper;
use Config;
$|++;
my $examples = XMLin("$ENV{'PAPARAZZI_SRC'}/conf/tests_conf.xml");
use Data::Dumper;
ok(1, "Parsed the tests_conf file");
foreach my $example (sort keys%{$examples->{'aircraft'}})
{
#next unless $example =~ m#easystar#i;
my $airframe = $examples->{'aircraft'}->{$example}->{'airframe'};
my $airframe_config = XMLin("$ENV{'PAPARAZZI_SRC'}/conf/$airframe");
foreach my $process (sort keys %{$airframe_config->{'firmware'}})
{
if ($process =~ m#setup|fixedwing|rotorcraft|lisa_test_progs#)
{
#warn "EX: [$example] ". Dumper($airframe_config->{'firmware'}->{$process}->{'target'});
foreach my $target (sort keys %{$airframe_config->{'firmware'}->{$process}->{'target'}})
{
next unless scalar $airframe_config->{'firmware'}->{$process}->{'target'}->{$target}->{'board'};
#warn "EXAMPLE: [$example] TARGET: [$target]\n";
my $make_options = "AIRCRAFT=$example clean_ac $target.compile";
my $output = run_program(
"Attempting to build the firmware $target for the airframe $example.",
$ENV{'PAPARAZZI_SRC'},
"make $make_options",
$ENV->{'TEST_VERBOSE'},1);
unlike($output, '/\bError\b/i', "The make output for the $example target $target does not contain the word \"Error\"");
}
}
elsif ($process =~ m#target#)
{
#warn "EXT: [$example] ". Dumper($airframe_config->{'firmware'}->{$process});
foreach my $target (sort keys %{$airframe_config->{'firmware'}->{$process}})
{
next unless scalar $airframe_config->{'firmware'}->{$process}->{$target}->{'board'};
#warn "EXAMPLET: [$example] TARGET: [$target]\n";
my $make_options = "AIRCRAFT=$example clean_ac $target.compile";
my $output = run_program(
"Attempting to build the firmware $target for the airframe $example.",
$ENV{'PAPARAZZI_SRC'},
"make $make_options",
$ENV->{'TEST_VERBOSE'},1);
unlike($output, '/\bError\b/i', "The make output for the $example target $target does not contain the word \"Error\"");
}
}
}
}
done_testing();
################################################################################
# functions used by this test script.
sub run_program
{
my $message = shift;
my $dir = shift;
my $command = shift;
my $verbose = shift;
my $dont_fail_on_error = shift;
warn "$message\n" if $verbose;
if (defined $dir)
{
$command = "cd $dir;" . $command;
}
my $prog = new Program("bash");
my $fh = $prog->open("-c \"$command\"");
warn "Running command: \"". $prog->last_command() ."\"\n" if $verbose;
$fh->autoflush(1);
my @output;
while (<$fh>)
{
warn $_ if $verbose;
chomp $_;
push @output, $_;
}
$fh->close;
my $exit_status = $?/256;
unless ($exit_status == 0)
{
if ($dont_fail_on_error)
{
warn "Error: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
}
else
{
die "Error: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
}
}
return wantarray ? @output : join "\n", @output;
}