- $_ = <IN>; # pass extra blank line
- chomp;
- die "this line should be blank ($_). Did you edit the file?" if /\W/;
- }
- my ($old_)=($_);
- # add my section
- $newmain .= " /* SGU: BEGIN FILE $infile */\n";
- $newmain .= " suite = xbt_test_suite_by_name(\"$suite_name\",$suite_title);\n";
- map {
- my ($name,$func,$title) = @{$_};
- $newmain .= " xbt_test_suite_push(suite, \"$name\", $func, $title);\n";
- } @tests;
-
- $newmain .= " /* SGU: END FILE */\n\n";
- if ($old_ =~ /SGU: BEGIN FILE/ || $old_ =~ /SGU: END SUITES DECLARATION/) {
- $newmain .= $old_;
- }
-
- # pass the remaining
- while (<IN>) {
- $newmain .= $_;
- }
-close IN || die "$progname: Cannot close main file 'simgrid_units_main.c': $!\n";
-
-# write it back to main
-open OUT,">simgrid_units_main.c" || die "$progname: Cannot open main file 'simgrid_units_main.c': $!\n";
-print OUT $newmain;
-close OUT || die "$progname: Cannot close main file 'simgrid_units_main.c': $!\n";
+
+ print " Suite $suite_name: $suite_title (".(scalar @tests)." tests)\n";
+ map {
+ my ($name,$func,$title) = @{$_};
+ print " unit $name: func=$func; title=$title\n";
+ } @tests;
+
+ #while (my $t = shift @tests) {
+
+ # add this suite to the main
+ my $newmain="";
+ open IN,"simgrid_units_main.c" || die "$progname: Cannot open main file 'simgrid_units_main.c': $!\n";
+ # search prototypes
+ while (<IN>) {
+ $newmain .= $_;
+ # print "Look for proto: $_";
+ last if /SGU: BEGIN PROTOTYPES/;
+ }
+
+ # search my prototype
+ while (<IN>) {
+ # print "Seek protos: $_";
+ last if (/SGU: END PROTOTYPES/ || /SGU: BEGIN FILE $infile/);
+ $newmain .= $_;
+ }
+ if (/SGU: BEGIN FILE $infile/) { # found an old section for this file. Kill it
+ while (<IN>) {
+ last if /SGU: END FILE/;
+ }
+ $_ = <IN>; # pass extra blank line
+ chomp;
+ die "this line should be blank ($_). Did you edit the file?" if /\W/;
+ }
+ my ($old_)=($_);
+ # add my section
+ $newmain .= " /* SGU: BEGIN FILE $infile */\n";
+ map {
+ my ($name,$func,$title) = @{$_};
+ $newmain .= " void $func(void);\n"
+ } @tests;
+
+ $newmain .= " /* SGU: END FILE */\n\n";
+ if ($old_ =~ /SGU: BEGIN FILE/ || $old_ =~ /SGU: END PROTOTYPES/) {
+ $newmain .= $old_;
+ }
+
+ # pass remaining prototypes, search declarations
+ while (<IN>) {
+ $newmain .= $_ unless /SGU: END PROTOTYPES/;
+ last if /SGU: BEGIN SUITES DECLARATION/;
+ }
+
+ ### Done with prototypes. And now, the actual code
+
+ # search my prototype
+ while (<IN>) {
+ last if (/SGU: END SUITES DECLARATION/ || /SGU: BEGIN FILE $infile/);
+ $newmain .= $_;
+ }
+ if (/SGU: BEGIN FILE $infile/) { # found an old section for this file. Kill it
+ while (<IN>) {
+ last if /SGU: END FILE/;
+ }
+ $_ = <IN>; # pass extra blank line
+ chomp;
+ die "this line should be blank ($_). Did you edit the file?" if /\W/;
+ }
+ my ($old_)=($_);
+ # add my section
+ $newmain .= " /* SGU: BEGIN FILE $infile */\n";
+ $newmain .= " suite = xbt_test_suite_by_name(\"$suite_name\",$suite_title);\n";
+ map {
+ my ($name,$func,$title) = @{$_};
+ $newmain .= " xbt_test_suite_push(suite, \"$name\", $func, $title);\n";
+ } @tests;
+
+ $newmain .= " /* SGU: END FILE */\n\n";
+ if ($old_ =~ /SGU: BEGIN FILE/ || $old_ =~ /SGU: END SUITES DECLARATION/) {
+ $newmain .= $old_;
+ }
+
+ # pass the remaining
+ while (<IN>) {
+ $newmain .= $_;
+ }
+ close IN || die "$progname: Cannot close main file 'simgrid_units_main.c': $!\n";
+
+ # write it back to main
+ open OUT,">simgrid_units_main.c" || die "$progname: Cannot open main file 'simgrid_units_main.c': $!\n";
+ print OUT $newmain;
+ close OUT || die "$progname: Cannot close main file 'simgrid_units_main.c': $!\n";
+} # end if process_one($)