From 18c443d3a8564da46c3fad1e4cc36ad34b0947be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 17 Oct 2013 14:58:24 +0200 Subject: [PATCH] Fix dependency issues in the test framework When a constant in a test case is a symbol (either preprocessor or enum value), enclose the corresponding translation code in the ifdef's attached the test function, so that it compiles even if it isn't defined. --- tests/scripts/generate_code.pl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/scripts/generate_code.pl b/tests/scripts/generate_code.pl index 1e33ac612..6c2ac6e0f 100755 --- a/tests/scripts/generate_code.pl +++ b/tests/scripts/generate_code.pl @@ -144,7 +144,12 @@ while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\// my @res = $test_data =~ /^$mapping_regex/msg; foreach my $value (@res) { - $mapping_values{$value} = 1 if ($value !~ /^\d+$/); + next unless ($value !~ /^\d+$/); + if ( $mapping_values{$value} ) { + ${ $mapping_values{$value} }{$function_pre_code} = 1; + } else { + $mapping_values{$value} = { $function_pre_code => 1 }; + } } } @@ -204,13 +209,23 @@ END # Make mapping code while( my ($key, $value) = each(%mapping_values) ) { - $mapping_code .= << "END"; + my $key_mapping_code = << "END"; if( strcmp( str, "$key" ) == 0 ) { *value = ( $key ); return( 0 ); } END + + # handle depenencies, unless used at least one without depends + if ($value->{""}) { + $mapping_code .= $key_mapping_code; + next; + } + for my $ifdef ( keys %$value ) { + (my $endif = $ifdef) =~ s!ifdef!endif //!g; + $mapping_code .= $ifdef . $key_mapping_code . $endif; + } } $dispatch_code =~ s/^(.+)/ $1/mg;