File: check_log.c

package info (click to toggle)
owncloud-client 2.2.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,144 kB
  • ctags: 5,433
  • sloc: cpp: 35,894; ansic: 7,917; perl: 1,474; python: 217; ruby: 174; makefile: 38; sh: 23
file content (98 lines) | stat: -rw-r--r-- 2,771 bytes parent folder | download | duplicates (4)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * libcsync -- a library to sync a directory with another
 *
 * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
#include <string.h>

#include "support.h"

#include "config_csync.h"
#include "csync_log.h"

static void setup(void) {
  csync_log_init();
}

static void teardown(void) {
  csync_log_fini();
}

START_TEST (log_create)
{
  fail_unless((csync_log_init() == 0), NULL);
  fail_unless((csync_log_fini() == 0), NULL);
}
END_TEST

START_TEST (log_load)
{
  char buf[256];
  snprintf(buf, (size_t) 256 - 1, "%s/%s", SOURCEDIR, "config/ocsync_log.conf");
  fail_unless(csync_log_load(buf) == 0);
}
END_TEST

START_TEST (log_prio)
{
  CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_ALERT, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_CRIT, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTICE, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_NOTSET, "log %s", "test");
  CSYNC_LOG(CSYNC_LOG_PRIORITY_UNKNOWN, "log %s", "test");
}
END_TEST

START_TEST (log_null)
{
  char *z = NULL;
  CSYNC_LOG(CSYNC_LOG_PRIORITY_UNKNOWN, "log %s", z);
}
END_TEST

static Suite *log_suite(void) {
  Suite *s = suite_create("Logger");

  create_case(s, "log_create", log_create);
  create_case_fixture(s, "log_load", log_load, setup, teardown);
  create_case_fixture(s, "log_prio", log_prio, setup, teardown);
  create_case_fixture(s, "log_null", log_null, setup, teardown);

  return s;
}

int main(void) {
  int nf;

  Suite *s = log_suite();

  SRunner *sr;
  sr = srunner_create(s);
  srunner_run_all(sr, CK_VERBOSE);
  nf = srunner_ntests_failed(sr);
  srunner_free(sr);

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