Fix unit test failures

When the unit tests were run without installing the libraries in their
final locations, the loading of the modules would fail. Using locations
relative to the build directory allows unit testing without having to
install the libraries.
This commit is contained in:
Markus Mäkelä 2017-12-28 15:01:29 +02:00
parent a46881c0cc
commit 95983ddaf4
3 changed files with 30 additions and 4 deletions

View File

@ -15,6 +15,8 @@
#include <iostream>
#include <fstream>
#include <tr1/unordered_map>
#include <maxscale/alloc.h>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/log_manager.h>
#include "storagefactory.hh"
@ -126,11 +128,16 @@ int main(int argc, char* argv[])
if ((argc == 2) || (argc == 3))
{
char* libdir = MXS_STRDUP("../../../../../query_classifier/qc_sqlite/");
set_libdir(libdir);
if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT))
{
if (qc_setup(NULL, NULL) && qc_process_init(QC_INIT_BOTH))
{
const char* zModule = argv[1];
libdir = MXS_STRDUP("../storage/storage_inmemory/");
set_libdir(libdir);
StorageFactory* pFactory = StorageFactory::Open(zModule);
@ -172,6 +179,9 @@ int main(int argc, char* argv[])
{
cerr << "error: Could not initialize log." << endl;
}
// TODO: Remove this once globally allocated memory is freed
MXS_FREE(libdir);
}
else
{

View File

@ -13,6 +13,8 @@
#include <maxscale/cppdefs.hh>
#include <iostream>
#include <maxscale/alloc.h>
#include <maxscale/paths.h>
#include "teststorage.hh"
#include "testerlrustorage.hh"
@ -46,7 +48,13 @@ private:
int main(int argc, char* argv[])
{
TestLRUStorage test(&cout);
char* libdir = MXS_STRDUP("../../../../../query_classifier/qc_sqlite/");
set_libdir(libdir);
return test.run(argc, argv);
TestLRUStorage test(&cout);
int rv = test.run(argc, argv);
// TODO: Remove this once globally allocated memory is freed
MXS_FREE(libdir);
return rv;
}

View File

@ -13,6 +13,8 @@
#include <maxscale/cppdefs.hh>
#include <iostream>
#include <maxscale/alloc.h>
#include <maxscale/paths.h>
#include "teststorage.hh"
#include "testerrawstorage.hh"
@ -46,7 +48,13 @@ private:
int main(int argc, char* argv[])
{
TestRawStorage test(&cout);
char* libdir = MXS_STRDUP("../../../../../query_classifier/qc_sqlite/");
set_libdir(libdir);
return test.run(argc, argv);
TestRawStorage test(&cout);
int rv = test.run(argc, argv);
// TODO: Remove this once globally allocated memory is freed
MXS_FREE(libdir);
return rv;
}