X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNELTest%2FTestInterpKernelUtils.cxx;h=5adeb43fc15ee2b67c8588b9550ef92fff8b29f0;hb=aa702382d781b69b0e45feb8007789523c04f35b;hp=7573e85cf565908b26e52cbc97a0b205678e8e6a;hpb=10f37bf6f33a762626d7f1093b2f5450c1688667;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx index 7573e85cf..5adeb43fc 100644 --- a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx +++ b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 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 // 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 @@ -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 check' 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; }