1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <config.h>
#include "attribute.h"
#include <disfluid.h>
#include <unistd.h>
#include <locale.h>
#include "gettext.h"
#include "progname.h"
#include "relocatable.h"
#include <glib.h>
#define _(String) gettext (String)
#define N_(String) (String)
int
main (int argc, char *argv[])
{
(void) argc;
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
size_t n_tests, n_errors;
char *tests_output = disfluid_run_tests (&n_tests, &n_errors);
const char *bindir = relocate (INSTALLDIR);
char *disfluid_exec = malloc (strlen (bindir) + strlen ("/disfluid") + 1);
if (disfluid_exec == NULL)
{
abort ();
}
strcpy (disfluid_exec, bindir);
strcat (disfluid_exec, "/disfluid");
char *arg_0 = NULL;
if (asprintf (&arg_0, "%s", disfluid_exec) < 0)
{
abort ();
}
char *arg_1 = NULL;
if (asprintf (&arg_1, "--%s=%lu", _("n-tests-run"), n_tests) < 0)
{
abort ();
}
char *arg_2 = NULL;
if (asprintf (&arg_2, "--%s=%lu", _("n-tests-errors"), n_errors) < 0)
{
abort ();
}
char *arg_3 = NULL;
if (asprintf (&arg_3, "--%s=%s", _("tests-output"), tests_output) < 0)
{
abort ();
}
char *args[] = { arg_0, arg_1, arg_2, arg_3, NULL };
int error = execv (disfluid_exec, args);
for (size_t i = 0; args[i] != NULL; i++)
{
free (args[i]);
}
free (tests_output);
if (error)
{
fprintf (stderr, "%s:%d: cannot execute %s.\n", __FILE__, __LINE__,
disfluid_exec);
free (disfluid_exec);
return EXIT_FAILURE;
}
free (disfluid_exec);
return EXIT_SUCCESS;
}
|