[Compbench-devel] CompBenchmarks++/CBM-PI/t 05-KB-Option-Descriptions.pl, NONE, 1.1 05-KB-Option-Lo
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-04-12 19:58:08
|
Update of /cvsroot/compbench/CompBenchmarks++/CBM-PI/t In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15061 Added Files: 05-KB-Option-Descriptions.pl 05-KB-Option-Logics.pl Log Message: CEL obsoleted. Logic is integrated within descriptions. (Renamed file). --- NEW FILE: 05-KB-Option-Descriptions.pl --- #!/usr/bin/perl -w -I .. # ----------------------------------------------------------------------------- # $Id: 05-KB-Option-Descriptions.pl,v 1.1 2007/04/12 19:58:04 xfred Exp $ # # This is free software. # For details, see the GNU Public License in the COPYING file, or # Look http://www.fsf.org # ----------------------------------------------------------------------------- use strict; use CBM; my $sys; push(@INC, "lib"); require "libtest.pl"; require "compilers.pl"; our %COMPILER_FAKE_INTERFACES; our @COMPILER_FAKE_INTERFACES; our %COMPILER_FAKE_OPTIONS; use Test::More; sub plan_count_tests { my $n = 0; my $c; foreach $c (@COMPILER_FAKE_INTERFACES) { my $expect = compiler_option_number_expected($COMPILER_FAKE_INTERFACES{$c}); $n+=(3+($expect*6)); } return($n); } plan tests => (plan_count_tests()); our $top_srcdir; my $T; my $F; sub test_options_descriptions { my $OD = shift; my $compiler = shift; my $n; $n=$OD->DescriptionNumber(); my $expect = compiler_option_number_expected($compiler); ok($n eq $expect, "$compiler: DescriptionNumber() returns $expect (has $n in " . $OD->DescriptionFile() . ")"); my $i; my %unique_id; my %unique_opt; my $c = (split('-', $compiler))[0]; $c=~ s/g\+\+/gxx/; my $D; for($i=0; $i<$n; $i++) { $D = $OD->Description($i); ok($D->Id() ne "", "$compiler: D$i has identifier"); $unique_id{$D->Id()}++; ok($D->ShortDescription() ne "", "$compiler: D$i has short description"); ok($D->EditorDescription() ne "", "$compiler: D$i has editor's description"); ok($D->Option() ne "", "$compiler: D$i has option (value)"); $unique_id{$D->Option()}++; # !!! # my $fid = "kb-$c-option-" . $D->Id() . "-is-compatible"; # ok(defined(CBM::celFunctionGet($fid)), "$fid defined"); } foreach(keys %unique_id) { ok($unique_id{$_} == 1, "$compiler: option $_ is defined only once"); } foreach(keys %unique_opt) { ok($unique_opt{$_} == 1, "$compiler: value $_ is defined only once"); } } sub test_compilers { my $fake; my $CS = CBM::CompilerSelector->new($sys); foreach(@COMPILER_FAKE_INTERFACES) { $fake="$top_srcdir/reference/$_"; ok(-x $fake, "$fake is an executable"); my $C = $CS->select("$fake"); ok(defined($C)); test_options_descriptions($C->OptionDescriptions(), $COMPILER_FAKE_INTERFACES{$_}); } } $sys = CBM::Init(); test_compilers(); $sys->done(); --- NEW FILE: 05-KB-Option-Logics.pl --- #!/usr/bin/perl -w -I .. use strict; use CBM; my $sys; push(@INC, "lib"); require "libtest.pl"; require "compilers.pl"; our $top_srcdir; our %COMPILER_FAKE_INTERFACES; our @COMPILER_FAKE_INTERFACES; our %COMPILER_FAKE_OPTIONS; use Test::More; sub count_tests_fake_compiler_branches { return((@COMPILER_FAKE_INTERFACES+0)); } sub count_tests_fake_compiler_option_using_vars { my $fake_c; my $c_branch; my $count = 0; foreach $fake_c (@COMPILER_FAKE_INTERFACES) { my %set_variable_count; my $option_set; $c_branch=$COMPILER_FAKE_INTERFACES{$fake_c}; $option_set=$COMPILER_FAKE_OPTIONS{$c_branch}; my $opt; foreach $opt (keys %{$option_set}) { my @operations = @{$option_set->{$opt}}; my $o; foreach $o (@operations) { if ($o =~ /^option-exclusive (.+)/) { $set_variable_count{$1}++; } } } foreach(keys %set_variable_count) { my $c = $set_variable_count{$_}; if ($c>1) { $count+=($c*($c-1))/2; } else { $count++; } } } return($count); } sub count_tests_fake_compiler_option_implied_bys { my $fake_c; my $c_branch; my $option_set; my $count = 0; foreach $fake_c (@COMPILER_FAKE_INTERFACES) { my %implied_count; $c_branch=$COMPILER_FAKE_INTERFACES{$fake_c}; $option_set=$COMPILER_FAKE_OPTIONS{$c_branch}; my $opt; foreach $opt (keys %{$option_set}) { my @operations = @{$option_set->{$opt}}; my $o; foreach $o (@operations) { if ($o =~ /^implied-by (.+)/) { my @ib = split(' ', $1); my $ib; foreach $ib (@ib) { $implied_count{$ib}++; } } } } foreach(keys %implied_count) { my $c = $implied_count{$_}; $count+=($c+1); } } return($count); } sub test_compilers { my $CS = new CBM::CompilerSelector($sys); foreach(@COMPILER_FAKE_INTERFACES) { my $fake_c = "$top_srcdir/reference/$_"; ok(-x $fake_c, "$fake_c is executable"); my $C = $CS->select($fake_c); ok(defined($C), "CBM::Compiler instance can be retrieved for $fake_c"); } } sub test_option_using_vars { my $fake_c; my $c_branch; my $option_set; my $opt; foreach $fake_c (@COMPILER_FAKE_INTERFACES) { $c_branch=$COMPILER_FAKE_INTERFACES{$fake_c}; $option_set=$COMPILER_FAKE_OPTIONS{$c_branch}; my %set_variable_options; foreach $opt (keys %{$option_set}) { my @operations = @{$option_set->{$opt}}; my $o; foreach $o (@operations) { if ($o =~ /^option-exclusive (.+)/) { push(@{$set_variable_options{$1}}, $opt); } } } my $CS = new CBM::CompilerSelector($sys); my $fake_cmd = "$top_srcdir/reference/$fake_c"; my $C = $CS->select($fake_cmd); my $var; foreach $var (keys %set_variable_options) { my $i; my $j; my $n = (@{$set_variable_options{$var}})+0; for($i=0;$i<$n;$i++) { if ($n==1) { ok(0, "$opt is the only option to use exclusive variable $var"); } for($j=$i+1;$j<$n;$j++) { my $l0 = compiler_option_litteral($C, $set_variable_options{$var}[$i]); my $l1 = compiler_option_litteral($C, $set_variable_options{$var}[$j]); my $opt_string = "$l0 $l1"; my $r = $C->analyzeOptions($opt_string); my $x = "1\nOption $l1 is incompatible with $l0\n"; ok($r eq $x, "Analyzing $opt_string on " . $C->Name() . " : expects ($x) has ($r)\n"); } } } } } sub test_option_implied_bys { my $fake_c; my $c_branch; my $option_set; my $opt; foreach $fake_c (@COMPILER_FAKE_INTERFACES) { $c_branch=$COMPILER_FAKE_INTERFACES{$fake_c}; $option_set=$COMPILER_FAKE_OPTIONS{$c_branch}; my %implied_by; foreach $opt (keys %{$option_set}) { my @operations = @{$option_set->{$opt}}; my $o; foreach $o (@operations) { if ($o =~ /^implied-by (.+)/) { my @ib = split(' ', $1); my $ib; foreach $ib (@ib) { push(@{$implied_by{$ib}}, $opt); } } } } my $CS = new CBM::CompilerSelector($sys); my $fake_cmd = "$top_srcdir/reference/$fake_c"; my $C = $CS->select($fake_cmd); my $i; foreach $i (keys %implied_by) { my $l0 = compiler_option_litteral($C, $i); my $opt_string = "$l0"; my $r = $C->analyzeOptions($opt_string); my $x = "1\n"; ok($r eq $x, "Analyzing $opt_string on " . $C->Name() . " : expects ($x) has ($r)\n"); } foreach $i (keys %implied_by) { my @ib = @{$implied_by{$i}}; my $ib; foreach $ib (@ib) { my $l0 = compiler_option_litteral($C, $i); my $l1 = compiler_option_litteral($C, $ib); my $opt_string = "$l0 $l1"; my $r = $C->analyzeOptions($opt_string); my $x = "1\nOption $l1 is implied by $l0\n"; ok($r eq $x, "Analyzing $opt_string on " . $C->Name() . " : expects ($x) has ($r)\n"); } } } } plan tests => (count_tests_fake_compiler_branches()*2+ count_tests_fake_compiler_option_using_vars()+ count_tests_fake_compiler_option_implied_bys()); $sys = CBM::Init(); test_compilers(); test_option_using_vars(); test_option_implied_bys(); $sys->done(); |