tests.c 848 Bytes
Newer Older
1 2
/* See LICENSE file for license and copyright information */

Sebastian Ramacher's avatar
Sebastian Ramacher committed
3
#include <gtk/gtk.h>
4
#include <stdlib.h>
5

6
#include "tests.h"
Moritz Lipp's avatar
Moritz Lipp committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
int run_suite(Suite* suite)
{
  SRunner* suite_runner = srunner_create(suite);
  srunner_run_all(suite_runner, CK_NORMAL);
  const int number_failed = srunner_ntests_failed(suite_runner);

  int ret = EXIT_SUCCESS;
  if (number_failed != 0) {
    ret = EXIT_FAILURE;

    const int tests_run = srunner_ntests_run(suite_runner);
    TestResult** results = srunner_failures(suite_runner);

    for (int i = 0; i < tests_run; ++i) {
      if (tr_ctx(results[i]) == CK_CTX_SETUP) {
        /* mark tests as skipped */
        ret = 77;
        break;
      }
    }
  }
Moritz Lipp's avatar
Moritz Lipp committed
29

30
  srunner_free(suite_runner);
Moritz Lipp's avatar
Moritz Lipp committed
31

32 33
  return ret;
}
34

35
void setup(void)
36
{
37
  fail_unless(gtk_init_check(NULL, NULL) == TRUE, "GTK+ initializitation failed", NULL);
38
}