fix tests
Pierre Marechal [Fri, 9 Nov 2007 12:27:22 +0000 (12:27 +0000)]
12 files changed:
scilab/modules/completion/unit_tests/completion.tst
scilab/modules/core/unit_tests/auto.dia.ref
scilab/modules/core/unit_tests/auto.tst
scilab/modules/core/unit_tests/breakpoints.dia.ref
scilab/modules/core/unit_tests/breakpoints.tst
scilab/modules/core/unit_tests/opcode.tst
scilab/modules/core/unit_tests/pause.dia.ref
scilab/modules/core/unit_tests/pause.tst
scilab/modules/development_tools/macros/unit_test_run.sci
scilab/modules/randlib/unit_tests/grandb.dia.ref
scilab/modules/randlib/unit_tests/grandb.tst
scilab/modules/special_functions/unit_tests/specfun.tst

index 5566861..fc27002 100644 (file)
@@ -17,10 +17,10 @@ r = completion('w','files')
 
 // memory leak
 
-for i=1:1000000,a=completion('w');end;
-for i=1:1000000,a=completion('w',"functions");end;
-for i=1:1000000,a=completion('w',"commands");end;
-for i=1:1000000,a=completion('w',"variables");end;
-for i=1:1000000,a=completion('w',"macros");end;
-for i=1:1000000,a=completion('w',"graphics_properties");end;
-for i=1:1000000,a=completion('w',"files");end;
+//for i=1:1000000,a=completion('w');end;
+//for i=1:1000000,a=completion('w',"functions");end;
+//for i=1:1000000,a=completion('w',"commands");end;
+//for i=1:1000000,a=completion('w',"variables");end;
+//for i=1:1000000,a=completion('w',"macros");end;
+//for i=1:1000000,a=completion('w',"graphics_properties");end;
+//for i=1:1000000,a=completion('w',"files");end;
index 8481348..aa6ab10 100644 (file)
@@ -1,3 +1,5 @@
+// <-- TEST WITH GRAPHIC -->
+
 // Copyright INRIA
 // test conversion transfer <---> state-space
 // 1- coff inversion 
index e6ec2f7..b218d35 100644 (file)
@@ -75,7 +75,6 @@ L=macr2lst(foo);
 if or(L(5)<>["27","6","23","sin"]) then pause,end // create varfunptr
 if type(foo())<>130 then pause,end
 
-return
 sin=1
 sin //devrait repondre 1 or il essaye d'executer sin
 a=sin //est ok 
index 95391b8..8cf8d9a 100644 (file)
@@ -1,3 +1,5 @@
+// <-- INTERACTIVE TEST -->
+
 // Copyright INRIA
 a=1;
 deff('[x]=tata(y)','x=-y,write(%io(2),''enter quit''),pause,x=+20')
index 1bc926e..5df4545 100644 (file)
@@ -28,12 +28,15 @@ function unit_test_run(varargin)
        test_skipped_count = 0;
        
        displayed_txt      = '';
+       details_failed     = '';
        
        // =======================================================
        // Gestion des tests à lancer
        // =======================================================
        
-       if (rhs == 0) | ((rhs == 1) & (varargin(1)==[])) then
+       if (rhs == 0) ..
+                               | ((rhs == 1) & (varargin(1)==[])) ..
+                               | ((rhs == 2) & (varargin(1)==[]) & (varargin(1)==[])) then
                
                // No input argument
                // unit_test_run()
@@ -122,44 +125,57 @@ function unit_test_run(varargin)
        end
        
        // Test launch
-       
+       printf("   TMPDIR = %s\n",TMPDIR);
        printf("\n");
        
        for i=1:test_count
                
-               printf("\t %02d/%02d - ",i,test_count);
+               printf("   %02d/%02d - ",i,test_count);
                printf("[%s] %s",test_list(i,1),test_list(i,2));
                for j = length(test_list(i,2) + test_list(i,1)):50
                        printf(".");
                end
                
