Skip to content

Commit

Permalink
[test] update compile_all_aircrafts test
Browse files Browse the repository at this point in the history
Also replace LOCAL_CFLAGS (which wasn't used anymore) with USER_CFLAGS (and add where missing).
Now you can e.g. test compile all aircrafts/targets in your conf and add extra flags like treating warnings as errors:

$ J=AUTO USER_CFLAGS=-Werror prove conf/examples
  • Loading branch information
flixr committed Nov 7, 2014
1 parent 7b892a5 commit 8df5ffb
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion conf/Makefile.chibios-libopencm3
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ DLIBS = -lm -lopencm3_stm32f4
#

# List all user C define here, like -D_DEBUG=1
UDEFS = $($(TARGET).CFLAGS) $(LOCAL_CFLAGS) -DUSE_OCM3_SYSTICK_INIT=0
UDEFS = $($(TARGET).CFLAGS) $(USER_CFLAGS) -DUSE_OCM3_SYSTICK_INIT=0

# Define ASM defines here
UADEFS =
Expand Down
2 changes: 1 addition & 1 deletion conf/Makefile.geode
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CFLAGS += -mtune=geode # optimize for geode
CFLAGS + = -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wmissing-prototypes -Wnested-externs
CFLAGS += $(CSTANDARD)
CFLAGS += $($(TARGET).CFLAGS) $(LOCAL_CFLAGS)
CFLAGS += $($(TARGET).CFLAGS) $(USER_CFLAGS)

#Additional libraries.
MATH_LIB = -lm
Expand Down
2 changes: 1 addition & 1 deletion conf/Makefile.jsbsim
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Q=@
# Compilation flags
#

CFLAGS = -W -Wall $(INCLUDES) -I$(PAPARAZZI_SRC)/sw/airborne/$(SRC_ARCH) $($(TARGET).CFLAGS) $(LOCAL_CFLAGS) -O$(OPT)
CFLAGS = -W -Wall $(INCLUDES) -I$(PAPARAZZI_SRC)/sw/airborne/$(SRC_ARCH) $($(TARGET).CFLAGS) $(USER_CFLAGS) -O$(OPT)

LDFLAGS = -lm $($(TARGET).LDFLAGS)

Expand Down
2 changes: 1 addition & 1 deletion conf/Makefile.lpc21
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CFLAGS += -Wshadow
CFLAGS += -Wnested-externs

CFLAGS += $(CSTANDARD)
CFLAGS += $($(TARGET).CFLAGS) $(LOCAL_CFLAGS)
CFLAGS += $($(TARGET).CFLAGS) $(USER_CFLAGS)

# Assembler flags.
ASFLAGS = -Wa,-adhlns=$(OBJDIR)/$(notdir $(<:.S=.lst))
Expand Down
4 changes: 2 additions & 2 deletions conf/Makefile.nps
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Q=@
CFLAGS = -W -Wall
CFLAGS += $(INCLUDES)
CFLAGS += $($(TARGET).CFLAGS)
CFLAGS += $(LOCAL_CFLAGS)
CFLAGS += $(USER_CFLAGS)
CFLAGS += -O$(OPT)
CFLAGS += -g
CFLAGS += -std=gnu99
Expand All @@ -44,7 +44,7 @@ CFLAGS += $(shell pkg-config --cflags-only-I ivy-glib)
CXXFLAGS = -W -Wall
CXXFLAGS += $(INCLUDES)
CXXFLAGS += $($(TARGET).CFLAGS)
CXXFLAGS += $(LOCAL_CFLAGS)
CXXFLAGS += $(USER_CFLAGS)
CXXFLAGS += -O$(OPT)
CXXFLAGS += -g
CXXFLAGS += $(shell pkg-config --cflags-only-I ivy-glib)
Expand Down
2 changes: 2 additions & 0 deletions conf/Makefile.omap
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CFLAGS += -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wmissing-prototypes -Wnested-externs
CFLAGS += $(CSTANDARD)
CFLAGS += $($(TARGET).CFLAGS)
CFLAGS += $(USER_CFLAGS)

LDFLAGS += -lm

Expand All @@ -62,6 +63,7 @@ CXXFLAGS += -g -ffunction-sections -fdata-sections
CXXFLAGS += -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=vfp -march=armv7-a
CXXFLAGS += -Wall -Wextra
CXXFLAGS += $($(TARGET).CXXFLAGS)
CXXFLAGS += $(USER_CFLAGS)

SRC_C_OMAP = $($(TARGET).srcs)
OBJ_C_OMAP = $(SRC_C_OMAP:%.c=$(OBJDIR)/%.o)
Expand Down
2 changes: 1 addition & 1 deletion conf/Makefile.pentium-m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CFLAGS += -m32
CFLAGS += -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wmissing-prototypes -Wnested-externs
CFLAGS += $(CSTANDARD)
CFLAGS += $($(TARGET).CFLAGS) $(LOCAL_CFLAGS)
CFLAGS += $($(TARGET).CFLAGS) $(USER_CFLAGS)

#Additional libraries.
MATH_LIB = -lm
Expand Down
2 changes: 1 addition & 1 deletion conf/Makefile.sim
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ INCLUDES += -I $(shell $(OCAMLC) -where)
CFLAGS = -W -Wall
CFLAGS += $(INCLUDES)
CFLAGS += $($(TARGET).CFLAGS)
CFLAGS += $(LOCAL_CFLAGS)
CFLAGS += $(USER_CFLAGS)
CFLAGS += -fPIC
CFLAGS += -O$(OPT)
CFLAGS += -g
Expand Down
2 changes: 2 additions & 0 deletions conf/Makefile.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ CFLAGS += -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -Wshadow
CFLAGS += -Wnested-externs

CFLAGS += $(USER_CFLAGS)

#CFLAGS += -fno-diagnostics-show-caret

ifneq ($(ARCH_L), )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#!/usr/bin/perl -w

#
# Reads conf/conf.xml (can be symlink to e.g. conf/conf_tests.xml)
# and compiles all targets of all aircrafts.
#
# Mandatory environment variables:
# PAPARAZZI_SRC : path to paparazzi source directory
# PAPARAZZI_HOME : path to paparazz home directory containing the conf
#
# optional environment variables:
# TEST_VERBOSE : set to 1 to print the compile output even if there was no error
#
# environment variables passed on to make:
# J=AUTO : detect number of CPUs to set jobs for parallel compilation
#
# Example on how to test compile all aircrafts/targets in your current conf.xml
# with parallel compilation and treating all warnings as errors:
# J=AUTO USER_CFLAGS=-Werror prove tests/examples
#

use Test::More;
use lib "$ENV{'PAPARAZZI_SRC'}/tests/lib";
use XML::Simple;
Expand All @@ -9,28 +28,28 @@ use Config;

$|++;
my $xmlSimple = XML::Simple->new(ForceArray => 1);
my $examples = $xmlSimple->XMLin("$ENV{'PAPARAZZI_SRC'}/conf/conf.xml");
my $conf = $xmlSimple->XMLin("$ENV{'PAPARAZZI_HOME'}/conf/conf.xml");

ok(1, "Parsed the tests configuration file");
foreach my $example (sort keys%{$examples->{'aircraft'}})
ok(1, "Parsed the configuration file");
foreach my $aircraft (sort keys%{$conf->{'aircraft'}})
{
my $airframe = $examples->{'aircraft'}->{$example}->{'airframe'};
my $airframe_config = $xmlSimple->XMLin("$ENV{'PAPARAZZI_SRC'}/conf/$airframe");
my $airframe = $conf->{'aircraft'}->{$aircraft}->{'airframe'};
my $airframe_config = $xmlSimple->XMLin("$ENV{'PAPARAZZI_HOME'}/conf/$airframe");
foreach my $process (sort keys %{$airframe_config->{'firmware'}})
{
#warn "EX: [$example] ". Dumper($airframe_config->{'firmware'}->{$process}->{'target'});
#warn "EX: [$aircraft] ". Dumper($airframe_config->{'firmware'}->{$process}->{'target'});
foreach my $target (sort keys %{$airframe_config->{'firmware'}->{$process}->{'target'}})
{
#warn "EXAMPLE: [$example] TARGET: [$target]\n";
my $make_options = "AIRCRAFT=$example clean_ac $target.compile";
#warn "AIRCRAFT: [$aircraft] TARGET: [$target]\n";
my $make_options = "AIRCRAFT=$aircraft clean_ac $target.compile";
my ($exit_status, $output) = run_program(
"Attempting to build the firmware $target for the aircraft $example.",
"Attempting to build the firmware $target for the aircraft $aircraft.",
$ENV{'PAPARAZZI_SRC'},
"make $make_options",
$ENV{'TEST_VERBOSE'},1);
# print output if it failed and we didn't already print it in verbose mode
warn "$output\n" if $exit_status && !$ENV{'TEST_VERBOSE'};
ok($exit_status == 0, "Compile aircraft: $example, target: $target");
ok($exit_status == 0, "Compile aircraft: $aircraft, target: $target");
}
}
}
Expand Down Expand Up @@ -68,13 +87,14 @@ sub run_program
my $exit_status = $?/256;
unless ($exit_status == 0)
{
my $err_msg = "\nError: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
if ($dont_fail_on_error)
{
warn "\nError: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
warn $err_msg;
}
else
{
die "\nError: The command \"". $prog->last_command() ."\" failed to complete successfully. Exit status: $exit_status\n";
die $err_msg;
}
}
my $output_string = join "\n", @output;
Expand Down

0 comments on commit 8df5ffb

Please sign in to comment.