Loading Common/Servers/Scheduler/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) SchedulerImpl IRALibrary # 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/Servers/Scheduler/test/external/__init__.py 0 → 100644 +0 −0 Empty file added. Common/Servers/Scheduler/test/functional/__init__.py 0 → 100644 +0 −0 Empty file added. Common/Servers/Scheduler/test/gtest/procedurelist.cpp 0 → 100644 +86 −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 "Schedule.h" using namespace Schedule; class TestProcedure : public ::testing::Test { public: TestProcedure(); virtual ~TestProcedure(); IRA::CString filename, basepath; std::string fullname; char* _basepath; CProcedureList *cpl; }; TestProcedure::TestProcedure() : filename("procedure.cfg") { char* _basepath = get_current_dir_name(); basepath = IRA::CString(_basepath); fullname = std::string((const char*)(basepath + "/" + filename)); cpl = new CProcedureList(basepath + "/", filename); free(_basepath); } TestProcedure::~TestProcedure() { delete cpl; } TEST_F(TestProcedure, can_open_procedure_file) { std::ifstream input_file; input_file.open(fullname.c_str()); ASSERT_TRUE(input_file.good()); ASSERT_TRUE(input_file.is_open()); input_file.close(); } TEST_F(TestProcedure, CProcedureList_constructor) { ASSERT_EQ(cpl->getTotalLines(), (DWORD)0); } TEST_F(TestProcedure, CProcedureList_readAll) { ASSERT_TRUE(cpl->readAll(false)) << "error: " << (const char*)cpl->getLastError(); } TEST_F(TestProcedure, CProcedureList_readAll_with_check) { ASSERT_TRUE(cpl->readAll(true)) << "error: " << (const char*)cpl->getLastError(); } TEST_F(TestProcedure, CProcedureList_getProcedure_by_name) { cpl->readAll(false); std::vector<IRA::CString> commands; WORD args; bool result = cpl->getProcedure("PROCEDURE_WAIT2", commands, args); ASSERT_TRUE(result) << "error: " << (const char*)cpl->getLastError(); ASSERT_EQ(commands[0], IRA::CString("wait=2")); } TEST_F(TestProcedure, CProcedureList_getProcedure_by_name_with_params) { cpl->readAll(false); std::vector<IRA::CString> commands; WORD args; bool result = cpl->getProcedure("PROCEDURE_WAIT_PARAM", commands, args); ASSERT_TRUE(result) << "error: " << (const char*)cpl->getLastError(); ASSERT_EQ(args, (WORD)1) << "error: " << (const char*)cpl->getLastError(); } Common/Servers/Scheduler/test/procedure.cfg 0 → 100644 +7 −0 Original line number Diff line number Diff line PROCEDURE_WAIT2{ wait=2 } PROCEDURE_WAIT_PARAM(1){ wait=$1 } Loading
Common/Servers/Scheduler/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) SchedulerImpl IRALibrary # 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/Servers/Scheduler/test/gtest/procedurelist.cpp 0 → 100644 +86 −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 "Schedule.h" using namespace Schedule; class TestProcedure : public ::testing::Test { public: TestProcedure(); virtual ~TestProcedure(); IRA::CString filename, basepath; std::string fullname; char* _basepath; CProcedureList *cpl; }; TestProcedure::TestProcedure() : filename("procedure.cfg") { char* _basepath = get_current_dir_name(); basepath = IRA::CString(_basepath); fullname = std::string((const char*)(basepath + "/" + filename)); cpl = new CProcedureList(basepath + "/", filename); free(_basepath); } TestProcedure::~TestProcedure() { delete cpl; } TEST_F(TestProcedure, can_open_procedure_file) { std::ifstream input_file; input_file.open(fullname.c_str()); ASSERT_TRUE(input_file.good()); ASSERT_TRUE(input_file.is_open()); input_file.close(); } TEST_F(TestProcedure, CProcedureList_constructor) { ASSERT_EQ(cpl->getTotalLines(), (DWORD)0); } TEST_F(TestProcedure, CProcedureList_readAll) { ASSERT_TRUE(cpl->readAll(false)) << "error: " << (const char*)cpl->getLastError(); } TEST_F(TestProcedure, CProcedureList_readAll_with_check) { ASSERT_TRUE(cpl->readAll(true)) << "error: " << (const char*)cpl->getLastError(); } TEST_F(TestProcedure, CProcedureList_getProcedure_by_name) { cpl->readAll(false); std::vector<IRA::CString> commands; WORD args; bool result = cpl->getProcedure("PROCEDURE_WAIT2", commands, args); ASSERT_TRUE(result) << "error: " << (const char*)cpl->getLastError(); ASSERT_EQ(commands[0], IRA::CString("wait=2")); } TEST_F(TestProcedure, CProcedureList_getProcedure_by_name_with_params) { cpl->readAll(false); std::vector<IRA::CString> commands; WORD args; bool result = cpl->getProcedure("PROCEDURE_WAIT_PARAM", commands, args); ASSERT_TRUE(result) << "error: " << (const char*)cpl->getLastError(); ASSERT_EQ(args, (WORD)1) << "error: " << (const char*)cpl->getLastError(); }
Common/Servers/Scheduler/test/procedure.cfg 0 → 100644 +7 −0 Original line number Diff line number Diff line PROCEDURE_WAIT2{ wait=2 } PROCEDURE_WAIT_PARAM(1){ wait=$1 }