-               [status_id,status_msg] = unit_test_run_onetest(test_list(i,1),test_list(i,2));
+               [status_id,status_msg,status_details] = unit_test_run_onetest(test_list(i,1),test_list(i,2));
                printf("%s \n",status_msg);
+
+               // Recencement des tests
                
                if status_id == 0 then
                        test_passed_count = test_passed_count + 1;
+                       
                elseif status_id == 10 then
                        test_skipped_count = test_skipped_count + 1;
+                       
                elseif status_id > 0 then
                        test_failed_count = test_failed_count + 1;
+                       details_failed = [ details_failed ; sprintf("   TEST : [%s] %s",test_list(i,1),test_list(i,2))];
+                       details_failed = [ details_failed ; sprintf("     %s",status_msg) ];
+                       details_failed = [ details_failed ; status_details ];
+                       details_failed = [ details_failed ; "" ];
                end
+               
        end
        
        // Summary
        
-       test_passed_percent  = test_passed_count / test_count * 100;
+       test_passed_percent  = test_passed_count  / test_count * 100;
        test_skipped_percent = test_skipped_count / test_count * 100;
-       test_failed_percent  = test_failed_count / test_count * 100;
-
-       printf("\n");
-       printf("\t---------------------------------------------------------------------------------------\n");
-       printf("\tSummary\n\n");
-       printf("\ttests                     %4d - 100 percent \n",test_count);
-       printf("\tpassed                    %4d - %3d percent \n",test_passed_count,test_passed_percent);
-       printf("\tfailed                    %4d - %3d percent \n",test_failed_count,test_failed_percent);
-       printf("\tskipped                   %4d - %3d percent \n",test_failed_count,test_failed_percent);
-       printf("\t---------------------------------------------------------------------------------------\n");
+       test_failed_percent  = test_failed_count  / test_count * 100;
        
+       printf("\n");
+       printf("   ---------------------------------------------------------------------------------------\n");
+       printf("   Summary\n\n");
+       printf("   tests                     %4d - 100 percent \n",test_count);
+       printf("   passed                    %4d - %3d percent \n",test_passed_count ,test_passed_percent);
+       printf("   failed                    %4d - %3d percent \n",test_failed_count ,test_failed_percent);
+       printf("   skipped                   %4d - %3d percent \n",test_skipped_count,test_skipped_percent);
+       printf("   ---------------------------------------------------------------------------------------\n\n");
+       printf("   Details\n\n");
+       printf("%s\n",details_failed);
+       printf("\n");
+       printf("   ---------------------------------------------------------------------------------------\n");
+
 endfunction
 
 //-----------------------------------------------------------------------------
@@ -213,20 +229,21 @@ endfunction
 // => Run one test
 //-----------------------------------------------------------------------------
 
-function [status_id,status_msg] = unit_test_run_onetest(module,test)
+function [status_id,status_msg,status_details] = unit_test_run_onetest(module,test)
        
        global check_ref;
        global create_ref;
        
-       status_id  = 0 ;
-       status_msg = "passed" ;
+       status_id      = 0 ;
+       status_msg     = "passed" ;
+       status_details = "";
        
-       [status_id,status_msg] = unit_test_run_checkerror(module,test);
+       [status_id,status_msg,status_details] = unit_test_run_checkerror(module,test);
        
        if check_ref | create_ref then
                // Check ref or create ref
                if status_id == 0 then
-                       [status_id,status_msg] = unit_test_run_proc_ref(module,test);
+                       [status_id,status_msg,status_details] = unit_test_run_proc_ref(module,test);
                end
        end
        
@@ -243,10 +260,11 @@ endfunction
 // => Check the test
 //-----------------------------------------------------------------------------
 
-function [status_id,status_msg] = unit_test_run_checkerror(module,test)
+function [status_id,status_msg,status_details] = unit_test_run_checkerror(module,test)
        
-       status_id  = 0 ;
-       status_msg = "passed" ;
+       status_id      = 0 ;
+       status_msg     = "passed" ;
+       status_details = "";
        
        // Some definitions
        
