1 /* Self tests for unpack_field_as_long
3 Copyright (C) 2018-2022 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 "gdbsupport/selftest.h"
22 #include "selftest-arch.h"
25 #include "arch-utils.h"
31 unpack_field_as_long_tests (struct gdbarch
*arch
)
34 const struct builtin_type
*bt
= builtin_type (arch
);
35 struct type
*struct_type
= arch_composite_type (arch
, "<<selftest>>",
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);
42 memset (buffer
, 0, sizeof (buffer
));
44 if (gdbarch_byte_order (arch
) == BFD_ENDIAN_BIG
)
49 SELF_CHECK (unpack_field_as_long (struct_type
, buffer
, 0) == -1);
50 SELF_CHECK (unpack_field_as_long (struct_type
, buffer
, 1) == 23);
56 void _initialize_unpack_selftests ();
58 _initialize_unpack_selftests ()
60 selftests::register_test_foreach_arch
61 ("unpack_field_as_long", selftests::unpack::unpack_field_as_long_tests
);