Commit 53a8b8e1 authored by Matthieu Schaller's avatar Matthieu Schaller

Make the logger and dump tests use unique filenames in /tmp/ and remove the files upon completion.

parent 05c1e1c0
......@@ -40,6 +40,7 @@
#include "hydro.h"
#include "hydro_properties.h"
#include "lock.h"
#include "logger.h"
#include "map.h"
#include "multipole.h"
#include "parallel_io.h"
......
......@@ -32,11 +32,8 @@
#include <sys/types.h>
#include <unistd.h>
/* This object's header. */
#include "../src/dump.h"
/* Local headers. */
#include "../src/threadpool.h"
#include "swift.h"
void dump_mapper(void *map_data, int num_elements, void *extra_data) {
struct dump *d = (struct dump *)extra_data;
......@@ -51,10 +48,14 @@ int main(int argc, char *argv[]) {
/* Some constants. */
const int num_threads = 4;
const char *filename = "/tmp/dump_test.out";
const int num_runs = 20;
const int chunk_size = 1000;
/* Some constants. */
char filename[256];
const int now = time(NULL);
sprintf(filename, "/tmp/SWIFT_dump_test_%d.out", now);
/* Prepare a threadpool to write to the dump. */
struct threadpool t;
threadpool_init(&t, num_threads);
......@@ -84,12 +85,15 @@ int main(int argc, char *argv[]) {
/* Clean the threads */
threadpool_clean(&t);
/* Be clean */
remove(filename);
/* Return a happy number. */
return 0;
}
#else
int main() { return 0; }
int main(int argc, char *argv[]) { return 0; }
#endif /* HAVE_POSIX_FALLOCATE */
......@@ -28,12 +28,8 @@
#include <string.h>
#include <unistd.h>
/* This object's header. */
#include "../src/logger.h"
/* Local headers. */
#include "../src/dump.h"
#include "../src/part.h"
#include "swift.h"
void test_log_parts(struct dump *d) {
......@@ -225,7 +221,9 @@ void test_log_timestamps(struct dump *d) {
int main(int argc, char *argv[]) {
/* Some constants. */
const char *filename = "/tmp/dump_test.out";
char filename[256];
const int now = time(NULL);
sprintf(filename, "/tmp/SWIFT_logger_test_%d.out", now);
/* Prepare a dump. */
struct dump d;
......@@ -243,13 +241,15 @@ int main(int argc, char *argv[]) {
/* Finalize the dump. */
dump_close(&d);
/* Be clean */
remove(filename);
/* Return a happy number. */
printf("PASS\n");
return 0;
}
#else
int main() { return 0; }
int main(int argc, char *argv[]) { return 0; }
#endif /* HAVE_POSIX_FALLOCATE */
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