From 6248cd30815eebb1a95e99b812c58e17825bbd6c Mon Sep 17 00:00:00 2001
From: Marco Bartolini <bartolini@ira.inaf.it>
Date: Tue, 2 Feb 2016 09:16:56 +0000
Subject: [PATCH] Added Roach component to SystemMake Makefile Common Modules

---
 Common/Misc/getTemplateForTest/src/Makefile   |  8 +-
 .../src/gettemplatefortest.py                 |  6 +-
 .../Misc/getTemplateForTest/src/install_gmock | 32 -------
 .../templates/discos-test/Makefile            | 90 +++++++++++++++++++
 .../discos-test/external/__init__.py          |  0
 .../discos-test/functional/__init__.py        |  0
 .../templates/discos-test/pyunit/__init__.py  |  0
 .../templates/discos-test/unittest.cpp        |  6 ++
 .../src/MedMinorServoControl.cpp              |  1 +
 9 files changed, 103 insertions(+), 40 deletions(-)
 delete mode 100644 Common/Misc/getTemplateForTest/src/install_gmock
 create mode 100644 Common/Misc/getTemplateForTest/templates/discos-test/Makefile
 create mode 100644 Common/Misc/getTemplateForTest/templates/discos-test/external/__init__.py
 create mode 100644 Common/Misc/getTemplateForTest/templates/discos-test/functional/__init__.py
 create mode 100644 Common/Misc/getTemplateForTest/templates/discos-test/pyunit/__init__.py
 create mode 100644 Common/Misc/getTemplateForTest/templates/discos-test/unittest.cpp

diff --git a/Common/Misc/getTemplateForTest/src/Makefile b/Common/Misc/getTemplateForTest/src/Makefile
index b4f45ecef..ec0e1703f 100644
--- a/Common/Misc/getTemplateForTest/src/Makefile
+++ b/Common/Misc/getTemplateForTest/src/Makefile
@@ -15,8 +15,6 @@
 PY_SCRIPTS         = getTemplateForTest
 PY_MODULES         = gettemplatefortest
 
-SCRIPTS_L          = install_gmock
-
 #
 #>>>>> END OF standard rules
 
@@ -37,7 +35,7 @@ all:	do_all
 	@echo " . . . 'all' done" 
 
 clean_templates:
-	rm -rf $(INTROOT)/templates/test
+	rm -rf $(INTROOT)/templates/discos-test
 	@echo " . . . templates removed from introot"
 
 clean : clean_all clean_templates
@@ -50,8 +48,8 @@ man   : do_man
 	@echo " . . . man page(s) done"
 
 install_templates:
-	cp -r ../templates/test $(INTROOT)/templates
-	find $(INTROOT)/templates/test -type d -name ".svn" | xargs rm -rf
+	cp -r ../templates/discos-test $(INTROOT)/templates
+	find $(INTROOT)/templates/discos-test -type d -name ".svn" | xargs rm -rf
 	@echo " . . . templates installed"
 
 install : install_all install_templates
diff --git a/Common/Misc/getTemplateForTest/src/gettemplatefortest.py b/Common/Misc/getTemplateForTest/src/gettemplatefortest.py
index e25cf8b0a..9ed6c70f2 100644
--- a/Common/Misc/getTemplateForTest/src/gettemplatefortest.py
+++ b/Common/Misc/getTemplateForTest/src/gettemplatefortest.py
@@ -6,7 +6,7 @@ usage = """
 getTmplateForTest - create a test directory containing the necessary code templates
                     used for component automated testing.
                     This command should be run from within a Component directory at
-                    the first level of depth, creating a 'test' directory at the same level 
+                    the first level of depth, creating a 'discos-test' directory at the same level 
                     of 'src, objects' ecc...
 """                    
 
@@ -19,7 +19,7 @@ def get_introot():
 
 def get_template_dir_name():
     introot = get_introot()
-    return os.path.join(introot, "templates/test")
+    return os.path.join(introot, "templates/discos-test")
 
 def get_template_dir():
     template_dir = get_template_dir_name()
@@ -40,7 +40,7 @@ def command_line_util(args):
         print usage
         sys.exit(0)
     else:
-        target_dir = 'test' # Default target directory
+        target_dir = 'discos-test' # Default target directory
 
     if os.path.exists(target_dir):
         msg = "ERROR: %s directory already exists." %target_dir