@@ -337,7 +355,8 @@ function [status_id,status_msg] = unit_test_run_checkerror(module,test)
        tmp_errfile_info = fileinfo(tmp_errfile);
        
        if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
-               status_msg = "failed : error_output not empty"
+               status_msg = "failed  : error_output not empty"
+               status_details = sprintf("     Check the following file : \n     - %s",tmp_errfile);
                status_id  = 5;
                return;
        end
@@ -347,7 +366,9 @@ function [status_id,status_msg] = unit_test_run_checkerror(module,test)
        
        //Check for execution errors
        if grep(dia,"<--Error on the test script file-->")<>[] then
-               status_msg = "failed : premature end of the test script";
+               status_msg = "failed  : premature end of the test script";
+               status_details = sprintf("     Check the following file : \n     - %s",tmp_diafile);
+               status_details = [ status_details ; sprintf("     Or launch the following command : \n     - exec %s;",tstfile) ];
                status_id = 3;
                return;
        end
@@ -358,14 +379,18 @@ function [status_id,status_msg] = unit_test_run_checkerror(module,test)
        //Check for execution errors
        
        if grep(dia,"!--error")<>[] then
-               status_msg = "failed : the string (!--error) has been detected";
+               status_msg     = "failed  : the string (!--error) has been detected";
+               status_details = sprintf("     Check the following file : \n     - %s",tmp_diafile);
+               status_details = [ status_details ; sprintf("     Or launch the following command : \n     - exec %s;",tstfile) ];
                status_id  = 1;
                return;
        end
        
        if grep(dia,"error on test")<>[] then
-               status_msg = "failed : one or several unit tests failed";
-               status_id  = 2;
+               status_msg     = "failed  : one or several unit tests failed";
+               status_details = sprintf("     Check the following file : \n     - %s",tmp_diafile);
+               status_details = [ status_details ; sprintf("     Or launch the following command : \n     - exec %s;",tstfile) ];
+               status_id      = 2;
                return;
        end
        
@@ -382,13 +407,14 @@ endfunction
 // => Check ref or generate ref
 //-----------------------------------------------------------------------------
 
-function [status_id,status_msg] = unit_test_run_proc_ref(module,test)
+function [status_id,status_msg,status_details] = unit_test_run_proc_ref(module,test)
        
        global create_ref;
        global check_ref;
        
-       status_id  = 0 ;
-       status_msg = "passed" ;
+       status_id      = 0 ;
+       status_msg     = "passed" ;
+       status_details = "";
        
        // Some definitions
        
@@ -405,8 +431,10 @@ function [status_id,status_msg] = unit_test_run_proc_ref(module,test)
        
        if check_ref then
                if fileinfo(reffile) == [] then
-                       status_msg = "failed : the ref file doesn''t exist";
-                       status_id  = 5;
+                       status_msg     = "failed  : the ref file doesn''t exist";
+                       status_details = "     Add or create the following file"+reffile+" file";
+                       status_details = sprintf("     Add or create the following file : \n     - %s",reffile);
+                       status_id      = 5;
                        return;
                end
        end
@@ -480,6 +508,16 @@ function [status_id,status_msg] = unit_test_run_proc_ref(module,test)
        // Launch the test exec
        host(unit_test_cmd);
        
+       // First Check
+       tmp_errfile_info = fileinfo(tmp_errfile);
+       
+       if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
+               status_msg = "failed  : error_output not empty"
+               status_details = sprintf("     Check the following file : \n     - %s",tmp_errfile);
+               status_id  = 5;
+               return;
+       end
+       
        //  Do some modification in  dia file
        dia = mgetl(tmp_diafile);
        
@@ -552,11 +590,13 @@ function [status_id,status_msg] = unit_test_run_proc_ref(module,test)
                        
                        if or(ref<>dia) then
                                if MSDOS then
-                                       status_msg = "failed : dia and ref are not equal";
-                                       status_id = 4;
+                                       status_msg     = "failed  : dia and ref are not equal";
+                                       status_details = sprintf("     Compare the following files : \n     - %s\n     - %s",diafile,reffile);
+                                       status_id      = 4;
                                else
