changeset 7243:e8d7eed42935

[project @ 2007-12-04 02:10:17 by jwe]
author jwe
date Tue, 04 Dec 2007 02:10:18 +0000
parents e4398e3903be
children 5a9561046b89
files scripts/ChangeLog scripts/testfun/test.m src/ChangeLog src/DLD-FUNCTIONS/luinc.cc src/DLD-FUNCTIONS/spqr.cc test/ChangeLog test/build_sparse_tests.sh test/fntests.m
diffstat 8 files changed, 114 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,5 +1,9 @@
 2007-12-03  David Bateman  <dbateman@free.fr>
 
+	* testfun/test.m: Disable "testif" test block to avoid spurious
+	skipped test for "make check". Avoid printing variables for
+	skipped tests.
+
 	* testfun/test.m: Add "testif" type to allow for conditional tests.
 
 	* plot/plotyy.m: Use activepositionproperty property of axes
--- a/scripts/testfun/test.m
+++ b/scripts/testfun/test.m
@@ -480,7 +480,8 @@
       fputs (__fid, __msg);
       fflush (__fid);
       ## show the variable context
-      if (! strcmp (__type, "error") && ! all (__shared == " "))
+      if (! strcmp (__type, "error") && ! strcmp (__type, "testif") &&
+	  ! all (__shared == " "))
 	fputs (__fid, "shared variables ");
 	eval (sprintf ("fdisp(__fid,bundle(%s));", __shared)); 
 	fflush (__fid);
@@ -618,9 +619,11 @@
 %!testif OCTAVE_SOURCE
 %! ## This test should be run
 %! assert (true);
-%!testif HAVE_FOOBAR
-%! ## missing feature. Fail if this test is run
-%! error("Failed missing feature test");
+
+### Disable this test to avoid spurious skipped test for "make check"
+% !testif HAVE_FOOBAR
+% ! ## missing feature. Fail if this test is run
+% ! error("Failed missing feature test");
 
 ### Test for a known failure
 %!xtest error("This test is known to fail")
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,8 @@
 2007-12-03  David Bateman  <dbateman@free.fr>
 
+	* DLD-FUNCTIONS/luinc.cc: Make tests conditional on HAVE_UMFPACK.
+	* DLD-FUNCTIONS/spqr.cc: Make tests conditional on HAVE_CXSPARSE.
+
 	* DLD-FUNCTIONS/regexp.cc: Use "%!testif" blocks for conditional
 	tests on PCRE.
 
