test_ctf_writer_LDADD = $(LIBTAP) \
$(top_builddir)/lib/libbabeltrace.la \
- $(top_builddir)/formats/ctf/libbabeltrace-ctf.la
+ $(top_builddir)/formats/ctf/libbabeltrace-ctf.la \
+ libtestcommon.a
test_bt_values_LDADD = $(LIBTAP) \
$(top_builddir)/lib/libbabeltrace.la
test_ctf_ir_ref_LDADD = $(LIBTAP) \
$(top_builddir)/lib/libbabeltrace.la \
- $(top_builddir)/formats/ctf/libbabeltrace-ctf.la
+ $(top_builddir)/formats/ctf/libbabeltrace-ctf.la \
+ libtestcommon.a
test_bt_ctf_field_type_validation_LDADD = $(LIBTAP) \
$(top_builddir)/lib/libbabeltrace.la \
#include <babeltrace/context.h>
#include <babeltrace/iterator.h>
+#include <babeltrace/compat/dirent.h>
+#include <sys/stat.h>
struct bt_context *create_context_with_path(const char *path)
{
}
return ctx;
}
+
+void recursive_rmdir(const char *path)
+{
+ struct dirent *entry;
+ DIR *dir = opendir(path);
+
+ if (!dir) {
+ perror("# opendir");
+ return;
+ }
+
+ while ((entry = readdir(dir))) {
+ struct stat st;
+ char filename[PATH_MAX];
+
+ if (snprintf(filename, sizeof(filename), "%s/%s",
+ path, entry->d_name) <= 0) {
+ continue;
+ }
+
+ if (stat(filename, &st)) {
+ continue;
+ }
+
+ if (S_ISREG(st.st_mode)) {
+ unlinkat(bt_dirfd(dir), entry->d_name, 0);
+ }
+ }
+
+ rmdir(path);
+ closedir(dir);
+}
* Lib BabelTrace - Common function to all tests
*
* Copyright 2012 - Yannick Brosseau <yannick.brosseau@gmail.com>
+ * Copyright 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
struct bt_context;
+void recursive_rmdir(const char *path);
struct bt_context *create_context_with_path(const char *path);
#endif /* _TESTS_COMMON_H */
#include <babeltrace/object-internal.h>
#include <babeltrace/compat/stdlib.h>
#include <assert.h>
+#include "common.h"
#define NR_TESTS 41
BT_PUT(field);
ret = bt_ctf_stream_append_event(user->stream, user->event);
assert(!ret);
+ recursive_rmdir(trace_path);
}
static void test_put_order_swap(size_t *array, size_t a, size_t b)
#include "tap/tap.h"
#include <math.h>
#include <float.h>
-#include <sys/stat.h>
+#include "common.h"
#define METADATA_LINE_SIZE 512
#define SEQUENCE_TEST_LENGTH 10
static int64_t current_time = 42;
-static
-void delete_trace(const char *trace_path)
-{
- /* Remove all trace files and delete temporary trace directory */
- struct dirent *entry;
- DIR *trace_dir = opendir(trace_path);
-
- if (!trace_dir) {
- perror("# opendir");
- return;
- }
-
- while ((entry = readdir(trace_dir))) {
- struct stat st;
- char filename[PATH_MAX];
-
- if (snprintf(filename, sizeof(filename), "%s/%s",
- trace_path, entry->d_name) <= 0) {
- continue;
- }
-
- if (stat(filename, &st)) {
- continue;
- }
-
- if (S_ISREG(st.st_mode)) {
- unlinkat(bt_dirfd(trace_dir), entry->d_name, 0);
- }
- }
-
- rmdir(trace_path);
- closedir(trace_dir);
-}
-
/* Return 1 if uuids match, zero if different. */
static
int uuid_match(const unsigned char *uuid_a, const unsigned char *uuid_b)
bt_put(non_writer_clock);
bt_put(packet);
bt_put(packet2);
- delete_trace(trace_path);
+ recursive_rmdir(trace_path);
}
static
free(metadata_string);
bt_put(stream_class);
- delete_trace(trace_path);
+ recursive_rmdir(trace_path);
return 0;
}