-                                       status_msg = "failed : dia and ref are not equal";
-                                       status_id = 4;
+                                       status_msg     = "failed  : dia and ref are not equal";
+                                       status_details = sprintf("     Compare the following files : \n     - %s\n     - %s",diafile,reffile);
+                                       status_id      = 4;
                                end
                        end
                else
index 081250e..2410cdf 100644 (file)
  
 // Copyright INRIA
  
 grand('setgen','clcg4');
  
 // Low level test for grand
  
-getf('unit_tests/grandb.sci')
  
-tstbot()
+// Copyright INRIA
+//**********************************************************************
+//     A test program for the bottom level routines
+//     Scilab implementation of tstbot.f
+//**********************************************************************
+NB       = 10
+ NB  =
+    10.  
+NR       = 1000
+ NR  =
+    1000.  
+answer   = ones(NB,NR);
+genlst   = [1,5,10,20,32]
+ genlst  =
+    1.    5.    10.    20.    32.  
+nbad     = 0;
+str      = ['For five virtual generators of the 101';..
+                       ' This test generates'+string(NB)+' numbers then resets the block';..
+                       '      and does it again';..
+                       ' Any disagreements are reported -- there should be none'];
+                       
+write (%io(2),str);
 For five virtual generators of the 101
  This test generates10 numbers then resets the block
       and does it again
  Any disagreements are reported -- there should be none
+//
+//     Set up Generators
+//
+grand('setall',12345,54321,6789,9876);
+//
+//     For a selected set of generators
+//
+for ixgen = 1:5
+       igen = genlst(ixgen)
+       grand('setcgn',igen);
+       write(%io(2),' Testing generator '+string(igen));
+       //
+       //     Use NB blocks
+       //
+       grand('initgn',-1);
+       SD=grand('getsd');iseed1=SD(1);iseed2=SD(2);
+       for iblock = 1:NB
+               //     Generate NR numbers
+               answer(iblock,1:NR)= grand(1,NR,'lgi');
+               grand('initgn',1);
+       end
+       grand('initgn',-1);
+       //
+       //     Do it again and compare answers
+       //
+       SD=grand('getsd');iseed1=SD(1);iseed2=SD(2);
+       //
+       //     Use NB blocks
+       //
+       for iblock = 1:NB
+               
+               //     Generate NR numbers
+               itmp = grand(1,NR,'lgi');
+               if itmp<>answer(iblock,:) then
+                       str=[' Disagreement on regeneration of numbers';...
+                       ' Block '+string(iblock)+' N within Block '];
+                       write(%io(2),str);
+               end
+               
+               if itmp<>answer(iblock,:) then bugmes();quit;end
+               
+               grand('initgn',1);
+               
+       end
+       
+       write (%io(2), ' Finished testing generator '+string(igen));
+       write (%io(2), ' Test completed successfully');
+       
+end
+ igen  =
+    1.  
  Testing generator 1
  Finished testing generator 1
  Test completed successfully
+ igen  =
+    5.  
  Testing generator 5
  Finished testing generator 5
  Test completed successfully
+ igen  =
+    10.  
  Testing generator 10
  Finished testing generator 10
  Test completed successfully
+ igen  =
+    20.  
  Testing generator 20
  Finished testing generator 20
  Test completed successfully
+ igen  =
+    32.  
  Testing generator 32
  Finished testing generator 32
  Test completed successfully
index 1123127..5e7f937 100644 (file)
@@ -1,5 +1,76 @@
 // Copyright INRIA
+
 grand('setgen','clcg4');
