Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this user
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux
/
mxq
Public
forked from
mariux64/mxq
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Issues
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Issues
Files
issues/issue15
manpages
mysql
web
.gitignore
LICENSE
Makefile
README.md
mx_flock.c
mx_flock.h
mx_getopt.c
mx_getopt.h
mx_log.c
mx_log.h
mx_mysql.c
mx_mysql.h
mx_util.c
mx_util.h
mxq.h
mxq_group.c
mxq_group.h
mxq_job.c
mxq_job.h
mxq_log.c
mxqadmin.c
mxqd.c
mxqd.h
mxqdctl-hostconfig.sh
mxqdump.c
mxqkill.c
mxqsub.c
os-release
test.c
test_mx_log.c
test_mx_mysql.c
test_mx_util.c
Breadcrumbs
mxq
/
test_mx_log.c
Blame
Blame
Latest commit
History
History
119 lines (99 loc) · 3.84 KB
Breadcrumbs
mxq
/
test_mx_log.c
Top
File metadata and controls
Code
Blame
119 lines (99 loc) · 3.84 KB
Raw
#include <stdio.h> #include <assert.h> #include <errno.h> #include <syslog.h> #include "mx_log.h" int mx_log_print(char *msg, size_t len) { mx_free_null(msg); return len; } static int test_mx_log(void) { int cnt = 0; cnt += !!mx_log(MX_LOG_EMERG, "emerg %s", "emerg"); cnt += !!mx_log(MX_LOG_ALERT, "alert %s", "alert"); cnt += !!mx_log(MX_LOG_CRIT, "crit %s", "crit"); cnt += !!mx_log(MX_LOG_ERR, "err %s", "err"); cnt += !!mx_log(MX_LOG_WARNING, "warning %s", "warning"); cnt += !!mx_log(MX_LOG_NOTICE, "notice %s", "notice"); cnt += !!mx_log(MX_LOG_INFO, "info %s", "info"); cnt += !!mx_log(MX_LOG_DEBUG, "debug %s", "debug"); return cnt; } static int test_mx_log_shortname(void) { int cnt = 0; cnt += !!mx_log_fatal("_emerg %s", "fatal"); cnt += !!mx_log_emerg("_emerg %s", "emerg"); cnt += !!mx_log_alert("_alert %s", "alert"); cnt += !!mx_log_crit("_crit %s", "crit"); cnt += !!mx_log_err("_err %s", "err"); cnt += !!mx_log_warning("_warning %s", "warning"); cnt += !!mx_log_notice("_notice %s", "notice"); cnt += !!mx_log_info("_info %s", "info"); cnt += !!mx_log_debug("_debug %s", "debug"); return cnt; } static int test_mx_log_level(int level) { int x; int curr; curr = mx_log_level_get(); assert(mx_log_level_set(level) == curr); assert(mx_log_level_get() == level); assert(test_mx_log_shortname() == level+(level>MX_LOG_NONE)); assert((x = test_mx_log()) == level); return x; } static void test_mx_log_level_mxlog_to_syslog(void) { errno=0; assert(mx_log_level_mxlog_to_syslog(MX_LOG_NONE) == -EINVAL); assert(errno == 0); assert(mx_log_level_mxlog_to_syslog(MX_LOG_EMERG) == LOG_EMERG); assert(mx_log_level_mxlog_to_syslog(MX_LOG_ALERT) == LOG_ALERT); assert(mx_log_level_mxlog_to_syslog(MX_LOG_CRIT) == LOG_CRIT); assert(mx_log_level_mxlog_to_syslog(MX_LOG_ERR) == LOG_ERR); assert(mx_log_level_mxlog_to_syslog(MX_LOG_WARNING) == LOG_WARNING); assert(mx_log_level_mxlog_to_syslog(MX_LOG_NOTICE) == LOG_NOTICE); assert(mx_log_level_mxlog_to_syslog(MX_LOG_INFO) == LOG_INFO); assert(mx_log_level_mxlog_to_syslog(MX_LOG_DEBUG) == LOG_DEBUG); } static void test_mx_log_level_syslog_to_mxlog(void) { errno=0; assert(mx_log_level_syslog_to_mxlog(LOG_EMERG-1) == -EINVAL); assert(errno == 0); errno=0; assert(mx_log_level_syslog_to_mxlog(LOG_DEBUG+1) == -EINVAL); assert(errno == 0); assert(mx_log_level_syslog_to_mxlog(LOG_EMERG) == MX_LOG_EMERG); assert(mx_log_level_syslog_to_mxlog(LOG_ALERT) == MX_LOG_ALERT); assert(mx_log_level_syslog_to_mxlog(LOG_CRIT) == MX_LOG_CRIT); assert(mx_log_level_syslog_to_mxlog(LOG_ERR) == MX_LOG_ERR); assert(mx_log_level_syslog_to_mxlog(LOG_WARNING) == MX_LOG_WARNING); assert(mx_log_level_syslog_to_mxlog(LOG_NOTICE) == MX_LOG_NOTICE); assert(mx_log_level_syslog_to_mxlog(LOG_INFO) == MX_LOG_INFO); assert(mx_log_level_syslog_to_mxlog(LOG_DEBUG) == MX_LOG_DEBUG); } int main(int argc, char *argv[]) { test_mx_log_level_syslog_to_mxlog(); test_mx_log_level_mxlog_to_syslog(); assert(mx_log_level_get() == MX_LOG_WARNING); assert(mx_log_level_set(1000) == -EINVAL); assert(mx_log_level_get() == MX_LOG_WARNING); assert(test_mx_log() == 5); assert(mx_log(MX_LOG_EMERG, "") == 0); assert(test_mx_log_level(MX_LOG_NONE) == 0); assert(test_mx_log_level(MX_LOG_EMERG) == 1); assert(test_mx_log_level(MX_LOG_ALERT) == 2); assert(test_mx_log_level(MX_LOG_CRIT) == 3); assert(test_mx_log_level(MX_LOG_ERR) == 4); assert(test_mx_log_level(MX_LOG_WARNING) == 5); assert(test_mx_log_level(MX_LOG_NOTICE) == 6); assert(test_mx_log_level(MX_LOG_INFO) == 7); assert(test_mx_log_level(MX_LOG_DEBUG) == 8); return 0; }
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
You can’t perform that action at this time.