|
2 | 2 | import json
|
3 | 3 |
|
4 | 4 |
|
5 |
| -def main(): |
6 |
| - os.system( |
7 |
| - "python3 count-lines.py $VERUS_DIR/source/tools/line_count/zookeeper_table zookeeper" |
8 |
| - ) |
9 |
| - os.system( |
10 |
| - "python3 count-lines.py $VERUS_DIR/source/tools/line_count/rabbitmq_table rabbitmq" |
11 |
| - ) |
12 |
| - os.system( |
13 |
| - "python3 count-lines.py $VERUS_DIR/source/tools/line_count/fluent_table fluent" |
14 |
| - ) |
| 5 | +def count_total_lines(data): |
| 6 | + lines = 0 |
| 7 | + for key in data: |
| 8 | + for inner_key in data[key]: |
| 9 | + lines += data[key][inner_key] |
| 10 | + return lines |
| 11 | + |
| 12 | + |
| 13 | +def gen_for_controller(controller): |
15 | 14 | os.system(
|
16 |
| - "python3 count-anvil-lines.py $VERUS_DIR/source/tools/line_count/lib_table" |
17 |
| - ) |
18 |
| - zk_data = json.load(open("zookeeper-lines.json")) |
19 |
| - rmq_data = json.load(open("rabbitmq-lines.json")) |
20 |
| - fb_data = json.load(open("fluent-lines.json")) |
21 |
| - anvil_data = json.load(open("anvil-lines.json")) |
22 |
| - print("ZooKeeper:") |
23 |
| - print( |
24 |
| - "Liveness & {} & -- & {}".format( |
25 |
| - zk_data["liveness_theorem"]["Trusted"], |
26 |
| - zk_data["liveness_proof"]["Proof"], |
27 |
| - ) |
28 |
| - ) |
29 |
| - print( |
30 |
| - "Conformance & 5 & -- & {}".format( |
31 |
| - zk_data["reconcile_impl"]["Proof"] - 5, |
32 |
| - ) |
33 |
| - ) |
34 |
| - print( |
35 |
| - "Controller model & -- & -- & {}".format( |
36 |
| - zk_data["reconcile_model"]["Proof"], |
37 |
| - ) |
38 |
| - ) |
39 |
| - print( |
40 |
| - "Controller impl & -- & {} & --".format( |
41 |
| - zk_data["reconcile_model"]["Exec"] + zk_data["reconcile_impl"]["Exec"], |
42 |
| - ) |
43 |
| - ) |
44 |
| - print( |
45 |
| - "Trusted wrapper & {} & -- & --".format( |
46 |
| - zk_data["wrapper"]["Trusted"], |
47 |
| - ) |
48 |
| - ) |
49 |
| - print( |
50 |
| - "Trusted ZooKeeper API & {} & -- & --".format( |
51 |
| - zk_data["external_model"]["Trusted"], |
52 |
| - ) |
53 |
| - ) |
54 |
| - print( |
55 |
| - "Trusted entry point & {} & -- & --".format( |
56 |
| - zk_data["entry"]["Trusted"], |
| 15 | + "python3 count-lines.py $VERUS_DIR/source/tools/line_count/{}_table {}".format( |
| 16 | + controller, controller |
57 | 17 | )
|
58 | 18 | )
|
| 19 | + data = json.load(open("{}-lines.json".format(controller))) |
| 20 | + |
| 21 | + total_lines = count_total_lines(data) |
| 22 | + total_lines -= data["liveness_inv"]["Proof"] |
59 | 23 |
|
60 |
| - print("RabbitMQ:") |
| 24 | + print("{}:".format(controller)) |
61 | 25 | print(
|
62 | 26 | "Liveness & {} & -- & {}".format(
|
63 |
| - rmq_data["liveness_theorem"]["Trusted"], |
64 |
| - rmq_data["liveness_proof"]["Proof"], |
| 27 | + data["liveness_theorem"]["Trusted"], |
| 28 | + data["liveness_proof"]["Proof"], |
65 | 29 | )
|
66 | 30 | )
|
67 |
| - print( |
68 |
| - "Safety & {} & -- & {}".format( |
69 |
| - rmq_data["safety_theorem"]["Trusted"], |
70 |
| - rmq_data["safety_proof"]["Proof"], |
| 31 | + total_lines -= data["liveness_theorem"]["Trusted"] |
| 32 | + total_lines -= data["liveness_proof"]["Proof"] |
| 33 | + |
| 34 | + if controller == "rabbitmq": |
| 35 | + print( |
| 36 | + "Safety & {} & -- & {}".format( |
| 37 | + data["safety_theorem"]["Trusted"], |
| 38 | + data["safety_proof"]["Proof"], |
| 39 | + ) |
| 40 | + ) |
| 41 | + total_lines -= data["safety_theorem"]["Trusted"] |
| 42 | + total_lines -= data["safety_proof"]["Proof"] |
| 43 | + |
| 44 | + if controller == "fluent": |
| 45 | + print( |
| 46 | + "Conformance & 10 & -- & {}".format( |
| 47 | + data["reconcile_impl"]["Proof"] - 10, |
| 48 | + ) |
71 | 49 | )
|
72 |
| - ) |
73 |
| - print( |
74 |
| - "Conformance & 5 & -- & {}".format( |
75 |
| - rmq_data["reconcile_impl"]["Proof"] - 5, |
| 50 | + else: |
| 51 | + print( |
| 52 | + "Conformance & 5 & -- & {}".format( |
| 53 | + data["reconcile_impl"]["Proof"] - 5, |
| 54 | + ) |
76 | 55 | )
|
77 |
| - ) |
| 56 | + total_lines -= data["reconcile_impl"]["Proof"] |
78 | 57 | print(
|
79 | 58 | "Controller model & -- & -- & {}".format(
|
80 |
| - rmq_data["reconcile_model"]["Proof"], |
| 59 | + data["reconcile_model"]["Proof"], |
81 | 60 | )
|
82 | 61 | )
|
| 62 | + total_lines -= data["reconcile_model"]["Proof"] |
83 | 63 | print(
|
84 | 64 | "Controller impl & -- & {} & --".format(
|
85 |
| - rmq_data["reconcile_model"]["Exec"] + rmq_data["reconcile_impl"]["Exec"], |
| 65 | + data["reconcile_model"]["Exec"] + data["reconcile_impl"]["Exec"], |
86 | 66 | )
|
87 | 67 | )
|
| 68 | + total_lines -= data["reconcile_model"]["Exec"] + data["reconcile_impl"]["Exec"] |
88 | 69 | print(
|
89 | 70 | "Trusted wrapper & {} & -- & --".format(
|
90 |
| - rmq_data["wrapper"]["Trusted"], |
| 71 | + data["wrapper"]["Trusted"], |
91 | 72 | )
|
92 | 73 | )
|
| 74 | + total_lines -= data["wrapper"]["Trusted"] |
| 75 | + if controller == "zookeeper": |
| 76 | + print( |
| 77 | + "Trusted ZooKeeper API & {} & -- & --".format( |
| 78 | + data["external_model"]["Trusted"], |
| 79 | + ) |
| 80 | + ) |
| 81 | + total_lines -= data["external_model"]["Trusted"] |
93 | 82 | print(
|
94 | 83 | "Trusted entry point & {} & -- & --".format(
|
95 |
| - rmq_data["entry"]["Trusted"], |
| 84 | + data["entry"]["Trusted"], |
96 | 85 | )
|
97 | 86 | )
|
| 87 | + total_lines -= data["entry"]["Trusted"] |
| 88 | + print("{} lines are not included".format(total_lines)) |
98 | 89 |
|
99 |
| - print("Fluent:") |
100 |
| - print( |
101 |
| - "Liveness & {} & -- & {}".format( |
102 |
| - fb_data["liveness_theorem"]["Trusted"], |
103 |
| - fb_data["liveness_proof"]["Proof"], |
104 |
| - ) |
105 |
| - ) |
106 |
| - print( |
107 |
| - "Conformance & 10 & -- & {}".format( |
108 |
| - fb_data["reconcile_impl"]["Proof"] - 10, |
109 |
| - ) |
110 |
| - ) |
111 |
| - print( |
112 |
| - "Controller model & -- & -- & {}".format( |
113 |
| - fb_data["reconcile_model"]["Proof"], |
114 |
| - ) |
115 |
| - ) |
116 |
| - print( |
117 |
| - "Controller impl & -- & {} & --".format( |
118 |
| - fb_data["reconcile_model"]["Exec"] + fb_data["reconcile_impl"]["Exec"], |
119 |
| - ) |
| 90 | + |
| 91 | +def main(): |
| 92 | + gen_for_controller("zookeeper") |
| 93 | + gen_for_controller("rabbitmq") |
| 94 | + gen_for_controller("fluent") |
| 95 | + |
| 96 | + os.system( |
| 97 | + "python3 count-anvil-lines.py $VERUS_DIR/source/tools/line_count/lib_table" |
120 | 98 | )
|
| 99 | + anvil_data = json.load(open("anvil-lines.json")) |
| 100 | + total_lines = count_total_lines(anvil_data) |
| 101 | + total_lines -= anvil_data["test_lines"]["Exec"] |
| 102 | + print("Anvil:") |
121 | 103 | print(
|
122 |
| - "Trusted wrapper & {} & -- & --".format( |
123 |
| - fb_data["wrapper"]["Trusted"], |
| 104 | + "Lemmas & -- & -- & {}".format( |
| 105 | + anvil_data["k8s_lemma_lines"]["Proof"] |
| 106 | + + anvil_data["tla_lemma_lines"]["Proof"] |
124 | 107 | )
|
125 | 108 | )
|
126 |
| - print( |
127 |
| - "Trusted entry point & {} & -- & --".format( |
128 |
| - fb_data["entry"]["Trusted"], |
129 |
| - ) |
| 109 | + total_lines -= ( |
| 110 | + anvil_data["k8s_lemma_lines"]["Proof"] + anvil_data["tla_lemma_lines"]["Proof"] |
130 | 111 | )
|
131 |
| - print("Anvil:") |
132 | 112 | print(
|
133 | 113 | "TLA embedding & {} & -- & --".format(
|
134 | 114 | anvil_data["tla_embedding_lines"]["Trusted"]
|
135 | 115 | )
|
136 | 116 | )
|
| 117 | + total_lines -= anvil_data["tla_embedding_lines"]["Trusted"] |
| 118 | + print("Model & {} & -- & --".format(anvil_data["other_lines"]["Trusted"])) |
| 119 | + total_lines -= anvil_data["other_lines"]["Trusted"] |
137 | 120 | print(
|
138 |
| - "Model & {} & -- & --".format( |
139 |
| - anvil_data["other_lines"]["Trusted"] |
140 |
| - + anvil_data["object_model_lines"]["Trusted"] |
141 |
| - ) |
142 |
| - ) |
143 |
| - print( |
144 |
| - "Lemmas & -- & -- & {}".format( |
145 |
| - anvil_data["k8s_lemma_lines"]["Proof"] |
146 |
| - + anvil_data["tla_lemma_lines"]["Proof"] |
147 |
| - ) |
| 121 | + "Object view & {} & -- & --".format(anvil_data["object_model_lines"]["Trusted"]) |
148 | 122 | )
|
| 123 | + total_lines -= anvil_data["object_model_lines"]["Trusted"] |
149 | 124 | print(
|
150 |
| - "Shim layer & {} & -- & --".format( |
| 125 | + "Object wrapper & {} & -- & --".format( |
151 | 126 | anvil_data["object_wrapper_lines"]["Trusted"]
|
152 |
| - + anvil_data["other_lines"]["Exec"] |
153 | 127 | )
|
154 | 128 | )
|
| 129 | + total_lines -= anvil_data["object_wrapper_lines"]["Trusted"] |
| 130 | + print("Shim layer & {} & -- & --".format(anvil_data["other_lines"]["Exec"])) |
| 131 | + total_lines -= anvil_data["other_lines"]["Exec"] |
| 132 | + print("{} lines are not included".format(total_lines)) |
155 | 133 |
|
156 | 134 |
|
157 | 135 | if __name__ == "__main__":
|
|
0 commit comments