projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: tap.h conflicts with Clang C++ headers
[lttng-tools.git]
/
tests
/
unit
/
test_utils_expand_path.cpp
diff --git
a/tests/unit/test_utils_expand_path.cpp
b/tests/unit/test_utils_expand_path.cpp
index 428acad2285191827a65232ce6bf1bc6e7e94bf7..9fe1619ee9bf031a71989487e4edc6cac62edf5f 100644
(file)
--- a/
tests/unit/test_utils_expand_path.cpp
+++ b/
tests/unit/test_utils_expand_path.cpp
@@
-13,16
+13,18
@@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <tap/tap.h>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/common.hpp>
-#include <common/utils.h>
-#include <common/common.h>
+#include <tap/tap.h>
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
int lttng_opt_mi;
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
int lttng_opt_mi;
+namespace {
struct valid_test_input {
const char *input;
const char *relative_part;
struct valid_test_input {
const char *input;
const char *relative_part;
@@
-40,7
+42,7
@@
struct symlink_test_input {
};
/* Valid test cases */
};
/* Valid test cases */
-st
atic st
ruct valid_test_input valid_tests_inputs[] = {
+struct valid_test_input valid_tests_inputs[] = {
{ "/a/b/c/d/e", "", "/a/b/c/d/e" },
{ "/a//b//c/d/e", "", "/a/b/c/d/e" },
{ "./a/b/c/d/e", ".", "/a/b/c/d/e" },
{ "/a/b/c/d/e", "", "/a/b/c/d/e" },
{ "/a//b//c/d/e", "", "/a/b/c/d/e" },
{ "./a/b/c/d/e", ".", "/a/b/c/d/e" },
@@
-66,22
+68,22
@@
static struct valid_test_input valid_tests_inputs[] = {
{ "/a/..", "", "/" },
};
char **valid_tests_expected_results;
{ "/a/..", "", "/" },
};
char **valid_tests_expected_results;
-
static
const int num_valid_tests =
+const int num_valid_tests =
sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]);
/* Symlinks test cases */
char tree_origin[] = "/tmp/test_utils_expand_path.XXXXXX";
sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]);
/* Symlinks test cases */
char tree_origin[] = "/tmp/test_utils_expand_path.XXXXXX";
-
static
const char * const tree_dirs[] = {
+const char * const tree_dirs[] = {
"a",
"a/b",
"a/b/c",
"a/e",
};
"a",
"a/b",
"a/b/c",
"a/e",
};
-
static
const int num_tree_dirs =
+const int num_tree_dirs =
sizeof(tree_dirs) / sizeof(tree_dirs[0]);
sizeof(tree_dirs) / sizeof(tree_dirs[0]);
-st
atic st
ruct tree_symlink tree_symlinks[] = {
+struct tree_symlink tree_symlinks[] = {
{ "a/d", "b/c/" },
{ "a/g", "d/" },
{ "a/b/f", "../e/" },
{ "a/d", "b/c/" },
{ "a/g", "d/" },
{ "a/b/f", "../e/" },
@@
-89,7
+91,7
@@
static struct tree_symlink tree_symlinks[] = {
{ "a/b/k", "c/g/" },
{ "a/b/c/g", "../../../" },
};
{ "a/b/k", "c/g/" },
{ "a/b/c/g", "../../../" },
};
-
static
const int num_tree_symlinks =
+const int num_tree_symlinks =
sizeof(tree_symlinks) / sizeof(tree_symlinks[0]);
static struct symlink_test_input symlink_tests_inputs[] = {
sizeof(tree_symlinks) / sizeof(tree_symlinks[0]);
static struct symlink_test_input symlink_tests_inputs[] = {
@@
-99,15
+101,16
@@
static struct symlink_test_input symlink_tests_inputs[] = {
{ "a/g/../l/../", "a/b/" },
{ "a/b/h/g/", "" },
};
{ "a/g/../l/../", "a/b/" },
{ "a/b/h/g/", "" },
};
-
static
const int num_symlink_tests =
+const int num_symlink_tests =
sizeof(symlink_tests_inputs) / sizeof(symlink_tests_inputs[0]);
/* Invalid test cases */
sizeof(symlink_tests_inputs) / sizeof(symlink_tests_inputs[0]);
/* Invalid test cases */
-
static
char *invalid_tests_inputs[] = {
+char *invalid_tests_inputs[] = {
NULL,
};
NULL,
};
-
static
const int num_invalid_tests =
+const int num_invalid_tests =
sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
+} /* namespace */
#define PRINT_ERR(fmt, args...) \
fprintf(stderr, "test_utils_expand_path: error: " fmt "\n", ## args)
#define PRINT_ERR(fmt, args...) \
fprintf(stderr, "test_utils_expand_path: error: " fmt "\n", ## args)
@@
-131,14
+134,14
@@
static int prepare_valid_results(void)
}
/* allocate memory for the expected results */
}
/* allocate memory for the expected results */
- valid_tests_expected_results =
(char **) zmalloc(sizeof(char *) *
num_valid_tests);
+ valid_tests_expected_results =
calloc<char *>(
num_valid_tests);
if (!valid_tests_expected_results) {
PRINT_ERR("out of memory");
ret = -1;
goto end;
}
for (i = 0; i < num_valid_tests; i++) {
if (!valid_tests_expected_results) {
PRINT_ERR("out of memory");
ret = -1;
goto end;
}
for (i = 0; i < num_valid_tests; i++) {
- valid_tests_expected_results[i] =
(char *) malloc
(PATH_MAX);
+ valid_tests_expected_results[i] =
calloc<char>
(PATH_MAX);
if (valid_tests_expected_results[i] == NULL) {
PRINT_ERR("malloc expected results");
ret = -1;
if (valid_tests_expected_results[i] == NULL) {
PRINT_ERR("malloc expected results");
ret = -1;
@@
-271,7
+274,7
@@
static void test_utils_expand_path(void)
result = utils_expand_path(valid_tests_inputs[i].input);
ok(result != NULL &&
result = utils_expand_path(valid_tests_inputs[i].input);
ok(result != NULL &&
-
strcmp(result, valid_tests_expected_results[i]) == 0
, name);
+
strcmp(result, valid_tests_expected_results[i]) == 0, "%s"
, name);
free(result);
}
free(result);
}
@@
-301,12
+304,12
@@
static void test_utils_expand_path(void)
PRINT_ERR("truncation occurred while concatenating paths \"%s\" and \"%s\"",
real_tree_origin,
symlink_tests_inputs[i].input);
PRINT_ERR("truncation occurred while concatenating paths \"%s\" and \"%s\"",
real_tree_origin,
symlink_tests_inputs[i].input);
- fail(name);
+ fail(
"%s",
name);
continue;
}
result = utils_expand_path(tmppath);
ok(result != NULL && strcmp(result + treelen,
continue;
}
result = utils_expand_path(tmppath);
ok(result != NULL && strcmp(result + treelen,
-
symlink_tests_inputs[i].expected_result) == 0
, name);
+
symlink_tests_inputs[i].expected_result) == 0, "%s"
, name);
free(result);
}
free(result);
}
@@
-322,11
+325,11
@@
static void test_utils_expand_path(void)
if (result != NULL) {
free(result);
}
if (result != NULL) {
free(result);
}
- ok(result == NULL, name);
+ ok(result == NULL,
"%s",
name);
}
}
}
}
-int main(
int argc, char **argv
)
+int main(
void
)
{
if (prepare_symlink_tree() != 0) {
goto error_mkdir;
{
if (prepare_symlink_tree() != 0) {
goto error_mkdir;
This page took
0.025811 seconds
and
4
git commands to generate.