Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / unittests / tracepoint-selftests.c
CommitLineData
62c222b6
SM
1/* Self tests for tracepoint-related code for GDB, the GNU debugger.
2
88b9d363 3 Copyright (C) 2018-2022 Free Software Foundation, Inc.
62c222b6
SM
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
268a13a5 21#include "gdbsupport/selftest.h"
62c222b6
SM
22#include "tracepoint.h"
23
24namespace selftests {
25namespace tracepoint_tests {
26
27static void
28test_parse_static_tracepoint_marker_definition ()
29{
30 static_tracepoint_marker marker;
31 const char def[] = ("1234:6d61726b657231:6578747261207374756666,"
32 "abba:6d61726b657232:,"
33 "cafe:6d61726b657233:6d6f72657374756666");
34 const char *start = def;
35 const char *end;
36
37 parse_static_tracepoint_marker_definition (start, &end, &marker);
38
39 SELF_CHECK (marker.address == 0x1234);
5d9310c4
SM
40 SELF_CHECK (marker.str_id == "marker1");
41 SELF_CHECK (marker.extra == "extra stuff");
62c222b6
SM
42 SELF_CHECK (end == strchr (start, ','));
43
44 start = end + 1;
45 parse_static_tracepoint_marker_definition (start, &end, &marker);
46
47 SELF_CHECK (marker.address == 0xabba);
5d9310c4
SM
48 SELF_CHECK (marker.str_id == "marker2");
49 SELF_CHECK (marker.extra == "");
62c222b6
SM
50 SELF_CHECK (end == strchr (start, ','));
51
52 start = end + 1;
53 parse_static_tracepoint_marker_definition (start, &end, &marker);
54
55 SELF_CHECK (marker.address == 0xcafe);
5d9310c4
SM
56 SELF_CHECK (marker.str_id == "marker3");
57 SELF_CHECK (marker.extra == "morestuff");
62c222b6
SM
58 SELF_CHECK (end == def + strlen (def));
59}
60
61} /* namespace tracepoint_tests */
62} /* namespace selftests */
63
6c265988 64void _initialize_tracepoint_selftests ();
62c222b6
SM
65void
66_initialize_tracepoint_selftests ()
67{
68 selftests::register_test
69 ("parse_static_tracepoint_marker_definition",
70 selftests::tracepoint_tests::test_parse_static_tracepoint_marker_definition);
71}
This page took 0.520105 seconds and 4 git commands to generate.