c-ipfs/test/core/test_daemon.h

33 lines
641 B
C
Raw Normal View History

#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;
pthread_t daemon_thread;
2017-04-27 16:35:26 +00:00
char* ipfs_path = "/tmp/.ipfs";
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;
}
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;
}