Commit 8298403a authored by Martin Kampas's avatar Martin Kampas

Sandbox: refact. to be able use normal QFile API

parent 08e44cd7
This diff is collapsed.
......@@ -9,6 +9,7 @@
#define _SANDBOX_P_H
#include <QtCore/QDir>
#include <QtCore/QSet>
#include <QtCore/QString>
class Sandbox {
......@@ -31,18 +32,25 @@ class Sandbox {
Sandbox(const QString &sandboxPath, Usage usage, Scopes scopes);
~Sandbox();
bool activate();
bool isActive() const;
void addWorldFiles(const QString &directory, QDir::Filters filters = QDir::NoFilter,
bool addWorldFiles(const QString &directory, QDir::Filters filters = QDir::NoFilter,
const QStringList &filterNames = QStringList());
private:
bool copyFile(QAbstractFileEngine *src, QAbstractFileEngine *dst);
bool prepare();
private:
static Sandbox *s_instance;
QString m_sandboxPath;
static Sandbox *s_activeInstance;
const bool m_defaultConstructed;
const Usage m_usage;
const Scopes m_scopes;
const QString m_sandboxPath;
bool m_prepared;
QString m_tempDir;
QString m_workingSandboxPath;
QSet<QString> m_overlayEnabledDirectories;
FileEngineHandler *m_handler;
};
......
......@@ -50,6 +50,7 @@ void SsuKs::run(){
qout << "Using sandbox at " << sandbox << endl;
Sandbox *sb = new Sandbox(sandbox, Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
sb->addWorldFiles(SSU_BOARD_MAPPING_CONFIGURATION_DIR);
sb->activate();
}
SsuKickstarter kickstarter;
......
......@@ -22,6 +22,9 @@ void RndSsuCliTest::init(){
m_sandbox = new Sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ChildProcesses);
if (!m_sandbox->activate()){
QFAIL("Failed to activate sandbox");
}
setenv("LD_PRELOAD", qPrintable(QString("%1/libsandboxhook.so").arg(TESTS_PATH)), 1);
}
......
......@@ -11,8 +11,11 @@
#include "urlresolvertest.cpp"
int main(int argc, char **argv){
Sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
UrlResolverTest urlResolverTest;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment