You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Deep build refactoring phase 1 (#3562)
* configcpp refactored * logging and datatypes refactored * more dataconvert * chore(build): massive removals, auto add files to debian install file * chore(codemanagement): nodeps headers, potentioal library * chore(build): configure before autobake * chore(build): use custom cmake commands for components, mariadb-plugin-columnstore.install generated * chore(build): install deps as separate step for build-packages * more deps * check debian/mariadb-plugin-columnstore.install automatically * chore(build): add option for multibracnh compilation * Fix warning
This commit is contained in:
@ -1,16 +1,4 @@
|
||||
set(configcpp_LIB_SRCS configcpp.cpp xmlparser.cpp)
|
||||
include_directories(${ENGINE_COMMON_INCLUDES})
|
||||
|
||||
# ########## next target ###############
|
||||
|
||||
set(configcpp_LIB_SRCS configcpp.cpp xmlparser.cpp configstream.cpp)
|
||||
|
||||
columnstore_library(configcpp ${configcpp_LIB_SRCS})
|
||||
add_dependencies(configcpp loggingcpp)
|
||||
|
||||
target_compile_definitions(configcpp PUBLIC BOOST_NO_CXX11_SCOPED_ENUMS)
|
||||
|
||||
install(
|
||||
TARGETS configcpp
|
||||
DESTINATION ${ENGINE_LIBDIR}
|
||||
COMPONENT columnstore-engine
|
||||
)
|
||||
columnstore_link(configcpp PRIVATE LibXml2::LibXml2 boost_filesystem)
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Calpont Version="V1.0.0">
|
||||
<Message>
|
||||
<Name>Message</Name>
|
||||
<Dir>.</Dir>
|
||||
<Length>875</Length>
|
||||
<Version>V1.0</Version>
|
||||
</Message>
|
||||
<SystemConfig>
|
||||
<SystemVersion>V1.0</SystemVersion>
|
||||
</SystemConfig>
|
||||
</Calpont>
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XCalpont Version="V1.0.0">
|
||||
<Message>
|
||||
<Name>Message</Name>
|
||||
<Dir>.</Dir>
|
||||
<Length>875</Length>
|
||||
<Version>V1.0</Version>
|
||||
</Message>
|
||||
<SystemConfig>
|
||||
<SystemVersion>V1.0</SystemVersion>
|
||||
</SystemConfig>
|
||||
</XCalpont>
|
@ -25,8 +25,6 @@
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
@ -36,31 +34,20 @@ using namespace std;
|
||||
using namespace boost;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
//#define NDEBUG
|
||||
#include <cassert>
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "configcpp.h"
|
||||
|
||||
#include "exceptclasses.h"
|
||||
#include "installdir.h"
|
||||
#include <tr1/unordered_map>
|
||||
|
||||
#include "bytestream.h"
|
||||
|
||||
namespace config
|
||||
{
|
||||
|
||||
@ -460,44 +447,6 @@ void Config::write(const string& configFile) const
|
||||
}
|
||||
}
|
||||
|
||||
void Config::writeConfigFile(messageqcpp::ByteStream msg) const
|
||||
{
|
||||
struct flock fl;
|
||||
int fd;
|
||||
|
||||
// get config file name being udated
|
||||
string fileName;
|
||||
msg >> fileName;
|
||||
|
||||
fl.l_type = F_WRLCK; // write lock
|
||||
fl.l_whence = SEEK_SET;
|
||||
fl.l_start = 0;
|
||||
fl.l_len = 0;
|
||||
fl.l_pid = getpid();
|
||||
|
||||
// lock file if it exists
|
||||
if ((fd = open(fileName.c_str(), O_WRONLY)) >= 0)
|
||||
{
|
||||
if (fcntl(fd, F_SETLKW, &fl) == -1)
|
||||
throw runtime_error("Config::write: file lock error " + fileName);
|
||||
|
||||
ofstream out(fileName.c_str());
|
||||
out << msg;
|
||||
|
||||
fl.l_type = F_UNLCK; // unlock
|
||||
|
||||
if (fcntl(fd, F_SETLK, &fl) == -1)
|
||||
throw runtime_error("Config::write: file unlock error " + fileName);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ofstream out(fileName.c_str());
|
||||
out << msg;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void Config::deleteInstanceMap()
|
||||
{
|
||||
|
@ -42,7 +42,6 @@ class ByteStream;
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace config
|
||||
{
|
||||
/** @brief a config file I/F class
|
||||
@ -55,7 +54,6 @@ namespace config
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
|
||||
/** @brief Config factory method
|
||||
*
|
||||
* Creates a singleton Config object
|
||||
@ -96,8 +94,7 @@ class Config
|
||||
* @param name the param name whose value is to be returned
|
||||
* @param values the values in the section are returned in this vector
|
||||
*/
|
||||
void getConfig(const std::string& section, const std::string& name,
|
||||
std::vector<std::string>& values);
|
||||
void getConfig(const std::string& section, const std::string& name, std::vector<std::string>& values);
|
||||
|
||||
/** @brief set name's value in section
|
||||
*
|
||||
@ -132,13 +129,6 @@ class Config
|
||||
*/
|
||||
void write(const std::string& fileName) const;
|
||||
|
||||
/** @brief write a stream copy of config file to disk
|
||||
*
|
||||
* write a stream copy of config file to disk. used to distributed mass updates to system nodes
|
||||
*
|
||||
*/
|
||||
void writeConfigFile(messageqcpp::ByteStream msg) const;
|
||||
|
||||
/** @brief return the name of this config file
|
||||
*
|
||||
* return the name of this config file.
|
||||
@ -256,12 +246,10 @@ class Config
|
||||
|
||||
static Config& globConfigInstance();
|
||||
|
||||
|
||||
Config(const Config& rhs);
|
||||
Config& operator=(const Config& rhs);
|
||||
Config(const std::string& configFile);
|
||||
|
||||
|
||||
xmlDocPtr fDoc;
|
||||
const std::string fConfigFile;
|
||||
time_t fMtime;
|
||||
@ -272,11 +260,8 @@ class Config
|
||||
*
|
||||
*/
|
||||
void checkAndReloadConfig();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace config
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/******************************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
******************************************************************************************/
|
||||
#include "mcsconfig.h"
|
||||
|
||||
#include <string>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <stdexcept>
|
||||
using namespace std;
|
||||
|
||||
#include "bytestream.h"
|
||||
using namespace messageqcpp;
|
||||
|
||||
#include "configstream.h"
|
||||
|
||||
namespace config
|
||||
{
|
||||
ConfigStream::ConfigStream(const ByteStream& bs) : fParser()
|
||||
{
|
||||
init(reinterpret_cast<const xmlChar*>(bs.buf()));
|
||||
}
|
||||
|
||||
ConfigStream::ConfigStream(const string& str) : fParser()
|
||||
{
|
||||
init(reinterpret_cast<const xmlChar*>(str.c_str()));
|
||||
}
|
||||
|
||||
ConfigStream::ConfigStream(const char* cptr) : fParser()
|
||||
{
|
||||
init(reinterpret_cast<const xmlChar*>(cptr));
|
||||
}
|
||||
|
||||
ConfigStream::~ConfigStream()
|
||||
{
|
||||
if (fDoc != NULL)
|
||||
xmlFreeDoc(fDoc);
|
||||
}
|
||||
|
||||
void ConfigStream::init(const xmlChar* xp)
|
||||
{
|
||||
fDoc = xmlParseDoc(xp);
|
||||
|
||||
if (fDoc == NULL)
|
||||
throw runtime_error("ConfigStream::ConfigStream: bad XML stream");
|
||||
}
|
||||
|
||||
} // namespace config
|
@ -1,63 +0,0 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/******************************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
******************************************************************************************/
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#include "bytestream.h"
|
||||
|
||||
#include "xmlparser.h"
|
||||
|
||||
namespace config
|
||||
{
|
||||
/** @brief a config ByteStream I/F class
|
||||
*
|
||||
*/
|
||||
class ConfigStream
|
||||
{
|
||||
public:
|
||||
ConfigStream(const messageqcpp::ByteStream& bs);
|
||||
ConfigStream(const std::string& str);
|
||||
ConfigStream(const char* cptr);
|
||||
~ConfigStream();
|
||||
|
||||
const std::string getConfig(const std::string& section, const std::string& name) const
|
||||
{
|
||||
return fParser.getConfig(fDoc, section, name);
|
||||
}
|
||||
|
||||
private:
|
||||
ConfigStream(const ConfigStream& rhs);
|
||||
ConfigStream& operator=(const ConfigStream& rhs);
|
||||
|
||||
void init(const xmlChar* xp);
|
||||
|
||||
XMLParser fParser;
|
||||
xmlDocPtr fDoc;
|
||||
};
|
||||
|
||||
} // namespace config
|
||||
|
@ -1,14 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by libconfigcpp.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
@ -1,371 +0,0 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
using namespace boost;
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "bytestream.h"
|
||||
using namespace messageqcpp;
|
||||
|
||||
#include "configcpp.h"
|
||||
#include "configstream.h"
|
||||
using namespace config;
|
||||
|
||||
class ConfigFileTest : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(ConfigFileTest);
|
||||
|
||||
CPPUNIT_TEST(test1);
|
||||
|
||||
CPPUNIT_TEST_EXCEPTION(test2, std::runtime_error);
|
||||
CPPUNIT_TEST(test3);
|
||||
CPPUNIT_TEST(test4);
|
||||
CPPUNIT_TEST_EXCEPTION(test5, std::runtime_error);
|
||||
CPPUNIT_TEST_EXCEPTION(test6, std::runtime_error);
|
||||
CPPUNIT_TEST_EXCEPTION(test7, std::invalid_argument);
|
||||
CPPUNIT_TEST_EXCEPTION(test8, std::invalid_argument);
|
||||
CPPUNIT_TEST(test9);
|
||||
CPPUNIT_TEST(test10);
|
||||
CPPUNIT_TEST(test11);
|
||||
CPPUNIT_TEST(test12);
|
||||
CPPUNIT_TEST_EXCEPTION(test13_1, std::runtime_error);
|
||||
CPPUNIT_TEST_EXCEPTION(test13_2, std::runtime_error);
|
||||
CPPUNIT_TEST(test14);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void test1()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml");
|
||||
string value;
|
||||
value = c1->getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
|
||||
value = c1->getConfig("Message", "xName");
|
||||
CPPUNIT_ASSERT(value.size() == 0);
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test2()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./yadayada.xml");
|
||||
string value;
|
||||
|
||||
value = c1->getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value.size() == 0);
|
||||
|
||||
value = c1->getConfig("Message", "xName");
|
||||
CPPUNIT_ASSERT(value.size() == 0);
|
||||
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test3()
|
||||
{
|
||||
Config* c1;
|
||||
string value;
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
c1 = Config::makeConfig("./Columnstore.xml");
|
||||
value = c1->getConfig("Message", "Name");
|
||||
assert(value == "Message");
|
||||
}
|
||||
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test4()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml");
|
||||
string value;
|
||||
|
||||
value = c1->getConfig("SystemConfig", "SystemVersion");
|
||||
c1->setConfig("SystemConfig", "SystemVersion", "2.2.versionversionversion");
|
||||
value = c1->getConfig("SystemConfig", "SystemVersion");
|
||||
CPPUNIT_ASSERT(value == "2.2.versionversionversion");
|
||||
|
||||
::unlink("./Columnstore.xml.new");
|
||||
c1->write("./Columnstore.xml.new");
|
||||
|
||||
value = c1->getConfig("SystemConfig", "SystemVersion");
|
||||
CPPUNIT_ASSERT(value == "2.2.versionversionversion");
|
||||
|
||||
c1->setConfig("SystemConfig", "SystemVersion1", "V1.x");
|
||||
value = c1->getConfig("SystemConfig", "SystemVersion1");
|
||||
CPPUNIT_ASSERT(value == "V1.x");
|
||||
|
||||
c1->setConfig("SystemConfig1", "SystemVersion1", "Vx.x");
|
||||
value = c1->getConfig("SystemConfig1", "SystemVersion1");
|
||||
CPPUNIT_ASSERT(value == "Vx.x");
|
||||
|
||||
c1->write("./Columnstore.xml.new");
|
||||
Config* c2 = Config::makeConfig("./Columnstore.xml.new");
|
||||
value = c2->getConfig("SystemConfig1", "SystemVersion1");
|
||||
CPPUNIT_ASSERT(value == "Vx.x");
|
||||
c2->setConfig("SystemConfig", "SystemVersion1", "V1.1");
|
||||
value = c2->getConfig("SystemConfig", "SystemVersion1");
|
||||
CPPUNIT_ASSERT(value == "V1.1");
|
||||
c2->write();
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test5()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml");
|
||||
c1->write("/cantwritethis");
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test6()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./XColumnstore.xml");
|
||||
// compiler warning...we won't actually get here
|
||||
c1 = 0;
|
||||
}
|
||||
|
||||
void test7()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml");
|
||||
string s;
|
||||
string n;
|
||||
string v;
|
||||
c1->setConfig(s, n, v);
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test8()
|
||||
{
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml");
|
||||
string s;
|
||||
string n;
|
||||
string v;
|
||||
v = c1->getConfig(s, n);
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test9()
|
||||
{
|
||||
string value;
|
||||
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml");
|
||||
Config* c2 = Config::makeConfig("./Columnstore.xml.new");
|
||||
|
||||
value = c1->getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
|
||||
value = c2->getConfig("SystemConfig", "SystemVersion1");
|
||||
CPPUNIT_ASSERT(value == "V1.1");
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test10()
|
||||
{
|
||||
string value;
|
||||
|
||||
setenv("CALPONT_CONFIG_FILE", "./Columnstore.xml", 1);
|
||||
Config* c1 = Config::makeConfig();
|
||||
|
||||
value = c1->getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test11()
|
||||
{
|
||||
string value;
|
||||
struct stat stat_buf;
|
||||
struct utimbuf utime_buf;
|
||||
|
||||
CPPUNIT_ASSERT(stat("./Columnstore.xml.new", &stat_buf) == 0);
|
||||
|
||||
Config* c1 = Config::makeConfig("./Columnstore.xml.new");
|
||||
|
||||
value = c1->getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
|
||||
utime_buf.actime = utime_buf.modtime = stat_buf.st_mtime + 1;
|
||||
CPPUNIT_ASSERT(utime("./Columnstore.xml.new", &utime_buf) == 0);
|
||||
|
||||
value = c1->getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
|
||||
void test12()
|
||||
{
|
||||
string value;
|
||||
int64_t ival;
|
||||
uint64_t uval;
|
||||
|
||||
value = "10";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == 10);
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == 10);
|
||||
|
||||
value = "0x10";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == 0x10);
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == 0x10);
|
||||
|
||||
value = "010";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == 010);
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == 010);
|
||||
|
||||
value = "-10";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == -10);
|
||||
|
||||
value = "10K";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024));
|
||||
|
||||
value = "10k";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024));
|
||||
|
||||
value = "10M";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024 * 1024));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024 * 1024));
|
||||
|
||||
value = "10m";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024 * 1024));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024 * 1024));
|
||||
|
||||
value = "10G";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024 * 1024 * 1024LL));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024 * 1024 * 1024ULL));
|
||||
|
||||
value = "10g";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024 * 1024 * 1024LL));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024 * 1024 * 1024ULL));
|
||||
|
||||
value = "10MB";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == (10 * 1024 * 1024));
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == (10 * 1024 * 1024));
|
||||
|
||||
value = "0x7afafafafafafafa";
|
||||
ival = Config::fromText(value);
|
||||
CPPUNIT_ASSERT(ival == 0x7afafafafafafafaLL);
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == 0x7afafafafafafafaULL);
|
||||
|
||||
value = "-0x7afafafafafafafa";
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == 0x8505050505050506ULL);
|
||||
|
||||
value = "-1";
|
||||
uval = Config::uFromText(value);
|
||||
CPPUNIT_ASSERT(uval == 0xffffffffffffffffULL);
|
||||
}
|
||||
|
||||
void test13_1()
|
||||
{
|
||||
string value;
|
||||
int64_t ival;
|
||||
|
||||
value = "2.2MB"; // invalid char causes throw
|
||||
ival = Config::fromText(value);
|
||||
}
|
||||
|
||||
void test13_2()
|
||||
{
|
||||
string value;
|
||||
int64_t ival;
|
||||
|
||||
value = "10,000"; // invalid char causes throw
|
||||
ival = Config::fromText(value);
|
||||
}
|
||||
|
||||
void test14()
|
||||
{
|
||||
ByteStream bs;
|
||||
ifstream ifs("./Columnstore.xml");
|
||||
ifs >> bs;
|
||||
string id(".");
|
||||
string value;
|
||||
{
|
||||
ConfigStream cs(bs, id);
|
||||
value = cs.getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
}
|
||||
string bss(reinterpret_cast<const char*>(bs.buf()), bs.length());
|
||||
{
|
||||
ConfigStream cs(bss, id);
|
||||
value = cs.getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
}
|
||||
{
|
||||
ConfigStream cs(bss.c_str(), id);
|
||||
value = cs.getConfig("Message", "Name");
|
||||
CPPUNIT_ASSERT(value == "Message");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ConfigFileTest);
|
||||
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest(registry.makeTest());
|
||||
bool wasSuccessful = runner.run("", false);
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
using namespace boost;
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "configcpp.h"
|
||||
#include "writeonce.h"
|
||||
using namespace config;
|
||||
|
||||
namespace
|
||||
{
|
||||
const string cf("./woparms.dat");
|
||||
}
|
||||
|
||||
class WOConfigFileTest : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(WOConfigFileTest);
|
||||
|
||||
CPPUNIT_TEST(test1);
|
||||
CPPUNIT_TEST_EXCEPTION(test2, std::runtime_error);
|
||||
CPPUNIT_TEST_EXCEPTION(test3, std::runtime_error);
|
||||
CPPUNIT_TEST_EXCEPTION(test4, std::runtime_error);
|
||||
CPPUNIT_TEST(test5);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
unlink(cf.c_str());
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
unlink(cf.c_str());
|
||||
}
|
||||
|
||||
void test1()
|
||||
{
|
||||
WriteOnceConfig woc(cf);
|
||||
CPPUNIT_ASSERT(woc.owns("SystemConfig", "DBRootCount"));
|
||||
CPPUNIT_ASSERT(woc.owns("SystemConfig", "DBRMRoot"));
|
||||
|
||||
CPPUNIT_ASSERT(!woc.owns("dummy", "dummy"));
|
||||
|
||||
int vali;
|
||||
|
||||
woc.setConfig("SystemConfig", "DBRootCount", "10");
|
||||
vali = Config::fromText(woc.getConfig("SystemConfig", "DBRootCount"));
|
||||
CPPUNIT_ASSERT(vali == 10);
|
||||
|
||||
WriteOnceConfig woc2(cf.c_str());
|
||||
vali = Config::fromText(woc2.getConfig("SystemConfig", "DBRootCount"));
|
||||
CPPUNIT_ASSERT(vali == 10);
|
||||
}
|
||||
|
||||
void test2()
|
||||
{
|
||||
WriteOnceConfig woc(cf);
|
||||
woc.getConfig("dummy", "dummy");
|
||||
}
|
||||
|
||||
void test3()
|
||||
{
|
||||
WriteOnceConfig woc(cf);
|
||||
woc.setConfig("dummy", "dummy", "100");
|
||||
}
|
||||
|
||||
void test4()
|
||||
{
|
||||
WriteOnceConfig woc(cf);
|
||||
woc.setConfig("SystemConfig", "DBRootCount", "10");
|
||||
woc.setConfig("SystemConfig", "DBRootCount", "11");
|
||||
}
|
||||
|
||||
void test5()
|
||||
{
|
||||
WriteOnceConfig woc(cf);
|
||||
woc.setConfig("SystemConfig", "DBRootCount", "10");
|
||||
woc.setConfig("SystemConfig", "DBRootCount", "11", true);
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(WOConfigFileTest);
|
||||
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest(registry.makeTest());
|
||||
bool wasSuccessful = runner.run("", false);
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
}
|
@ -19,7 +19,9 @@
|
||||
* $Id$
|
||||
*
|
||||
******************************************************************************************/
|
||||
#include "mcsconfig.h"
|
||||
// #include "mcsconfig.h"
|
||||
|
||||
#include "basic/string_utils.h"
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
@ -27,7 +29,6 @@
|
||||
#include <libxml/parser.h>
|
||||
#include <vector>
|
||||
|
||||
#include "collation.h"
|
||||
using namespace std;
|
||||
|
||||
#include "xmlparser.h"
|
||||
|
Reference in New Issue
Block a user