[asl] 117/177: Improve Tests

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 69534470cbe06e71149fc6103640673895d9fbfc
Author: Avtech Scientific <AvtechScientific at users.noreply.github.com>
Date:   Tue Jul 28 13:31:30 2015 +0300

    Improve Tests
---
 CMakeLists.txt                                    | 12 ++++--
 COPYRIGHT.md                                      |  1 -
 doc/Developer-Guide/Doxyfile.cmake.in             |  2 +-
 test/testABD/CMakeLists.txt                       |  2 +-
 test/testABD/testABDFormat.cc                     | 45 ++++++++++----------
 test/testACL/CMakeLists.txt                       | 11 ++++-
 test/testACL/{testHardware.cc => asl-hardware.cc} |  0
 test/testACL/testKernel.cc                        | 52 ++++++++++++-----------
 test/testACL/testKernelMerger.cc                  |  5 +--
 test/testACL/testOperators.cc                     |  6 +--
 10 files changed, 75 insertions(+), 61 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f6cf2f..af5d8df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,15 +37,21 @@ include(${VTK_USE_FILE})
 include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
 
 add_subdirectory(src)
-add_subdirectory(test)
+
+# ToDo: move installation of asl-hardware out of the tests
+# and add/enable WITH_TESTS option
+# if (WITH_TESTS)
+	enable_testing()
+	add_subdirectory(test)
+# endif()
 
 if (WITH_EXAMPLES)
 	add_subdirectory(examples)
-endif (WITH_EXAMPLES)
+endif()
 
 if (WITH_API_DOC)
 	add_subdirectory(doc)
-endif (WITH_API_DOC)
+endif()
 
 # Packaging
 set(CPACK_GENERATOR "TGZ")
