aboutsummaryrefslogtreecommitdiff
path: root/tests/torture.c
blob: ec39eca33be85e242d6980ec1f811caf6a938208 (plain)
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
#include "torture.h"

#include <stdio.h>

void torture_create_case(Suite *s, const char *name, TFun function) {
  TCase *tc_new = tcase_create(name);
  tcase_set_timeout(tc_new, 30);
  suite_add_tcase (s, tc_new);
  tcase_add_test(tc_new, function);
}

void torture_create_case_fixture(Suite *s, const char *name, TFun function, void (*setup)(void), void (*teardown)(void)) {
  TCase *tc_new = tcase_create(name);
  tcase_add_checked_fixture(tc_new, setup, teardown);
  tcase_set_timeout(tc_new, 30);
  suite_add_tcase (s, tc_new);
  tcase_add_test(tc_new, function);
}

void torture_create_case_timeout(Suite *s, const char *name, TFun function, int timeout) {
  TCase *tc_new = tcase_create(name);
  tcase_set_timeout(tc_new, timeout);
  suite_add_tcase (s, tc_new);
  tcase_add_test(tc_new, function);
}

static int verbosity=0;
int torture_libssh_verbosity(void){
  return verbosity;
}

int main(int argc, char **argv) {
  Suite *s = NULL;
  SRunner *sr = NULL;
  struct argument_s arguments;
  int nf;

  memset(&arguments,0,sizeof(struct argument_s));

  torture_cmdline_parse(argc, argv, &arguments);
  verbosity=arguments.verbose;
  s = torture_make_suite();

  sr = srunner_create(s);
  if (arguments.nofork) {
    srunner_set_fork_status(sr, CK_NOFORK);
  }
  srunner_run_all(sr, CK_VERBOSE);
  nf = srunner_ntests_failed(sr);
  srunner_free(sr);

  return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}