1*e0c4386eSCy Schubert /*
2*e0c4386eSCy Schubert  * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert  * Copyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
4*e0c4386eSCy Schubert  *
5*e0c4386eSCy Schubert  * Licensed under the Apache License 2.0 (the "License").  You may not use
6*e0c4386eSCy Schubert  * this file except in compliance with the License.  You can obtain a copy
7*e0c4386eSCy Schubert  * in the file LICENSE in the source distribution or at
8*e0c4386eSCy Schubert  * https://www.openssl.org/source/license.html
9*e0c4386eSCy Schubert  */
10*e0c4386eSCy Schubert 
11*e0c4386eSCy Schubert #include <string.h>
12*e0c4386eSCy Schubert #include <openssl/params.h>
13*e0c4386eSCy Schubert #include "testutil.h"
14*e0c4386eSCy Schubert 
15*e0c4386eSCy Schubert /* On machines that dont support <inttypes.h> just disable the tests */
16*e0c4386eSCy Schubert #if !defined(OPENSSL_NO_INTTYPES_H)
17*e0c4386eSCy Schubert 
18*e0c4386eSCy Schubert # ifdef OPENSSL_SYS_VMS
19*e0c4386eSCy Schubert #  define strtoumax strtoull
20*e0c4386eSCy Schubert #  define strtoimax strtoll
21*e0c4386eSCy Schubert # endif
22*e0c4386eSCy Schubert 
23*e0c4386eSCy Schubert typedef struct {
24*e0c4386eSCy Schubert     OSSL_PARAM *param;
25*e0c4386eSCy Schubert     int32_t i32;
26*e0c4386eSCy Schubert     int64_t i64;
27*e0c4386eSCy Schubert     uint32_t u32;
28*e0c4386eSCy Schubert     uint64_t u64;
29*e0c4386eSCy Schubert     double d;
30*e0c4386eSCy Schubert     int valid_i32, valid_i64, valid_u32, valid_u64, valid_d;
31*e0c4386eSCy Schubert     void *ref, *datum;
32*e0c4386eSCy Schubert     size_t size;
33*e0c4386eSCy Schubert } PARAM_CONVERSION;
34*e0c4386eSCy Schubert 
param_conversion_load_stanza(PARAM_CONVERSION * pc,const STANZA * s)35*e0c4386eSCy Schubert static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s)
36*e0c4386eSCy Schubert {
37*e0c4386eSCy Schubert 
38*e0c4386eSCy Schubert     static int32_t datum_i32, ref_i32;
39*e0c4386eSCy Schubert     static int64_t datum_i64, ref_i64;
40*e0c4386eSCy Schubert     static uint32_t datum_u32, ref_u32;
41*e0c4386eSCy Schubert     static uint64_t datum_u64, ref_u64;
42*e0c4386eSCy Schubert     static double datum_d, ref_d;
43*e0c4386eSCy Schubert     static OSSL_PARAM params[] = {
44*e0c4386eSCy Schubert         OSSL_PARAM_int32("int32",   &datum_i32),
45*e0c4386eSCy Schubert         OSSL_PARAM_int64("int64",   &datum_i64),
46*e0c4386eSCy Schubert         OSSL_PARAM_uint32("uint32", &datum_u32),
47*e0c4386eSCy Schubert         OSSL_PARAM_uint64("uint64", &datum_u64),
48*e0c4386eSCy Schubert         OSSL_PARAM_double("double", &datum_d),
49*e0c4386eSCy Schubert         OSSL_PARAM_END
50*e0c4386eSCy Schubert     };
51*e0c4386eSCy Schubert     int def_i32 = 0, def_i64 = 0, def_u32 = 0, def_u64 = 0, def_d = 0;
52*e0c4386eSCy Schubert     const PAIR *pp = s->pairs;
53*e0c4386eSCy Schubert     const char *type = NULL;
54*e0c4386eSCy Schubert     char *p;
55*e0c4386eSCy Schubert     int i;
56*e0c4386eSCy Schubert 
57*e0c4386eSCy Schubert     memset(pc, 0, sizeof(*pc));
58*e0c4386eSCy Schubert 
59*e0c4386eSCy Schubert     for (i = 0; i < s->numpairs; i++, pp++) {
60*e0c4386eSCy Schubert         p = "";
61*e0c4386eSCy Schubert         if (OPENSSL_strcasecmp(pp->key, "type") == 0) {
62*e0c4386eSCy Schubert             if (type != NULL) {
63*e0c4386eSCy Schubert                 TEST_info("Line %d: multiple type lines", s->curr);
64*e0c4386eSCy Schubert                 return 0;
65*e0c4386eSCy Schubert             }
66*e0c4386eSCy Schubert             pc->param = OSSL_PARAM_locate(params, type = pp->value);
67*e0c4386eSCy Schubert             if (pc->param == NULL) {
68*e0c4386eSCy Schubert                 TEST_info("Line %d: unknown type line", s->curr);
69*e0c4386eSCy Schubert                 return 0;
70*e0c4386eSCy Schubert             }
71*e0c4386eSCy Schubert         } else if (OPENSSL_strcasecmp(pp->key, "int32") == 0) {
72*e0c4386eSCy Schubert             if (def_i32++) {
73*e0c4386eSCy Schubert                 TEST_info("Line %d: multiple int32 lines", s->curr);
74*e0c4386eSCy Schubert                 return 0;
75*e0c4386eSCy Schubert             }
76*e0c4386eSCy Schubert             if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) {
77*e0c4386eSCy Schubert                 pc->valid_i32 = 1;
78*e0c4386eSCy Schubert                 pc->i32 = (int32_t)strtoimax(pp->value, &p, 10);
79*e0c4386eSCy Schubert             }
80*e0c4386eSCy Schubert         } else if (OPENSSL_strcasecmp(pp->key, "int64") == 0) {
81*e0c4386eSCy Schubert             if (def_i64++) {
82*e0c4386eSCy Schubert                 TEST_info("Line %d: multiple int64 lines", s->curr);
83*e0c4386eSCy Schubert                 return 0;
84*e0c4386eSCy Schubert             }
85*e0c4386eSCy Schubert             if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) {
86*e0c4386eSCy Schubert                 pc->valid_i64 = 1;
87*e0c4386eSCy Schubert                 pc->i64 = (int64_t)strtoimax(pp->value, &p, 10);
88*e0c4386eSCy Schubert             }
89*e0c4386eSCy Schubert         } else if (OPENSSL_strcasecmp(pp->key, "uint32") == 0) {
90*e0c4386eSCy Schubert             if (def_u32++) {
91*e0c4386eSCy Schubert                 TEST_info("Line %d: multiple uint32 lines", s->curr);
92*e0c4386eSCy Schubert                 return 0;
93*e0c4386eSCy Schubert             }
94*e0c4386eSCy Schubert             if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) {
95*e0c4386eSCy Schubert                 pc->valid_u32 = 1;
96*e0c4386eSCy Schubert                 pc->u32 = (uint32_t)strtoumax(pp->value, &p, 10);
97*e0c4386eSCy Schubert             }
98*e0c4386eSCy Schubert         } else if (OPENSSL_strcasecmp(pp->key, "uint64") == 0) {
99*e0c4386eSCy Schubert             if (def_u64++) {
100*e0c4386eSCy Schubert                 TEST_info("Line %d: multiple uint64 lines", s->curr);
101*e0c4386eSCy Schubert                 return 0;
102*e0c4386eSCy Schubert             }
103*e0c4386eSCy Schubert             if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) {
104*e0c4386eSCy Schubert                 pc->valid_u64 = 1;
105*e0c4386eSCy Schubert                 pc->u64 = (uint64_t)strtoumax(pp->value, &p, 10);
106*e0c4386eSCy Schubert             }
107*e0c4386eSCy Schubert         } else if (OPENSSL_strcasecmp(pp->key, "double") == 0) {
108*e0c4386eSCy Schubert             if (def_d++) {
109*e0c4386eSCy Schubert                 TEST_info("Line %d: multiple double lines", s->curr);
110*e0c4386eSCy Schubert                 return 0;
111*e0c4386eSCy Schubert             }
112*e0c4386eSCy Schubert             if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) {
113*e0c4386eSCy Schubert                 pc->valid_d = 1;
114*e0c4386eSCy Schubert                 pc->d = strtod(pp->value, &p);
115*e0c4386eSCy Schubert             }
116*e0c4386eSCy Schubert         } else {
117*e0c4386eSCy Schubert             TEST_info("Line %d: unknown keyword %s", s->curr, pp->key);
118*e0c4386eSCy Schubert             return 0;
119*e0c4386eSCy Schubert         }
120*e0c4386eSCy Schubert         if (*p != '\0') {
121*e0c4386eSCy Schubert             TEST_info("Line %d: extra characters at end '%s' for %s",
122*e0c4386eSCy Schubert                       s->curr, p, pp->key);
123*e0c4386eSCy Schubert             return 0;
124*e0c4386eSCy Schubert         }
125*e0c4386eSCy Schubert     }
126*e0c4386eSCy Schubert 
127*e0c4386eSCy Schubert     if (!TEST_ptr(type)) {
128*e0c4386eSCy Schubert         TEST_info("Line %d: type not found", s->curr);
129*e0c4386eSCy Schubert         return 0;
130*e0c4386eSCy Schubert     }
131*e0c4386eSCy Schubert 
132*e0c4386eSCy Schubert     if (OPENSSL_strcasecmp(type, "int32") == 0) {
133*e0c4386eSCy Schubert         if (!TEST_true(def_i32) || !TEST_true(pc->valid_i32)) {
134*e0c4386eSCy Schubert             TEST_note("errant int32 on line %d", s->curr);
135*e0c4386eSCy Schubert             return 0;
136*e0c4386eSCy Schubert         }
137*e0c4386eSCy Schubert         datum_i32 = ref_i32 = pc->i32;
138*e0c4386eSCy Schubert         pc->datum = &datum_i32;
139*e0c4386eSCy Schubert         pc->ref = &ref_i32;
140*e0c4386eSCy Schubert         pc->size = sizeof(ref_i32);
141*e0c4386eSCy Schubert     } else if (OPENSSL_strcasecmp(type, "int64") == 0) {
142*e0c4386eSCy Schubert         if (!TEST_true(def_i64) || !TEST_true(pc->valid_i64)) {
143*e0c4386eSCy Schubert             TEST_note("errant int64 on line %d", s->curr);
144*e0c4386eSCy Schubert             return 0;
145*e0c4386eSCy Schubert         }
146*e0c4386eSCy Schubert         datum_i64 = ref_i64 = pc->i64;
147*e0c4386eSCy Schubert         pc->datum = &datum_i64;
148*e0c4386eSCy Schubert         pc->ref = &ref_i64;
149*e0c4386eSCy Schubert         pc->size = sizeof(ref_i64);
150*e0c4386eSCy Schubert     } else if (OPENSSL_strcasecmp(type, "uint32") == 0) {
151*e0c4386eSCy Schubert         if (!TEST_true(def_u32) || !TEST_true(pc->valid_u32)) {
152*e0c4386eSCy Schubert             TEST_note("errant uint32 on line %d", s->curr);
153*e0c4386eSCy Schubert             return 0;
154*e0c4386eSCy Schubert         }
155*e0c4386eSCy Schubert         datum_u32 = ref_u32 = pc->u32;
156*e0c4386eSCy Schubert         pc->datum = &datum_u32;
157*e0c4386eSCy Schubert         pc->ref = &ref_u32;
158*e0c4386eSCy Schubert         pc->size = sizeof(ref_u32);
159*e0c4386eSCy Schubert     } else if (OPENSSL_strcasecmp(type, "uint64") == 0) {
160*e0c4386eSCy Schubert         if (!TEST_true(def_u64) || !TEST_true(pc->valid_u64)) {
161*e0c4386eSCy Schubert             TEST_note("errant uint64 on line %d", s->curr);
162*e0c4386eSCy Schubert             return 0;
163*e0c4386eSCy Schubert         }
164*e0c4386eSCy Schubert         datum_u64 = ref_u64 = pc->u64;
165*e0c4386eSCy Schubert         pc->datum = &datum_u64;
166*e0c4386eSCy Schubert         pc->ref = &ref_u64;
167*e0c4386eSCy Schubert         pc->size = sizeof(ref_u64);
168*e0c4386eSCy Schubert     } else if (OPENSSL_strcasecmp(type, "double") == 0) {
169*e0c4386eSCy Schubert         if (!TEST_true(def_d) || !TEST_true(pc->valid_d)) {
170*e0c4386eSCy Schubert             TEST_note("errant double on line %d", s->curr);
171*e0c4386eSCy Schubert             return 0;
172*e0c4386eSCy Schubert         }
173*e0c4386eSCy Schubert         datum_d = ref_d = pc->d;
174*e0c4386eSCy Schubert         pc->datum = &datum_d;
175*e0c4386eSCy Schubert         pc->ref = &ref_d;
176*e0c4386eSCy Schubert         pc->size = sizeof(ref_d);
177*e0c4386eSCy Schubert     } else {
178*e0c4386eSCy Schubert         TEST_error("type unknown at line %d", s->curr);
179*e0c4386eSCy Schubert         return 0;
180*e0c4386eSCy Schubert     }
181*e0c4386eSCy Schubert     return 1;
182*e0c4386eSCy Schubert }
183*e0c4386eSCy Schubert 
param_conversion_test(const PARAM_CONVERSION * pc,int line)184*e0c4386eSCy Schubert static int param_conversion_test(const PARAM_CONVERSION *pc, int line)
185*e0c4386eSCy Schubert {
186*e0c4386eSCy Schubert     int32_t i32;
187*e0c4386eSCy Schubert     int64_t i64;
188*e0c4386eSCy Schubert     uint32_t u32;
189*e0c4386eSCy Schubert     uint64_t u64;
190*e0c4386eSCy Schubert     double d;
191*e0c4386eSCy Schubert 
192*e0c4386eSCy Schubert     if (!pc->valid_i32) {
193*e0c4386eSCy Schubert         if (!TEST_false(OSSL_PARAM_get_int32(pc->param, &i32))) {
194*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion to int32 on line %d", line);
195*e0c4386eSCy Schubert             return 0;
196*e0c4386eSCy Schubert         }
197*e0c4386eSCy Schubert     } else {
198*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_get_int32(pc->param, &i32))
199*e0c4386eSCy Schubert             || !TEST_true(i32 == pc->i32)) {
200*e0c4386eSCy Schubert             TEST_note("unexpected conversion to int32 on line %d", line);
201*e0c4386eSCy Schubert             return 0;
202*e0c4386eSCy Schubert         }
203*e0c4386eSCy Schubert         memset(pc->datum, 44, pc->size);
204*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_set_int32(pc->param, i32))
205*e0c4386eSCy Schubert             || !TEST_mem_eq(pc->datum, pc->size, pc->ref, pc->size)) {
206*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion from int32 on line %d",
207*e0c4386eSCy Schubert                       line);
208*e0c4386eSCy Schubert             return 0;
209*e0c4386eSCy Schubert         }
210*e0c4386eSCy Schubert     }
211*e0c4386eSCy Schubert 
212*e0c4386eSCy Schubert     if (!pc->valid_i64) {
213*e0c4386eSCy Schubert         if (!TEST_false(OSSL_PARAM_get_int64(pc->param, &i64))) {
214*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion to int64 on line %d", line);
215*e0c4386eSCy Schubert             return 0;
216*e0c4386eSCy Schubert         }
217*e0c4386eSCy Schubert     } else {
218*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_get_int64(pc->param, &i64))
219*e0c4386eSCy Schubert             || !TEST_true(i64 == pc->i64)) {
220*e0c4386eSCy Schubert             TEST_note("unexpected conversion to int64 on line %d", line);
221*e0c4386eSCy Schubert             return 0;
222*e0c4386eSCy Schubert         }
223*e0c4386eSCy Schubert         memset(pc->datum, 44, pc->size);
224*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_set_int64(pc->param, i64))
225*e0c4386eSCy Schubert             || !TEST_mem_eq(pc->datum, pc->size, pc->ref, pc->size)) {
226*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion from int64 on line %d",
227*e0c4386eSCy Schubert                       line);
228*e0c4386eSCy Schubert             return 0;
229*e0c4386eSCy Schubert         }
230*e0c4386eSCy Schubert     }
231*e0c4386eSCy Schubert 
232*e0c4386eSCy Schubert     if (!pc->valid_u32) {
233*e0c4386eSCy Schubert         if (!TEST_false(OSSL_PARAM_get_uint32(pc->param, &u32))) {
234*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion to uint32 on line %d", line);
235*e0c4386eSCy Schubert             return 0;
236*e0c4386eSCy Schubert         }
237*e0c4386eSCy Schubert     } else {
238*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_get_uint32(pc->param, &u32))
239*e0c4386eSCy Schubert             || !TEST_true(u32 == pc->u32)) {
240*e0c4386eSCy Schubert             TEST_note("unexpected conversion to uint32 on line %d", line);
241*e0c4386eSCy Schubert             return 0;
242*e0c4386eSCy Schubert         }
243*e0c4386eSCy Schubert         memset(pc->datum, 44, pc->size);
244*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_set_uint32(pc->param, u32))
245*e0c4386eSCy Schubert             || !TEST_mem_eq(pc->datum, pc->size, pc->ref, pc->size)) {
246*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion from uint32 on line %d",
247*e0c4386eSCy Schubert                       line);
248*e0c4386eSCy Schubert             return 0;
249*e0c4386eSCy Schubert         }
250*e0c4386eSCy Schubert     }
251*e0c4386eSCy Schubert 
252*e0c4386eSCy Schubert     if (!pc->valid_u64) {
253*e0c4386eSCy Schubert         if (!TEST_false(OSSL_PARAM_get_uint64(pc->param, &u64))) {
254*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion to uint64 on line %d", line);
255*e0c4386eSCy Schubert             return 0;
256*e0c4386eSCy Schubert         }
257*e0c4386eSCy Schubert     } else {
258*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_get_uint64(pc->param, &u64))
259*e0c4386eSCy Schubert             || !TEST_true(u64 == pc->u64)) {
260*e0c4386eSCy Schubert             TEST_note("unexpected conversion to uint64 on line %d", line);
261*e0c4386eSCy Schubert             return 0;
262*e0c4386eSCy Schubert         }
263*e0c4386eSCy Schubert         memset(pc->datum, 44, pc->size);
264*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_set_uint64(pc->param, u64))
265*e0c4386eSCy Schubert             || !TEST_mem_eq(pc->datum, pc->size, pc->ref, pc->size)) {
266*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion from uint64 on line %d",
267*e0c4386eSCy Schubert                       line);
268*e0c4386eSCy Schubert             return 0;
269*e0c4386eSCy Schubert         }
270*e0c4386eSCy Schubert     }
271*e0c4386eSCy Schubert 
272*e0c4386eSCy Schubert     if (!pc->valid_d) {
273*e0c4386eSCy Schubert         if (!TEST_false(OSSL_PARAM_get_double(pc->param, &d))) {
274*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion to double on line %d", line);
275*e0c4386eSCy Schubert             return 0;
276*e0c4386eSCy Schubert         }
277*e0c4386eSCy Schubert     } else {
278*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_get_double(pc->param, &d))) {
279*e0c4386eSCy Schubert             TEST_note("unable to convert to double on line %d", line);
280*e0c4386eSCy Schubert             return 0;
281*e0c4386eSCy Schubert         }
282*e0c4386eSCy Schubert         /*
283*e0c4386eSCy Schubert          * Check for not a number (NaN) without using the libm functions.
284*e0c4386eSCy Schubert          * When d is a NaN, the standard requires d == d to be false.
285*e0c4386eSCy Schubert          * It's less clear if d != d should be true even though it generally is.
286*e0c4386eSCy Schubert          * Hence we use the equality test and a not.
287*e0c4386eSCy Schubert          */
288*e0c4386eSCy Schubert         if (!(d == d)) {
289*e0c4386eSCy Schubert             /*
290*e0c4386eSCy Schubert              * We've encountered a NaN so check it's really meant to be a NaN.
291*e0c4386eSCy Schubert              * We ignore the case where the two values are both different NaN,
292*e0c4386eSCy Schubert              * that's not resolvable without knowing the underlying format
293*e0c4386eSCy Schubert              * or using libm functions.
294*e0c4386eSCy Schubert              */
295*e0c4386eSCy Schubert             if (!TEST_false(pc->d == pc->d)) {
296*e0c4386eSCy Schubert                 TEST_note("unexpected NaN on line %d", line);
297*e0c4386eSCy Schubert                 return 0;
298*e0c4386eSCy Schubert             }
299*e0c4386eSCy Schubert         } else if (!TEST_true(d == pc->d)) {
300*e0c4386eSCy Schubert             TEST_note("unexpected conversion to double on line %d", line);
301*e0c4386eSCy Schubert             return 0;
302*e0c4386eSCy Schubert         }
303*e0c4386eSCy Schubert         memset(pc->datum, 44, pc->size);
304*e0c4386eSCy Schubert         if (!TEST_true(OSSL_PARAM_set_double(pc->param, d))
305*e0c4386eSCy Schubert             || !TEST_mem_eq(pc->datum, pc->size, pc->ref, pc->size)) {
306*e0c4386eSCy Schubert             TEST_note("unexpected valid conversion from double on line %d",
307*e0c4386eSCy Schubert                       line);
308*e0c4386eSCy Schubert             return 0;
309*e0c4386eSCy Schubert         }
310*e0c4386eSCy Schubert     }
311*e0c4386eSCy Schubert 
312*e0c4386eSCy Schubert     return 1;
313*e0c4386eSCy Schubert }
314*e0c4386eSCy Schubert 
run_param_file_tests(int i)315*e0c4386eSCy Schubert static int run_param_file_tests(int i)
316*e0c4386eSCy Schubert {
317*e0c4386eSCy Schubert     STANZA *s;
318*e0c4386eSCy Schubert     PARAM_CONVERSION pc;
319*e0c4386eSCy Schubert     const char *testfile = test_get_argument(i);
320*e0c4386eSCy Schubert     int res = 1;
321*e0c4386eSCy Schubert 
322*e0c4386eSCy Schubert     if (!TEST_ptr(s = OPENSSL_zalloc(sizeof(*s))))
323*e0c4386eSCy Schubert         return 0;
324*e0c4386eSCy Schubert     if (!test_start_file(s, testfile)) {
325*e0c4386eSCy Schubert         OPENSSL_free(s);
326*e0c4386eSCy Schubert         return 0;
327*e0c4386eSCy Schubert     }
328*e0c4386eSCy Schubert 
329*e0c4386eSCy Schubert     while (!BIO_eof(s->fp)) {
330*e0c4386eSCy Schubert         if (!test_readstanza(s)) {
331*e0c4386eSCy Schubert             res = 0;
332*e0c4386eSCy Schubert             goto end;
333*e0c4386eSCy Schubert         }
334*e0c4386eSCy Schubert         if (s->numpairs != 0)
335*e0c4386eSCy Schubert             if (!param_conversion_load_stanza(&pc, s)
336*e0c4386eSCy Schubert                 || !param_conversion_test(&pc, s->curr))
337*e0c4386eSCy Schubert                 res = 0;
338*e0c4386eSCy Schubert         test_clearstanza(s);
339*e0c4386eSCy Schubert     }
340*e0c4386eSCy Schubert end:
341*e0c4386eSCy Schubert     test_end_file(s);
342*e0c4386eSCy Schubert     OPENSSL_free(s);
343*e0c4386eSCy Schubert     return res;
344*e0c4386eSCy Schubert }
345*e0c4386eSCy Schubert 
346*e0c4386eSCy Schubert #endif /* OPENSSL_NO_INTTYPES_H */
347*e0c4386eSCy Schubert 
348*e0c4386eSCy Schubert OPT_TEST_DECLARE_USAGE("file...\n")
349*e0c4386eSCy Schubert 
setup_tests(void)350*e0c4386eSCy Schubert int setup_tests(void)
351*e0c4386eSCy Schubert {
352*e0c4386eSCy Schubert     size_t n;
353*e0c4386eSCy Schubert 
354*e0c4386eSCy Schubert     if (!test_skip_common_options()) {
355*e0c4386eSCy Schubert         TEST_error("Error parsing test options\n");
356*e0c4386eSCy Schubert         return 0;
357*e0c4386eSCy Schubert     }
358*e0c4386eSCy Schubert 
359*e0c4386eSCy Schubert     n = test_get_argument_count();
360*e0c4386eSCy Schubert     if (n == 0)
361*e0c4386eSCy Schubert         return 0;
362*e0c4386eSCy Schubert 
363*e0c4386eSCy Schubert #if !defined(OPENSSL_NO_INTTYPES_H)
364*e0c4386eSCy Schubert     ADD_ALL_TESTS(run_param_file_tests, n);
365*e0c4386eSCy Schubert #endif /* OPENSSL_NO_INTTYPES_H */
366*e0c4386eSCy Schubert 
367*e0c4386eSCy Schubert     return 1;
368*e0c4386eSCy Schubert }
369