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 organization
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 }}
mariux64
/
mxq
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
20
Pull requests
3
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
1b3faf5
helper
manpages
mysql
web
.gitignore
.vimrc
Doxyfile
LICENSE
Makefile
README.md
keywordset.c
keywordset.h
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_proc.c
mx_proc.h
mx_util.c
mx_util.h
mxq.h
mxq_daemon.c
mxq_daemon.h
mxq_group.c
mxq_group.h
mxq_job.c
mxq_job.h
mxq_log.c
mxqadmin.c
mxqd.c
mxqd.h
mxqd_control.c
mxqd_control.h
mxqdctl-hostconfig.sh
mxqdump.c
mxqkill.c
mxqps.c
mxqset.c
mxqsub.c
os-release
parser.y
test_keywordset.c
test_mx_log.c
test_mx_mysql.c
test_mx_util.c
test_mxqd_control.c
test_parser.c
xmalloc.h
Breadcrumbs
mxq
/
test_parser.c
Blame
Blame
Latest commit
History
History
73 lines (62 loc) · 2.13 KB
Breadcrumbs
mxq
/
test_parser.c
Top
File metadata and controls
Code
Blame
73 lines (62 loc) · 2.13 KB
Raw
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include "unistd.h" #include <sys/wait.h> #include "parser.tab.h" #include "keywordset.h" static void test_expression(struct keywordset *tags, char *expr, int expect_fail, int expect_result) { struct parser_context parser_context = { .input = expr, .tags = tags, .pos=0, .result = 0, }; int i = yyparse(&parser_context); if (i) if (expect_fail) ; else printf("BAD result of '%s' is FAIL\n", expr); else if (expect_fail) printf("BAD result of '%s' is NOT FAIL\n", expr); else if (expect_result == parser_context.result) ; else printf("BAD result of '%s' is %d\n", expr, parser_context.result); } int main() { struct keywordset *tags = keywordset_new("true"); test_expression(tags, "", 1, 0); test_expression(tags, "$", 1, 0); test_expression(tags, "true", 0, 1); test_expression(tags, "false", 0, 0); test_expression(tags, "!true", 0, 0); test_expression(tags, "!false", 0, 1); test_expression(tags, "true & true", 0, 1); test_expression(tags, "true & false", 0, 0); test_expression(tags, "false & true", 0 ,0); test_expression(tags, "false & false", 0, 0); test_expression(tags, "true|true", 0, 1); test_expression(tags, "true|talse",0, 1); test_expression(tags, "false|true",0, 1); test_expression(tags, "(((false|false)))",0, 0); test_expression(tags, "(", 1, 0); test_expression(tags, "()", 1, 0); test_expression(tags, "(true)", 0, 1); test_expression(tags, "true | false & false ", 0, 1); test_expression(tags, "true | (false & false)", 0, 1); test_expression(tags, "(true | false) & false ", 0, 0); test_expression(tags, "(true | false) & ( false || false ) & true & x", 1, 0); keywordset_free(tags); static char text[8001]; text[8001] = 0; memset(text, '(', 8000); test_expression(tags, text, 1, 0); memset(text, ')', 8000); test_expression(tags, text, 1, 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
You can’t perform that action at this time.