Connection::~Connection()
{
- sqlite3_close(handle);
+ ::sqlite3_close(handle);
}
int Connection::exec(const std::string& query)
throw runtime::Exception(getErrorMessage());
}
- return sqlite3_changes(handle);
-}
-
-bool Connection::isTableExists(const std::string& tableName)
-{
- return false;
+ return ::sqlite3_changes(handle);
}
} // namespace database
Statement::~Statement()
{
- if (::sqlite3_finalize(statement) != SQLITE_OK) {
- throw runtime::Exception(getErrorMessage());
- }
+ ::sqlite3_finalize(statement);
}
void Statement::reset()
{
- if (::sqlite3_clear_bindings(statement) != SQLITE_OK) {
- throw runtime::Exception(getErrorMessage());
- }
-
if (::sqlite3_reset(statement) != SQLITE_OK) {
throw runtime::Exception(getErrorMessage());
}
std::string Error::message()
{
- return message(errno);
+ return message(lastErrorCode());
}
std::string GetSystemErrorMessage(int errorCode)
std::string GetSystemErrorMessage()
{
- return GetSystemErrorMessage(errno);
+ return Error::message();
}
} // namespace runtime
namespace runtime {
-Path::Path()
-{
-}
-
-Path::Path(const std::string& path)
-{
- assign(path);
-}
-
-Path::Path(const char* path)
-{
- assign(path);
-}
-
-Path::Path(const Path& path)
- : pathname(path.pathname)
-{
-}
-
-Path::~Path()
-{
-}
-
-Path& Path::assign(const Path& path)
-{
- if (&path != this) {
- pathname = path.pathname;
- }
-
- return *this;
-}
-
-Path& Path::assign(const std::string& path)
-{
- pathname = path;
-
- return *this;
-}
-
-Path& Path::assign(const char* path)
-{
- return assign(std::string(path));
-}
-
-Path& Path::operator=(const Path& path)
-{
- return assign(path);
-}
-
-Path& Path::operator=(const std::string& path)
-{
- return assign(path);
-}
-
-Path& Path::operator=(const char* path)
-{
- return assign(path);
-}
-
File::File()
: descriptor(-1)
{
{
}
-File::File(const Path& filePath)
- : descriptor(-1), path(filePath)
-{
-}
-
File::File(const File& file)
: File(file.getPath())
{
bool File::exists() const
{
struct stat st;
- return (::stat(path.getPathname().c_str(), &st) == 0);
+ return (::stat(path.c_str(), &st) == 0);
}
bool File::canRead() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
bool File::canWrite() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
bool File::canExecute() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
bool File::isLink() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
bool File::isFile() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
bool File::isDirectory() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
bool File::isDevice() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
return (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode));
}
-bool File::isHidden() const
-{
- return false;
-}
-
mode_t File::getMode() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
uid_t File::getUid() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
gid_t File::getGid() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
size_t File::size() const
{
struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
+ if (::stat(path.c_str(), &st) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
return st.st_size;
}
-std::string File::toString() const
-{
- struct stat st;
- if (::stat(path.getPathname().c_str(), &st) != 0) {
- throw runtime::Exception(runtime::GetSystemErrorMessage());
- }
-
- return std::string("Test String");
-}
-
void File::create(mode_t mode)
{
while (1) {
- descriptor = ::creat(path.getPathname().c_str(), mode);
+ descriptor = ::creat(path.c_str(), mode);
if (descriptor == -1) {
if (errno != EINTR) {
continue;
void File::open(int flags)
{
while (1) {
- descriptor = ::open(path.getPathname().c_str(), flags);
- if (descriptor == -1) {
- if (errno != EINTR) {
- continue;
- }
- throw runtime::Exception(runtime::GetSystemErrorMessage());
- }
- return;
- }
-}
-
-void File::open(int flags, mode_t mode)
-{
- close();
-
- while (1) {
- descriptor = ::open(path.getPathname().c_str(), flags, mode);
+ descriptor = ::open(path.c_str(), flags);
if (descriptor == -1) {
if (errno != EINTR) {
continue;
}
} else {
open(O_RDONLY);
- destFile.open(O_WRONLY | O_CREAT, getMode());
+ destFile.create(getMode());
::sendfile(destFile.descriptor, descriptor, 0, size());
destFile.close();
close();
return destFile;
}
-void File::moveTo(const std::string& dest)
-{
-}
-
-void File::renameTo(const std::string& dest)
-{
-}
-
void File::remove(bool recursive)
{
if (isDirectory()) {
++iter;
}
}
- if (::rmdir(path.getPathname().c_str()) != 0) {
+ if (::rmdir(path.c_str()) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
} else {
- if (::unlink(path.getPathname().c_str()) != 0) {
+ if (::unlink(path.c_str()) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
}
void File::makeBaseDirectory(uid_t uid, gid_t gid)
{
- std::string::size_type i = path.isRelative() ? -1 : 0;
- const std::string& pathStr = path.getPathname();
+ std::string::size_type i = path[0] != '/' ? -1 : 0;
+ const std::string& pathStr = path;
while ((i = pathStr.find('/', i + 1)) != std::string::npos) {
std::string substr = pathStr.substr(0, i);
int ret = ::mkdir(substr.c_str(), 0777);
makeBaseDirectory(uid, gid);
}
- if (::mkdir(path.getPathname().c_str(), 0777) == -1) {
- throw runtime::Exception("mkdir failed in makeDirectory: " + path.getPathname());
+ if (::mkdir(path.c_str(), 0777) == -1) {
+ throw runtime::Exception("mkdir failed in makeDirectory: " + path);
}
if ((uid | gid) != 0) {
void File::chown(uid_t uid, gid_t gid, bool recursive)
{
- if (::chown(path.getPathname().c_str(), uid, gid) != 0) {
+ if (::chown(path.c_str(), uid, gid) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
void File::chmod(mode_t mode, bool recursive)
{
- if (::chmod(path.getPathname().c_str(), mode) != 0) {
+ if (::chmod(path.c_str(), mode) != 0) {
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
reset(dir);
}
-DirectoryIterator::DirectoryIterator(const Path& dir)
- : DirectoryIterator(dir.getPathname())
-{
-}
-
DirectoryIterator::~DirectoryIterator()
{
if (directoryHandle != nullptr) {
return *this;
}
-DirectoryIterator& DirectoryIterator::operator=(const Path& dir)
-{
- reset(dir.getPathname());
- return *this;
-}
-
DirectoryIterator& DirectoryIterator::operator++()
{
next();
namespace runtime {
-class Path {
-public:
- Path();
- Path(const std::string& path);
- Path(const char* path);
- Path(const Path& path);
-
- ~Path();
-
- Path& operator=(const Path& path);
- Path& operator=(const std::string& path);
- Path& operator=(const char* path);
-
- bool operator==(const Path& path) const
- {
- return (pathname == path.pathname);
- }
-
- bool operator!=(const Path& path) const
- {
- return !(pathname == path.pathname);
- }
-
- bool isAbsolute() const
- {
- return (pathname[0] == '/');
- }
-
- bool isRelative() const
- {
- return (pathname[0] != '/');
- }
-
- const std::string& getPathname() const
- {
- return pathname;
- }
-
- const std::string getFilename() const
- {
- return pathname.substr(pathname.rfind('/') + 1);
- }
-
-private:
- Path& assign(const Path& path);
- Path& assign(const std::string& path);
- Path& assign(const char* path);
-
- std::string pathname;
-};
-
class File {
public:
File();
File(const char* pathname);
File(const std::string& pathname);
File(const File& file);
- File(const Path& filePath);
File(const std::string& path, int flags);
~File();
return *this;
}
- File& operator=(const Path& filePath)
- {
- path = filePath;
- return *this;
- }
-
bool operator<(const File& file) const;
bool operator>(const File& file) const;
bool operator<=(const File& file) const;
bool isFile() const;
bool isDirectory() const;
bool isDevice() const;
- bool isHidden() const;
mode_t getMode() const;
uid_t getUid() const;
void create(mode_t mode);
void open(int flags);
- void open(int flags, mode_t mode);
void read(void *buffer, const size_t size) const;
void write(const void *buffer, const size_t size) const;
void close();
File copyTo(const std::string& pathname);
- void moveTo(const std::string& pathname);
- void renameTo(const std::string& pathname);
void remove(bool recursive = false);
void makeBaseDirectory(uid_t uid = 0, gid_t gid = 0);
void makeDirectory(bool recursive = false, uid_t uid = 0, gid_t gid = 0);
void chown(uid_t uid, gid_t gid, bool recursive = false);
void chmod(mode_t mode, bool recursive = false);
- std::string toString() const;
-
const std::string& getPath() const
{
- return path.getPathname();
+ return path;
}
const std::string getName() const
{
- return path.getFilename();
+ return path.substr(path.rfind('/') + 1);
}
private:
int descriptor;
- Path path;
+ std::string path;
};
class DirectoryIterator {
public:
DirectoryIterator();
DirectoryIterator(const std::string& dir);
- DirectoryIterator(const Path& dir);
~DirectoryIterator();
DirectoryIterator& operator=(const std::string& dir);
- DirectoryIterator& operator=(const Path& dir);
DirectoryIterator& operator++();
bool operator==(const DirectoryIterator& iterator) const
{
}
-Process::Process(const Process& proc)
-{
-}
-
Process::~Process()
{
}
-Process& Process::operator=(const Process& proc)
-{
- return *this;
-}
-
int Process::execute()
{
pid = ::fork();
Process(const std::string& prog);
Process(const std::string& prog, const std::vector<std::string>& args);
- Process(const Process& proc);
+ Process(const Process& proc) = delete;
~Process();
- Process& operator=(const Process& proc);
+ Process& operator=(const Process& proc) = delete;
int execute();
int start();
xml.cpp
filesystem.cpp
shadow.cpp
+ proc.cpp
${DPM_TESTBENCH}/testbench.cpp
)
"ID INTEGER PRIMARY KEY AUTOINCREMENT," \
"PKG TEXT," \
"KEY TEXT," \
- "IS_USED INTEGER)";
+ "IS_USED INTEGER," \
+ "USER INTEGER)";
try {
database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
}
}
-TESTCASE(StatementTest)
+TESTCASE(InvalidStatementTest)
{
- std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?)";
+ try {
+ database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+ database::Statement stmt(db, "INVALID STATEMENT");
+ } catch (runtime::Exception& e) {
+ }
+}
+
+TESTCASE(ColumnBindTestWithIndex1)
+{
+ std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?, ?)";
try {
+ const char *str = "PACKAGE";
+ void *blob = (void *)str;
+ double user=5001;
+ sqlite3_int64 used = 1;
+ std::string key = "test key";
+
database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
database::Statement stmt(db, query);
- stmt.bind(1, "test package");
- stmt.bind(2, "test key");
- stmt.bind(3, false);
+ stmt.bind(1, blob, 8);
+ stmt.bind(2, key);
+ stmt.bind(3, used);
+ stmt.bind(4, user);
stmt.exec();
database::Statement select(db, "SELECT * FROM CLIENT");
- TEST_EXPECT(4, select.getColumnCount());
+ TEST_EXPECT(5, select.getColumnCount());
+ stmt.clearBindings();
+ stmt.reset();
} catch (runtime::Exception& e) {
TEST_FAIL(e.what());
}
}
-TESTCASE(ColumnTest)
+TESTCASE(ColumnBindTestWithIndex2)
{
- std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?)";
+ std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?, ?)";
try {
database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
database::Statement stmt(db, query);
- stmt.bind(1, "test package");
- stmt.bind(2, "test key");
+ stmt.bind(1, "TEST PACKAGE");
+ stmt.bind(2, "TEST KEY");
stmt.bind(3, false);
+ stmt.bind(4, 5001);
+ stmt.exec();
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+}
+
+TESTCASE(ColumnBindTestWithName1)
+{
+ std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
+
+ try {
+ database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+ database::Statement stmt(db, query);
+ stmt.bind(":PKG", "TEST PACKAGE");
+ stmt.bind(":KEY", "TEST KEY");
+ stmt.bind(":IS_USED", true);
+ stmt.bind(":USER", 5001);
+ stmt.exec();
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+}
+
+TESTCASE(ColumnBindTestWithName2)
+{
+ std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
+
+ try {
+ const char *str = "PACKAGE";
+ void *blob = (void *)str;
+ double user = 5001;
+ sqlite3_int64 used = 1;
+ std::string key = "test key";
+
+ database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+ database::Statement stmt(db, query);
+ stmt.bind(":PKG", blob, 8);
+ stmt.bind(":KEY", key);
+ stmt.bind(":IS_USED", used);
+ stmt.bind(":USER", user);
stmt.exec();
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+}
+
+TESTCASE(ColumnTest)
+{
+ try {
+ database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
database::Statement select(db, "SELECT * FROM CLIENT");
- select.step();
- database::Column id = select.getColumn(0);
- database::Column pkg = select.getColumn(1);
- database::Column key = select.getColumn(2);
- database::Column used = select.getColumn(3);
-
- std::cout << "Id Column Name: " << id.getName() << std::endl;
- std::cout << "Pkg Column Name: " << pkg.getName() << std::endl;
- std::cout << "Key Column Name: " << key.getName() << std::endl;
- std::cout << "Used Column Name: " << used.getName() << std::endl;
-
- std::cout << "Id Column Value: " << id.getInt() << std::endl;
- std::cout << "Pkg Column Value: " << pkg.getText() << std::endl;
- std::cout << "Key Column Value: " << key.getText() << std::endl;
- std::cout << "Used Column Value: " << used.getInt() << std::endl;
+ while (select.step()) {
+ for (int i = 0; i < select.getColumnCount(); i++) {
+ TEST_EXPECT(false, select.isNullColumn(i));
+ std::cout << "C: " << select.getColumnName(i);
+ }
+ std::cout << std::endl;
+
+ database::Column id = select.getColumn(0);
+ database::Column pkg = select.getColumn(1);
+ database::Column key = select.getColumn(2);
+ database::Column used = select.getColumn(3);
+
+ std::cout << "Column: " << id.getName()
+ << ", Int: " << id.getInt()
+ << ", Int64: " << id.getInt64()
+ << ", Double: " << id.getDouble()
+ << ", Type: " << id.getType()
+ << ", Bytes: " << id.getBytes()
+ << ", Double: " << id.getDouble()
+ << std::endl;
+ std::cout << "Column: " << pkg.getName()
+ << ", Text: " << pkg.getText()
+ << ", Type: " << pkg.getType()
+ << ", Bytes: " << pkg.getBytes()
+ << ", Blob: " << (const char*)pkg.getBlob()
+ << std::endl;
+ std::cout << "Column: " << key.getName()
+ << ", Text: " << key.getText()
+ << ", Type: " << key.getType()
+ << ", Bytes: " << key.getBytes()
+ << ", Blob: " << (const char*)key.getBlob()
+ << std::endl;
+ std::cout << "Column: " << used.getName()
+ << ", Int: " << used.getInt()
+ << ", Int64: " << used.getInt64()
+ << ", Double: " << used.getDouble()
+ << ", Type: " << used.getType()
+ << ", Bytes: " << used.getBytes()
+ << std::endl;
+ }
} catch (runtime::Exception& e) {
TEST_FAIL(e.what());
}
}
+TESTCASE(InvalidDB)
+{
+ try {
+ database::Connection db("/tmp/invalid.db", database::Connection::ReadWrite);
+ } catch (runtime::Exception& e) {
+
+ }
+}
#include <sys/stat.h>
#include <unistd.h>
#include <signal.h>
+#include <fcntl.h>
#include <iostream>
#include <string>
TESTCASE(DirectoryIteration)
{
- runtime::DirectoryIterator iter(runtime::Path("/dev"));
+ runtime::DirectoryIterator iter("/dev");
runtime::DirectoryIterator end;
+ TEST_EXPECT(false, iter == end);
+
while (iter != end) {
- runtime::File &file = *iter;
- std::cout << "File Name: " << file.getPath()
- << " Is Dev File: " << file.isDevice()
- << " Is Reg FIle: " << file.isFile()
- << " Is Directory: " << file.isDirectory()
- << " Is Link: " << file.isLink()
- << std::endl;
++iter;
}
}
+TESTCASE(FileIO)
+{
+ char readbuf[100];
+ char testbuf[100] = "Test Data";
+
+ runtime::File tmp("/tmp/test-file");
+ try {
+ tmp.create(755);
+ tmp.lock();
+ tmp.write(testbuf, ::strlen(testbuf));
+ tmp.unlock();
+ tmp.close();
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+
+ try {
+ runtime::File tmpFile("/tmp/test-file", O_RDWR);
+ tmpFile.read(readbuf, ::strlen(testbuf));
+ tmpFile.close();
+ tmpFile.remove();
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+}
+
+TESTCASE(DirOperation)
+{
+ runtime::File testDir("/tmp/dpm-unit-test/dir");
+ try {
+ testDir.makeDirectory(true, ::getuid(), ::getgid());
+ testDir.chown(::getuid(), ::getgid(), false);
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+
+ runtime::File dir("/tmp/dpm-unit-test");
+ try {
+ dir.chmod(777, true);
+ dir.remove(true);
+ } catch (runtime::Exception& e) {
+ TEST_FAIL(e.what());
+ }
+}
+
+TESTCASE(FileAttribute)
+{
+ runtime::File tmp("/tmp");
+
+ TEST_EXPECT(true, tmp.exists());
+ TEST_EXPECT(true, tmp.canRead());
+ TEST_EXPECT(true, tmp.canWrite());
+ TEST_EXPECT(true, tmp.canExecute());
+ TEST_EXPECT(false, tmp.isLink());
+ TEST_EXPECT(false, tmp.isFile());
+ TEST_EXPECT(true, tmp.isDirectory());
+ TEST_EXPECT(false, tmp.isDevice());
+
+ std::cout << " UID: " << tmp.getUid()
+ << " GID: " << tmp.getGid()
+ << " Size: " << tmp.size()
+ << " Mode: " << tmp.getMode()
+ << " Path: " << tmp.getPath()
+ << " File: " << tmp.getName() << std::endl;
+}
int main(int /*argc*/, char** /*argv*/)
{
- audit::Logger::setLogLevel(audit::LogLevel::Info);
+ audit::Logger::setLogLevel(audit::LogLevel::Trace);
+ TRACE("Trace");
+ INFO("Info");
+ DEBUG("Debug");
+ WARN("Warning");
+ ERROR("Error");
testbench::Testbench::runAllTestSuites();
return 0;
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <string>
+#include <vector>
+
+#include "exception.h"
+#include "process.h"
+#include "audit/logger.h"
+
+#include "testbench/testbench.h"
+
+TESTCASE(ProcTerminate)
+{
+ try {
+ runtime::Process proc("/bin/bash");
+ proc.execute();
+ if (proc.isRunning()) {
+ proc.terminate();
+ }
+ } catch (runtime::Exception& e) {
+ }
+}
+
+TESTCASE(ProcWithArg)
+{
+ try {
+ std::vector<std::string> args = {
+ "-l",
+ "-a"
+ };
+ runtime::Process proc("/bin/ls", args);
+ proc.execute();
+ } catch (runtime::Exception& e) {
+ }
+}
String method1(String& arg1)
{
- INFO("[SERVER] Remote method1 is called with: " + arg1.value);
return String("Method1 result");
}
String method2(String& arg1, String& arg2)
{
- INFO("[SERVER] Remote method2 is called with: " + arg1.value + ", " + arg2.value);
return String("Method2 result");
}
String method3(String& arg1, String& arg2, String& arg3)
{
- INFO("[SERVER] Remote method3 is called with: " + arg1.value + ", " + arg2.value + ", " + arg3.value);
return String("Method3 result");
}
String method4(String& arg1, String& arg2, String& arg3, String& arg4)
{
- INFO("[SERVER] Remote method4 is called with: " + arg1.value + ", " + arg2.value + ", " + arg3.value + ", " + arg4.value);
return String("Method4 result");
}
void connect()
{
auto policyChangedListener = [this](const std::string& name, int value) {
- std::cout << "Policy Changed: " << name << " : " << value << std::endl;
policyChangeNotificationTriggered = true;
};
auto policySignalListener = [this](const std::string& name) {
- std::cout << "Signal Triggered" << std::endl;
signalTriggered = true;
};
client.requestSignal();
client.requestPolicyChangeNotification();
- sleep(5);
-
client.disconnect();
} catch (runtime::Exception& e) {
ERROR(e.what());
int showZoneInstances()
{
try {
- runtime::DirectoryIterator iter(runtime::Path("/var/run/zone")), end;
+ runtime::DirectoryIterator iter("/var/run/zone"), end;
while (iter != end) {
const std::string& path = (*iter).getPath();