cuke: abort if bins are missing, closes #1341

This commit is contained in:
Emil Tin 2015-01-12 13:56:43 +01:00
parent 7e70fa63d7
commit eebf3a54e2
3 changed files with 147 additions and 3 deletions

103
Util/FingerPrint.cpp Normal file
View File

@ -0,0 +1,103 @@
/*
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "FingerPrint.h"
#include "OSRMException.h"
#include <boost/uuid/name_generator.hpp>
#include <algorithm>
#include <string>
#define HAS64BITS 0
#define MD5PREPARE "2a7459472965fa17443822b826aa61f8"
#define MD5RTREE "74e5d04195aebe6500db7b61603f1d69"
#define MD5GRAPH "53ec17ab0e1fc4737fc7599b3467928a"
#define MD5OBJECTS "434731cd393154817166fcec8b0ceab0"
FingerPrint::FingerPrint() : magic_number(1297240911)
{
md5_prepare[32] = md5_tree[32] = md5_graph[32] = md5_objects[32] = '\0';
boost::uuids::name_generator gen(named_uuid);
std::string temp_string;
std::memcpy(md5_prepare, MD5PREPARE, strlen(MD5PREPARE));
temp_string += md5_prepare;
std::memcpy(md5_tree, MD5RTREE, 32);
temp_string += md5_tree;
std::memcpy(md5_graph, MD5GRAPH, 32);
temp_string += md5_graph;
std::memcpy(md5_objects, MD5OBJECTS, 32);
temp_string += md5_objects;
named_uuid = gen(temp_string);
has_64_bits = HAS64BITS;
}
FingerPrint::~FingerPrint() {}
const boost::uuids::uuid &FingerPrint::GetFingerPrint() const { return named_uuid; }
bool FingerPrint::IsMagicNumberOK() const { return 1297240911 == magic_number; }
bool FingerPrint::TestGraphUtil(const FingerPrint &other) const
{
if (!other.IsMagicNumberOK())
{
throw OSRMException("hsgr input file misses magic number. Check or reprocess the file");
}
return std::equal(md5_graph, md5_graph + 32, other.md5_graph);
}
bool FingerPrint::TestPrepare(const FingerPrint &other) const
{
if (!other.IsMagicNumberOK())
{
throw OSRMException("osrm input file misses magic number. Check or reprocess the file");
}
return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare);
}
bool FingerPrint::TestRTree(const FingerPrint &other) const
{
if (!other.IsMagicNumberOK())
{
throw OSRMException("r-tree input file misses magic number. Check or reprocess the file");
}
return std::equal(md5_tree, md5_tree + 32, other.md5_tree);
}
bool FingerPrint::TestQueryObjects(const FingerPrint &other) const
{
if (!other.IsMagicNumberOK())
{
throw OSRMException("missing magic number. Check or reprocess the file");
}
return std::equal(md5_objects, md5_objects + 32, other.md5_objects);
}

29
Util/GitDescription.cpp Normal file
View File

@ -0,0 +1,29 @@
/*
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define GIT_DESCRIPTION "v0.4.3-234-g8eccfaa"
char g_GIT_DESCRIPTION[] = GIT_DESCRIPTION;

View File

@ -64,6 +64,19 @@ unless File.exists? TEST_FOLDER
raise "*** Test folder #{TEST_FOLDER} doesn't exist."
end
def verify_osrm_is_not_running
if OSRMLoader::OSRMBaseLoader.new.osrm_up?
raise "*** osrm-routed is already running."
end
end
def verify_existance_of_binaries
["osrm-extract", "osrm-prepare", "osrm-routed"].each do |bin|
unless File.exists? "#{BIN_PATH}/#{bin}"
raise "*** #{BIN_PATH}/#{bin} is missing. Build failed?"
end
end
end
if ENV['OS']=~/Windows.*/ then
EXE='.exe'
@ -74,10 +87,9 @@ else
end
AfterConfiguration do |config|
if OSRMLoader::OSRMBaseLoader.new.osrm_up?
raise "*** osrm-routed is already running."
end
clear_log_files
verify_osrm_is_not_running
verify_existance_of_binaries
end
at_exit do