diff --git a/Common/Misc/getTemplateForTest/src/install_gmock b/Common/Misc/getTemplateForTest/src/install_gmock
deleted file mode 100644
index efaf2a576..000000000
--- a/Common/Misc/getTemplateForTest/src/install_gmock
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-if [[ $(id -u) -ne 0 ]] ; then echo "Script must be run as root" ; exit 1 ; fi
-GMOCK=gmock-1.7.0
-GMOCK_BASE_URL=https://googlemock.googlecode.com/files
-BUILDDIR=build
-PWD=`pwd`
-TMPDIR=`mktemp -d`
-cd $TMPDIR
-wget $GMOCK_BASE_URL/$GMOCK.zip
-unzip $GMOCK.zip
-cd $GMOCK
-export GMOCK_HOME=`pwd`
-mkdir $BUILDDIR
-cd $BUILDDIR
-cmake ..
-make
-chmod a+x *.a
-cp *.a /usr/local/lib
-cd $GMOCK_HOME/include
-cp -r gmock /usr/local/include
-cd $GMOCK_HOME/gtest
-mkdir $BUILDDIR
-cd $BUILDDIR
-cmake ..
-make
-chmod a+x *.a
-cp *.a /usr/local/lib
-cd $GMOCK_HOME/gtest/include
-cp -r gtest /usr/local/include
-cd $PWD
-rm -rf $TMPDIR
-
diff --git a/Common/Misc/getTemplateForTest/templates/discos-test/Makefile b/Common/Misc/getTemplateForTest/templates/discos-test/Makefile
new file mode 100644
index 000000000..61373fb49
--- /dev/null
+++ b/Common/Misc/getTemplateForTest/templates/discos-test/Makefile
@@ -0,0 +1,90 @@
+# CPP UNIT TESTING SETUP
+#--------------
+GTEST_HOME=/usr/local/include/gtest
+GMOCK_HOME=/usr/local/include/gmock
+GTEST_LIBS=gtest gtest_main
+
+USER_INC=-I$(GTEST_HOME) -I$(GMOCK_HOME)
+USER_LIBS=C++ pthread
+# END OF CPP UNIT TESTING SETUP
+#---------------------
+
+# DEFINE YOUR CPP UNIT TEST EXECUTABLES HERE as:
+#
+# EXECTUABLES_L = unittest
+# unittest_OBJECTS = unittest
+# unittest_LIBS = $(GTEST_LIBS) <ComponentNameImpl>
+
+EXECUTABLES_L = unittest
+unittest_OBJECTS = unittest
+unittest_LIBS = $(GTEST_LIBS) 
+
+# END OF CUSTOMIZATION
+# do not edit below this line
+#----------------------------
+
+CSOURCENAMES = \
+	$(foreach exe, $(EXECUTABLES) $(EXECUTABLES_L), $($(exe)_OBJECTS)) \
+	$(foreach rtos, $(RTAI_MODULES) , $($(rtos)_OBJECTS)) \
+	$(foreach lib, $(LIBRARIES) $(LIBRARIES_L), $($(lib)_OBJECTS))
+
+MAKEDIRTMP := $(shell searchFile include/acsMakefile)
+ifneq ($(MAKEDIRTMP),\#error\#)
+   MAKEDIR := $(MAKEDIRTMP)/include
+   include $(MAKEDIR)/acsMakefile
+endif
+
+# TEST TARGETS
+#TODO: unittest(2) discover pyunit
+
+do_unit: all
+	@echo "running cpp unit tests"
+	../bin/unittest --gtest_output=xml:results/cppunittest.xml
+
+do_pyunit:
+	@echo "running python unit tests"
+	python -m unittest pyunit
+
+do_functional:
+	@echo "running python functional tests"
+	python -m unittest functional
+
+do_external:
+	@echo "running python external tests"
+	python -m unittest external
+
+clean_test:
+	rm -f results/*.xml
+	rm -f functional/*.pyc
+	rm -f pyunit/*.pyc
+	rm -f external/*.pyc
+
+unit: do_unit
+	@echo " . . . 'unit' done"
+
+pyunit: do_pyunit
+	@echo " . . . 'pyunit' done"
+
+functional: do_functional
+	@echo " . . . 'functional' done"
+
+external: do_external
+	@echo " . . . 'external' done"
+
+# TARGETS
+# -------
+all:	do_all
+	@echo " . . . 'all' done" 
+
+clean : clean_all clean_test
+	@echo " . . . clean done"
+
+clean_dist : clean_all clean_dist_all clean_test
+	@echo " . . . clean_dist done"
+
+man   : do_man 
+	@echo " . . . man page(s) done"
+
+install : install_all
+	@echo " . . . installation done"
+
diff --git a/Common/Misc/getTemplateForTest/templates/discos-test/external/__init__.py b/Common/Misc/getTemplateForTest/templates/discos-test/external/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/Common/Misc/getTemplateForTest/templates/discos-test/functional/__init__.py b/Common/Misc/getTemplateForTest/templates/discos-test/functional/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/Common/Misc/getTemplateForTest/templates/discos-test/pyunit/__init__.py b/Common/Misc/getTemplateForTest/templates/discos-test/pyunit/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/Common/Misc/getTemplateForTest/templates/discos-test/unittest.cpp b/Common/Misc/getTemplateForTest/templates/discos-test/unittest.cpp
new file mode 100644
index 000000000..59cb6295f
--- /dev/null
+++ b/Common/Misc/getTemplateForTest/templates/discos-test/unittest.cpp
@@ -0,0 +1,6 @@
+#include "gtest/gtest.h"
+
+TEST(FakeTest, Success){
+    EXPECT_EQ(1, 1);
+}
+
diff --git a/Medicina/Servers/MedicinaMinorServo/src/MedMinorServoControl.cpp b/Medicina/Servers/MedicinaMinorServo/src/MedMinorServoControl.cpp
index c4196fb0f..440a9c3fa 100644
--- a/Medicina/Servers/MedicinaMinorServo/src/MedMinorServoControl.cpp
+++ b/Medicina/Servers/MedicinaMinorServo/src/MedMinorServoControl.cpp
@@ -281,6 +281,7 @@ MedMinorServoControl::reset()
     _commanded_status.enable = 0;
     _commanded_status.acknowledge = 0;
     _send_commanded_status(true);
+    //TODO: add a little wait time
     CUSTOM_LOG(LM_FULL_INFO,
            "MinorServo::MedMinorServoControl::reset",
            (LM_DEBUG, "enable = 0"));
-- 
GitLab