Loading Common/Libraries/ParserLibrary/include/SP_parser.i +3 −7 Original line number Diff line number Diff line Loading @@ -71,8 +71,8 @@ IRA::CString CParser<OBJ>::executeCommand(const IRA::CString& command,IRA::CStri logCommand.RTrim(); if (!timeTagged) { //sync operations if (elem->m_type==PROCEDURE){ CUSTOM_LOG(LM_FULL_INFO,"CParser::executeCommand()",(LM_NOTICE,"Procedure issued {%s}",(const char *)logCommand)); pushProcedure(instr,elem->m_procedure,inParams,parNum); // throws ProcedureErrorExImpl CUSTOM_LOG(LM_FULL_INFO,"CParser::executeCommand()",(LM_NOTICE,"Procedure issued {%s}",(const char *)logCommand)); return instr+m_answerDelimiter; //it informs that the procedure seems to be correct and it will be executed } else if (elem->m_type==COMMAND) { Loading Loading @@ -348,14 +348,10 @@ void CParser<OBJ>::pushProcedure(const IRA::CString& name,const ACS::stringSeq& for(unsigned i=0;i<procedure.length();i++) { //check procedure correctness //replace the place holders with the procedure arguments IRA::CString line((const char *)procedure[i]); /* FIXME: if parameters are specified starting from $1 as in bash the * following cycle should be changed to increment j by one as now it * starts from $0 */ for (WORD j=0;j<parNumber;j++) { IRA::CString pp; pp.Format("%c%d",PROCEDUREPARAMETER,j); /*pp.Format("%c%d",PROCEDUREPARAMETER,j+1);*/ //pp.Format("%c%d",PROCEDUREPARAMETER,j); pp.Format("%c%d",PROCEDUREPARAMETER,j+1); line.ReplaceAll((const char *)pp,procPrm[j]); } try { Loading Common/Libraries/ParserLibrary/test/Makefile 0 → 100644 +90 −0 Original line number Diff line number Diff line # 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) IRALibrary SlaLibrary ParserErrors ComponentErrors # 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" Common/Libraries/ParserLibrary/test/external/__init__.py 0 → 100644 +0 −0 Empty file added. Common/Libraries/ParserLibrary/test/functional/__init__.py 0 → 100644 +0 −0 Empty file added. Common/Libraries/ParserLibrary/test/gtest/procedures.cpp 0 → 100644 +109 −0 Original line number Diff line number Diff line #include "gtest/gtest.h" #include <unistd.h> #include <fstream> #include <string> #include <vector> #include <IRA> #include "SP_parser.h" using namespace SimpleParser; class TestObject { public: TestObject(){}; void empty_command(){return;}; void unary_command(const char* parameter); IRA::CString result; }; void TestObject::unary_command(const char* parameter) { result = IRA::CString(parameter); return; } class TestProcedureParsing : public ::testing::Test { public: TestProcedureParsing(); virtual ~TestProcedureParsing(); TestObject to; CParser<TestObject> *m_parser; }; TestProcedureParsing::TestProcedureParsing() { m_parser = new CParser<TestObject>(&to, 8, true); m_parser->add("empty_command", new function0<TestObject, non_constant, void_type>( &to, &TestObject::empty_command), 0); m_parser->add("unary_command", new function1<TestObject, non_constant, void_type, I<string_type> >( &to, &TestObject::unary_command), 1); ACS::stringSeq noarg_procedure, arg_procedure; noarg_procedure.length(1); noarg_procedure[0] = "empty_command"; m_parser->addExtraProcedure("empty_procedure", "testprocedure", noarg_procedure, 0); arg_procedure.length(1); arg_procedure[0] = "unary_command=$1"; m_parser->addExtraProcedure("unary_procedure", "testprocedure", arg_procedure, 1); } TestProcedureParsing::~TestProcedureParsing() { delete m_parser; } TEST_F(TestProcedureParsing, test_setup) { ASSERT_TRUE(true); } TEST_F(TestProcedureParsing, run_command_without_argument) { IRA::CString procedure = "empty_command"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); SUCCEED(); } TEST_F(TestProcedureParsing, run_procedure_without_argument) { IRA::CString procedure = "empty_procedure"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); SUCCEED(); } TEST_F(TestProcedureParsing, run_command_with_argument) { IRA::CString procedure = "unary_command=ciao"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); ASSERT_EQ(IRA::CString("ciao"), to.result); } TEST_F(TestProcedureParsing, run_procedure_with_argument) { IRA::CString procedure = "unary_procedure=ciao"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); sleep(5); ASSERT_EQ(IRA::CString("ciao"), to.result); } Loading
Common/Libraries/ParserLibrary/include/SP_parser.i +3 −7 Original line number Diff line number Diff line Loading @@ -71,8 +71,8 @@ IRA::CString CParser<OBJ>::executeCommand(const IRA::CString& command,IRA::CStri logCommand.RTrim(); if (!timeTagged) { //sync operations if (elem->m_type==PROCEDURE){ CUSTOM_LOG(LM_FULL_INFO,"CParser::executeCommand()",(LM_NOTICE,"Procedure issued {%s}",(const char *)logCommand)); pushProcedure(instr,elem->m_procedure,inParams,parNum); // throws ProcedureErrorExImpl CUSTOM_LOG(LM_FULL_INFO,"CParser::executeCommand()",(LM_NOTICE,"Procedure issued {%s}",(const char *)logCommand)); return instr+m_answerDelimiter; //it informs that the procedure seems to be correct and it will be executed } else if (elem->m_type==COMMAND) { Loading Loading @@ -348,14 +348,10 @@ void CParser<OBJ>::pushProcedure(const IRA::CString& name,const ACS::stringSeq& for(unsigned i=0;i<procedure.length();i++) { //check procedure correctness //replace the place holders with the procedure arguments IRA::CString line((const char *)procedure[i]); /* FIXME: if parameters are specified starting from $1 as in bash the * following cycle should be changed to increment j by one as now it * starts from $0 */ for (WORD j=0;j<parNumber;j++) { IRA::CString pp; pp.Format("%c%d",PROCEDUREPARAMETER,j); /*pp.Format("%c%d",PROCEDUREPARAMETER,j+1);*/ //pp.Format("%c%d",PROCEDUREPARAMETER,j); pp.Format("%c%d",PROCEDUREPARAMETER,j+1); line.ReplaceAll((const char *)pp,procPrm[j]); } try { Loading
Common/Libraries/ParserLibrary/test/Makefile 0 → 100644 +90 −0 Original line number Diff line number Diff line # 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) IRALibrary SlaLibrary ParserErrors ComponentErrors # 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"
Common/Libraries/ParserLibrary/test/gtest/procedures.cpp 0 → 100644 +109 −0 Original line number Diff line number Diff line #include "gtest/gtest.h" #include <unistd.h> #include <fstream> #include <string> #include <vector> #include <IRA> #include "SP_parser.h" using namespace SimpleParser; class TestObject { public: TestObject(){}; void empty_command(){return;}; void unary_command(const char* parameter); IRA::CString result; }; void TestObject::unary_command(const char* parameter) { result = IRA::CString(parameter); return; } class TestProcedureParsing : public ::testing::Test { public: TestProcedureParsing(); virtual ~TestProcedureParsing(); TestObject to; CParser<TestObject> *m_parser; }; TestProcedureParsing::TestProcedureParsing() { m_parser = new CParser<TestObject>(&to, 8, true); m_parser->add("empty_command", new function0<TestObject, non_constant, void_type>( &to, &TestObject::empty_command), 0); m_parser->add("unary_command", new function1<TestObject, non_constant, void_type, I<string_type> >( &to, &TestObject::unary_command), 1); ACS::stringSeq noarg_procedure, arg_procedure; noarg_procedure.length(1); noarg_procedure[0] = "empty_command"; m_parser->addExtraProcedure("empty_procedure", "testprocedure", noarg_procedure, 0); arg_procedure.length(1); arg_procedure[0] = "unary_command=$1"; m_parser->addExtraProcedure("unary_procedure", "testprocedure", arg_procedure, 1); } TestProcedureParsing::~TestProcedureParsing() { delete m_parser; } TEST_F(TestProcedureParsing, test_setup) { ASSERT_TRUE(true); } TEST_F(TestProcedureParsing, run_command_without_argument) { IRA::CString procedure = "empty_command"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); SUCCEED(); } TEST_F(TestProcedureParsing, run_procedure_without_argument) { IRA::CString procedure = "empty_procedure"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); SUCCEED(); } TEST_F(TestProcedureParsing, run_command_with_argument) { IRA::CString procedure = "unary_command=ciao"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); ASSERT_EQ(IRA::CString("ciao"), to.result); } TEST_F(TestProcedureParsing, run_procedure_with_argument) { IRA::CString procedure = "unary_procedure=ciao"; IRA::CString output; m_parser->run(procedure, output); //This is a google test macro RecordProperty("run_output", (const char*) output); sleep(5); ASSERT_EQ(IRA::CString("ciao"), to.result); }