blob: 73f3aa7da276d6ea8f63bf9257956450fd3d34bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "helpers.h"
#include <stdexcept>
#include <stdlib.h>
#include <dlfcn.h>
#include <fstream>
#include <boost/test/test_tools.hpp>
void
system(const std::string & cmd)
{
if (system(cmd.c_str())) {
// LCOV_EXCL_START
fprintf(stderr, "Failed to execute:\n\t%s\n", cmd.c_str());
throw std::runtime_error(cmd);
// LCOV_EXCL_STOP
}
}
void
diff(const boost::filesystem::path & left, const boost::filesystem::path & right)
{
std::ifstream fl(left.string());
std::ifstream fr(right.string());
std::string l, r;
std::copy_if(std::istreambuf_iterator<char>(fl), std::istreambuf_iterator<char>(), back_inserter(l), [](char x){ return !isspace(x); });
std::copy_if(std::istreambuf_iterator<char>(fr), std::istreambuf_iterator<char>(), back_inserter(r), [](char x){ return !isspace(x); });
BOOST_REQUIRE_EQUAL(l, r);
}
void *
loadlib(const boost::filesystem::path & so)
{
auto handle = dlopen(so.string().c_str(), RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
// LCOV_EXCL_START
throw std::runtime_error(dlerror());
// LCOV_EXCL_STOP
}
return handle;
}
void
closelib(void * handle)
{
if (dlclose(handle)) {
// LCOV_EXCL_START
throw std::runtime_error(dlerror());
// LCOV_EXCL_STOP
}
}
|