X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNELTest%2FTestInterpKernelUtils.cxx;h=5adeb43fc15ee2b67c8588b9550ef92fff8b29f0;hb=aa702382d781b69b0e45feb8007789523c04f35b;hp=a814f2dc12d153da9b1edb0c39bed85267c4beb6;hpb=75943f980f7b908052ef03c2c0154508f4b0a039;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx index a814f2dc1..5adeb43fc 100644 --- a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx +++ b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -18,26 +18,47 @@ // #include "TestInterpKernelUtils.hxx" +#include "InterpKernelException.hxx" #include +#ifdef WIN32 +#include +#define getcwd _getcwd +#else +#include +#endif +#include +#include namespace INTERP_TEST { std::string getResourceFile( const std::string& filename ) { std::string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make test' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; - } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; + bool good = false; + + if ( getenv("MEDCOUPLING_ROOT_DIR") ) { + // use MEDCOUPLING_ROOT_DIR env.var + resourceFile = getenv("MEDCOUPLING_ROOT_DIR"); + resourceFile += "/share/resources/med/"; + resourceFile += filename; + std::ifstream my_file(resourceFile); + if (my_file.good()) + good = true; } - resourceFile += filename; + if (!good) + { + resourceFile = getcwd(NULL, 0); + resourceFile += "/../../resources/"; + std::ifstream my_file(resourceFile); + if (!my_file.good()) + { + std::stringstream ss; + ss << "INTERP_TEST::getResourceFile(): could not open resource test file: " << filename << "\n"; + throw INTERP_KERNEL::Exception(ss.str().c_str()); + } + } + return resourceFile; }