[asl] 118/177: Fix Bug#8

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Aug 27 09:22:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository asl.

commit 180b5925f28304f23f9b87330c637e010d1f566d
Author: Avtech Scientific <AvtechScientific at users.noreply.github.com>
Date:   Tue Jul 28 18:36:53 2015 +0300

    Fix Bug#8
---
 CMakeLists.txt                         |  4 +++
 test/testABD/CMakeLists.txt            |  3 +-
 test/testABD/testABDFormat.cc          |  6 ++--
 test/testACL/CMakeLists.txt            | 18 +++++-----
 test/testACL/testKernel.cc             |  2 +-
 test/testACL/testKernelMerger.cc       |  8 +++--
 test/testACL/testMatrixOfElements.cc   | 39 ++++++++++-----------
 test/testACL/testOperators.cc          |  9 ++---
 test/testACL/testPrivateVar.cc         |  9 +++--
 test/testACL/testVectorOfElements.cc   | 22 ++++++------
 test/testAGL/CMakeLists.txt            |  3 +-
 test/testAGL/testVTK_IO.cc             |  6 ++--
 test/testMath/CMakeLists.txt           |  8 +++--
 test/testMath/testASLData.cc           | 18 +++++-----
 test/testMath/testDistanceFunction.cc  | 20 +++++------
 test/testMath/testReductionFunction.cc | 64 ++++++++++++++++++++++------------
 16 files changed, 137 insertions(+), 102 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index af5d8df..8474dda 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,10 @@ add_subdirectory(src)
 # ToDo: move installation of asl-hardware out of the tests
 # and add/enable WITH_TESTS option
 # if (WITH_TESTS)
+	# Input/Output tests are labled "IO" and may require input files
+	# Performance tests are labled "Performance"
+	# Run them: ctest [-C Release|Debug] -L Performance
+	# Exclude them: ctest [-C Release|Debug] -LE Performance
 	enable_testing()
 	add_subdirectory(test)
 # endif()
diff --git a/test/testABD/CMakeLists.txt b/test/testABD/CMakeLists.txt
index 9966dc1..53b349e 100644
--- a/test/testABD/CMakeLists.txt
+++ b/test/testABD/CMakeLists.txt
@@ -1,6 +1,5 @@
-
 include_directories(${CMAKE_SOURCE_DIR}/src)
 
 add_executable(testABDFormat testABDFormat.cc)
 target_link_libraries(testABDFormat asldata aslmath asl)
-add_test(testABDFormat, testABDFormat)
\ No newline at end of file
+add_test(NAME testABDFormat COMMAND testABDFormat)
\ No newline at end of file
diff --git a/test/testABD/testABDFormat.cc b/test/testABD/testABDFormat.cc
index 4ce4605..d623b62 100644
--- a/test/testABD/testABDFormat.cc
+++ b/test/testABD/testABDFormat.cc
@@ -53,7 +53,7 @@ bool testNumbers()
 	bool status((aui==bui) && (ai==bi) && (af==bf) && (ad==bd));
 	asl::errorMessage(status);
 
-	return status;		
+	return status;
 }
 
 bool testAVec()
@@ -120,7 +120,7 @@ bool testBlock()
 	bool status((ai == bi) && (af == bf) && (ad == bd));
 	asl::errorMessage(status);
 
-	return status;		
+	return status;
 }
 
 int main()
@@ -133,4 +133,4 @@ int main()
 	allTestsPassed &= testBlock();
 
 	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+}
\ No newline at end of file
diff --git a/test/testACL/CMakeLists.txt b/test/testACL/CMakeLists.txt
index db5b9f9..1ec36ae 100644
--- a/test/testACL/CMakeLists.txt
+++ b/test/testACL/CMakeLists.txt
@@ -7,28 +7,30 @@ install(TARGETS asl-hardware RUNTIME DESTINATION  ${CMAKE_INSTALL_BINDIR})
 
 add_executable(testVectorOfElements testVectorOfElements.cc)
 target_link_libraries(testVectorOfElements aslacl)
-add_test(testVectorOfElements, testVectorOfElements)
+add_test(NAME testVectorOfElements COMMAND testVectorOfElements)
 
 add_executable(testMatrixOfElements testMatrixOfElements.cc)
 target_link_libraries(testMatrixOfElements aslacl aslmath asldata asl)
-add_test(testMatrixOfElements, testMatrixOfElements)
+add_test(NAME testMatrixOfElements COMMAND testMatrixOfElements)
 
 add_executable(testPerformance testPerformance.cc)
 target_link_libraries(testPerformance aslacl)
-add_test(testPerformance, testPerformance)
+add_test(NAME testPerformance COMMAND testPerformance)
+set_tests_properties(testPerformance PROPERTIES LABELS Performance)
 
 add_executable(testKernel testKernel.cc)
 target_link_libraries(testKernel aslacl)
-add_test(testKernel, testKernel)
+add_test(NAME testKernel COMMAND testKernel)
 
 add_executable(testOperators testOperators.cc)
 target_link_libraries(testOperators aslacl)
-add_test(testOperators, testOperators)
+add_test(NAME testOperators COMMAND testOperators)
 
 add_executable(testKernelMerger testKernelMerger.cc)
 target_link_libraries(testKernelMerger aslacl)
-add_test(testKernelMerger, testKernelMerger)
+add_test(NAME testKernelMerger COMMAND testKernelMerger)
 
 add_executable(testPrivateVar testPrivateVar.cc)
-target_link_libraries(testPrivateVar aslacl)
-add_test(testPrivateVar, testPrivateVar)
\ No newline at end of file
+target_link_libraries(testPrivateVar aslacl)
+add_test(NAME testPrivateVar COMMAND testPrivateVar)
+set_tests_properties(testPrivateVar PROPERTIES LABELS Performance)
\ No newline at end of file
diff --git a/test/testACL/testKernel.cc b/test/testACL/testKernel.cc
index 8b8bc5b..b9d8488 100644
--- a/test/testACL/testKernel.cc
+++ b/test/testACL/testKernel.cc
@@ -435,4 +435,4 @@ int main()
 	allTestsPassed &= testSubvector();
 	
 	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+}
