Motr  M0
addb2grammar_test.py
Go to the documentation of this file.
1 #
2 # Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # For any questions about this software or licensing,
17 # please email opensource@seagate.com or cortx-questions@seagate.com.
18 #
19 
20 import unittest
21 import addb2grammar
22 
23 # WARNING
24 # WARNING: Do not delete trailing blank-spaces here! They are significatnt!
25 # WARNING
26 
27 singular_defs=[
28 """
29 * 2015-10-24-04:21:44.073956527 m0t1fs-create <4700000000000XXX:YYYYY>, mode: 100644, rc: 0
30 """,
31 
32 """
33 * 2015-10-24-04:21:44.073956527 m0t1fs-create <4700000000000000:10007>, mode: 100644, rc: 0
34 | node <11186d8bf0e34117:ab1897c062a22573>
35 | thread ffff88007407ca80, 7081
36 """,
37 
38 # this one is triky, trailing tab after 'ast' and missing attr value
39 """
40 * 2019-08-09-09:24:38.824262804 /FOM states: Init -[Schedule]-> Ready nr: 0 min: -1 max: 0 avg: 0.000000 dev: 0.000000 datum: 0 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0
41 | locality 0
42 | ast
43 """
44 ]
45 
46 
47 multiple_defs="""
48 * 2015-10-24-04:21:44.073956527 m0t1fs-create <4700000000000XXX:YYYYY>, mode: 100644, rc: 0
49 * 2015-10-24-04:21:44.073956527 m0t1fs-create <4700000000000000:10007>, mode: 100644, rc: 0
50 | node <11186d8bf0e34117:ab1897c062a22573>
51 | thread ffff88007407ca80, 7081
52 * 2015-04-20-14:36:13.687531192 alloc size: 40, addr: @0x7fd27c53eb20
53 | node <f3b62b87d9e642b2:96a4e0520cc5477b>
54 | locality 1
55 | thread 7fd28f5fe700
56 | fom @0x7fd1f804f710, 'IO fom' transitions: 13 phase: Zero-copy finish
57 | stob-io-launch 2015-04-20-14:36:13.629431319, <200000000000003:10000>, count: 8, bvec-nr: 8, ivec-nr: 1, offset: 0
58 | stob-io-launch 2015-04-20-14:36:13.666152841, <100000000adf11e:3>, count: 8, bvec-nr: 8, ivec-nr: 8, offset: 65536
59 * 2015-04-14-15:33:11.998165453 fom-descr service: <7300000000000001:0>, sender: c28baccf27e0001, req-opcode: Read request, rep-opcode: Read reply, local: false
60 | : 0 |
61 | 1 : 0 |
62 | 3 : 0 |
63 | 5 : 0 |
64 | 7 : 0 |
65 | 9 : 0 |
66 | 11 : 0 |
67 | 13 : 0 |
68 | 15 : 0 |
69 | 17 : 0 |
70 | 19 : 0 |
71 | 21 : 0 |
72 | 23 : 0 |
73 | 25 : 0 |
74 | node <11186d8bf0e34117:ab1897c062a22573>
75 | locality 3
76 | thread 7f79e57fb700
77 | ast
78 | fom @0x7f795008ed20, 'IO fom', transitions: 0, phase: 0
79 * 2019-08-09-09:24:38.824262804 /FOM states: Init -[Schedule]-> Ready nr: 0 min: -1 max: 0 avg: 0.000000 dev: 0.000000 datum: 0 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0 0: 0
80 | : 0 |
81 | 0 : 0 |
82 | 0 : 0 |
83 | 0 : 0 |
84 | 0 : 0 |
85 | 0 : 0 |
86 | 0 : 0 |
87 | 0 : 0 |
88 | 0 : 0 |
89 | 0 : 0 |
90 | 0 : 0 |
91 | 0 : 0 |
92 | 0 : 0 |
93 | 0 : 0 |
94 | node <a9be317d8e664514:b5d3bfe7e01fa1f8>
95 | pid 26163
96 | locality 0
97 | thread 7fb6e4a0b700
98 | ast
99 * 2019-08-09-09:24:38.824264676 /XXX states: YYY -[Failed]-> ZZZ nr: 0 min: -1 max: 0 avg: 0.000000
100 | : 0 |
101 | 0 : 0 |
102 | 0 : 0 |
103 | 0 : 0 |
104 | 0 : 0 |
105 | 0 : 0 |
106 | 0 : 0 |
107 | 0 : 0 |
108 | 0 : 0 |
109 | 0 : 0 |
110 | 0 : 0 |
111 | 0 : 0 |
112 | 0 : 0 |
113 | 0 : 0 |
114 | node <aYbe3Z7d8e6645Z4:b5d3bfe7e0ZfaZf8>
115 | pid 26163
116 | locality 0
117 | thread 7fb6e4a0b700
118 | ast
119 """
120 
121 
122 class ADDB2GrammarTest(unittest.TestCase):
123  def setUp(self):
125 
126  def test_singular(self):
127  for t in singular_defs:
128  res = self.grammar.parse(t)
129  self.assertTrue(res.is_valid)
130 
131  def test_multiple(self):
132  res = self.grammar.parse(multiple_defs)
133  self.assertTrue(res.is_valid)
134 
135 if __name__ == '__main__':
136  unittest.main()
static int parse(struct scanner *s)
Definition: beck.c:1059