test/harness/loupe-test.c
author ali <ali@juiblex.co.uk>
Sun Oct 27 17:01:47 2013 +0000 (2013-10-27)
changeset 103 d22d8cd4f628
parent 96 8c2d6a0cf717
permissions -rw-r--r--
Fix bug #13: Character sets
     1 #include <stdlib.h>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <glib.h>
     5 #include <bl/bl.h>
     6 #include "testcase.h"
     7 #include "testcaseio.h"
     8 
     9 static gboolean show_output;
    10 
    11 static GOptionEntry options[]={
    12     { "show-output", 'o', 0, G_OPTION_ARG_NONE, &show_output,
    13       "Show bookloupe output", NULL },
    14     { NULL }
    15 };
    16 
    17 /*
    18  * Returns FALSE if the test should be considered to have failed.
    19  * (returns TRUE on pass or expected-fail).
    20  */
    21 gboolean run_test(const char *filename)
    22 {
    23     Testcase *testcase;
    24     gboolean retval;
    25     testcase=testcase_parse_file(filename);
    26     if (!testcase)
    27 	return FALSE;
    28     if (show_output)
    29 	retval=testcase_show_output(testcase);
    30     else
    31 	retval=testcase_run(testcase);
    32     testcase_free(testcase);
    33     return retval;
    34 }
    35 
    36 int main(int argc,char **argv)
    37 {
    38     int i;
    39     gboolean pass=TRUE;
    40     GError *err=NULL;
    41     GOptionContext *context;
    42     context=g_option_context_new("file - run a bookloupe testcase");
    43     g_option_context_add_main_entries(context,options,NULL);
    44     if (!g_option_context_parse(context,&argc,&argv,&err))
    45     {
    46 	g_printerr("loupe-test: %s\n",err->message);
    47 	g_printerr("Use \"%s --help\" for help\n",argv[0]);
    48 	exit(1);
    49     }
    50     bl_set_print_handlers();
    51     g_setenv("BOOKLOUPE_CONFIG_PATH",".",TRUE);
    52     for(i=1;i<argc;i++)
    53 	pass&=run_test(argv[i]);
    54     return pass?0:1;
    55 }