733a39a6819289b24dd783c5c92e8cbff27a569e
2 * Copyright (c) - 2019 Jonathan Rajotte-Julien
3 * <jonathan.rajotte-julien@efficios.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by as
7 * published by the Free Software Foundation; only version 2 of the License.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "backward-compatibility-group-by.h"
28 /* Number of TAP tests in this file */
29 #define NUM_TESTS_PER_TEST 1
43 int lttng_opt_verbose
;
45 struct test tests
[] = {
46 /* Default name session streaming. */
47 {"hostname/auto-20190918-164429/ust/uid/1000/64-bit",
48 "auto-20190918-164429", "hostname",
49 "20190918-164429", "", "ust/uid/1000/64-bit",
51 /* Custom default name session */
52 {"hostname/custom_auto-20190319-120000/ust/uid/1000/64-bit",
53 "custom_auto-20190319-120000", "hostname",
54 "20190319-120000", "", "ust/uid/1000/64-bit",
56 /* Named session streaming */
57 {"hostname/test-20190918-164709/ust/uid/1000/64-bit", "test",
58 "hostname", "20190918-164709", "",
59 "ust/uid/1000/64-bit", true},
60 /* Default session snapshot streaming */
61 {"hostname//snapshot-1-20190918-164829-0/ust//uid/1000/64-bit",
62 "my_session", "hostname", "", "",
63 "snapshot-1-20190918-164829-0/ust//uid/1000/64-bit",
65 /* Named session snapshot streaming */
66 {"hostname//snapshot-1-20190918-175919-0/ust//uid/1000/64-bit",
67 "my_session", "hostname", "", "",
68 "snapshot-1-20190918-175919-0/ust//uid/1000/64-bit",
70 /* Default name session, live */
71 {"hostname//auto-20190918-171641/ust/uid/1000/64-bit",
72 "auto-20190918-171641", "hostname",
73 "20190918-171641", "", "ust/uid/1000/64-bit",
75 /* Named session, live */
76 {"hostname//test-20190918-180333//ust/uid/1000/64-bit",
77 "test-20190918-180333", "hostname",
78 "20190918-180333", "", "/ust/uid/1000/64-bit",
80 /* Default name session, streaming & live , extra path */
81 {"hostname/extra/path/ust/uid/1000/64-bit",
82 "auto-20190919-122110", "hostname",
83 "20190919-122110", "extra",
84 "path/ust/uid/1000/64-bit", true},
85 /* Named session, live, extra path */
86 {"hostname/extra/path/ust/uid/1000/64-bit", "test", "hostname",
87 "", "extra", "path/ust/uid/1000/64-bit", true},
88 /* Named session, snapshot, extra path */
89 {"hostname/extra/path/snapshot-1-20190919-140702-0/ust//uid/1000/64-bit",
90 "test", "hostname", "", "extra",
91 "path/snapshot-1-20190919-140702-0/ust//uid/1000/64-bit",
94 /* Named session with valid datetime in it */
95 /* Default name session, extra path with session name in it*/
96 {"hostname/test-20190319-120000-20190918-180921/ust/uid/1000/64-bit",
97 "test-20190319-120000", "hostname",
98 "20190918-180921", "", "ust/uid/1000/64-bit",
101 {"", "test", "", "", "", "", false},
102 /* Path without second token */
103 {"hostname", "test", "hostname", "", "", "", false},
105 {"hostname/test", "test", "hostname", "", "", "", true},
106 /* Path with ession name but no datetime */
107 {"hostname/test/ust/uid/1000/64-bit", "test", "hostname", "",
108 "", "ust/uid/1000/64-bit", true},
111 static char *craft_expected(struct test
*test
)
116 ret
= asprintf(&result
, "%s/%s%s%s/%s%s%s", test
->session_name
,
118 test
->creation_time
[0] != '\0' ? "-" : "",
119 test
->creation_time
, test
->extra_path
,
120 test
->extra_path
[0] != '\0' ? "/" : "", test
->leftover
);
127 int main(int argc
, char **argv
)
129 int num_test
= sizeof(tests
) / sizeof(struct test
);
131 plan_tests(NUM_TESTS_PER_TEST
* num_test
);
132 diag("Backward compatibility utils for lttng-relayd --group-by-session");
133 for (int i
= 0; i
< num_test
; i
++) {
134 char *expected
= NULL
;
137 expected
= craft_expected(&tests
[i
]);
139 fprintf(stderr
, "Failed to craft expected output\n");
143 result
= backward_compat_group_by_session(
144 tests
[i
].stream_path
, tests
[i
].session_name
);
145 if (!result
&& tests
[i
].is_valid
) {
146 fprintf(stderr
, "Failed to get result\n");
148 } else if (!result
&& tests
[i
].is_valid
== false) {
149 pass("Returned null as expected");
153 ok(strncmp(expected
, result
, strlen(expected
)) == 0,
154 "In: %s, out: %s, expected: %s",
155 tests
[i
].stream_path
, result
, expected
);
160 return exit_status();
This page took 0.037146 seconds and 4 git commands to generate.