Browse Source

+ implement timeout wrapper call for testsuite (remote only)
* reduce number of remote logins for speed

git-svn-id: trunk@8870 -

micha 18 years ago
parent
commit
ce4acf5b49
6 changed files with 52 additions and 10 deletions
  1. 6 0
      tests/Makefile
  2. 6 0
      tests/Makefile.fpc
  3. 4 0
      tests/readme.txt
  4. 1 0
      tests/test/theapthread.pp
  5. 31 10
      tests/utils/dotest.pp
  6. 4 0
      tests/utils/testu.pp

+ 6 - 0
tests/Makefile

@@ -1452,9 +1452,15 @@ endif
 ifdef TEST_REMOTEPATH
 ifdef TEST_REMOTEPATH
 override DOTESTOPT+=-P$(TEST_REMOTEPATH)
 override DOTESTOPT+=-P$(TEST_REMOTEPATH)
 endif
 endif
+ifdef TEST_DELBEFORE
+override DOTESTOPT+=-B
+endif
 ifdef TEST_DELTEMP
 ifdef TEST_DELTEMP
 override DOTESTOPT+=-Z
 override DOTESTOPT+=-Z
 endif
 endif
+ifdef TEST_TIMEOUT
+override DOTESTOPT+=-O
+endif
 ifdef TEST_VERBOSE
 ifdef TEST_VERBOSE
 override DOTESTOPT+=-V
 override DOTESTOPT+=-V
 Q=
 Q=

+ 6 - 0
tests/Makefile.fpc

@@ -194,9 +194,15 @@ endif
 ifdef TEST_REMOTEPATH
 ifdef TEST_REMOTEPATH
 override DOTESTOPT+=-P$(TEST_REMOTEPATH)
 override DOTESTOPT+=-P$(TEST_REMOTEPATH)
 endif
 endif
+ifdef TEST_DELBEFORE
+override DOTESTOPT+=-B
+endif
 ifdef TEST_DELTEMP
 ifdef TEST_DELTEMP
 override DOTESTOPT+=-Z
 override DOTESTOPT+=-Z
 endif
 endif
+ifdef TEST_TIMEOUT
+override DOTESTOPT+=-O
+endif
 ifdef TEST_VERBOSE
 ifdef TEST_VERBOSE
 override DOTESTOPT+=-V
 override DOTESTOPT+=-V
 Q=
 Q=

+ 4 - 0
tests/readme.txt

@@ -39,6 +39,8 @@ SKIPTARGET.........Not for these OS targets (win32,macos,etc).
 VERSION............Compiler with at lest this version number required.
 VERSION............Compiler with at lest this version number required.
 MAXVERSION.........Compiler with at most this version number required.
 MAXVERSION.........Compiler with at most this version number required.
 RESULT.............Exit code of execution of test expected
 RESULT.............Exit code of execution of test expected
+TIMEOUT............Timeout indication for test in seconds (only used if
+                   enabled by defining TEST_TIMEOUT)
 GRAPH..............Requires graph unit
 GRAPH..............Requires graph unit
 FAIL...............Compilation must fail
 FAIL...............Compilation must fail
 RECOMPILE..........After compiling a test, recompile the test for a second
 RECOMPILE..........After compiling a test, recompile the test for a second
@@ -102,6 +104,7 @@ TEST_CCOMPILER         defaults to installed gcc compiler, but only
                        if driver and test full-targets are the same.
                        if driver and test full-targets are the same.
 TEST_VERBOSE           let dotest be more verbose, only usefull for debugging
 TEST_VERBOSE           let dotest be more verbose, only usefull for debugging
 TEST_DELTEMP           delete temporary executable/object/ppu file, default is off
 TEST_DELTEMP           delete temporary executable/object/ppu file, default is off
+TEST_TIMEOUT           use timeout wrapper for (remote) execution
 
 
   (Please add more test options if needed)
   (Please add more test options if needed)
 
 
@@ -125,6 +128,7 @@ TEST_SSH             set this to use ssh/scp to execute the test
 TEST_PUTTY           test using putty when remote testing (pscp and plink)
 TEST_PUTTY           test using putty when remote testing (pscp and plink)
 TEST_REMOTEOPT       extra options to remote program
 TEST_REMOTEOPT       extra options to remote program
 TEST_REMOTEPATH      set remote path to use, default is /tmp
 TEST_REMOTEPATH      set remote path to use, default is /tmp
+TEST_DELBEFORE       delete remote executable before uploading
 TEST_DELTEMP         delete executable after running, so the remote system
 TEST_DELTEMP         delete executable after running, so the remote system
                      doesn't need much free disk space
                      doesn't need much free disk space
 TEST_REMOTEPW        pass a password with -pw to remote tools, mainly usefull for putty
 TEST_REMOTEPW        pass a password with -pw to remote tools, mainly usefull for putty

