xref: /aosp_15_r20/external/curl/tests/libtest/lib1912.c (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker /***************************************************************************
2*6236dae4SAndroid Build Coastguard Worker  *                                  _   _ ____  _
3*6236dae4SAndroid Build Coastguard Worker  *  Project                     ___| | | |  _ \| |
4*6236dae4SAndroid Build Coastguard Worker  *                             / __| | | | |_) | |
5*6236dae4SAndroid Build Coastguard Worker  *                            | (__| |_| |  _ <| |___
6*6236dae4SAndroid Build Coastguard Worker  *                             \___|\___/|_| \_\_____|
7*6236dae4SAndroid Build Coastguard Worker  *
8*6236dae4SAndroid Build Coastguard Worker  * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
9*6236dae4SAndroid Build Coastguard Worker  *
10*6236dae4SAndroid Build Coastguard Worker  * This software is licensed as described in the file COPYING, which
11*6236dae4SAndroid Build Coastguard Worker  * you should have received as part of this distribution. The terms
12*6236dae4SAndroid Build Coastguard Worker  * are also available at https://curl.se/docs/copyright.html.
13*6236dae4SAndroid Build Coastguard Worker  *
14*6236dae4SAndroid Build Coastguard Worker  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15*6236dae4SAndroid Build Coastguard Worker  * copies of the Software, and permit persons to whom the Software is
16*6236dae4SAndroid Build Coastguard Worker  * furnished to do so, under the terms of the COPYING file.
17*6236dae4SAndroid Build Coastguard Worker  *
18*6236dae4SAndroid Build Coastguard Worker  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19*6236dae4SAndroid Build Coastguard Worker  * KIND, either express or implied.
20*6236dae4SAndroid Build Coastguard Worker  *
21*6236dae4SAndroid Build Coastguard Worker  * SPDX-License-Identifier: curl
22*6236dae4SAndroid Build Coastguard Worker  *
23*6236dae4SAndroid Build Coastguard Worker  ***************************************************************************/
24*6236dae4SAndroid Build Coastguard Worker #include "test.h"
25*6236dae4SAndroid Build Coastguard Worker 
26*6236dae4SAndroid Build Coastguard Worker #include "testutil.h"
27*6236dae4SAndroid Build Coastguard Worker #include "warnless.h"
28*6236dae4SAndroid Build Coastguard Worker #include "memdebug.h"
29*6236dae4SAndroid Build Coastguard Worker 
30*6236dae4SAndroid Build Coastguard Worker #define print_err(name, exp) \
31*6236dae4SAndroid Build Coastguard Worker   fprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", name, exp);
32*6236dae4SAndroid Build Coastguard Worker 
test(char * URL)33*6236dae4SAndroid Build Coastguard Worker CURLcode test(char *URL)
34*6236dae4SAndroid Build Coastguard Worker {
35*6236dae4SAndroid Build Coastguard Worker /* Only test if GCC typechecking is available */
36*6236dae4SAndroid Build Coastguard Worker   int error = 0;
37*6236dae4SAndroid Build Coastguard Worker #ifdef CURLINC_TYPECHECK_GCC_H
38*6236dae4SAndroid Build Coastguard Worker   const struct curl_easyoption *o;
39*6236dae4SAndroid Build Coastguard Worker   for(o = curl_easy_option_next(NULL);
40*6236dae4SAndroid Build Coastguard Worker       o;
41*6236dae4SAndroid Build Coastguard Worker       o = curl_easy_option_next(o)) {
42*6236dae4SAndroid Build Coastguard Worker     CURL_IGNORE_DEPRECATION(
43*6236dae4SAndroid Build Coastguard Worker       /* Test for mismatch OR missing typecheck macros */
44*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_long_option(o->id) !=
45*6236dae4SAndroid Build Coastguard Worker           (o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
46*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
47*6236dae4SAndroid Build Coastguard Worker         error++;
48*6236dae4SAndroid Build Coastguard Worker       }
49*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
50*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_OFF_T");
51*6236dae4SAndroid Build Coastguard Worker         error++;
52*6236dae4SAndroid Build Coastguard Worker       }
53*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
54*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_STRING");
55*6236dae4SAndroid Build Coastguard Worker         error++;
56*6236dae4SAndroid Build Coastguard Worker       }
57*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
58*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_SLIST");
59*6236dae4SAndroid Build Coastguard Worker         error++;
60*6236dae4SAndroid Build Coastguard Worker       }
61*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
62*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_CBPTR");
63*6236dae4SAndroid Build Coastguard Worker         error++;
64*6236dae4SAndroid Build Coastguard Worker       }
65*6236dae4SAndroid Build Coastguard Worker       /* From here: only test that the type matches if macro is known */
66*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
67*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_FUNCTION");
68*6236dae4SAndroid Build Coastguard Worker         error++;
69*6236dae4SAndroid Build Coastguard Worker       }
70*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
71*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_FUNCTION");
72*6236dae4SAndroid Build Coastguard Worker         error++;
73*6236dae4SAndroid Build Coastguard Worker       }
74*6236dae4SAndroid Build Coastguard Worker       if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
75*6236dae4SAndroid Build Coastguard Worker         print_err(o->name, "CURLOT_OBJECT");
76*6236dae4SAndroid Build Coastguard Worker         error++;
77*6236dae4SAndroid Build Coastguard Worker       }
78*6236dae4SAndroid Build Coastguard Worker       /* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
79*6236dae4SAndroid Build Coastguard Worker     )
80*6236dae4SAndroid Build Coastguard Worker   }
81*6236dae4SAndroid Build Coastguard Worker #endif
82*6236dae4SAndroid Build Coastguard Worker   (void)URL;
83*6236dae4SAndroid Build Coastguard Worker   return error == 0 ? CURLE_OK : TEST_ERR_FAILURE;
84*6236dae4SAndroid Build Coastguard Worker }
85