]> granicus.if.org Git - strace/blob - mpers_test.sh
rtnl_link: use internal rtnl_link_stats* and ifla_port_vsi definitions
[strace] / mpers_test.sh
1 #!/bin/sh -efu
2 #
3 # Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
4 # Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
5 # Copyright (c) 2015-2019 The strace developers.
6 # All rights reserved.
7 #
8 # SPDX-License-Identifier: LGPL-2.1-or-later
9
10 [ "x${D:-0}" != x1 ] || set -x
11
12 mpers_name="$1"; shift
13 mpers_cc_flags="$1"; shift
14 size="$(printf %s "$mpers_name" |tr -cd '[0-9]')"
15 [ "$size" -gt 0 ]
16
17 srcdir=${0%/*}
18 mpers_sh="${srcdir}/mpers.sh"
19
20 mpers_dir="mpers-$mpers_name"
21 mkdir -p "$mpers_dir"
22
23 sample="$mpers_dir/sample.c"
24 cat > "$sample" <<EOF
25 #include "mpers_type.h"
26 #include DEF_MPERS_TYPE(sample_struct)
27 typedef struct {
28         struct {
29                 void *p;
30                 char sc;
31                 /* unsigned char mpers_filler_1[1]; */
32                 short ss;
33                 unsigned char uc;
34                 /* unsigned char mpers_filler_2[3]; */
35                 int si;
36                 unsigned ui;
37                 long sl;
38                 unsigned short us;
39                 /* unsigned char mpers_filler_3[6]; */
40                 long long sll __attribute__((__aligned__(8)));
41                 unsigned long long ull;
42                 unsigned long ul;
43                 long asl[3][5][7];
44                 char f;
45                 /* unsigned char mpers_end_filler_4[7]; */
46         } s;
47         union {
48                 long long sll;
49                 unsigned long long ull;
50                 void *p;
51                 long sl;
52                 unsigned long ul;
53                 int si;
54                 unsigned ui;
55                 short ss[7][9];
56                 unsigned short us[4];
57                 char sc;
58                 unsigned char uc;
59         } u[3][2];
60         short f[0];
61 } sample_struct;
62 #include MPERS_DEFS
63 EOF
64
65 expected="$mpers_dir/sample.expected"
66 mpers_ptr_t="uint${size}_t"
67 cat > "$expected" <<EOF
68 #include <stdint.h>
69 #ifndef mpers_ptr_t_is_${mpers_ptr_t}
70 typedef ${mpers_ptr_t} mpers_ptr_t;
71 #define mpers_ptr_t_is_${mpers_ptr_t}
72 #endif
73 typedef
74 struct {
75 struct {
76 mpers_ptr_t p;
77 char sc;
78 unsigned char mpers_filler_1[1];
79 int16_t ss;
80 unsigned char uc;
81 unsigned char mpers_filler_2[3];
82 int32_t si;
83 uint32_t ui;
84 int${size}_t sl;
85 uint16_t us;
86 unsigned char mpers_filler_3[6];
87 int64_t sll;
88 uint64_t ull;
89 uint${size}_t ul;
90 int${size}_t asl[3][5][7];
91 char f;
92 unsigned char mpers_end_filler_4[7];
93 } ATTRIBUTE_PACKED s;
94 union {
95 int64_t sll;
96 uint64_t ull;
97 mpers_ptr_t p;
98 int${size}_t sl;
99 uint${size}_t ul;
100 int32_t si;
101 uint32_t ui;
102 int16_t ss[7][9];
103 uint16_t us[4];
104 char sc;
105 unsigned char uc;
106 } u[3][2];
107 int16_t f[0];
108 } ATTRIBUTE_PACKED ${mpers_name}_sample_struct;
109 #define MPERS_${mpers_name}_sample_struct ${mpers_name}_sample_struct
110 EOF
111
112 CFLAGS="$CPPFLAGS -I${srcdir} -DMPERS_IS_${mpers_name}" \
113 CPPFLAGS="$CPPFLAGS -I${srcdir} -DIN_MPERS -DMPERS_IS_${mpers_name}" \
114 "$mpers_sh" "$mpers_name" "$mpers_cc_flags" "$sample"
115 cmp "$expected" "$mpers_dir"/sample_struct.h > /dev/null