tests.c 766 Bytes
Newer Older
1
/* SPDX-License-Identifier: Zlib */
2

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
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;
    TestResult** results = srunner_failures(suite_runner);

Sebastian Ramacher's avatar
Sebastian Ramacher committed
19
    for (int i = 0; i < number_failed; ++i) {
20 21 22 23 24 25 26
      if (tr_ctx(results[i]) == CK_CTX_SETUP) {
        /* mark tests as skipped */
        ret = 77;
        break;
      }
    }
  }
Moritz Lipp's avatar
Moritz Lipp committed
27

28
  srunner_free(suite_runner);
Moritz Lipp's avatar
Moritz Lipp committed
29

30 31
  return ret;
}
32

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