SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / tests / unit / test_buffer_view.c
CommitLineData
1831ae68
FD
1/*
2 * Copyright (C) - EfficiOS, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by as
6 * published by the Free Software Foundation; only version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18#include <common/buffer-view.h>
19#include <tap/tap.h>
20
21static const int TEST_COUNT = 5;
22
23/* For error.h */
24int lttng_opt_quiet = 1;
25int lttng_opt_verbose;
26int lttng_opt_mi;
27
28static void test_validate_string(void)
29{
30 const char buf[] = {'A', 'l', 'l', 'o', '\0'};
31 struct lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5);
32 struct lttng_buffer_view view_minus_one =
33 lttng_buffer_view_init(buf, 0, 4);
34
35 ok1(!lttng_buffer_view_validate_string(&view, buf, 4));
36 ok1(lttng_buffer_view_validate_string(&view, buf, 5));
37 ok1(!lttng_buffer_view_validate_string(&view, buf, 6));
38
39 ok1(!lttng_buffer_view_validate_string(&view_minus_one, buf, 4));
40 ok1(!lttng_buffer_view_validate_string(&view_minus_one, buf, 5));
41}
42
43int main(void)
44{
45 plan_tests(TEST_COUNT);
46
47 test_validate_string();
48
49 return exit_status();
50}
This page took 0.025279 seconds and 5 git commands to generate.