File: gcache_tests.cpp

package info (click to toggle)
galera-3 25.3.37-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,744 kB
  • sloc: cpp: 106,056; ansic: 8,979; sh: 1,310; tcl: 59; makefile: 10
file content (48 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download | duplicates (7)
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
// Copyright (C) 2010-2017 Codership Oy <info@codership.com>

#include <cstdlib>
#include <cstdio>
#include <string>

extern "C" {
#include <galerautils.h>
}

#include "gcache_tests.hpp"

#define LOG_FILE "gcache_tests.log"

int main(int argc, char* argv[])
{
    bool  no_fork  = (argc >= 2 && std::string(argv[1]) == "nofork");
    FILE* log_file = 0;

    if (!no_fork)
    {
        log_file = fopen (LOG_FILE, "w");
        if (!log_file) return EXIT_FAILURE;
        gu_conf_set_log_file (log_file);
    }

    gu_conf_debug_on();

    int failed = 0;

    for (int i = 0; suites[i] != 0; ++i)
    {
        SRunner* sr = srunner_create(suites[i]());

        if (no_fork) srunner_set_fork_status(sr, CK_NOFORK);

        srunner_run_all(sr, CK_NORMAL);
        failed += srunner_ntests_failed(sr);
        srunner_free(sr);
    }

    if (log_file != 0) fclose(log_file);
    printf ("Total tests failed: %d\n", failed);

    if (0 == failed && 0 != log_file) ::unlink(LOG_FILE);

    return failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}