Make test cases run fuse in a parallel thread. For now, test cases don't use mock fs implementation, but real cryfs. This is to be changed soon.
This commit is contained in:
parent
c495e6b475
commit
6aeaae5436
@ -1,32 +0,0 @@
|
||||
#include "Daemon.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
using std::function;
|
||||
|
||||
Daemon::Daemon(function<void()> runnable)
|
||||
: _runnable(runnable), _child_pid(0) {
|
||||
}
|
||||
|
||||
void Daemon::start() {
|
||||
_child_pid = fork();
|
||||
if (_child_pid == 0) {
|
||||
_runnable();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Daemon::stop() {
|
||||
int retval = kill(_child_pid, SIGINT);
|
||||
if (retval != 0) {
|
||||
throw std::runtime_error("Failed killing child process");
|
||||
}
|
||||
int status;
|
||||
pid_t pid = waitpid(_child_pid, &status, 0);
|
||||
if (pid != _child_pid) {
|
||||
throw std::runtime_error("Failed waiting for child process to die");
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef TEST_TESTUTILS_DAEMON_H_
|
||||
#define TEST_TESTUTILS_DAEMON_H_
|
||||
|
||||
#include <functional>
|
||||
|
||||
class Daemon {
|
||||
public:
|
||||
Daemon(std::function<void()> runnable);
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
std::function<void()> _runnable;
|
||||
pid_t _child_pid;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user