+ 1 - 0
tests/test/theapthread.pp

@@ -1,3 +1,4 @@
+{ %TIMEOUT=105 }
 {$mode objfpc}{$h+}
 {$mode objfpc}{$h+}
 
 
 uses
 uses

+ 31 - 10
tests/utils/dotest.pp

@@ -34,6 +34,8 @@ uses
 
 
 type
 type
   tcompinfo = (compver,comptarget,compcpu);
   tcompinfo = (compver,comptarget,compcpu);
+  tdelexecutable = (deBefore, deAfter);
+  tdelexecutables = set of tdelexecutable;
 
 
 const
 const
   ObjExt='o';
   ObjExt='o';
@@ -47,6 +49,7 @@ const
   ExeExt='exe';
   ExeExt='exe';
 {$endif MACOS}
 {$endif MACOS}
 {$endif UNIX}
 {$endif UNIX}
+  DefaultTimeout=3;
 
 
 var
 var
   Config : TConfig;
   Config : TConfig;
@@ -78,13 +81,14 @@ const
   TargetDir : string = '';
   TargetDir : string = '';
   BenchmarkInfo : boolean = false;
   BenchmarkInfo : boolean = false;
   ExtraCompilerOpts : string = '';
   ExtraCompilerOpts : string = '';
-  DelExecutable : boolean = false;
+  DelExecutable : TDelExecutables = [];
   RemoteAddr : string = '';
   RemoteAddr : string = '';
   RemotePath : string = '/tmp';
   RemotePath : string = '/tmp';
   RemotePara : string = '';
   RemotePara : string = '';
   rshprog : string = 'rsh';
   rshprog : string = 'rsh';
   rcpprog : string = 'rcp';
   rcpprog : string = 'rcp';
   rquote : char = '''';
   rquote : char = '''';
+  UseTimeout : boolean = false;
   emulatorname : string = '';
   emulatorname : string = '';
 
 
 Function FileExists (Const F : String) : Boolean;
 Function FileExists (Const F : String) : Boolean;
@@ -693,6 +697,7 @@ var
   FullExeLogFile,
   FullExeLogFile,
   TestRemoteExe,
   TestRemoteExe,
   TestExe  : string;
   TestExe  : string;
+  execcmd  : string;
   execres  : boolean;
   execres  : boolean;
   EndTicks,
   EndTicks,
   StartTicks : int64;
   StartTicks : int64;
@@ -742,12 +747,26 @@ begin
     begin
     begin
       { We don't want to create subdirs, remove paths from the test }
       { We don't want to create subdirs, remove paths from the test }
       TestRemoteExe:=RemotePath+'/'+SplitFileName(TestExe);
       TestRemoteExe:=RemotePath+'/'+SplitFileName(TestExe);
-      ExecuteRemote(rshprog,RemotePara+' '+RemoteAddr+' rm -f '+TestRemoteExe);
+      if deBefore in DelExecutable then
+        ExecuteRemote(rshprog,RemotePara+' '+RemoteAddr+' rm -f '+TestRemoteExe);
       ExecuteRemote(rcpprog,RemotePara+' '+TestExe+' '+RemoteAddr+':'+TestRemoteExe);
       ExecuteRemote(rcpprog,RemotePara+' '+TestExe+' '+RemoteAddr+':'+TestRemoteExe);
       { rsh doesn't pass the exitcode, use a second command to print the exitcode
       { rsh doesn't pass the exitcode, use a second command to print the exitcode
         on the remoteshell to stdout }
         on the remoteshell to stdout }
-      execres:=ExecuteRemote(rshprog,RemotePara+' '+RemoteAddr+' '+rquote+'chmod 755 '+TestRemoteExe+
-        ' ; cd '+RemotePath+' ; '+TestRemoteExe+' ; echo "TestExitCode: $?"'+rquote);
+      execcmd:=RemotePara+' '+RemoteAddr+' '+rquote+'chmod 755 '+TestRemoteExe+
+        ' ; cd '+RemotePath+' ;';
+      if UseTimeout then
+      begin
+        execcmd:=execcmd+'timeout -9 ';
+        if Config.Timeout=0 then
+          Config.Timeout:=DefaultTimeout;
+        str(Config.Timeout,s);
+        execcmd:=execcmd+s;
+      end;
+      execcmd:=execcmd+' '+TestRemoteExe+' ; echo "TestExitCode: $?"';
+      if deAfter in DelExecutable then
+        execcmd:=execcmd+' ; rm -f '+TestRemoteExe;
+      execcmd:=execcmd+rquote;
+      execres:=ExecuteRemote(rshprog,execcmd);
       { Check for TestExitCode error in output, sets ExecuteResult }
       { Check for TestExitCode error in output, sets ExecuteResult }
       CheckTestExitCode(EXELogFile);
       CheckTestExitCode(EXELogFile);
     end
     end
@@ -823,11 +842,9 @@ begin
      RunExecutable:=true;
      RunExecutable:=true;
    end;
    end;
 
 
-  if DelExecutable then
+  if deAfter in DelExecutable then
     begin
     begin
       Verbose(V_Debug,'Deleting executable '+TestExe);
       Verbose(V_Debug,'Deleting executable '+TestExe);
-      if RemoteAddr<>'' then
-        ExecuteRemote(rshprog,RemotePara+' '+RemoteAddr+' rm -f '+TestRemoteExe);
       RemoveFile(TestExe);
       RemoveFile(TestExe);
       RemoveFile(ForceExtension(TestExe,ObjExt));
       RemoveFile(ForceExtension(TestExe,ObjExt));
       RemoveFile(ForceExtension(TestExe,PPUExt));
       RemoveFile(ForceExtension(TestExe,PPUExt));
@@ -846,7 +863,7 @@ var
     writeln('dotest [Options] <File>');
     writeln('dotest [Options] <File>');
     writeln;
     writeln;
     writeln('Options can be:');
     writeln('Options can be:');
-    writeln('  -B            output benchmark information');
+    writeln('  -B            delete executable before remote upload');
     writeln('  -C<compiler>  set compiler to use');
     writeln('  -C<compiler>  set compiler to use');
     writeln('  -V            verbose');
     writeln('  -V            verbose');
     writeln('  -E            execute test also');
     writeln('  -E            execute test also');
@@ -855,6 +872,7 @@ var
     writeln('  -G            include graph tests');
     writeln('  -G            include graph tests');
     writeln('  -K            include known bug tests');
     writeln('  -K            include known bug tests');
     writeln('  -I            include interactive tests');
     writeln('  -I            include interactive tests');
+    writeln('  -O            use timeout wrapper for (remote) execution');
     writeln('  -M<emulator>  run the tests using the given emulator');
     writeln('  -M<emulator>  run the tests using the given emulator');
     writeln('  -R<remote>    run the tests remotely with the given rsh/ssh address');
     writeln('  -R<remote>    run the tests remotely with the given rsh/ssh address');
     writeln('  -S            use ssh instead of rsh');
     writeln('  -S            use ssh instead of rsh');
@@ -891,6 +909,8 @@ begin
              DoAll:=true;
              DoAll:=true;
            end;
            end;
 
 
+         'B' : Include(DelExecutable,deBefore);
+
          'C' : CompilerBin:=Para;
          'C' : CompilerBin:=Para;
 
 
          'E' : DoExecute:=true;
          'E' : DoExecute:=true;
@@ -915,6 +935,8 @@ begin
 
 
          'M' : EmulatorName:=Para;
          'M' : EmulatorName:=Para;
 
 
+         'O' : UseTimeout:=true;
+
          'P' : RemotePath:=Para;
          'P' : RemotePath:=Para;
 
 
          'R' : RemoteAddr:=Para;
          'R' : RemoteAddr:=Para;
@@ -953,8 +975,7 @@ begin
 
 
          'Y' : ExtraCompilerOpts:= ExtraCompilerOpts +' '+ Para;
          'Y' : ExtraCompilerOpts:= ExtraCompilerOpts +' '+ Para;
 
 
-         'Z' :
-           DelExecutable:=true;
+         'Z' : Include(DelExecutable,deAfter);
         end;
         end;
      end
      end
     else
     else

+ 4 - 0
tests/utils/testu.pp

@@ -34,6 +34,7 @@ type
     NoRun         : boolean;
     NoRun         : boolean;
     UsesGraph     : boolean;
     UsesGraph     : boolean;
     ShouldFail    : boolean;
     ShouldFail    : boolean;
+    Timeout       : longint;
     Category      : string;
     Category      : string;
     Note          : string;
     Note          : string;
   end;
   end;
@@ -253,6 +254,9 @@ begin
                   R.Note:='Note: '+res;
                   R.Note:='Note: '+res;
                   Verbose(V_Normal,r.Note);
                   Verbose(V_Normal,r.Note);
                 end
                 end
+              else
+               if GetEntry('TIMEOUT') then
+                Val(res,r.Timeout,code)
               else
               else
                Verbose(V_Error,'Unknown entry: '+s);
                Verbose(V_Error,'Unknown entry: '+s);
             end;
             end;