X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Flib%2Ftest_ctf_writer.c;h=ee979f0b1b3f5a88c783752f478d936b43a42f63;hp=0e4219c532281d016967e78e108036146ebac967;hb=6399beda8a82855d34fca3fa1d178753c10fffdd;hpb=0954670a32efeaa4a5ffe1f24c9a31fe0ab6744c diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 0e4219c5..ee979f0b 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -19,7 +19,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #include #include #include @@ -28,17 +27,19 @@ #include #include #include -#include +#include #include #include #include +#include #include #include #include #include #include -#include +#include #include "tap/tap.h" +#include #define METADATA_LINE_SIZE 512 #define SEQUENCE_TEST_LENGTH 10 @@ -93,7 +94,7 @@ void validate_metadata(char *parser_path, char *metadata_path) goto result; } - execl(parser_path, "ctf-parser-test", NULL); + execl(parser_path, "ctf-parser-test", (char *) NULL); perror("# Could not launch the ctf metadata parser process"); exit(-1); } @@ -127,12 +128,12 @@ result: rewind(metadata_fp); /* Output the metadata and parser output as diagnostic */ - while (getline(&line, &len, metadata_fp) > 0) { + while (bt_getline(&line, &len, metadata_fp) > 0) { diag("%s", line); } rewind(parser_output_fp); - while (getline(&line, &len, parser_output_fp) > 0) { + while (bt_getline(&line, &len, parser_output_fp) > 0) { diag("%s", line); } @@ -200,7 +201,7 @@ void validate_trace(char *parser_path, char *trace_path) goto result; } - execl(parser_path, "babeltrace", trace_path, NULL); + execl(parser_path, "babeltrace", trace_path, (char *) NULL); perror("# Could not launch the babeltrace process"); exit(-1); } @@ -224,7 +225,7 @@ result: diag("malloc error"); } rewind(babeltrace_output_fp); - while (getline(&line, &len, babeltrace_output_fp) > 0) { + while (bt_getline(&line, &len, babeltrace_output_fp) > 0) { diag("%s", line); } @@ -728,7 +729,7 @@ int main(int argc, char **argv) plan_no_plan(); - if (!mkdtemp(trace_path)) { + if (!bt_mkdtemp(trace_path)) { perror("# perror"); } @@ -756,7 +757,8 @@ int main(int argc, char **argv) NULL), "bt_ctf_writer_add_environment_field error with NULL field value"); - if (uname(&name)) { + /* On Solaris, uname() can return any positive value on success */ + if (uname(&name) < 0) { perror("uname"); return -1; } @@ -845,8 +847,20 @@ int main(int argc, char **argv) struct dirent *entry; while ((entry = readdir(trace_dir))) { - if (entry->d_type == DT_REG) { - unlinkat(dirfd(trace_dir), entry->d_name, 0); + struct stat st; + char filename[PATH_MAX]; + + if (snprintf(filename, sizeof(filename), "%s/%s", + trace_path, entry->d_name) <= 0) { + continue; + } + + if (stat(entry->d_name, &st)) { + continue; + } + + if (S_ISREG(st.st_mode)) { + unlinkat(bt_dirfd(trace_dir), entry->d_name, 0); } }