From 8a6ebb7719d233ae40abb3eb276217d77a92857d Mon Sep 17 00:00:00 2001
From: olivier-stasse <olivier.stasse@aist.go.jp>
Date: Wed, 24 Nov 2010 14:39:31 +0900
Subject: [PATCH] Correct tests to accept the sample humanoid robot specific
 case.

---
 unitTesting/CMakeLists.txt   | 85 ++++++++++++++++++++++--------------
 unitTesting/test_djj.cpp     |  1 +
 unitTesting/test_dyn.cpp     | 48 ++++++++++++--------
 unitTesting/test_results.cpp |  4 +-
 4 files changed, 85 insertions(+), 53 deletions(-)

diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt
index 919267c..1a0c081 100644
--- a/unitTesting/CMakeLists.txt
+++ b/unitTesting/CMakeLists.txt
@@ -16,40 +16,61 @@
 ADD_DEFINITIONS(-DDEBUG=2)
 
 SET(tests
-	dummy
-	test_djj
-    test_dyn
-	test_results)
+  dummy
+  test_djj
+  test_dyn
+  test_results)
 
 SET(test_dyn_plugins_dependencies dynamic)
 
+# getting the information for the robot.
+SET(samplemodelpath ${JRL_DYNAMICS_PKGDATAROOTDIR}/examples/data/)
+SET(samplespec
+  ${JRL_DYNAMICS_PKGDATAROOTDIR}/examples/data/sampleSpecificities.xml
+  )
+SET(sampleljr
+  ${JRL_DYNAMICS_PKGDATAROOTDIR}/examples/data/sampleLinkJointRank.xml
+  )
+SET(sampleinitconfig
+  ${JRL_DYNAMICS_PKGDATAROOTDIR}/examples/data/sampleInitConfig.dat)
+
+LIST(APPEND LOGGING_WATCHED_VARIABLES samplespec sampleljr)
+
 FOREACH(test ${tests})
-	SET(EXECUTABLE_NAME "${test}_exe")
-	ADD_EXECUTABLE(${EXECUTABLE_NAME}
-	  ${test}.cpp)
-
-	TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
-	  	zmpreffromcom
-		force-compensation
-		integrator-force-exact
-		mass-apparent
-		integrator-force-rk4
-		integrator-force
-		angle-estimator
-		waist-attitude-from-sensor
-		)
-
-    PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} jrl-dynamics)
-    PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} hrp2-dynamics)
-    PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} sot-core)
-    PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph)
-    PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} jrl-mal)
-
-    IF(${test}_plugins_dependencies)
-        ADD_DEPENDENCIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}")
-        TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}")
-    ENDIF(${test}_plugins_dependencies)
-
-
-	ADD_TEST(${test} ${EXECUTABLE_NAME})
+  SET(EXECUTABLE_NAME "${test}_exe")
+  ADD_EXECUTABLE(${EXECUTABLE_NAME}
+    ${test}.cpp)
+
+  TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
+    zmpreffromcom
+    force-compensation
+    integrator-force-exact
+    mass-apparent
+    integrator-force-rk4
+    integrator-force
+    angle-estimator
+    waist-attitude-from-sensor
+    )
+
+  PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} jrl-dynamics)
+  PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} hrp2-dynamics)
+  PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} sot-core)
+  PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph)
+  PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} jrl-mal)
+
+
+  IF(${test}_plugins_dependencies)
+    ADD_DEPENDENCIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}")
+    TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}")
+  ENDIF(${test}_plugins_dependencies)
+
+
+  ADD_TEST(${test} ${EXECUTABLE_NAME}
+    ${samplemodelpath} sample.wrl ${samplespec} ${sampleljr} )
+
+  IF (UNIX)
+    SET_PROPERTY(TEST ${test} PROPERTY 
+      ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_BINARY_DIR}/src")
+  ENDIF(UNIX)
+
 ENDFOREACH(test)
