FreeTDS API
Loading...
Searching...
No Matches
test_base.h
1/* Base tests utilities
2 * Copyright (C) 2025 Aaron M. Ucko
3 * Copyright (C) 2025 Frediano Ziglio
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This 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 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21#ifndef _tdsguard_afBM6E9n8CuIFSBHNNblq5_
22#define _tdsguard_afBM6E9n8CuIFSBHNNblq5_
23
24/*
25 * Base header for FreeTDS unit tests, even those just covering helpers
26 * from the utils and replacements trees. Should be included first
27 * (possibly via a common.h) to be certain of preceding <assert.h>.
28 */
29
30/* Ensure assert is always active. */
31#if defined(assert) && defined(NDEBUG)
32# error "Include test_base.h (or common.h) earlier"
33#endif
34
35#undef NDEBUG
36
37#include <config.h>
38
39#include <freetds/bool.h>
40#include <freetds/macros.h>
41
42/*
43 * Tests should define test_main in lieu of main so that they can be
44 * configured to suppress automation-unfriendly crash dialog boxes on
45 * Windows. To that end, they can use the TEST_MAIN macro, which cleanly
46 * avoids warnings for the tests that ignore their arguments (but still
47 * provides the details under conventional names for the remainder).
48 */
49int test_main(int argc, char **argv);
50
51#define TEST_MAIN() int test_main(int argc TDS_UNUSED, char **argv TDS_UNUSED)
52
53typedef struct
54{
55 char server[512];
56 char database[512];
57 char user[512];
58 char password[512];
59 char driver[1024]; /* ODBC-only */
60 char charset[512]; /* TDS only */
61 int maxlength;
62 bool fverbose;
63 bool initialized;
64 bool tried_env;
66
67extern COMMON_PWD common_pwd;
68
69#define DEFAULT_PWD_PATH "../../../PWD"
70
71/*
72 * Both return the path used (favoring $TDSPWDFILE in the absence of
73 * tried_env) on success or NULL on failure (silently in the case of
74 * try_read_login_info), and defer to any existing settings from
75 * e.g. the command line.
76 */
77const char *read_login_info_base(COMMON_PWD * common_pwd, const char *default_path);
78const char *try_read_login_info_base(COMMON_PWD * common_pwd, const char *default_path);
79
80#endif /* _tdsguard_afBM6E9n8CuIFSBHNNblq5_ */
Definition test_base.h:54