static void test_cr_xml_parse_filelists_00(void) { GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_REPO_00_FILELISTS, NULL, NULL, pkgcb, NULL, NULL, NULL, &tmp_err); g_assert(tmp_err == NULL); g_assert_cmpint(ret, ==, CRE_OK); }
static void test_cr_xml_parse_filelists_bad_file_type_00(void) { int parsed = 0; GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_MRF_BAD_TYPE_FIL, NULL, NULL, pkgcb, &parsed, NULL, NULL, &tmp_err); g_assert(tmp_err == NULL); g_assert_cmpint(ret, ==, CRE_OK); g_assert_cmpint(parsed, ==, 2); }
static void test_cr_xml_parse_filelists_no_pkgid(void) { int parsed = 0; GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_MRF_NO_PKGID_FIL, NULL, NULL, pkgcb, &parsed, NULL, NULL, &tmp_err); g_assert(tmp_err != NULL); g_error_free(tmp_err); g_assert_cmpint(ret, ==, CRE_BADXMLFILELISTS); }
static void test_cr_xml_parse_filelists_unknown_element_02(void) { int parsed = 0; GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_MRF_UE_FIL_02, NULL, NULL, pkgcb, &parsed, NULL, NULL, &tmp_err); g_assert(tmp_err == NULL); g_assert_cmpint(ret, ==, CRE_OK); g_assert_cmpint(parsed, ==, 2); }
static void test_cr_xml_parse_filelists_pkgcb_interrupt(void) { int parsed = 0; GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_REPO_02_FILELISTS, NULL, NULL, pkgcb_interrupt, &parsed, NULL, NULL, &tmp_err); g_assert(tmp_err != NULL); g_error_free(tmp_err); g_assert_cmpint(ret, ==, CRE_CBINTERRUPTED); g_assert_cmpint(parsed, ==, 1); }
static void test_cr_xml_parse_filelists_skip_fake_bash_01(void) { int parsed = 0; GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_MRF_UE_FIL_01, newpkgcb_skip_fake_bash, NULL, pkgcb, &parsed, NULL, NULL, &tmp_err); g_assert(tmp_err == NULL); g_assert_cmpint(ret, ==, CRE_OK); g_assert_cmpint(parsed, ==, 0); }
static void test_cr_xml_parse_filelists_warningcb_interrupt(void) { int parsed = 0, numofwarnings = 0; GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_MRF_BAD_TYPE_FIL, NULL, NULL, pkgcb, &parsed, warningcb_interrupt, &numofwarnings, &tmp_err); g_assert(tmp_err != NULL); g_error_free(tmp_err); g_assert_cmpint(ret, ==, CRE_CBINTERRUPTED); g_assert_cmpint(parsed, ==, 1); g_assert_cmpint(numofwarnings, ==, 1); }
static void test_cr_xml_parse_filelists_bad_file_type_01(void) { char *warnmsgs; int parsed = 0; GString *warn_strings = g_string_new(0); GError *tmp_err = NULL; int ret = cr_xml_parse_filelists(TEST_MRF_BAD_TYPE_FIL, NULL, NULL, pkgcb, &parsed, warningcb, warn_strings, &tmp_err); g_assert(tmp_err == NULL); g_assert_cmpint(ret, ==, CRE_OK); g_assert_cmpint(parsed, ==, 2); warnmsgs = g_string_free(warn_strings, FALSE); g_assert_cmpstr(warnmsgs, ==, "Unknown file type \"foo\";"); g_free(warnmsgs); }
static gboolean filelists_to_sqlite(const gchar *fil_xml_path, cr_SqliteDb *fil_db, GError **err) { int rc; rc = cr_xml_parse_filelists(fil_xml_path, NULL, NULL, pkgcb, (void *) fil_db, warningcb, (void *) fil_xml_path, err); if (rc != CRE_OK) return FALSE; return TRUE; }
static int cr_load_xml_files(GHashTable *hashtable, const char *primary_xml_path, const char *filelists_xml_path, const char *other_xml_path, GStringChunk *chunk, GHashTable *pkglist_ht, GError **err) { cr_CbData cb_data; GError *tmp_err = NULL; assert(hashtable); // Prepare cb data cb_data.state = PARSING_PRI; cb_data.ht = hashtable; cb_data.chunk = chunk; cb_data.pkglist_ht = pkglist_ht; cb_data.ignored_pkgIds = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); cb_data.pkgKey = G_GINT64_CONSTANT(0); cr_xml_parse_primary(primary_xml_path, primary_newpkgcb, &cb_data, primary_pkgcb, &cb_data, cr_warning_cb, "Primary XML parser", (filelists_xml_path) ? 0 : 1, &tmp_err); g_hash_table_destroy(cb_data.ignored_pkgIds); cb_data.ignored_pkgIds = NULL; if (tmp_err) { int code = tmp_err->code; g_debug("primary.xml parsing error: %s", tmp_err->message); g_propagate_prefixed_error(err, tmp_err, "primary.xml parsing: "); return code; } cb_data.state = PARSING_FIL; if (filelists_xml_path) { cr_xml_parse_filelists(filelists_xml_path, newpkgcb, &cb_data, pkgcb, &cb_data, cr_warning_cb, "Filelists XML parser", &tmp_err); if (tmp_err) { int code = tmp_err->code; g_debug("filelists.xml parsing error: %s", tmp_err->message); g_propagate_prefixed_error(err, tmp_err, "filelists.xml parsing: "); return code; } } cb_data.state = PARSING_OTH; if (other_xml_path) { cr_xml_parse_other(other_xml_path, newpkgcb, &cb_data, pkgcb, &cb_data, cr_warning_cb, "Other XML parser", &tmp_err); if (tmp_err) { int code = tmp_err->code; g_debug("other.xml parsing error: %s", tmp_err->message); g_propagate_prefixed_error(err, tmp_err, "other.xml parsing: "); return code; } } return CRE_OK; }