-// Low level test for grand 
-getf('unit_tests/grandb.sci') 
-tstbot()
+
+// Low level test for grand
+
+// Copyright INRIA
+//**********************************************************************
+//     A test program for the bottom level routines
+//     Scilab implementation of tstbot.f
+//**********************************************************************
+NB       = 10
+NR       = 1000
+answer   = ones(NB,NR);
+genlst   = [1,5,10,20,32]
+nbad     = 0;
+
+str      = ['For five virtual generators of the 101';..
+                       ' This test generates'+string(NB)+' numbers then resets the block';..
+                       '      and does it again';..
+                       ' Any disagreements are reported -- there should be none'];
+                       
+write (%io(2),str);
+
+//
+//     Set up Generators
+//
+
+grand('setall',12345,54321,6789,9876);
+
+//
+//     For a selected set of generators
+//
+
+for ixgen = 1:5
+       igen = genlst(ixgen)
+       grand('setcgn',igen);
+       write(%io(2),' Testing generator '+string(igen));
+       //
+       //     Use NB blocks
+       //
+       grand('initgn',-1);
+       SD=grand('getsd');iseed1=SD(1);iseed2=SD(2);
+       for iblock = 1:NB
+               //     Generate NR numbers
+               answer(iblock,1:NR)= grand(1,NR,'lgi');
+               grand('initgn',1);
+       end
+       grand('initgn',-1);
+       //
+       //     Do it again and compare answers
+       //
+       SD=grand('getsd');iseed1=SD(1);iseed2=SD(2);
+       //
+       //     Use NB blocks
+       //
+       for iblock = 1:NB
+               
+               //     Generate NR numbers
+               itmp = grand(1,NR,'lgi');
+               if itmp<>answer(iblock,:) then
+                       str=[' Disagreement on regeneration of numbers';...
+                       ' Block '+string(iblock)+' N within Block '];
+                       write(%io(2),str);
+               end
+               
+               if itmp<>answer(iblock,:) then pause,end
+               
+               grand('initgn',1);
+               
+       end
+       
+       write (%io(2), ' Finished testing generator '+string(igen));
+       write (%io(2), ' Test completed successfully');
+       
+end
index f34cd32..b48d4a4 100644 (file)
@@ -1,4 +1,3 @@
-path=get_absolute_file_path('specfun.tst');
 function r=testresult(eps)
   if argn(2)<=0 then eps=1d-10;end
   if or(isnan(real(y))<>isnan(real(yref)))  then r=%t,return,end;
@@ -14,7 +13,7 @@ ieee(1)
 // ------------------------------ besseli(alpha,x)------------------------------
 
 //test of numerical precision reference computed by maple
-exec(path+'besseli_ref.sce',-1)
+exec(SCI'/modules/special/functions/unit_tests/besseli_ref.sce',-1)
 besselI=besseli(alpha',x);
 if norm((besselI-besselI_ref)./abs(besselI_ref),1)>1d6*%eps then pause,end
 
@@ -1105,7 +1104,7 @@ y=besseli(alpha,x,1);
 if testresult() then pause,end
 // ------------------------------ besselj(alpha,x)------------------------------
 //test of numerical precision reference computed by maple
-exec(path+'besselj_ref.sce',-1)
+exec(SCI'/modules/special/functions/unit_tests/besselj_ref.sce',-1)
 besselJ=besselj(alpha',x);
 if norm((besselJ-besselJ_ref)./abs(besselJ_ref),1)>1d6*%eps then pause,end
 
@@ -2290,7 +2289,7 @@ y=besselj(alpha,x,1);
 if testresult() then pause,end
 // ------------------------------ besselk(alpha,x)------------------------------
 //test of numerical precision reference computed by maple
-exec(path+'besselk_ref.sce',-1)
+exec(SCI'/modules/special/functions/unit_tests/besselk_ref.sce',-1)
 besselK=besselk(alpha',x);
 if norm((besselK-besselK_ref)./abs(besselK_ref),1)>1d6*%eps then pause,end
 
@@ -3380,7 +3379,7 @@ y=besselk(alpha,x,1);
 if testresult() then pause,end
 // ------------------------------ bessely(alpha,x)------------------------------
 //test of numerical precision reference computed by maple
-exec(path+'bessely_ref.sce',-1)
+exec(SCI'/modules/special/functions/unit_tests/bessely_ref.sce',-1)
 besselY=bessely(alpha',x);
 if norm((besselY-besselY_ref)./abs(besselY_ref),1)>1d6*%eps then pause,end