2017-04-17 16:58:47 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include "ipfs/core/daemon.h"
|
|
|
|
#include "../test_helper.h"
|
|
|
|
#include "libp2p/utils/logger.h"
|
|
|
|
|
|
|
|
int test_daemon_startup_shutdown() {
|
2017-04-27 16:35:26 +00:00
|
|
|
int retVal = 0;
|
2017-04-17 16:58:47 +00:00
|
|
|
pthread_t daemon_thread;
|
2017-04-27 16:35:26 +00:00
|
|
|
char* ipfs_path = "/tmp/.ipfs";
|
2017-04-17 16:58:47 +00:00
|
|
|
char* peer_id = NULL;
|
|
|
|
|
2017-04-27 16:35:26 +00:00
|
|
|
if (!drop_and_build_repository(ipfs_path, 4001, NULL, &peer_id)) {
|
|
|
|
fprintf(stderr, "Unable to drop and build repository at %s\n", ipfs_path);
|
|
|
|
goto exit;
|
|
|
|
}
|
2017-04-17 16:58:47 +00:00
|
|
|
|
|
|
|
pthread_create(&daemon_thread, NULL, test_daemon_start, (void*)ipfs_path);
|
|
|
|
|
|
|
|
ipfs_daemon_stop();
|
|
|
|
|
|
|
|
pthread_join(daemon_thread, NULL);
|
|
|
|
|
2017-04-27 16:35:26 +00:00
|
|
|
retVal = 1;
|
|
|
|
exit:
|
|
|
|
if (peer_id != NULL)
|
|
|
|
free(peer_id);
|
|
|
|
|
|
|
|
return retVal;
|
2017-04-17 16:58:47 +00:00
|
|
|
}
|