Ejemplo n.º 1
0
int
main (int argc, char ** argv)
{
    const char *location = g_getenv("GNC_TEST_FILES");
    int files_tested = 0;
    GDir *xml2_dir;

    qof_init();
    cashobjects_register();
    do_test(qof_load_backend_library ("../.libs/", GNC_LIB_NAME),
            " loading gnc-backend-xml GModule failed");

    if (!location)
    {
        location = "test-files/xml2";
    }

    xaccLogDisable();

    if ((xml2_dir = g_dir_open(location, 0, NULL)) == NULL)
    {
        failure("unable to open xml2 directory");
    }
    else
    {
        const gchar *entry;

        while ((entry = g_dir_read_name(xml2_dir)) != NULL)
        {
            if (g_str_has_suffix(entry, ".gml2"))
            {
                gchar *to_open = g_build_filename(location, entry, (gchar*)NULL);
                if (!g_file_test(to_open, G_FILE_TEST_IS_DIR))
                {
                    test_load_file(to_open);
                    files_tested++;
                }
                g_free(to_open);
            }
        }
    }

    g_dir_close(xml2_dir);

    if (files_tested == 0)
    {
        failure("handled 0 files in test-load-xml2");
    }

    print_test_results();
    qof_close();
    exit(get_rv());
}
int
main (int argc, char ** argv)
{
    const char *location = g_getenv("GNC_ACCOUNT_PATH");
    GSList *list = NULL;
    GDir *ea_dir;

    g_setenv ("GNC_UNINSTALLED", "1", TRUE);

    if (!location)
    {
        location = "../../../../accounts/C";
    }

    gnc_module_system_init();
    gnc_module_load("gnucash/engine", 0);

    if ((ea_dir = g_dir_open(location, 0, NULL)) == NULL)
    {
        failure("unable to open ea directory");
    }
    else
    {
        const gchar *entry;

        while ((entry = g_dir_read_name(ea_dir)) != NULL)
        {
            if (g_str_has_suffix(entry, da_ending))
            {
                gchar *to_open = g_build_filename(location, entry, (gchar*)NULL);
                if (!g_file_test(to_open, G_FILE_TEST_IS_DIR))
                {
                    test_load_file(to_open);
                }
                g_free(to_open);
            }
        }
    }
    g_dir_close(ea_dir);

    {
        list = gnc_load_example_account_list(location);

        do_test(list != NULL, "gnc_load_example_account_list");

        gnc_free_example_account_list(list);
    }


    print_test_results();
    exit(get_rv());
}
Ejemplo n.º 3
0
void
test_files_in_dir(int argc, char **argv, gxpf_callback cb,
                  sixtp *parser, const char *parser_tag,
                  QofBook *book)
{
    int count;
    sixtp *main_parser;
    sixtp *top_parser;


    top_parser = sixtp_new();
    main_parser = sixtp_new();

    if (!sixtp_add_some_sub_parsers(top_parser, TRUE, "gnc-v2", main_parser,
                                    NULL, NULL))
        return;

    if (!sixtp_add_some_sub_parsers(main_parser, TRUE, parser_tag, parser,
                                    NULL, NULL))
        return;


    for (count = 1; count < argc; count++)
    {
        struct stat file_info;
        const char *to_open = argv[count];
        if (g_stat(to_open, &file_info) != 0)
        {
            printf("cannot stat %s.\n", to_open);
            failure("unable to stat file");
        }
        else
        {
            if (!S_ISDIR(file_info.st_mode))
            {
#ifdef __DEBUG
                printf( "testing load of file \"%s\":\n", argv[count] );
#endif
                test_load_file(to_open, cb, top_parser, book);
            }
        }
    }

    sixtp_destroy(top_parser);
}