Gwion coverage report


Directory: src/
File: src/main.c
Date: 2023-01-30 18:32:28
Exec Total Coverage
Lines: 15 16 93.8%
Functions: 2 2 100.0%
Branches: 3 4 75.0%

Line Branch Exec Source
1 #include <signal.h>
2 #include "gwion_util.h"
3 #include "gwion_ast.h"
4 #include "gwion_env.h"
5 #include "vm.h"
6 #include "gwion.h"
7 #include "arg.h"
8
9 static struct Gwion_ gwion = {};
10
11 1 static void sig(int unused NUSED) {
12
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(gwion.vm)
13 1 gwion.vm->bbq->is_running = false;
14 else
15 exit(EXIT_FAILURE);
16 1 }
17
18 #ifdef __AFL_HAVE_MANUAL_CONTROL
19
20 #include "compile.h"
21
22 static void afl_run(const Gwion gwion) {
23 const Env env = gwion->env;
24 __AFL_INIT();
25 while (__AFL_LOOP(128)) {
26 const Nspc nspc = env->global_nspc;
27 env->curr = env->global_nspc = new_nspc(gwion->mp, "[afl]");
28 env->global_nspc->parent = nspc;
29 FILE *f = fdopen(0, "r");
30 if (compile_file(gwion, "afl", f)) gwion_run(gwion);
31 free_nspc(env->global_nspc, env->gwion);
32 env->curr = env->global_nspc = nspc;
33 }
34 }
35
36 int main(int argc, char **argv) {
37 Arg arg = {};
38 gwion_ini(&gwion, &arg);
39 arg_release(&arg);
40 afl_run(&gwion);
41 return EXIT_SUCCESS;
42 }
43
44 #else
45
46 #ifdef GWION_CONFIG_ARGS
47 ANN char **config_args(int *, char **const);
48 #endif
49 #ifdef GWION_EMBED
50 ANN void gwion_embed(const Gwion);
51 #endif
52
53 707 int main(int argc, char **argv) {
54 #ifndef GWION_CONFIG_ARGS
55 707 CliArg arg = {.arg = {.argc = argc, .argv = argv}, .loop = false};
56 #else
57 char **config_argv = config_args(&argc, argv);
58 CliArg arg = {.arg = {.argc = argc, .argv = config_argv}, .loop = false};
59 #endif
60 707 signal(SIGINT, sig);
61 707 signal(SIGTERM, sig);
62 707 const m_bool ini = gwion_ini(&gwion, &arg);
63 #ifdef GWION_EMBED
64 gwion_embed(&gwion);
65 #endif
66 707 arg_compile(&gwion, &arg);
67 707 arg_release(&arg);
68 #ifdef GWION_CONFIG_ARGS
69 free(config_argv);
70 #endif
71
2/2
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 69 times.
707 if (ini > 0) gwion_run(&gwion);
72 707 gwion_end(&gwion);
73 707 gwion.vm = NULL;
74 707 exit(EXIT_SUCCESS);
75 }
76
77 #endif
78