3 #include <glib/gstdio.h>
12 #include "test-stuff.h"
14 #include "test-file-stuff.h"
21 const char *possible_envs[] =
23 "C",
"af",
"ar",
"az",
"be",
"bg",
"bg_BG.cp1251",
"br",
"ca",
"cs",
24 "cy",
"cz",
"da",
"de",
"de_AT",
"el",
"en",
"en_AU",
"en_CA",
"en_GB",
25 "eo",
"es",
"es_DO",
"es_ES",
"es_GT",
"es_HN",
"es_MX",
"es_PA",
26 "es_PE",
"es_SV",
"et",
"et_EE",
"eu",
"fi",
"fi_FI",
"fr",
"ga",
27 "gd",
"gl",
"gr",
"gv",
"he",
"hr",
"hu",
"id",
"is",
"it",
"ja",
28 "ja_JP",
"ja_JP.SJIS",
"ko",
"ko_KR",
"ko_KR.eucKR",
"kw",
"l10n",
29 "locale.alias",
"lt",
"nl",
"nn",
"no",
"no@nynorsk",
"no_NO",
"no_NY",
30 "pl",
"pl_PL",
"pt",
"pt_BR",
"pt_PT",
"ro",
"ru",
"ru_RU",
"rudos",
31 "rukoi8",
"ruwin",
"sk",
"sl",
"sl_SI",
"sp",
"sr",
"sr_YU",
"sv",
"ta",
32 "tr",
"uk",
"vi",
"vi_VN.VISCII",
"wa",
"zh",
"zh_CN",
"zh_CN.EUC",
33 "zh_CN.GB2312",
"zh_TW",
"zh_TW.Big5",
37 const char *possible_vars[] =
39 "LANG",
"LC_CTYPE",
"LC_COLLATE",
"LC_TIME",
"LC_NUMERIC",
40 "LC_MONETARY",
"LC_MESSAGES",
44 const char *diff_command =
"cmp %s %s";
45 const char *test_dir =
"test-files/xml2";
46 const char *base_env =
"C";
49 gen_new_file_name(
const char *filename,
const char *env)
53 ret = g_new(
char, strlen(filename) + strlen(env) + 2);
54 strcpy(ret, filename);
62 run_command_get_return(
const char *command)
64 return system(command);
68 test_file(
const char *filename)
72 for (i = 0; possible_envs[i] != NULL; i++)
77 char *new_file = gen_new_file_name(filename, possible_envs[i]);
80 session = qof_session_new();
86 qof_session_destroy(session);
87 return g_strdup_printf(
"qof_session_begin errorid %d", err);
90 qof_session_load(session, NULL);
94 qof_session_destroy(session);
95 return g_strdup_printf(
"qof_session_load errorid %d", err);
98 if (!g_setenv(
"LANG", possible_envs[i], TRUE))
99 return g_strdup(
"setenv for LANG");
101 new_session = qof_session_new();
108 qof_session_destroy(session);
109 qof_session_destroy(new_session);
110 return g_strdup_printf(
"qof_session_begin 2 with LANG=%s",
116 cmd = g_strdup_printf(diff_command, filename, new_file);
118 if (run_command_get_return(cmd) != 0)
122 qof_session_destroy(session);
123 qof_session_destroy(new_session);
124 return g_strdup_printf(
"run_command_get_return with LANG=%s",
130 qof_session_destroy(session);
131 qof_session_destroy(new_session);
138 main(
int argc,
char **argv)
145 if ((adir = g_dir_open(test_dir, 0, NULL)) == NULL)
147 failure_args(
"g_dir_open", __FILE__, __LINE__,
148 "couldn't open dir %s", test_dir);
152 const gchar *next_file;
154 while ((next_file = g_dir_read_name(adir)) != NULL)
156 struct stat file_info;
159 filename = g_build_filename(test_dir, next_file, (gchar*) NULL);
161 if (g_stat(filename, &file_info) != 0)
163 failure_args(
"stat", __FILE__, __LINE__,
164 "couldn't stat file %s: %s", filename,
170 if (!g_setenv(
"LANG", base_env, TRUE))
172 failure_args(
"setenv", __FILE__, __LINE__,
173 "setenv of LANG failed");
178 if (!S_ISDIR(file_info.st_mode))
180 char *msg = test_file(filename);
184 failure_args(
"test_file", __FILE__, __LINE__,
185 "failure testing file %s with msg %s",
196 print_test_results();
void qof_session_save(QofSession *session, QofPercentageFunc percentage_func)
QofBackendError
The errors that can be reported to the GUI & other front-end users.
void xaccLogDisable(void)
api for GnuCash version 2 XML-based file format
QofBackendError qof_session_pop_error(QofSession *session)
void gnc_engine_init(int argc, char **argv)
All type declarations for the whole Gnucash engine.
API for the transaction logger.
void qof_session_begin(QofSession *session, const char *book_id, gboolean ignore_lock, gboolean create, gboolean force)