Mercurial > hg > orthanc
changeset 429:09b3c6265a94
unit test for fedora 18 problem
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 May 2013 15:13:01 +0200 |
parents | 6f00823be12a |
children | f746592d8301 |
files | OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancInitialization.h Resources/CMake/LuaConfiguration.cmake UnitTests/main.cpp |
diffstat | 4 files changed, 33 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/OrthancInitialization.cpp Wed May 08 13:06:04 2013 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Wed May 08 15:13:01 2013 +0200 @@ -280,32 +280,40 @@ } - std::string InterpretStringParameterAsPath(const std::string& parameter) + std::string InterpretRelativePath(const std::string& baseDirectory, + const std::string& relativePath) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::filesystem::path base(baseDirectory); + boost::filesystem::path relative(relativePath); + + return (base / relative).string(); /** The following lines should be equivalent to this one: - return (defaultDirectory_ / parameter).string(); + return (base / relative).string(); However, for some unknown reason, some versions of Boost do not - make the proper path resolution when "defaultDirectory_" is an + make the proper path resolution when "baseDirectory" is an absolute path. So, a hack is used below. **/ - boost::filesystem::path p(parameter); - - if (p.is_absolute()) + if (relative.is_absolute()) { - return p.string(); + return relative.string(); } else { - return (defaultDirectory_ / parameter).string(); + return (base / relative).string(); } } + std::string InterpretStringParameterAsPath(const std::string& parameter) + { + boost::mutex::scoped_lock lock(globalMutex_); + return InterpretRelativePath(defaultDirectory_.string(), parameter); + } + void GetGlobalListOfStringsParameter(std::list<std::string>& target, const std::string& key)
--- a/OrthancServer/OrthancInitialization.h Wed May 08 13:06:04 2013 +0200 +++ b/OrthancServer/OrthancInitialization.h Wed May 08 15:13:01 2013 +0200 @@ -62,6 +62,9 @@ void SetupRegisteredUsers(MongooseServer& httpServer); + std::string InterpretRelativePath(const std::string& baseDirectory, + const std::string& relativePath); + std::string InterpretStringParameterAsPath(const std::string& parameter); void GetGlobalListOfStringsParameter(std::list<std::string>& target,
--- a/Resources/CMake/LuaConfiguration.cmake Wed May 08 13:06:04 2013 +0200 +++ b/Resources/CMake/LuaConfiguration.cmake Wed May 08 15:13:01 2013 +0200 @@ -56,15 +56,12 @@ source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*) else() - CHECK_INCLUDE_FILE_CXX(lua.h HAVE_LUA_H) - if (NOT HAVE_LUA_H) + include(FindLua51) + + if (NOT LUA51_FOUND) message(FATAL_ERROR "Please install the liblua-dev package") endif() - CHECK_LIBRARY_EXISTS(lua lua_pcall "" HAVE_LUA_LIB) - if (NOT HAVE_LUA_LIB) - message(FATAL_ERROR "Please install the liblua-dev package") - endif() - - link_libraries(lua) + include_directories(${LUA_INCLUDE_DIR}) + link_libraries(${LUA_LIBRARIES}) endif()
--- a/UnitTests/main.cpp Wed May 08 13:06:04 2013 +0200 +++ b/UnitTests/main.cpp Wed May 08 15:13:01 2013 +0200 @@ -335,6 +335,14 @@ } +#if defined(__linux) +TEST(OrthancInitialization, AbsoluteDirectory) +{ + ASSERT_EQ("/tmp/coucou", InterpretRelativePath("/tmp", "coucou")); +} +#endif + + int main(int argc, char **argv) { // Initialize Google's logging library.