Add support for DT_MIPS_RLD_MAP_REL.
[glibc.git] / sunrpc / tst-xdrmem.c
blobbe4a7e1ff5041f67b0a3a80ee70bc418f726aa7b
1 /* Copyright (C) 2005-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <limits.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <rpc/rpc.h>
24 static int
25 do_test (void)
27 XDR xdrs;
28 unsigned char buf[8192];
29 int v_int;
30 u_int v_u_int;
31 long v_long;
32 u_long v_u_long;
33 quad_t v_hyper;
34 u_quad_t v_u_hyper;
35 quad_t v_longlong_t;
36 u_quad_t v_u_longlong_t;
37 short v_short;
38 u_short v_u_short;
39 char v_char;
40 u_char v_u_char;
41 bool_t v_bool;
42 enum_t v_enum;
43 char *v_wrapstring;
45 xdrmem_create (&xdrs, (char *) buf, sizeof (buf), XDR_ENCODE);
47 #define TESTS \
48 T(int, 0) \
49 T(int, CHAR_MAX) \
50 T(int, CHAR_MIN) \
51 T(int, SHRT_MAX) \
52 T(int, SHRT_MIN) \
53 T(int, INT_MAX) \
54 T(int, INT_MIN) \
55 T(int, 0x123) \
56 T(u_int, 0) \
57 T(u_int, UCHAR_MAX) \
58 T(u_int, USHRT_MAX) \
59 T(u_int, UINT_MAX) \
60 T(u_int, 0xdeadbeef) \
61 T(u_int, 0x12345678) \
62 T(long, 0) \
63 T(long, 2147483647L) \
64 T(long, -2147483648L) \
65 T(long, -305419896L) \
66 T(long, -305419896L) \
67 T(u_long, 0) \
68 T(u_long, 0xffffffffUL) \
69 T(u_long, 0xdeadbeefUL) \
70 T(u_long, 0x12345678UL) \
71 T(hyper, 0) \
72 T(hyper, CHAR_MAX) \
73 T(hyper, CHAR_MIN) \
74 T(hyper, SHRT_MAX) \
75 T(hyper, SHRT_MIN) \
76 T(hyper, INT_MAX) \
77 T(hyper, INT_MIN) \
78 T(hyper, LONG_MAX) \
79 T(hyper, LONG_MIN) \
80 T(hyper, LONG_LONG_MAX) \
81 T(hyper, LONG_LONG_MIN) \
82 T(hyper, 0x12312345678LL) \
83 T(hyper, 0x12387654321LL) \
84 T(u_hyper, 0) \
85 T(u_hyper, UCHAR_MAX) \
86 T(u_hyper, USHRT_MAX) \
87 T(u_hyper, UINT_MAX) \
88 T(u_hyper, ULONG_MAX) \
89 T(u_hyper, ULONG_LONG_MAX) \
90 T(u_hyper, 0xdeadbeefdeadbeefULL) \
91 T(u_hyper, 0x12312345678ULL) \
92 T(u_hyper, 0x12387654321ULL) \
93 T(longlong_t, 0) \
94 T(longlong_t, CHAR_MAX) \
95 T(longlong_t, CHAR_MIN) \
96 T(longlong_t, SHRT_MAX) \
97 T(longlong_t, SHRT_MIN) \
98 T(longlong_t, INT_MAX) \
99 T(longlong_t, INT_MIN) \
100 T(longlong_t, LONG_MAX) \
101 T(longlong_t, LONG_MIN) \
102 T(longlong_t, LONG_LONG_MAX) \
103 T(longlong_t, LONG_LONG_MIN) \
104 T(longlong_t, 0x12312345678LL) \
105 T(longlong_t, 0x12387654321LL) \
106 T(u_longlong_t, 0) \
107 T(u_longlong_t, UCHAR_MAX) \
108 T(u_longlong_t, USHRT_MAX) \
109 T(u_longlong_t, UINT_MAX) \
110 T(u_longlong_t, ULONG_MAX) \
111 T(u_longlong_t, ULONG_LONG_MAX) \
112 T(u_longlong_t, 0xdeadbeefdeadbeefULL)\
113 T(u_longlong_t, 0x12312345678ULL) \
114 T(u_longlong_t, 0x12387654321ULL) \
115 T(short, CHAR_MAX) \
116 T(short, CHAR_MIN) \
117 T(short, SHRT_MAX) \
118 T(short, SHRT_MIN) \
119 T(short, 0x123) \
120 T(u_short, 0) \
121 T(u_short, UCHAR_MAX) \
122 T(u_short, USHRT_MAX) \
123 T(u_short, 0xbeef) \
124 T(u_short, 0x5678) \
125 T(char, CHAR_MAX) \
126 T(char, CHAR_MIN) \
127 T(char, 0x23) \
128 T(u_char, 0) \
129 T(u_char, UCHAR_MAX) \
130 T(u_char, 0xef) \
131 T(u_char, 0x78) \
132 T(bool, 0) \
133 T(bool, 1) \
134 T(enum, 0) \
135 T(enum, CHAR_MAX) \
136 T(enum, CHAR_MIN) \
137 T(enum, SHRT_MAX) \
138 T(enum, SHRT_MIN) \
139 T(enum, INT_MAX) \
140 T(enum, INT_MIN) \
141 T(enum, 0x123) \
142 S(wrapstring, (char *) "") \
143 S(wrapstring, (char *) "hello, world")
145 #define T(type, val) \
146 v_##type = val; \
147 if (! xdr_##type (&xdrs, &v_##type)) \
149 puts ("encoding of " #type \
150 " " #val " failed"); \
151 return 1; \
153 #define S(type, val) T(type, val)
155 TESTS
156 #undef T
157 #undef S
159 xdr_destroy (&xdrs);
161 xdrmem_create (&xdrs, (char *) buf, sizeof (buf), XDR_DECODE);
163 #define T(type, val) \
164 v_##type = 0x15; \
165 if (! xdr_##type (&xdrs, &v_##type)) \
167 puts ("decoding of " #type \
168 " " #val " failed"); \
169 return 1; \
171 if (v_##type != val) \
173 puts ("decoded value differs, " \
174 "type " #type " " #val); \
175 return 1; \
177 #define S(type, val) \
178 v_##type = NULL; \
179 if (! xdr_##type (&xdrs, &v_##type)) \
181 puts ("decoding of " #type \
182 " " #val " failed"); \
183 return 1; \
185 if (strcmp (v_##type, val)) \
187 puts ("decoded value differs, " \
188 "type " #type " " #val); \
189 return 1; \
191 free (v_##type); \
192 v_##type = NULL;
194 TESTS
195 #undef T
196 #undef S
198 xdr_destroy (&xdrs);
200 return 0;
203 #define TEST_FUNCTION do_test ()
204 #include "../test-skeleton.c"