projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tests: Implement trigger capture test cases
[lttng-tools.git]
/
tests
/
unit
/
test_relayd_backward_compat_group_by_session.c
diff --git
a/tests/unit/test_relayd_backward_compat_group_by_session.c
b/tests/unit/test_relayd_backward_compat_group_by_session.c
index c5c9f1b9890e64fd6f13692c177cddf0db64a4d1..0ebcf34ab87cf873bd1ad6df6c54807ba61c6a60 100644
(file)
--- a/
tests/unit/test_relayd_backward_compat_group_by_session.c
+++ b/
tests/unit/test_relayd_backward_compat_group_by_session.c
@@
-12,18
+12,20
@@
#include <string.h>
#include <tap/tap.h>
#include <string.h>
#include <tap/tap.h>
+#include <common/time.h>
+
#include "backward-compatibility-group-by.h"
/* Number of TAP tests in this file */
#define NUM_TESTS_PER_TEST 1
struct test {
#include "backward-compatibility-group-by.h"
/* Number of TAP tests in this file */
#define NUM_TESTS_PER_TEST 1
struct test {
- char *stream_path;
- char *session_name;
- char *hostname;
- char *creation_time;
- char *extra_path;
- char *leftover;
+ c
onst c
har *stream_path;
+ c
onst c
har *session_name;
+ c
onst c
har *hostname;
+ c
onst c
har *creation_time;
+ c
onst c
har *extra_path;
+ c
onst c
har *leftover;
bool is_valid;
};
bool is_valid;
};
@@
-97,19
+99,32
@@
struct test tests[] = {
"", "ust/uid/1000/64-bit", true},
};
"", "ust/uid/1000/64-bit", true},
};
-static char *craft_expected(struct test *test)
+static char *craft_expected(struct test *test
, time_t relay_session_creation_time
)
{
int ret;
char *result = NULL;
{
int ret;
char *result = NULL;
+ char relay_session_creation_datetime[DATETIME_STR_LEN];
+
+ ret = time_to_datetime_str(relay_session_creation_time,
+ relay_session_creation_datetime,
+ sizeof(relay_session_creation_datetime));
+ if (ret < 0) {
+ result = NULL;
+ goto end;
+ }
- ret = asprintf(&result, "%s/%s
%s
%s/%s%s%s", test->session_name,
+ ret = asprintf(&result, "%s/%s
-
%s/%s%s%s", test->session_name,
test->hostname,
test->hostname,
- test->creation_time[0] != '\0' ? "-" : "",
- test->creation_time, test->extra_path,
+ test->creation_time[0] == '\0' ?
+ relay_session_creation_datetime :
+ test->creation_time,
+ test->extra_path,
test->extra_path[0] != '\0' ? "/" : "", test->leftover);
if (ret < 0) {
result = NULL;
test->extra_path[0] != '\0' ? "/" : "", test->leftover);
if (ret < 0) {
result = NULL;
+ goto end;
}
}
+end:
return result;
}
return result;
}
@@
-117,21
+132,28
@@
int main(int argc, char **argv)
{
int i;
int num_test = sizeof(tests) / sizeof(struct test);
{
int i;
int num_test = sizeof(tests) / sizeof(struct test);
+ const time_t test_time = time(NULL);
plan_tests(NUM_TESTS_PER_TEST * num_test);
diag("Backward compatibility utils for lttng-relayd --group-by-session");
plan_tests(NUM_TESTS_PER_TEST * num_test);
diag("Backward compatibility utils for lttng-relayd --group-by-session");
+
+ if (test_time == (time_t) -1) {
+ perror("Failed to sample time");
+ return exit_status();
+ }
+
for (i = 0; i < num_test; i++) {
char *expected = NULL;
char *result = NULL;
for (i = 0; i < num_test; i++) {
char *expected = NULL;
char *result = NULL;
- expected = craft_expected(&tests[i]);
+ expected = craft_expected(&tests[i]
, test_time
);
if (!expected) {
fprintf(stderr, "Failed to craft expected output\n");
goto loop;
}
if (!expected) {
fprintf(stderr, "Failed to craft expected output\n");
goto loop;
}
- result = backward_compat_group_by_session(
- tests[i].s
tream_path, tests[i].session_na
me);
+ result = backward_compat_group_by_session(
tests[i].stream_path,
+ tests[i].s
ession_name, test_ti
me);
if (!result && tests[i].is_valid) {
fprintf(stderr, "Failed to get result\n");
goto loop;
if (!result && tests[i].is_valid) {
fprintf(stderr, "Failed to get result\n");
goto loop;
This page took
0.02493 seconds
and
4
git commands to generate.