\ No newline at end of file
diff --git a/test/testACL/testKernelMerger.cc b/test/testACL/testKernelMerger.cc
index 479f508..32278a4 100644
--- a/test/testACL/testKernelMerger.cc
+++ b/test/testACL/testKernelMerger.cc
@@ -83,7 +83,9 @@ bool testKernelMerger()
 
 int main()
 {
-	testKernelMerger();
+	bool allTestsPassed(true);
+
+	allTestsPassed &= testKernelMerger();
 	
-	return 0;
-}
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
\ No newline at end of file
diff --git a/test/testACL/testMatrixOfElements.cc b/test/testACL/testMatrixOfElements.cc
index e88232c..f2c557c 100644
--- a/test/testACL/testMatrixOfElements.cc
+++ b/test/testACL/testMatrixOfElements.cc
@@ -40,7 +40,7 @@ using namespace std;
 
 bool testMatrixOperations()
 {
-	cout << "Test of \"Matrix Operations\" function...";
+	cout << "Test of \"Matrix Operations\" function..." << flush;
 
 	VectorOfElements vec0(3);
 	VectorOfElements vec1(1);
@@ -59,17 +59,16 @@ bool testMatrixOperations()
 	vector<cl_float> output(10);
 	copy(vec1[0], output);
 	
-	bool testResult(output[1] == 20.5);
-	if (testResult)	cout << " Ok" << endl;
-	else cout << " Error" << output[1] << endl;
+	bool status(output[1] == 20.5);
+	errorMessage(status);
 
-	return testResult;		
+	return status;
 }
 
 
 bool testSystemSolve()
 {
-	cout << "Test of \"System Solve Cramer's rule\" function...";
+	cout << "Test of \"System Solve Cramer's rule\" function..." << flush;
 
 	VectorOfElements vecB(2);
 	VectorOfElements vecX(2);
@@ -90,16 +89,15 @@ bool testSystemSolve()
 	vector<cl_float> output(10);
 	copy(vecX[0], output);
 	
-	bool testResult(output[1] > 0.09 && output[1] < .1);
-	if (testResult)	cout << " Ok" << endl;
-	else cout << " Error" << output[1] << endl;
+	bool status(output[1] > 0.09 && output[1] < .1);
+	errorMessage(status);
 
-	return testResult;		
+	return status;
 }
 
 bool testSystemSolveCG()
 {
-	cout << "Test of \"System Solve congugate gradient method\" function...";
+	cout << "Test of \"System Solve congugate gradient method\" function..." << flush;
 
 	VectorOfElements vecB(2);
 	VectorOfElements vecX(2);
@@ -120,19 +118,20 @@ bool testSystemSolveCG()
 	vector<cl_float> output(10);
 	copy(vecX[0], output);
 	
-	bool testResult(output[1] > 0.09 && output[1] < .1);
-	if (testResult)	cout << " Ok" << endl;
-	else cout << " Error" << output[1] << endl;
+	bool status(output[1] > 0.09 && output[1] < .1);
+	errorMessage(status);
 
-	return testResult;		
+	return status;		
 }
 
 
 int main()
 {
-	testMatrixOperations();
-	testSystemSolve();
-	testSystemSolveCG();
+	bool allTestsPassed(true);
 
-	return 0;
-}
+	allTestsPassed &= testMatrixOperations();
+	allTestsPassed &= testSystemSolve();
+	allTestsPassed &= testSystemSolveCG();
+
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
\ No newline at end of file
diff --git a/test/testACL/testOperators.cc b/test/testACL/testOperators.cc
index 5d545a5..a98ab7b 100644
--- a/test/testACL/testOperators.cc
+++ b/test/testACL/testOperators.cc
@@ -153,10 +153,11 @@ bool testAtomicSum()
 
 int main()
 {
+	bool allTestsPassed(true);
 
-	testIfElse();
-	testParser();
-	testAtomicSum();
+	allTestsPassed &= testIfElse();
+	allTestsPassed &= testParser();
+	allTestsPassed &= testAtomicSum();
 
-	return 0;
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/test/testACL/testPrivateVar.cc b/test/testACL/testPrivateVar.cc
index 9d7a3e8..fb65140 100644
--- a/test/testACL/testPrivateVar.cc
+++ b/test/testACL/testPrivateVar.cc
@@ -41,7 +41,7 @@ const acl::KernelConfiguration & kConf(acl::KERNEL_BASIC);
 
 bool testKernelUnoptimized()
 {
-	cout << "Test of \"Simple kernel\" function...";
+	cout << "Test of \"Simple kernel\" function..." << flush;
 
 	auto vec1(acl::generateVEData<float>(nLength,1u));
 	acl::Kernel k(kConf);
@@ -67,9 +67,10 @@ bool testKernelUnoptimized()
 	return true;		
 }
 
+
 bool testKernelUnoptimizedPlus()
 {
-	cout << "Test of \"Simple kernel\" function...";
+	cout << "Test of \"Simple kernel\" function..." << flush;
 
 	auto vec1(acl::generateVEData<float>(nLength,1u));
 	acl::Kernel k(kConf);
@@ -96,9 +97,11 @@ bool testKernelUnoptimizedPlus()
 
 	return true;		
 }
+
+
 bool testKernelOptimized()
 {
-	cout << "Test of \"Simple kernel\" function...";
+	cout << "Test of \"Simple kernel\" function..." << flush;
 
 	auto vec1(acl::generateVEData<float>(nLength,1u));
 	acl::Kernel k(kConf);
diff --git a/test/testACL/testVectorOfElements.cc b/test/testACL/testVectorOfElements.cc
index ab1ceb0..2dea103 100644
--- a/test/testACL/testVectorOfElements.cc
+++ b/test/testACL/testVectorOfElements.cc
@@ -39,7 +39,7 @@ using namespace std;
 
 bool testSimpleKernel()
 {
-	cout << "Test of \"Simple kernel\" function...";
+	cout << "Test of \"Simple kernel\" function..." << flush;
 
 	VectorOfElements vec0(3);
 	VectorOfElements vec1(1);
@@ -62,16 +62,16 @@ bool testSimpleKernel()
 	copy(vec0[2], output2);
 	copy(vec1[0], output3);
 	
-	bool testResult(output0[9]<0.101 && output1[2] ==1 && output2[5] ==2. && output3[1] ==6.);
-	if (testResult)	cout << " Ok" << endl;
-	else cout << " Error" << endl;
+	bool status(output0[9]<0.101 && output1[2] ==1 && output2[5] ==2. && output3[1] ==6.);
+	errorMessage(status);
 
-	return testResult;		
+	return status;		
 }
 
+
 bool testAdvancedOperations()
 {
-	cout << "Test of advanced operations...";
+	cout << "Test of advanced operations..." << flush;
 	VectorOfElements vec0(2);
 	VectorOfElements vec1(2);
 	VectorOfElements res(2);
@@ -111,8 +111,10 @@ bool testAdvancedOperations()
 
 int main()
 {
-	testSimpleKernel();
-	testAdvancedOperations();
+	bool allTestsPassed(true);
 
-	return 0;
-}
+	allTestsPassed &= testSimpleKernel();
+	allTestsPassed &= testAdvancedOperations();
+
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
\ No newline at end of file
diff --git a/test/testAGL/CMakeLists.txt b/test/testAGL/CMakeLists.txt
index 2537bc1..a1af920 100644
--- a/test/testAGL/CMakeLists.txt
+++ b/test/testAGL/CMakeLists.txt
@@ -3,4 +3,5 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
 
 add_executable(testVTK_IO testVTK_IO.cc)
 target_link_libraries(testVTK_IO aslnum aslvtk asl)
-
+add_test(NAME testVTK_IO COMMAND testVTK_IO)
+set_tests_properties(testVTK_IO PROPERTIES LABELS IO)
\ No newline at end of file
diff --git a/test/testAGL/testVTK_IO.cc b/test/testAGL/testVTK_IO.cc
index b4ccc6d..6fdb69e 100644
--- a/test/testAGL/testVTK_IO.cc
+++ b/test/testAGL/testVTK_IO.cc
@@ -33,7 +33,7 @@
 
 void testMINC()
 {
-	cout << "Test of MINC files reader..." << endl;
+	cout << "Test of MINC files reader..." << flush;
 
 	auto data(asl::read("subject04_crisp_v.mnc", 0));
 	
@@ -44,7 +44,7 @@ void testMINC()
 
 void testMINCplus()
 {
-	cout << "Test of MINC files reader +..." << endl;
+	cout << "Test of MINC files reader +..." << flush;
 
 	auto data(asl::read("subject04_crisp_v.mnc", 0));
 	
@@ -59,7 +59,7 @@ void testMINCplus()
 
 void testSurfaceSTL()
 {
-	cout << "Test of Surface STL files reader..." << endl;
+	cout << "Test of Surface STL files reader..." << flush;
 
 	auto data(asl::readSurface("bus.stl", 5));
 //	auto data(asl::readSurface("xx.vtp", .01));
diff --git a/test/testMath/CMakeLists.txt b/test/testMath/CMakeLists.txt
index 2879527..b34d524 100644
--- a/test/testMath/CMakeLists.txt
+++ b/test/testMath/CMakeLists.txt
@@ -1,11 +1,13 @@
-
 include_directories(${CMAKE_SOURCE_DIR}/src)
 
 add_executable(testASLData testASLData.cc)
 target_link_libraries(testASLData aslmath asl)
+add_test(NAME testASLData COMMAND testASLData)
 
 add_executable(testDistanceFunction testDistanceFunction.cc)
-target_link_libraries(testDistanceFunction aslmath aslvtk aslnum asl)
+target_link_libraries(testDistanceFunction aslmath aslvtk aslnum asl)
+add_test(NAME testDistanceFunction COMMAND testDistanceFunction)
 
 add_executable(testReductionFunction testReductionFunction.cc)
-target_link_libraries(testReductionFunction asl)
+target_link_libraries(testReductionFunction asl)
+add_test(NAME testReductionFunction COMMAND testReductionFunction)
\ No newline at end of file
diff --git a/test/testMath/testASLData.cc b/test/testMath/testASLData.cc
index 9d4c2ab..84c06e3 100644
--- a/test/testMath/testASLData.cc
+++ b/test/testMath/testASLData.cc
@@ -71,7 +71,7 @@ bool testInitData()
 
 bool testUploadToLocalMem()
 {
-	cout << "Test of UploadToLocalMem()...";
+	cout << "Test of UploadToLocalMem()..." << flush;
 
 	unsigned int componentsNum = 2;
 	unsigned int groupSize = 27;
@@ -124,7 +124,7 @@ bool testUploadToLocalMem()
 	kernel.compute();
 
 
-	bool status = true;
+	bool status(true);
 	vector<cl_float> src(totalSize);
 	vector<cl_float> dst(totalSize);
 	for (unsigned int i = 0; i < componentsNum; ++i)
@@ -139,14 +139,16 @@ bool testUploadToLocalMem()
 	
 	errorMessage(status);
 
-	return true;
+	return status;
 }
 
 int main()
 {
-	testSimpleKernel();
-	testInitData();
-	testUploadToLocalMem();
+	bool allTestsPassed(true);
+
+	allTestsPassed &= testSimpleKernel();
+	allTestsPassed &= testInitData();
+	allTestsPassed &= testUploadToLocalMem();
 		
-	return 0;
-}
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
\ No newline at end of file
diff --git a/test/testMath/testDistanceFunction.cc b/test/testMath/testDistanceFunction.cc
index c2f66df..696c39a 100644
--- a/test/testMath/testDistanceFunction.cc
+++ b/test/testMath/testDistanceFunction.cc
@@ -25,16 +25,15 @@
 	\example testDistanceFunction.cc
  */
 
-#include <math/aslVectors.h>
-#include <aslGenerators.h>
-#include <writers/aslVTKFormatWriters.h>
-#include <aslGeomInc.h>
+#include "math/aslVectors.h"
+#include "aslGenerators.h"
+#include "writers/aslVTKFormatWriters.h"
+#include "aslGeomInc.h"
 #include <stdlib.h>     /* srand, rand */
 #include <time.h>
-#include <data/aslDataWithGhostNodes.h>
-
-#include <num/aslDFOptimizer.h>
-#include <math/aslTemplates.h>
+#include "data/aslDataWithGhostNodes.h"
+#include "num/aslDFOptimizer.h"
+#include "math/aslTemplates.h"
 
 //typedef float FlT;
 typedef double FlT;
@@ -338,12 +337,13 @@ bool testDistFAdvanced3D()
 	asl::WriterVTKXML writer("distFAdvanced3D");
 	writer.addScalars("Bath", *mBath);
 	writer.addScalars("Platform", *mPlatform);
-	writer.addScalars("Crysstal", *mCrystal);
+	writer.addScalars("Crystal", *mCrystal);
 	writer.write();
 
 	return true;	
 }
 
+
 bool testDistFOptimizer()
 {
 	FlT r(10.);
@@ -380,4 +380,4 @@ int main()
 	testDistFOptimizer();
 	
 	return 0;
-}
+}
\ No newline at end of file
diff --git a/test/testMath/testReductionFunction.cc b/test/testMath/testReductionFunction.cc
index aac26bd..327a855 100644
--- a/test/testMath/testReductionFunction.cc
+++ b/test/testMath/testReductionFunction.cc
@@ -26,7 +26,7 @@
  */
 
 #include "acl/Kernels/aclKernel.h"
-#include <acl/aclUtilities.h>
+#include "acl/aclUtilities.h"
 #include "acl/aclMath/aclReductionAlgGenerator.h"
 #include "acl/aclGenerators.h"
 #include "aslUtilities.h"
@@ -34,20 +34,25 @@
 
 using namespace acl;
 
-void testSum()
+bool testSum()
 {
+	cout << "testSum..." << flush;
 	unsigned int n(101);
 	auto v(generateVEData<float>(n,1u));
 	initData(v, generateVEConstant(2));
 	auto summator(generateSumAlg<float>(v));
 	summator->generateAlg();
 	summator->compute();
-	bool b(asl::approxEqual(summator->res.v()[0],2.f*n));
-	cout<<"testSum: "<<(b? "Ok": "Error ")<<endl;
+	bool status(asl::approxEqual(summator->res.v()[0],2.f*n));
+	asl::errorMessage(status);
+
+	return status;
 }
 
-void testSum1()
+
+bool testSum1()
 {
+	cout << "testSum1..." << flush;
 	unsigned int n(100001);
 	VectorOfElements v1(generateVEData<float>(n,1u));
 	VectorOfElements v2(generateVEData<float>(n,1u));
@@ -56,38 +61,47 @@ void testSum1()
 	auto summator(generateSumAlg<float>(v1*v2));
 	summator->generateAlg();
 	summator->compute();
-	bool b(asl::approxEqual(summator->res.v()[0],6.f*n));
-	cout<<"testSum1: "<<(b? "Ok": "Error")<<endl;
+	bool status(asl::approxEqual(summator->res.v()[0],6.f*n));
+	asl::errorMessage(status);
+
+	return status;
 }
 
+
 bool testMin()
 {
+	cout << "testMin..." << flush;
 	VectorOfElements vI(generateVEIndex());
 	VectorOfElements v1(generateVEData<float>(101u,1u));
 	initData(v1, generateVEConstant(2));
 	auto minimizer(generateMinAlg<float>(v1*((vI-100)*(vI-100)+3)));
 	minimizer->generateAlg();
 	minimizer->compute();
-	bool b(asl::approxEqual(minimizer->res.v()[0],6.f));
-	cout<<"testMin: "<<(b? "Ok": "Error")<<endl;
-	return b;
+	bool status(asl::approxEqual(minimizer->res.v()[0],6.f));
+	asl::errorMessage(status);
+
+	return status;
 }
 
+
 bool testMax()
 {
+	cout << "testMax..." << flush;
 	VectorOfElements vI(generateVEIndex());
 	VectorOfElements v1(generateVEData<float>(100001u,1u));
 	initData(v1, generateVEConstant(2));
 	auto maximizer(generateMaxAlg<float>(v1*((1000.-vI)*(vI-1000.)-10.)));
 	maximizer->generateAlg();
 	maximizer->compute();
-	bool b(asl::approxEqual(maximizer->res.v()[0],-20.f));
-	cout<<"testMax: "<<(b? "Ok": "Error")<<endl;
-	return b;
+	bool status(asl::approxEqual(maximizer->res.v()[0],-20.f));
+	asl::errorMessage(status);
+
+	return status;
 }
 
 bool testProduct()
 {
+	cout << "testProduct..." << flush;
 	typedef double FT;
 	VectorOfElements vI(generateVEIndex());
 	VectorOfElements v1(generateVEData<FT>(100001u,1u));
@@ -98,18 +112,22 @@ bool testProduct()
 	                                       acl::typeToTypeID<FT>())));
 	alg->generateAlg();
 	alg->compute();
-	bool b(asl::approxEqual(alg->res.v()[0],256));
-	cout<<"testProduct: "<<(b? "Ok": "Error")<<endl;
-	return b;
+	bool status(asl::approxEqual(alg->res.v()[0],256));
+	asl::errorMessage(status);
+
+	return status;
 }
 
 
 int main()
 {
-	testSum();
-	testSum1();
-	testMin();
-	testMax();
-	testProduct();
-	return 0;
-}
+	bool allTestsPassed(true);
+
+	allTestsPassed &= testSum();
+	allTestsPassed &= testSum1();
+	allTestsPassed &= testMin();
+	allTestsPassed &= testMax();
+	allTestsPassed &= testProduct();
+
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/asl.git



More information about the debian-science-commits mailing list