--- a/src/DLD-FUNCTIONS/luinc.cc
+++ b/src/DLD-FUNCTIONS/luinc.cc
@@ -300,7 +300,7 @@
 
 /*
 
-%!test
+%!testif HAVE_UMFPACK
 %! a=sparse([1,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]);
 %! [l,u]=luinc(a,1e-10);
 %! assert(l*u, sparse([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
@@ -308,7 +308,7 @@
 %! [l,u]=luinc(a,opts);
 %! assert(l*u, sparse([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
 
-%!test
+%!testif HAVE_UMFPACK
 %! a=sparse([1i,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]);
 %! [l,u]=luinc(a,1e-10);
 %! assert(l*u, sparse([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
--- a/src/DLD-FUNCTIONS/spqr.cc
+++ b/src/DLD-FUNCTIONS/spqr.cc
@@ -148,13 +148,13 @@
 The deactivated tests below can't be tested till rectangular back-subs is
 implemented for sparse matrices.
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = sprandn(n,n,d)+speye(n,n);
 %! r = spqr(a);
 %! assert(r'*r,a'*a,1e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = sprandn(n,n,d)+speye(n,n);
 %! q = symamd(a);
@@ -162,13 +162,13 @@
 %! r = spqr(a);
 %! assert(r'*r,a'*a,1e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = sprandn(n,n,d)+speye(n,n);
 %! [c,r] = spqr(a,ones(n,1));
 %! assert (r\c,full(a)\ones(n,1),10e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = sprandn(n,n,d)+speye(n,n);
 %! b = randn(n,2);
@@ -176,20 +176,20 @@
 %! assert (r\c,full(a)\b,10e-10)
 
 %% Test under-determined systems!!
-%!#test
+%!#testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = sprandn(n,n+1,d)+speye(n,n+1);
 %! b = randn(n,2);
 %! [c,r] = spqr(a,b);
 %! assert (r\c,full(a)\b,10e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = 1i*sprandn(n,n,d)+speye(n,n);
 %! r = spqr(a);
 %! assert(r'*r,a'*a,1e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = 1i*sprandn(n,n,d)+speye(n,n);
 %! q = symamd(a);
@@ -197,13 +197,13 @@
 %! r = spqr(a);
 %! assert(r'*r,a'*a,1e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = 1i*sprandn(n,n,d)+speye(n,n);
 %! [c,r] = spqr(a,ones(n,1));
 %! assert (r\c,full(a)\ones(n,1),10e-10)
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = 1i*sprandn(n,n,d)+speye(n,n);
 %! b = randn(n,2);
@@ -211,7 +211,7 @@
 %! assert (r\c,full(a)\b,10e-10)
 
 %% Test under-determined systems!!
-%!#test
+%!#testif HAVE_CXSPARSE
 %! n = 20; d= 0.2;
 %! a = 1i*sprandn(n,n+1,d)+speye(n,n+1);
 %! b = randn(n,2);
@@ -352,12 +352,12 @@
 
 /* 
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n=20;
 %! a=speye(n,n);a=a(randperm(n),:);
 %! assert(a(dmperm(a),:),speye(n))
 
-%!test
+%!testif HAVE_CXSPARSE
 %! n=20;
 %! d=0.2;
 %! a=tril(sprandn(n,n,d),-1)+speye(n,n);
@@ -402,8 +402,10 @@
 /* 
 
 %!error(sprank(1,2));
-%!assert(sprank(speye(20)), 20)
-%!assert(sprank([1,0,2,0;2,0,4,0]),2)
+%!testif HAVE_CXSPARSE
+%! assert(sprank(speye(20)), 20)
+%!testif HAVE_CXSPARSE
+%! assert(sprank([1,0,2,0;2,0,4,0]),2)
 
 */
 /*
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-03  David Bateman  <dbateman@free.fr>
+
+	* fntests.m: Also count the skipped tests.
+	* build_sparse_tests.sh: As appropriate make tests conditional on
+	HAVE_UMFPACK, HAVE_CHOLMOD and HAVE_CXSPARSE.
+
 2007-11-26  David Bateman  <dbateman@free.fr>
 
 	* build_sparse_tests.sh: More care with sparse return values.
--- a/test/build_sparse_tests.sh
+++ b/test/build_sparse_tests.sh
@@ -179,7 +179,8 @@
 %% Note that the last four do not fail, but rather give a warning
 %% of a singular matrix, which is consistent with the full matrix
 %% behaviour. They are therefore disabled.. 
-%!assert(spinv(sparse([1,1;1,1+i])),sparse([1-1i,1i;1i,-1i]),10*eps);
+%!testif HAVE_UMFPACK
+%! assert(spinv(sparse([1,1;1,1+i])),sparse([1-1i,1i;1i,-1i]),10*eps);
 % !error spinv( sparse( [1,1;1,1]   ) );
 % !error spinv( sparse( [0,0;0,1]   ) );
 % !error spinv( sparse( [0,0;0,1+i] ) );
@@ -629,22 +630,23 @@
     gen_square_divop_tests
 
     cat >>$TESTS <<EOF
-%!assert(spdet(bs+speye(size(bs))),det(bf+eye(size(bf))),100*eps*abs(det(bf+eye(size(bf)))))
+%!testif HAVE_UMFPACK
+%! assert(spdet(bs+speye(size(bs))),det(bf+eye(size(bf))),100*eps*abs(det(bf+eye(size(bf)))))
 
-%!test 
+%!testif HAVE_UMFPACK 
 %! [l,u]=splu(sparse([1,1;1,1]));
 %! assert(l*u,[1,1;1,1],10*eps);
 
-%!test
+%!testif HAVE_UMFPACK
 %! [l,u]=splu(sparse([1,1;1,1+i]));
 %! assert(l,sparse([1,2,2],[1,1,2],1),10*eps);
 %! assert(u,sparse([1,1,2],[1,2,2],[1,1,1i]),10*eps);
 
-%!test ;# permuted LU
+%!testif HAVE_UMFPACK ;# permuted LU
 %! [L,U] = splu(bs);
 %! assert(L*U,bs,1e-10);
 
-%!test ;# simple LU + row permutations
+%!testif HAVE_UMFPACK ;# simple LU + row permutations
 %! [L,U,P] = splu(bs);
 %! assert(P'*L*U,bs,1e-10);
 %! # triangularity
@@ -653,7 +655,7 @@
 %! [i,j,v]=spfind(U);
 %! assert(j-i>=0);
 
-%!test ;# simple LU + row/col permutations
+%!testif HAVE_UMFPACK ;# simple LU + row/col permutations
 %! [L,U,P,Q] = splu(bs);
 %! assert(P'*L*U*Q',bs,1e-10);
 %! # triangularity
@@ -662,7 +664,7 @@
 %! [i,j,v]=spfind(U);
 %! assert(j-i>=0);
 
-%!test ;# LU with fixed column permutation
+%!testif HAVE_UMFPACK ;# LU with fixed column permutation
 %! [L,U,P] = splu(bs,colamd(bs));
 %! assert(P'*L*U,bs,1e-10);
 %! # triangularity
@@ -671,7 +673,7 @@
 %! [i,j,v]=spfind(U(:,colamd(bs)));
 %! assert(j-i>=0);
 
-%!test ;# LU with initial column permutation
+%!testif HAVE_UMFPACK ;# LU with initial column permutation
 %! [L,U,P,Q] = splu(bs,colamd(bs));
 %! assert(P'*L*U*Q',bs,1e-10);
 %! # triangularity
@@ -680,7 +682,7 @@
 %! [i,j,v]=spfind(U);
 %! assert(j-i>=0);
 
-%!test ;# inverse
+%!testif HAVE_UMFPACK ;# inverse
 %! assert(spinv(bs)*bs,sparse(eye(rows(bs))),1e-10);
 
 %!assert(bf\as',bf\af',100*eps);
@@ -693,11 +695,14 @@
 # Cholesky tests
 gen_cholesky_tests() {
     cat >>$TESTS <<EOF
-%!assert(spchol(bs)'*spchol(bs),bs,1e-10);
-%!assert(splchol(bs)*splchol(bs)',bs,1e-10);
-%!assert(splchol(bs),spchol(bs)',1e-10);
+%!testif HAVE_CHOLMOD
+%! assert(spchol(bs)'*spchol(bs),bs,1e-10);
+%!testif HAVE_CHOLMOD 
+%! assert(splchol(bs)*splchol(bs)',bs,1e-10);
+%!testif HAVE_CHOLMOD
+%! assert(splchol(bs),spchol(bs)',1e-10);
 
-%!test ;# Return Partial Cholesky factorization
+%!testif HAVE_CHOLMOD ;# Return Partial Cholesky factorization
 %! [RS,PS] = spchol(bs);
 %! assert(RS'*RS,bs,1e-10);
 %! assert(PS,0);
@@ -705,7 +710,7 @@
 %! assert(LS*LS',bs,1e-10);
 %! assert(PS,0);
 
-%!test ;# Permuted Cholesky factorization
+%!testif HAVE_CHOLMOD ;# Permuted Cholesky factorization
 %! [RS,PS,QS] = spchol(bs);
 %! assert(RS'*RS,QS*bs*QS',1e-10);
 %! assert(PS,0);
@@ -914,18 +919,26 @@
 %!assert(pds\xs,sparse(pdf\xf,1),1e-10);
 %!assert(ls\xf,lf\xf,1e-10);
 %!assert(sparse(ls\xs),sparse(lf\xf),1e-10);
-%!assert(pls\xf,plf\xf,1e-10);
-%!assert(sparse(pls\xs),sparse(plf\xf),1e-10);
+%!testif HAVE_UMFPACK
+%! assert(pls\xf,plf\xf,1e-10);
+%!testif HAVE_UMFPACK
+%! assert(sparse(pls\xs),sparse(plf\xf),1e-10);
 %!assert(us\xf,uf\xf,1e-10);
 %!assert(sparse(us\xs),sparse(uf\xf),1e-10);
-%!assert(pus\xf,puf\xf,1e-10);
-%!assert(sparse(pus\xs),sparse(puf\xf),1e-10);
+%!testif HAVE_UMFPACK
+%! assert(pus\xf,puf\xf,1e-10);
+%!testif HAVE_UMFPACK
+%! assert(sparse(pus\xs),sparse(puf\xf),1e-10);
 %!assert(bs\xf,bf\xf,1e-10);
 %!assert(sparse(bs\xs),sparse(bf\xf),1e-10);
-%!assert(cs\xf,cf\xf,1e-10);
-%!assert(sparse(cs\xs),sparse(cf\xf),1e-10);
-%!assert(bcs\xf,bcf\xf,1e-10);
-%!assert(sparse(bcs\xs),sparse(bcf\xf),1e-10);
+%!testif HAVE_UMFPACK
+%! assert(cs\xf,cf\xf,1e-10);
+%!testif HAVE_UMFPACK
+%! assert(sparse(cs\xs),sparse(cf\xf),1e-10);
+%!testif HAVE_UMFPACK
+%! assert(bcs\xf,bcf\xf,1e-10);
+%!testif HAVE_UMFPACk
+%! assert(sparse(bcs\xs),sparse(bcf\xf),1e-10);
 %!assert(ts\xf,tf\xf,1e-10);
 %!assert(sparse(ts\xs),sparse(tf\xf),1e-10);
 %!assert(tcs\xf,tcf\xf,1e-10);
@@ -945,7 +958,7 @@
 %! assert (sparse(a * x), b, feps);
 %! b = sprandn(sz(1),sz(2),0.2)+1i*sprandn(sz(1),sz(2),0.2); x = a \b; 
 %! assert (sparse(a * x), b, feps);
-%!test
+%!testif HAVE_CXSPARSE
 %! a = alpha*sprandn(10,11,0.2)+speye(10,11); f(a,[10,2],1e-10);
 %! ## Test this by forcing matrix_type, as can't get a certain 
 %! ## result for over-determined systems.
@@ -980,28 +993,32 @@
 %!assert(pds\xs,sparse(pdf\xs,true),100*eps)
 %!test
 %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]];
-%!assert(us*(us\xf),xf,100*eps)
-%!assert(us*(us\xs),xs,100*eps)
+%!testif HAVE_UMFPACK
+%! assert(us*(us\xf),xf,100*eps)
+%!testif HAVE_UMFPACK
+%! assert(us*(us\xs),xs,100*eps)
 %!test
 %! pus = us(:,[2,1,3:12]);
-%!assert(pus*(pus\xf),xf,100*eps)
-%!assert(pus*(pus\xs),xs,100*eps)
+%!testif HAVE_UMFPACK
+%! assert(pus*(pus\xf),xf,100*eps)
+%!testif HAVE_UMFPACK
+%! assert(pus*(pus\xs),xs,100*eps)
 %!test
 %! us = alpha*[speye(11,9),[1;sparse(8,1);1;0]];
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (us, xf);
 %! assert(us\xf,r\c,100*eps)
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (us, xs);
 %! r = matrix_type(r,"Singular"); ## Force Matrix Type
 %! assert(us\xs,r\c,100*eps)
 %!test
 %! pus = us(:,[1:8,10,9]);
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (pus, xf);
 %! r = matrix_type(r,"Singular"); ## Force Matrix Type
 %! assert(pus\xf,r\c,100*eps)
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (pus, xs);
 %! r = matrix_type(r,"Singular"); ## Force Matrix Type
 %! assert(pus\xs,r\c,100*eps)
@@ -1019,20 +1036,20 @@
 %! ls = alpha*[speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]];
 %! xf = beta * ones(12,2);
 %! xs = speye(12,12);
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (ls, xf);
 %! assert(ls\xf,r\c,100*eps)
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (ls, xs);
 %! r = matrix_type(r,"Singular"); ## Force Matrix Type
 %! assert(ls\xs,r\c,100*eps)
-%!test
+%!testif HAVE_CXSPARSE
 %! pls = ls(:,[1:8,10,9]);
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (pls, xf);
 %! r = matrix_type(r,"Singular"); ## Force Matrix Type
 %! assert(pls\xf,r\c,100*eps)
-%!test
+%!testif HAVE_CXSPARSE
 %! [c,r] = spqr (pls, xs);
 %! r = matrix_type(r,"Singular"); ## Force Matrix Type
 %! assert(pls\xs,r\c,100*eps)
--- a/test/fntests.m
+++ b/test/fntests.m
@@ -76,11 +76,11 @@
        || findstr (str, "%!error") || findstr (str, "%!warning"));
 endfunction
 
-function [dp, dn, dxf] = run_test_dir (fid, d);
+function [dp, dn, dxf, dsk] = run_test_dir (fid, d);
   global files_with_tests;
   global files_with_no_tests;
   lst = dir (d);
-  dp = dn = dxf = 0;
+  dp = dn = dxf = dsk = 0;
   for i = 1:length (lst)
     nm = lst(i).name;
     if (length (nm) > 5 && strcmp (nm(1:5), "test_")
@@ -89,7 +89,7 @@
       ffnm = fullfile (d, nm);
       if (hastests (ffnm))
 	print_test_file_name (nm);
-	[p, n, xf] = test (nm(1:(end-2)), "quiet", fid);
+	[p, n, xf, sk] = test (nm(1:(end-2)), "quiet", fid);
 	print_pass_fail (n, p);
 	files_with_tests(end+1) = ffnm;
       else
@@ -98,25 +98,27 @@
       dp += p;
       dn += n;
       dxf += xf;
+      dsk += sk;
     endif
   endfor
 endfunction
 
-function [dp, dn, dxf] = run_test_script (fid, d);
+function [dp, dn, dxf, dsk] = run_test_script (fid, d);
   global files_with_tests;
   global files_with_no_tests;
   global topsrcdir;
   global topbuilddir;
   lst = dir (d);
-  dp = dn = dxf = 0;
+  dp = dn = dxf = dsk = 0;
   for i = 1:length (lst)
     nm = lst(i).name;
     if (lst(i).isdir && ! strcmp (nm, ".") && ! strcmp (nm, "..")
 	&& ! strcmp (nm, "CVS"))
-      [p, n, xf] = run_test_script (fid, [d, "/", nm]);
+      [p, n, xf, sk] = run_test_script (fid, [d, "/", nm]);
       dp += p;
       dn += n;
       dxf += xf;
+      dsk += sk;
     endif
   endfor
   for i = 1:length (lst)
@@ -130,11 +132,12 @@
 	tmp = strrep (f, [topsrcdir, "/"], "");
 	tmp = strrep (tmp, [topbuilddir, "/"], "../");
 	print_test_file_name (tmp);
-	[p, n, xf] = test (f, "quiet", fid);
+	[p, n, xf, sk] = test (f, "quiet", fid);
 	print_pass_fail (n, p);
 	dp += p;
 	dn += n;
 	dxf += xf;
+	dsk += sk;
 	files_with_tests(end+1) = f;
       else
 	files_with_no_tests(end+1) = f;
@@ -171,20 +174,22 @@
     error ("could not open fntests.log for writing");
   endif
   test ("", "explain", fid);
-  dp = dn = dxf = 0;
+  dp = dn = dxf = dsk = 0;
   printf ("\nIntegrated test scripts:\n\n");
   for i = 1:length (fundirs)
-    [p, n, xf] = run_test_script (fid, fundirs{i});
+    [p, n, xf, sk] = run_test_script (fid, fundirs{i});
     dp += p;
     dn += n;
     dxf += xf;
+    dsk += sk;
   endfor
   printf ("\nFixed test scripts:\n\n");
   for i = 1:length (testdirs)
-    [p, n, xf] = run_test_dir (fid, testdirs{i});
+    [p, n, xf, sk] = run_test_dir (fid, testdirs{i});
     dp += p;
     dn += n;
     dxf += xf;
+    dsk += sk;
   endfor
   printf ("\nSummary:\n\n  PASS %6d\n", dp);
   nfail = dn - dp;
@@ -195,6 +200,13 @@
     printf ("\nExpected failures are known bugs. Please help improve\n");
     printf ("Octave by contributing fixes for them.\n");
   endif
+  if (dsk > 0)
+    printf ("\nThere were %d skipped tests (see fntest.log for details).\n", dsk);
+    printf ("Skipped tests are features that are disabled in this version\n");
+    printf ("of Octave as the needed libraries were not present when Octave\n");
+    printf ("was built\n");
+  endif
+
   n_files_with_no_tests = length (files_with_no_tests);
   n_files = n_files_with_no_tests + length (files_with_tests);
   printf ("\n%d (of %d) files have no tests.  Please help improve Octave by\n",