X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNamingService%2FTest%2FNamingServiceTest.cxx;h=9daff2e34f3c77b254b5c103a128ab96e986386e;hb=910e1b8c12ac2978e64847e9694b080c8381bc60;hp=033f8f87e64727db7795ea969db0679cf99b73b1;hpb=bbac39ee34bd6a5e6fd051024209399b97b818b1;p=modules%2Fkernel.git diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index 033f8f87e..9daff2e34 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,6 +23,10 @@ #include "NamingServiceTest.hxx" #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +#include "Basics_Utils.hxx" +#include "Basics_DirUtils.hxx" +#include "SALOME_LifeCycleCORBA.hxx" +#include "utilities.h" #include #include @@ -43,7 +47,9 @@ #define DEVTRACE(msg) #endif -#define TRACEFILE "/tmp/traceUnitTest.log" +#ifdef WIN32 +#define setenv Kernel_Utils::setenv +#endif // ============================================================================ /*! @@ -104,7 +110,14 @@ NSTEST::echo_ptr NSTEST_aFactory_i::createInstance() */ // ============================================================================ -void +std::string +NamingServiceTest::_getTraceFileName() +{ + std::string dir = Kernel_Utils::GetTmpDir(); + return dir + "traceUnitTest-NamingServiceTest.log"; +} + +void NamingServiceTest::setUp() { LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance(); @@ -112,7 +125,7 @@ NamingServiceTest::setUp() bp1->deleteInstance(bp1); // --- trace on file - const char *theFileName = TRACEFILE; + std::string theFileName = _getTraceFileName(); std::string s = "file:"; s += theFileName; @@ -122,7 +135,7 @@ NamingServiceTest::setUp() std::ofstream traceFile; // traceFile.open(theFileName, ios::out | ios::trunc); - traceFile.open(theFileName, std::ios::out | std::ios::app); + traceFile.open(theFileName.c_str(), std::ios::out | std::ios::app); CPPUNIT_ASSERT(traceFile); // file created empty, then closed traceFile.close(); @@ -152,7 +165,7 @@ NamingServiceTest::setUp() _factoryRef = _myFactory->_this(); _pman->activate(); _myFactory->_remove_ref(); - + } // ============================================================================ @@ -161,7 +174,7 @@ NamingServiceTest::setUp() */ // ============================================================================ -void +void NamingServiceTest::tearDown() { @@ -449,7 +462,7 @@ NamingServiceTest::testResolveFirst() * Test register and resolve multiple objects, test resolveFirst, relative path * Register a few objects in /nstestfirstrel/echo_n where n is the object id. * Resolve all the objects. - * ResolveFirst echo with a relative path /nstestfirstrel must give + * ResolveFirst echo with a relative path /nstestfirstrel must give * /nstestfirst/echo_i, corresponding to the first object. */ // ============================================================================ @@ -677,7 +690,7 @@ NamingServiceTest::testResolveComponentEmptyContainerName() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -709,7 +722,7 @@ NamingServiceTest::testResolveComponentUnknownContainerName() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -737,7 +750,7 @@ NamingServiceTest::testResolveComponentEmptyComponentName() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -761,7 +774,7 @@ NamingServiceTest::testResolveComponentUnknownComponentName() // ============================================================================ /*! - * Test with a false number nbproc. + * Test with a false number nbproc. * A positive number not corresponding to a registered component gives nil ref. * A negative number is not taken into account and may give a non nil ref. */ @@ -794,7 +807,7 @@ NamingServiceTest::testResolveComponentFalseNbproc() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -812,22 +825,15 @@ NamingServiceTest::testContainerName() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ void NamingServiceTest::testContainerNameParams() { - Engines::MachineParameters params; - params.container_name = ""; - params.hostname = ""; - params.OS = ""; - params.mem_mb = 0; - params.cpu_clock = 0; - params.nb_proc_per_node = 0; - params.nb_node = 0; - params.isMPI = false; + Engines::ContainerParameters params; + SALOME_LifeCycleCORBA::preSet(params); std::string ref0 = "FactoryServer"; std::string ret = _NS.ContainerName(params); @@ -841,7 +847,7 @@ NamingServiceTest::testContainerNameParams() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -859,22 +865,15 @@ NamingServiceTest::testBuildContainerNameForNS() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ void NamingServiceTest::testBuildContainerNameForNSParams() { - Engines::MachineParameters params; - params.container_name = ""; - params.hostname = ""; - params.OS = ""; - params.mem_mb = 0; - params.cpu_clock = 0; - params.nb_proc_per_node = 0; - params.nb_node = 0; - params.isMPI = false; + Engines::ContainerParameters params; + SALOME_LifeCycleCORBA::preSet(params); params.container_name = "theContainerName"; std::string ref0 = "/Containers/theHostName/theContainerName"; @@ -889,7 +888,7 @@ NamingServiceTest::testBuildContainerNameForNSParams() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -932,7 +931,7 @@ NamingServiceTest::testFind() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -979,7 +978,7 @@ NamingServiceTest::testCreateDirectory() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1006,11 +1005,11 @@ NamingServiceTest::testChangeDirectory() NSTEST::echo_var anEchoRef4 = myFactory->createInstance(); _NS.Register(anEchoRef4, "/Containers/anHostName/oneContainerName/theComponentName"); - + _NS.Change_Directory("/Containers/theHostName/otherContainerName"); obj = _NS.Resolve("theComponentName"); CPPUNIT_ASSERT(!CORBA::is_nil(obj)); - + NSTEST::echo_var anEchoRefa = NSTEST::echo::_narrow(obj); CPPUNIT_ASSERT(!CORBA::is_nil(anEchoRefa)); CPPUNIT_ASSERT(anEchoRefa->getId() == anEchoRef3->getId()); @@ -1018,7 +1017,7 @@ NamingServiceTest::testChangeDirectory() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1038,7 +1037,7 @@ NamingServiceTest::testCurrentDirectory() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1053,7 +1052,7 @@ NamingServiceTest::testList() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1068,7 +1067,7 @@ NamingServiceTest::testListDirectory() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1086,7 +1085,7 @@ NamingServiceTest::testListDirectoryRecurs() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1102,7 +1101,7 @@ NamingServiceTest::testListSubdirs() } // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1129,7 +1128,7 @@ NamingServiceTest::testDestroyName() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1200,7 +1199,7 @@ NamingServiceTest::testDestroyFullDirectory() // ============================================================================ /*! - * Test + * Test */ // ============================================================================ @@ -1209,12 +1208,12 @@ NamingServiceTest::testGetIorAddr() { CORBA::String_var root = _NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); - CPPUNIT_ASSERT(!CORBA::is_nil(obj)); + CPPUNIT_ASSERT(!CORBA::is_nil(obj)); } // ============================================================================ /*! - * Test + * Test */ // ============================================================================