Commit 95d5e8b5 authored by Pavel Vainerman's avatar Pavel Vainerman

(tests): добавил заготовку для тестов "extensions"(расширений).

Исправил пару ошибочек. Удалил лишние файлы.
parent 89406a14
......@@ -30,7 +30,7 @@ prefix(prefix)
}
int tmID=1;
for( ;it1.getCurrent(); ++it1,++tmID )
for( ;it1.getCurrent(); it1++,++tmID )
initRRD(it1,tmID);
}
// -----------------------------------------------------------------------------
......@@ -74,7 +74,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
throw SystemError(err.str());
}
for(;it_rra.getCurrent(); ++it_rra )
for(;it_rra.getCurrent(); it_rra++ )
{
string rra( it_rra.getProp("rra") );
if( rra.empty() )
......
SUBDIR=SMemoryTest
noinst_PROGRAMS = calibration digitalfilter
noinst_PROGRAMS = tests tests_with_conf tests_with_sm
calibration_SOURCES = calibration.cc
calibration_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
calibration_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include
tests_SOURCES = tests.cc calibration.cc digitalfilter.cc
tests_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
tests_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include -I$(includedir)/Catch
digitalfilter_SOURCES = digitalfilter.cc
digitalfilter_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
digitalfilter_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include
tests_with_conf_SOURCES = tests_with_conf.cc
tests_with_conf_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la
tests_with_conf_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include -I$(includedir)/Catch
tests_with_sm_SOURCES = tests_with_sm.cc
tests_with_sm_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \
$(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la $(SIGC_LIBS) $(COMCPP_LIBS)
tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include -I$(includedir)/Catch \
-I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(COMCPP_CFLAGS)
#include <catch.hpp>
#if 0
#include <iostream>
#include "Exceptions.h"
#include "UniXML.h"
......@@ -77,3 +80,4 @@ int main( int argc, const char** argv )
return 1;
}
#endif
\ No newline at end of file
#include <catch.hpp>
#if 0
#include <iostream>
#include <vector>
#include <iomanip>
......@@ -44,3 +47,4 @@ int main( int argc, const char** argv )
return 1;
}
#endif
\ No newline at end of file
#define CATCH_CONFIG_MAIN
#include <Catch/catch.hpp>
// не удивляйтесь, что тут нет main().. она спрятана в catch.cpp :)
#define CATCH_CONFIG_RUNNER
#include <catch.hpp>
#include <iostream>
#include "Configuration.h"
int main( int argc, char* argv[] )
{
Catch::Session session;
try
{
UniSetTypes::uniset_init(argc,argv);
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error
return returnCode;
return session.run();
}
catch( UniSetTypes::Exception& ex )
{
std::cerr << ex << std::endl;
}
return 1;
}
#!/bin/sh
# '--' - нужен для отделения аоргументов catch, от наших..
uniset-start.sh -f ./tests_with_conf $* -- --confile tests_with_conf.xml --prop-id2 -10
<?xml version = '1.0' encoding = 'UTF-8' ?>
<UNISETPLC>
<UserData></UserData>
<!-- Общие(стартовые) параметры по UniSet -->
<UniSet>
<NameService host="localhost" port="2809"/>
<LocalNode name="localhost"/>
<RootSection name="UNISET_PLC"/>
<CountOfNet name="1"/>
<RepeatCount name="3"/>
<RepeatTimeoutMS name="50"/>
<WatchDogTime name="0"/> <!-- [мин] -->
<PingNodeTime name="0"/> <!-- [сек] -->
<AutoStartUpTime name="1"/> <!-- [сек] -->
<DumpStateTime name="10"/><!-- [сек] -->
<SleepTickMS name="500"/><!-- [мсек] -->
<!-- Debug, logs -->
<UniSetDebug name="unideb" levels="crit,warn" file=""/>
<!-- Если не указано, то считается текущий каталог -->
<ConfDir name=""/>
<DataDir name=""/>
<BinDir name=""/>
<LogDir name=""/>
<DocDir name=""/>
<LockDir name=""/>
<testnode name="testnode" id2="-100"/>
<Services>
<LocalTimeService name="TimeService" MaxCountTimers="100" AskLifeTimeSEC="10"/>
<LocalInfoServer name="InfoServer" dbrepeat="1">
<RouteList>
</RouteList>
</LocalInfoServer>
<LocalDBServer name="DBServer" dbnode="" dbname="UNISET_PLC" dbuser="dbadmin" dbpass="dbadmin" pingTime="60000" reconnectTime="30000"/>
<LocalPrintServer device="/dev/lp0" checkTime="5000" />
</Services>
</UniSet>
<dlog name="dlog" levels="" file=""/>
<ObjectsMap idfromfile="1">
<!--
Краткие пояснения к полям секции 'sensors'
==========================================
node - узел на котором физически находится данный датчик
iotype - тип датчика
priority - приоритет сообщения об изменении данного датчика
textname - текстовое имя датчика
-->
<nodes port="2809">
<item id="1000" name="localhost" alias="" textname="Локальный узел" ip="127.0.0.1"/>
<item id="1001" name="node2" alias="" textname="Локальный узел" ip="127.0.0.1"/>
</nodes>
<!-- ************************ Датчики ********************** -->
<sensors name="Sensors">
<item id="1" name="Input1_S" textname="Команда 1" node="" iotype="DI" priority="Medium" default="1" />
<item id="4" name="Input2_S" textname="Команда 2" node="" iotype="DI" priority="Medium" />
<item id="140" name="Input3_S" textname="Команда 3" node="" iotype="DI" priority="Medium"/>
</sensors>
<thresholds name="thresholds">
</thresholds>
<controllers name="Controllers">
<item id="90" name="SharedMemory"/>
</controllers>
<!-- ******************* Идентификаторы сервисов ***************** -->
<services name="Services">
<item id="99" name="TimeService"/>
</services>
<!-- ******************* Идентификаторы объектов ***************** -->
<objects name="UniObjects">
<item id="100" name="TestProc"/>
</objects>
</ObjectsMap>
<messages name="messages" idfromfile="1" >
</messages>
</UNISETPLC>
#define CATCH_CONFIG_RUNNER
#include <catch.hpp>
#include <string>
#include "Debug.h"
#include "UniSetActivator.h"
#include "SharedMemory.h"
#include "Extensions.h"
// --------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// --------------------------------------------------------------------------
int main(int argc, char* argv[] )
{
Catch::Session session;
if( argc>1 && ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) )
{
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm");
return 0;
}
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error
return returnCode;
try
{
uniset_init(argc,argv);
/*
conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log");
string logname( conf->getLogDir() + logfilename );
ulog.logFile( logname );
dlog.logFile( logname );
*/
SharedMemory* shm = SharedMemory::init_smemory(argc, argv);
if( !shm )
return 1;
UniSetActivator* act = UniSetActivator::Instance();
act->addObject(static_cast<class UniSetObject*>(shm));
SystemMessage sm(SystemMessage::StartUp);
act->broadcast( sm.transport_msg() );
act->run(true);
int ret = session.run();
act->oaDestroy();
return ret;
}
catch( SystemError& err )
{
cerr << "(tests_with_sm): " << err << endl;
}
catch( Exception& ex )
{
cerr << "(tests_with_sm): " << ex << endl;
}
catch( std::exception& e )
{
cerr << "(tests_with_sm): " << e.what() << endl;
}
catch(...)
{
cerr << "(tests_with_sm): catch(...)" << endl;
}
return 1;
}
#!/bin/sh
# '--' - нужен для отделения аоргументов catch, от наших..
uniset-start.sh -f ./tests_with_sm $* -- --confile tests_with_sm.xml
......@@ -361,20 +361,21 @@ void UniSetActivator::work()
ucrit << myname << "(work): line: " << fe.line() << endl;
ucrit << myname << "(work): mesg: " << fe.errmsg() << endl;
}
catch(...)
{
ucrit << myname << "(work): catch ..." << endl;
}
ulogsys << myname << "(work): orb thread stopped!" << endl;
ulogsys << myname << "(oaDestroy): orb destroy... " << endl;
try
try
{
ulogsys << myname << "(oaDestroy): orb destroy... " << endl;
orb->destroy();
}
catch(omniORB::fatalException& fe)
{
orb->destroy();
ucrit << myname << "(work): : поймали omniORB::fatalException:" << endl;
ucrit << myname << "(work): file: " << fe.file() << endl;
ucrit << myname << "(work): line: " << fe.line() << endl;
ucrit << myname << "(work): mesg: " << fe.errmsg() << endl;
}
catch(...){}
ulogsys << myname << "(oaDestroy): orb destroy ok."<< endl;
}
......
#include <string.h>
// http://www.cpptalk.net/invalid-conversion-from-char-to-const-char-vt13716.html
main(int argc, char **argv)
{
char **t1;
const char **t2;
const char **t3 = new const char *[10]; // t3 - массив указателей на const char*
char * const *t4 = new char*[10]; // t4 - константный массив указателей на char*
const char * const * t5;
t1 = argv;
// t2 = argv; // error: invalid conversion from 'char**' to 'const char**'
t2 = (const char**) argv;
t4 = argv;
t3[0] = argv[0];
// t4[0] = argv[0]; // error: assignment of read-only location '* t4'
t3[0] = new char[100];
//strcpy(t3[0],"text"); // error: invalid conversion from 'const char*' to 'char*'
strcpy(t4[0],"text"); // error: invalid conversion from 'const char*' to 'char*'
t3[0] = "test";
// t4[0] = "test"; // error: assignment of read-only location '* t4', warning: deprecated conversion from string constant to 'char*'
t5 = argv;
t5 = t3;
t5 = t4;
}
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
string str;
getline(cin, str);
cout << "size of str=" << str.size() << ", strlen=" << strlen(str.c_str()) << endl;
}
#include <iostream>
#include <algorithm>
using namespace std;
#include "Exceptions.h"
#include "UniXML.h"
#include "UniSetTypes.h"
void check( const std::string& name, const std::string& true_res, const std::string& your_res )
{
cout<<name<<endl;
cout<<"Correct result: "<<true_res<<endl;
if( your_res == true_res )
cout<<"Your result: "<<your_res<<"\n"<<endl;
else
cout<<"Your result - ERROR!"<<"\n"<<endl;
}
void myf(xmlNode it)
{
cout<<it.name<<endl;
}
int main()
{
UniXML xml("iterator_test.xml");
UniXML::iterator it=xml.begin();
it.find("messages");
check( "Check find():", "messages", it.getName() );
it=xml.begin();
it.find("d7");
check( "Check find():", "d7", it.getName() );
it=xml.begin();
it.findName("c5","6abc");
check( "Check findName():", "c5", it.getName() );
it=xml.begin();
it.findName("messages","messages");
check( "Check findName():", "messages", it.getName() );
it=xml.begin();
it.find("UniSet");
it++;
++it;
check( "Check iterator ++ :", "ObjectsMap", it.getName() );
it=xml.begin();
it.find("testII");
it++;
it--;
--it;
check( "Check iterator -- :", "a2", it.getName() );
it=xml.begin();
it.goChildren();
cout<<"Check algorythm 'for_each()':\n";
for_each(it,xml.end(),myf);
cout<<"\nCorrect result for algoryhtm 'for_each()':\n"<<"UniSet \n"<<"dlog \n"
<<"ObjectsMap \n"<<"messages \n";
it=xml.begin();
it.find("test");
if( it.find("messages") )
cout << "ERROR! begin=<UniSet> but find <messages>!" << endl;
return 0;
}
<?xml version = '1.0' encoding = 'UTF-8' ?>
<UNISETPLC>
<UniSet>
<test name="testattr_0">
<a1 name="1abc"/>
<a2 name="2abc"/>
<testI name="testattr_1">
<b3 name="3abc"/>
<a2 name="3abc"/>
<testII name="testattr_2">
<c4 name="4abc"/>
<c5 name="5abc"/>
</testII>
<testIII name="testattr_3">
<d6 name="6abc"/>
<d7 name="7abc"/>
<a2 name="4abc"/>
<c5 name="6abc"/>
</testIII>
</testI>
<testIV name="testattr_4">
<e8 name="8abc"/>
<e9>
<f10 name="10abc">
</f10>
</e9>
</testIV>
<a2 name="5abc"/>
<c5 name="7abc"/>
</test>
</UniSet>
<dlog name="dlog" levels="" file=""/>
<ObjectsMap idfromfile="1">
</ObjectsMap>
<messages name="messages" idfromfile="1" >
<child>
</child>
</messages>
</UNISETPLC>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment