aboutsummaryrefslogtreecommitdiffstats
path: root/examples/basics.c
blob: 8b4938b05a16afb6f6cd75d99b02caeffb78d394 (plain) (blame)
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
#include "../eztester.h"
#include <stdio.h>
#include <unistd.h>

#define EZTESTER_IMPLEMENTATION
#include "../build/header/eztester.h"
#undef EZTESTER_IMPLEMENTATION

ez_status shell_exists() {
  int status = ez_shell(NULL);
  if (status) {
    return TEST_FAIL;
  } else {
    return TEST_PASS;
  }
}

ez_status python3_exists() {
  int status = ez_shell("/usr/bin/env python3 --version");
  if (status) {
    return TEST_FAIL;
  } else {
    return TEST_PASS;
  }
}

ez_status sleepy() {
  ez_log("Im feeling sleepy");
  sleep(2);
  ez_log("zzzzzzz");
  sleep(1);
  ez_log("ZZZZZZZZ");
  sleep(2);
  ez_log("oh, hello there.");
  return TEST_PASS;
}

int main(int argc, char *argv[]) {
  ez_list *list = ez_create_list(5);

  ez_register(
      list, (ez_test){ez_always_pass_test, "Always pass", 0});
  ez_register(
      list, (ez_test){ez_always_warn_test, "Always warn", 0});
  ez_register(list, (ez_test){sleepy, "Timeout test", 4e3});
  ez_register(list, (ez_test){python3_exists, "Python3 Exists", 0});

  ez_run(list, EXIT_ON_FAIL);

  return 0;
}