GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/main.c Lines: 14 14 100.0 %
Date: 2020-08-07 19:15:19 Branches: 2 2 100.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
1
static void sig(int unused NUSED) {
10
#ifdef BUILD_ON_WINDOWS
11
  exit(EXIT_FAILURE);
12
#else
13
1
  pthread_kill(pthread_self(), SIGTERM);
14
1
  pthread_exit(NULL);
15
#endif
16
}
17
18
#ifdef __AFL_HAVE_MANUAL_CONTROL
19
20
static void afl_run(const Gwion gwion) {
21
  gw_seed(gwion->vm->rand, 0);
22
  __AFL_INIT();
23
  while (__AFL_LOOP(256)) {
24
    FILE* f = fdopen(0, "r");
25
    push_global(gwion, "[afl]");
26
    if(compile_file(gwion, "afl", f))
27
      gwion_run(gwion);
28
    pop_global(gwion);
29
  }
30
}
31
32
#define gwion_run(a) { afl_run(a); return 0; }
33
#endif
34
35
733
int main(int argc, char** argv) {
36
733
  Arg arg = { .arg={.argc=argc, .argv=argv}, .loop=-1 };
37
733
  signal(SIGINT, sig);
38
733
  signal(SIGTERM, sig);
39
733
  struct Gwion_ gwion = {};
40
733
  const m_bool ini = gwion_ini(&gwion, &arg);
41
733
  arg_release(&arg);
42
733
  if(ini > 0)
43
730
    gwion_run(&gwion);
44
732
  gwion_end(&gwion);
45
732
  THREAD_RETURN(EXIT_SUCCESS);
46
}