diff --git a/COPYRIGHT.md b/COPYRIGHT.md
index dc5357a..0710e4f 100644
--- a/COPYRIGHT.md
+++ b/COPYRIGHT.md
@@ -21,5 +21,4 @@ Optional [commercial license](http://asl.org.il/licensing) is available for clos
 Some examples require input files (like .vti or .stl) that can be found in `examples/input_data`.
 
 1. All .stl files were originally obtained from [GrabCAD](https://grabcad.com/) and are subject to their [Terms of Service](https://grabcad.com/terms); some of them were modified.
-
 2. brain.vti was generated using  [BrainWeb](http://brainweb.bic.mni.mcgill.ca/brainweb/).
diff --git a/doc/Developer-Guide/Doxyfile.cmake.in b/doc/Developer-Guide/Doxyfile.cmake.in
index d8e261e..c40ad6f 100644
--- a/doc/Developer-Guide/Doxyfile.cmake.in
+++ b/doc/Developer-Guide/Doxyfile.cmake.in
@@ -1191,7 +1191,7 @@ HTML_COLORSTYLE_GAMMA  = 80
 # The default value is: YES.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_TIMESTAMP         = YES
+HTML_TIMESTAMP         = NO
 
 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
 # documentation will contain sections that can be hidden and shown after the
diff --git a/test/testABD/CMakeLists.txt b/test/testABD/CMakeLists.txt
index a76f717..9966dc1 100644
--- a/test/testABD/CMakeLists.txt
+++ b/test/testABD/CMakeLists.txt
@@ -3,4 +3,4 @@ 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
diff --git a/test/testABD/testABDFormat.cc b/test/testABD/testABDFormat.cc
index b467447..4ce4605 100644
--- a/test/testABD/testABDFormat.cc
+++ b/test/testABD/testABDFormat.cc
@@ -32,13 +32,14 @@
 
 bool testNumbers()
 {
+	cout << "Test of Numbers..." << flush;
 	unsigned int aui(3);
 	int ai(-2);	
 	float af(5);
 	double ad(4);	
 	
 	asl::ABDFileOut afO("test.abd");
-	afO<<aui<<ai<<af<<ad;
+	afO << aui << ai << af << ad;
 	afO.close();
 		
 	asl::ABDFileIn afI("test.abd");
@@ -47,7 +48,7 @@ bool testNumbers()
 	float bf(0);
 	double bd(0);	
 
-	afI>>bui>>bi>>bf>>bd;
+	afI >> bui >> bi >> bf >> bd;
 
 	bool status((aui==bui) && (ai==bi) && (af==bf) && (ad==bd));
 	asl::errorMessage(status);
@@ -57,18 +58,21 @@ bool testNumbers()
 
 bool testAVec()
 {
+	cout << "Test of AVec..." << flush;
 	asl::Block b(asl::makeAVec (10,15),0.1,asl::makeAVec (.1,1.));
 
 	asl::ABDFileOut afO("test.abd");
-	afO<<b;
+	afO << b;
 	afO.close();
 		
 	asl::ABDFileIn afI("test.abd");
 	asl::Block bn;
 
-	afI>>bn;
+	afI >> bn;
 
-	bool status((b.getSize()==bn.getSize()) && (b.dx==bn.dx) && (b.position==bn.position));
+	bool status((b.getSize() == bn.getSize()) &&
+	            (b.dx == bn.dx) &&
+	            (b.position == bn.position));
 	asl::errorMessage(status);
 
 	return status;		
@@ -76,18 +80,19 @@ bool testAVec()
 
 bool testString()
 {
+	cout << "Test of String..." << flush;
 	std::string b("Hello!!");
 
 	asl::ABDFileOut afO("test.abd");
-	afO<<b;
+	afO << b;
 	afO.close();
 		
 	asl::ABDFileIn afI("test.abd");
 	std::string bn;
 
-	afI>>bn;
+	afI >> bn;
 
-	bool status(b==bn);
+	bool status(b == bn);
 	asl::errorMessage(status);
 
 	return status;		
@@ -96,12 +101,13 @@ bool testString()
 
 bool testBlock()
 {
+	cout << "Test of Block..." << flush;
 	asl::AVec<int> ai(asl::makeAVec(2,3));	
 	asl::AVec<float> af(asl::makeAVec(2.f,3.f));	
 	asl::AVec<double> ad(asl::makeAVec(4.,5.));	
 
 	asl::ABDFileOut afO("test.abd");
-	afO<<ai<<af<<ad;
+	afO << ai << af << ad;
 	afO.close();
 		
 	asl::ABDFileIn afI("test.abd");
@@ -109,9 +115,9 @@ bool testBlock()
 	asl::AVec<float> bf(1);
 	asl::AVec<double> bd(1);	
 
-	afI>>bi>>bf>>bd;
+	afI >> bi >> bf >> bd;
 
-	bool status((ai==bi) && (af==bf) && (ad==bd));
+	bool status((ai == bi) && (af == bf) && (ad == bd));
 	asl::errorMessage(status);
 
 	return status;		
@@ -119,17 +125,12 @@ bool testBlock()
 
 int main()
 {
-	cout<<"Test of Numbers...";
-	testNumbers();
+	bool allTestsPassed(true);
 
-	cout<<"Test of String...";
-	testString();
+	allTestsPassed &= testNumbers();
+	allTestsPassed &= testAVec();
+	allTestsPassed &= testString();
+	allTestsPassed &= testBlock();
 
-	cout<<"Test of AVec...";	
-	testAVec();
-
-	cout<<"Test of Block...";	
-	testBlock();
-
-	return 0;
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/test/testACL/CMakeLists.txt b/test/testACL/CMakeLists.txt
index 39eb4e2..db5b9f9 100644
--- a/test/testACL/CMakeLists.txt
+++ b/test/testACL/CMakeLists.txt
@@ -1,27 +1,34 @@
 include_directories(${CMAKE_SOURCE_DIR}/src)
 
 # Install asl-hardware
-add_executable(asl-hardware testHardware.cc)
+add_executable(asl-hardware asl-hardware.cc)
 target_link_libraries(asl-hardware aslacl)
 install(TARGETS asl-hardware RUNTIME DESTINATION  ${CMAKE_INSTALL_BINDIR})
 
 add_executable(testVectorOfElements testVectorOfElements.cc)
-target_link_libraries(testVectorOfElements aslacl)
+target_link_libraries(testVectorOfElements aslacl)
+add_test(testVectorOfElements, testVectorOfElements)
 
 add_executable(testMatrixOfElements testMatrixOfElements.cc)
 target_link_libraries(testMatrixOfElements aslacl aslmath asldata asl)
+add_test(testMatrixOfElements, testMatrixOfElements)
 
 add_executable(testPerformance testPerformance.cc)
 target_link_libraries(testPerformance aslacl)
+add_test(testPerformance, testPerformance)
 
 add_executable(testKernel testKernel.cc)
 target_link_libraries(testKernel aslacl)
+add_test(testKernel, testKernel)
 
 add_executable(testOperators testOperators.cc)
 target_link_libraries(testOperators aslacl)
+add_test(testOperators, testOperators)
 
 add_executable(testKernelMerger testKernelMerger.cc)
 target_link_libraries(testKernelMerger aslacl)
+add_test(testKernelMerger, testKernelMerger)
 
 add_executable(testPrivateVar testPrivateVar.cc)
 target_link_libraries(testPrivateVar aslacl)
+add_test(testPrivateVar, testPrivateVar)
\ No newline at end of file
diff --git a/test/testACL/testHardware.cc b/test/testACL/asl-hardware.cc
similarity index 100%
rename from test/testACL/testHardware.cc
rename to test/testACL/asl-hardware.cc
diff --git a/test/testACL/testKernel.cc b/test/testACL/testKernel.cc
index 1404aa8..8b8bc5b 100644
--- a/test/testACL/testKernel.cc
+++ b/test/testACL/testKernel.cc
@@ -53,7 +53,7 @@ using namespace std;
 
 bool testCopy()
 {
-	cout << "Test of \"copy\" function...";
+	cout << "Test of \"copy\" function..." << flush;
 	Element vec0(new Array<cl_float> (10));
 	
 	vector<cl_float> input(10, 3);
@@ -71,7 +71,7 @@ bool testCopy()
 
 bool testKernel()
 {
-	cout << "Test of Kernel with double...";
+	cout << "Test of Kernel with double..." << flush;
 
 	Element vec0(new Array<cl_double>(10));
 	Element vec1(new Array<cl_double>(10));
@@ -103,7 +103,7 @@ bool testKernel()
 
 bool testKernelSIMD()
 {
-	cout << "Test of KernelSIMD...";
+	cout << "Test of KernelSIMD..." << flush;
 
 	Element vec0(new Array<cl_float>(11));
 	Element vec1(new Array<cl_float>(11));
@@ -135,7 +135,7 @@ bool testKernelSIMD()
 
 bool testKernelSIMDUA()
 {
-	cout << "Test of KernelSIMDUA...";
+	cout << "Test of KernelSIMDUA..." << flush;
 
 	Element vec0(new Array<cl_float> (11));
 	Element vec1(new Array<cl_float> (11));
@@ -170,7 +170,7 @@ bool testKernelSIMDUA()
 
 bool testPrivateVariable()
 {
-	cout << "Test of kernel with PrivateVariable...";
+	cout << "Test of kernel with PrivateVariable..." << flush;
 
 	Element vec0(new Array<cl_float>(10));
 	Element vec1(new Array<cl_float>(10));
@@ -205,7 +205,7 @@ bool testPrivateVariable()
 
 bool testPrivateArray()
 {
-	cout << "Test of kernel with PrivateArray...";
+	cout << "Test of kernel with PrivateArray..." << flush;
 	
 	vector<cl_int> inputGaIn({0, 4, 5});
 	vector<cl_float> inputGaOut(3, 0);
@@ -241,7 +241,7 @@ bool testPrivateArray()
 
 bool testVariable()
 {
-	cout << "Test of Variable functionality...";
+	cout << "Test of Variable functionality..." << flush;
 
 	Element vec0(new Array<cl_float> (10));
 	shared_ptr<Variable<cl_float> > a(new Variable<cl_float> (1.));	
@@ -266,7 +266,7 @@ bool testVariable()
 
 bool testVariableReference()
 {
-	cout << "Test of VariableReference functionality...";
+	cout << "Test of VariableReference functionality..." << flush;
 
 	Element vec0(new Array<cl_float> (10));
 	float v(1.);
@@ -293,7 +293,7 @@ bool testVariableReference()
 
 bool testSelect()
 {
-	cout << "Test of select function...";
+	cout << "Test of select function..." << flush;
 
 	Element vec0(new Array<cl_double> (10));
 	Element c0(new Constant<cl_double> (2.1));
@@ -327,7 +327,7 @@ bool testSelect()
 
 bool testSubvector()
 {
-	cout << "Test of Subvector...";
+	cout << "Test of Subvector..." << flush;
 	cl_float init[] = {16, 2, 77, 29, 23, 16, 2, 77, 29, 23};
 	shared_ptr<Array<cl_float> > vec0(new Array<cl_float>(10));
 	
@@ -347,7 +347,7 @@ bool testSubvector()
 
 bool testSwapBuffers()
 {
-	cout << "Test of Swap functionality...";
+	cout << "Test of Swap functionality..." << flush;
 	shared_ptr<Array<cl_float> > vec0(new Array<cl_float>(10));
 	shared_ptr<Array<cl_float> > vec1(new Array<cl_float>(10));
 	
@@ -369,7 +369,7 @@ bool testSwapBuffers()
 
 bool testLocalArray()
 {
-	cout << "Test of LocalArray and syncCopy with barrier()...";
+	cout << "Test of LocalArray and syncCopy with barrier()..." << flush;
 
 	KernelConfiguration kConf(KERNEL_BASIC);
 	kConf.local = true;
@@ -419,18 +419,20 @@ bool testLocalArray()
 
 int main()
 {
-	testCopy();
-	testKernel();
-	testKernelSIMD();
-	testKernelSIMDUA();
-	testPrivateVariable();
-	testPrivateArray();
-	testVariable();
-	testVariableReference();
-	testSelect();
-	testSwapBuffers();
-	testLocalArray();
-	testSubvector();
+	bool allTestsPassed(true);
+
+	allTestsPassed &= testCopy();
+	allTestsPassed &= testKernel();
+	allTestsPassed &= testKernelSIMD();
+	allTestsPassed &= testKernelSIMDUA();
+	allTestsPassed &= testPrivateVariable();
+	allTestsPassed &= testPrivateArray();
+	allTestsPassed &= testVariable();
+	allTestsPassed &= testVariableReference();
+	allTestsPassed &= testSelect();
+	allTestsPassed &= testSwapBuffers();
+	allTestsPassed &= testLocalArray();
+	allTestsPassed &= testSubvector();
 	
-	return 0;
+	return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/test/testACL/testKernelMerger.cc b/test/testACL/testKernelMerger.cc
index cd49400..479f508 100644
--- a/test/testACL/testKernelMerger.cc
+++ b/test/testACL/testKernelMerger.cc
@@ -40,7 +40,7 @@ using namespace std;
 
 bool testKernelMerger()
 {
-	cout << "Test of \"KernelMerger\" functionality...";
+	cout << "Test of \"KernelMerger\" functionality..." << flush;
 	ElementData vec0(new Array<cl_float> (10));
 	ElementData vec1(new Array<cl_float> (5));
 	ElementData vec2(new Array<cl_float> (8));
@@ -70,7 +70,6 @@ bool testKernelMerger()
 //	km.addKernel(k3);
 
 	km.setup();
-	cout<<km.getKernelSource()<<endl;
 	km.compute();
 
 	bool status((acl::map<float>(vec0).get()[9] == 2) && 
@@ -78,7 +77,7 @@ bool testKernelMerger()
 	            (acl::map<float>(vec2).get()[7] == 4));// &&
 //	            (acl::map<float>(vec3).get()[19] == 7));
 	errorMessage(status);
-
+	cout << km.getKernelSource() << endl;
 	return status;		
 }
 
diff --git a/test/testACL/testOperators.cc b/test/testACL/testOperators.cc
index 0cfd416..5d545a5 100644
--- a/test/testACL/testOperators.cc
+++ b/test/testACL/testOperators.cc
@@ -49,7 +49,7 @@ using namespace std;
 
 bool testIfElse()
 {
-	cout << "Test of If-Else...";
+	cout << "Test of If-Else..." << flush;
 
 	using namespace elementOperators;
 	shared_ptr<Variable<cl_int> > a(new Variable<cl_int> (15));
@@ -89,7 +89,7 @@ bool testIfElse()
 
 bool testParser()
 {
-	cout << "Test of Parser...";
+	cout << "Test of Parser..." << flush;
 
 	using namespace elementOperators;
 	shared_ptr<Variable<cl_int> > a(new Variable<cl_int> (15));
@@ -126,7 +126,7 @@ bool testParser()
 
 bool testAtomicSum()
 {
-	cout << "Test of Atomic Sum...";
+	cout << "Test of Atomic Sum..." << flush;
 
 	using namespace elementOperators;
 	Element c(new Constant<cl_int> (6));

-- 
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