1 /* Self tests for tracepoint-related code for GDB, the GNU debugger.
3 Copyright (C) 2018-2019 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
21 #include "common/selftest.h"
22 #include "tracepoint.h"
25 namespace tracepoint_tests {
28 test_parse_static_tracepoint_marker_definition ()
30 static_tracepoint_marker marker;
31 const char def[] = ("1234:6d61726b657231:6578747261207374756666,"
32 "abba:6d61726b657232:,"
33 "cafe:6d61726b657233:6d6f72657374756666");
34 const char *start = def;
37 parse_static_tracepoint_marker_definition (start, &end, &marker);
39 SELF_CHECK (marker.address == 0x1234);
40 SELF_CHECK (marker.str_id == "marker1");
41 SELF_CHECK (marker.extra == "extra stuff");
42 SELF_CHECK (end == strchr (start, ','));
45 parse_static_tracepoint_marker_definition (start, &end, &marker);
47 SELF_CHECK (marker.address == 0xabba);
48 SELF_CHECK (marker.str_id == "marker2");
49 SELF_CHECK (marker.extra == "");
50 SELF_CHECK (end == strchr (start, ','));
53 parse_static_tracepoint_marker_definition (start, &end, &marker);
55 SELF_CHECK (marker.address == 0xcafe);
56 SELF_CHECK (marker.str_id == "marker3");
57 SELF_CHECK (marker.extra == "morestuff");
58 SELF_CHECK (end == def + strlen (def));
61 } /* namespace tracepoint_tests */
62 } /* namespace selftests */
65 _initialize_tracepoint_selftests ()
67 selftests::register_test
68 ("parse_static_tracepoint_marker_definition",
69 selftests::tracepoint_tests::test_parse_static_tracepoint_marker_definition);