diff --git a/unitTesting/test_djj.cpp b/unitTesting/test_djj.cpp
index 9b4d24f..4ec9d62 100644
--- a/unitTesting/test_djj.cpp
+++ b/unitTesting/test_djj.cpp
@@ -225,4 +225,5 @@ int main(int argc, char *argv[])
   // The End!
   delete aHDR;
 
+  return true;
 }
diff --git a/unitTesting/test_dyn.cpp b/unitTesting/test_dyn.cpp
index 0bfa715..36cd6b5 100644
--- a/unitTesting/test_dyn.cpp
+++ b/unitTesting/test_dyn.cpp
@@ -28,28 +28,38 @@
 using namespace std;
 using namespace sot;
 
-int main( void )
+int main(int argc, char * argv[])
 {
 
-
+  if (argc!=5)
+    {
+      cerr << "Usage:" << endl;
+      cerr << "./" << argv[0] << " DIR_OF_VRML_MODEL VRML_MODEL_FILENAME PATH_TO_SPECIFICITIES_FILE PATH_TO_LINK2JOINT_FILE " << endl;
+      cerr << " DIR_OF_VRML_MODEL : Directory where the robot VRML model lies. "<< endl;
+      cerr << " VRML_MODEL_FILENAME : Filename of the VRML model describing the robot."  << endl;
+      cerr << " PATH_TO_SPECIFICITIES_FILE : Path to the file describing the humanoid robot specificities." << endl;
+      cerr << " PATH_TO_LINK2JOINT_FILE: Path to the file describing the relationship of the joint and the state vector."  << endl;
+    }
   Dynamic * dyn = new Dynamic("tot");
-  try {
-  dyn->setVrmlDirectory("~/src/OpenHRP/etc/HRP2JRL/");
-  dyn->setXmlSpecificityFile("~/src/PatternGeneratorJRL/src/data/HRP2Specificities.xml");
-  dyn->setXmlRankFile("~/src/PatternGeneratorJRL/src/data/HRP2LinkJointRank.xml");
-  dyn->setVrmlMainFile("HRP2JRLmain.wrl");
-
-  dyn->parseConfigFiles();
-  } catch (sot::ExceptionDynamic& e)
-  {
-	  if ( !strcmp(e.what(), "Error while parsing." )) {
-		  cout << "Could not locate the necessary files for this test" << endl;
-		  return 77;
-	  }
-	  else
-		  // rethrow
-		  throw e;
-  }
+  try 
+    {
+      dyn->setVrmlDirectory(argv[1]);
+      dyn->setXmlSpecificityFile(argv[3]);
+      dyn->setXmlRankFile(argv[4]);
+      dyn->setVrmlMainFile(argv[2]);
+      
+      dyn->parseConfigFiles();
+    } 
+  catch (sot::ExceptionDynamic& e)
+    {
+      if ( !strcmp(e.what(), "Error while parsing." )) {
+	cout << "Could not locate the necessary files for this test" << endl;
+	return 77;
+      }
+      else
+	// rethrow
+	throw e;
+    }
   
   istringstream iss;
   string help("help");
diff --git a/unitTesting/test_results.cpp b/unitTesting/test_results.cpp
index 904d25e..275db56 100644
--- a/unitTesting/test_results.cpp
+++ b/unitTesting/test_results.cpp
@@ -41,11 +41,11 @@ using namespace std;
 
 int main(int argc, char * argv[])
 {
-  if (argc!=5)
+  if (argc!=6)
     {
       cerr << " This program takes 4 arguments: " << endl;
       cerr << "./TestHumanoidDynamicRobot PATH_TO_VRML_FILE VRML_FILE_NAME "<< endl;
-      cerr << " PATH_TO_SPECIFICITIES_XML PATH PATH_TO_MAP_JOINT_2_RANK" << endl;
+      cerr << " PATH_TO_SPECIFICITIES_XML PATH PATH_TO_MAP_JOINT_2_RANK INITIAL_CONFIGURATION_FILE" << endl;
       exit(0);
     }	
 
-- 
GitLab