Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update CMakeLists for windows
[simgrid.git] / tools / sg_unit_extractor.pl
index 4e233f1..4b96fd8 100755 (executable)
@@ -1,6 +1,13 @@
 #! /usr/bin/perl
 
 use strict;
+use Fcntl ':flock';
+
+open SELF, "< $0" or die "Cannot open the lock file";
+if (!flock SELF, LOCK_EX | LOCK_NB) {
+    print STDERR "sg_unit_extractor already running. Cancelling...\n";
+    exit;
+}
 
 my $progname="sg_unit_extractor";
 # Get the args 
@@ -41,18 +48,24 @@ sub process_one($) {
            next
        }
        
-       if (m/XBT_TEST_SUITE\(\w*"([^"]*)"\w*,(.*?)\);/) { #" {
+       if (m/XBT_TEST_SUITE\(\w*"([^"]*)"\w*, *(.*?)\);/) { #" {
            die "$progname: Multiple suites in the same file ($infile) are not supported yet\n" if length($suite_name);
            ($suite_name,$suite_title)=($1,$2);
+           die "$progname: Empty suite name in $infile" unless length($suite_name);
+           die "$progname: Empty suite title in $infile" unless length($suite_title);
            next;
-        } 
+        } elsif (m/XBT_TEST_SUITE/) {
+           die "$progname: Parse error: This line seem to be a test suite declaration, but failed to parse it\n$_\n";
+       }
 
         if (m/XBT_TEST_UNIT\(\w*"([^"]*)"\w*,([^,]*),(.*?)\)/) { #"{
            die "$progname: multiply defined unit in file $infile: $1\n" if (defined($tests{$1}));
-      
+            
            my @t=($1,$2,$3);
            push @tests,\@t;
            $tests{$1} = 1;
+       } elsif (m/XBT_TEST_UNIT/) {
+           die "$progname: Parse error: This line seem to be a test unit, but failed to parse it\n$_\n";
        }
         $unit_source .= $_ if $takeit;
     }
@@ -79,7 +92,7 @@ sub process_one($) {
     print OUT "#include <stdio.h>\n";
     print OUT "#include \"xbt.h\"\n";
     print OUT $GENERATED;
-    print OUT "# $beginline \"$infile\" \n";
+    print OUT "#line $beginline \"$infile\" \n";
     print OUT "$unit_source";
     print OUT $GENERATED;
     close OUT || die "$progname: Cannot close output file '$outfile': $!\n";
@@ -151,7 +164,6 @@ int main(int argc, char *argv[]) {
       
   res = xbt_test_run(selection);
   xbt_test_exit();
-  xbt_exit();
   return res;
 }
 EOF