]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/unittests/unpack-selftests.c
gdb: add back declarations for _initialize functions
[thirdparty/binutils-gdb.git] / gdb / unittests / unpack-selftests.c
CommitLineData
15ce8941
TT
1/* Self tests for unpack_field_as_long
2
b811d2c2 3 Copyright (C) 2018-2020 Free Software Foundation, Inc.
15ce8941
TT
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"
15ce8941
TT
22#include "selftest-arch.h"
23#include "value.h"
24#include "gdbtypes.h"
25#include "arch-utils.h"
26
27namespace selftests {
28namespace unpack {
29
30static void
31unpack_field_as_long_tests (struct gdbarch *arch)
32{
33 gdb_byte buffer[8];
34 const struct builtin_type *bt = builtin_type (arch);
35 struct type *struct_type = arch_composite_type (arch, "<<selftest>>",
36 TYPE_CODE_STRUCT);
37
38 append_composite_type_field (struct_type, "field0", bt->builtin_int8);
39 append_composite_type_field_aligned (struct_type, "field1",
40 bt->builtin_uint32, 4);
41
42 memset (buffer, 0, sizeof (buffer));
43 buffer[0] = 255;
44 if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
45 buffer[7] = 23;
46 else
47 buffer[4] = 23;
48
49 SELF_CHECK (unpack_field_as_long (struct_type, buffer, 0) == -1);
50 SELF_CHECK (unpack_field_as_long (struct_type, buffer, 1) == 23);
51}
52
53}
54}
55
6c265988 56void _initialize_unpack_selftests ();
15ce8941
TT
57void
58_initialize_unpack_selftests ()
59{
60 selftests::register_test_foreach_arch
61 ("unpack_field_as_long", selftests::unpack::unpack_field_as_long_tests);
62}