interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / si / benchmarks / verify / test.om

225 lines · 6319 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note si/benchmarks/verify/test.om: positive & negative control test suite for
3note benchmarks-mv bundle validator, MEASURED vs MODELED discriminator, and ceiling comparator.
4note Compose with:
5note si/directives/om2.om om/tls/sha2.om si/benchmarks/verify/bundle.om si/benchmarks/verify/test.om
6
7text t_pass "PASS "
8text t_fail "FAIL "
9text t_nl "\n"
10
11text t_c1 "evidence_class_label_parsing_positive_and_negative"
12text t_c2 "measured_vs_modeled_anti_laundering_discriminator"
13text t_c3 "qualification_gate_refuses_modeled_and_estimated"
14text t_c4 "quantile_monotonicity_and_negative_controls"
15text t_c5 "bundle_metadata_sha_samples_and_throughput_controls"
16text t_c6 "hardware_ceiling_and_regression_basis_point_comparator"
17text t_c7 "bundle_digest_determinism_and_tamper_sensitivity"
18text t_done "PASS benchmarks-verify all 7 test suites passed\n"
19
20text t_lbl_m "MEASURED"
21text t_lbl_mod "MODELED"
22text t_lbl_est "ESTIMATED"
23text t_lbl_syn "SYNTHETIC"
24text t_lbl_bad "MEASURED_EST"
25
26text t_sha40_ok "3a9fe6de80123456789abcdef0123456789abcde"
27text t_sha40_bad "3a9fe6de"
28text t_sha64_ok "34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3"
29text t_sha64_bad "bad"
30
31fn report_case name view uchar * ok bool to int
32if ok
33w1 = bm_write_all int 1 t_pass
34w2 = bm_write_all int 1 name
35w3 = bm_write_all int 1 t_nl
36if and w1 and w2 w3
37ret int 0
38end
39ret int 1
40end
41w4 = bm_write_all int 1 t_fail
42w5 = bm_write_all int 1 name
43w6 = bm_write_all int 1 t_nl
44if and w4 and w5 w6
45ret int 1
46end
47ret int 1
48end
49
50fn test_class_labels to bool
51if ne bm_parse_class t_lbl_m BM_CLASS_MEASURED
52ret false
53end
54if ne bm_parse_class t_lbl_mod BM_CLASS_MODELED
55ret false
56end
57if ne bm_parse_class t_lbl_est BM_CLASS_ESTIMATED
58ret false
59end
60if ne bm_parse_class t_lbl_syn BM_CLASS_SYNTHETIC
61ret false
62end
63note Negative control: ambiguous hybrid label rejected
64if ne bm_parse_class t_lbl_bad ulong 0
65ret false
66end
67ret true
68end
69
70fn test_discriminator to bool
71note Clean hardware-measured run with 100 samples passes
72if ne bm_discriminate_class BM_CLASS_MEASURED ulong 100 true false false BM_OK
73ret false
74end
75note MODELED run with extrapolated=true is allowed as MODELED
76if ne bm_discriminate_class BM_CLASS_MODELED ulong 0 false false true BM_OK
77ret false
78end
79note Negative controls: extrapolated or missing HW receipt labeled MEASURED MUST be refused
80if ne bm_discriminate_class BM_CLASS_MEASURED ulong 100 true false true BM_ERR_MODELED_AS_MEASURED
81ret false
82end
83if ne bm_discriminate_class BM_CLASS_MEASURED ulong 100 false false false BM_ERR_MODELED_AS_MEASURED
84ret false
85end
86if ne bm_discriminate_class BM_CLASS_MEASURED ulong 100 true true false BM_ERR_DIRTY_TREE
87ret false
88end
89if ne bm_discriminate_class BM_CLASS_MEASURED ulong 0 true false false BM_ERR_TOO_FEW_SAMPLES
90ret false
91end
92ret true
93end
94
95fn test_qualification_gate to bool
96if ne bm_allow_qualification BM_CLASS_MEASURED BM_OK
97ret false
98end
99if ne bm_allow_qualification BM_CLASS_MODELED BM_ERR_NOT_MEASURED
100ret false
101end
102if ne bm_allow_qualification BM_CLASS_ESTIMATED BM_ERR_NOT_MEASURED
103ret false
104end
105if ne bm_allow_qualification BM_CLASS_SYNTHETIC BM_ERR_NOT_MEASURED
106ret false
107end
108ret true
109end
110
111fn test_quantiles to bool
112if ne bm_validate_quantiles ulong 100 ulong 120 ulong 150 ulong 180 ulong 210 BM_OK
113ret false
114end
115note Negative controls: zero min, p50 < min, p95 < p50, p99 < p95, max < p99
116if ne bm_validate_quantiles ulong 0 ulong 120 ulong 150 ulong 180 ulong 210 BM_ERR_NONMONOTONIC_Q
117ret false
118end
119if ne bm_validate_quantiles ulong 130 ulong 120 ulong 150 ulong 180 ulong 210 BM_ERR_NONMONOTONIC_Q
120ret false
121end
122if ne bm_validate_quantiles ulong 100 ulong 160 ulong 150 ulong 180 ulong 210 BM_ERR_NONMONOTONIC_Q
123ret false
124end
125if ne bm_validate_quantiles ulong 100 ulong 120 ulong 190 ulong 180 ulong 210 BM_ERR_NONMONOTONIC_Q
126ret false
127end
128if ne bm_validate_quantiles ulong 100 ulong 120 ulong 150 ulong 220 ulong 210 BM_ERR_NONMONOTONIC_Q
129ret false
130end
131ret true
132end
133
134fn test_bundle_meta to bool
135if ne bm_validate_bundle_shas t_sha40_ok t_sha64_ok BM_OK
136ret false
137end
138if ne bm_validate_bundle_counts ulong 50 ulong 30 ulong 1200 BM_OK
139ret false
140end
141if ne bm_validate_bundle_shas t_sha40_bad t_sha64_ok BM_ERR_BAD_SHA
142ret false
143end
144if ne bm_validate_bundle_shas t_sha40_ok t_sha64_bad BM_ERR_BAD_SHA
145ret false
146end
147if ne bm_validate_bundle_counts ulong 10 ulong 30 ulong 1200 BM_ERR_TOO_FEW_SAMPLES
148ret false
149end
150if ne bm_validate_bundle_counts ulong 50 ulong 30 ulong 0 BM_ERR_ZERO_THROUGHPUT
151ret false
152end
153ret true
154end
155
156fn test_ceiling_and_regression to bool
157note Ceiling check: 240 GB/s <= 273 GB/s passes; 300 GB/s > 273 GB/s refused
158if ne bm_check_ceiling ulong 240 ulong 273 BM_OK
159ret false
160end
161if ne bm_check_ceiling ulong 300 ulong 273 BM_ERR_EXCEEDS_CEILING
162ret false
163end
164if ne bm_check_ceiling ulong 100 ulong 0 BM_ERR_EXCEEDS_CEILING
165ret false
166end
167note Regression check: 500 bps (5%) budget on baseline 1000us -> 1050us passes, 1051us refused
168if ne bm_check_latency_regression ulong 1000 ulong 1050 ulong 500 BM_OK
169ret false
170end
171if ne bm_check_latency_regression ulong 1000 ulong 1051 ulong 500 BM_ERR_REGRESSION
172ret false
173end
174if ne bm_check_latency_regression ulong 0 ulong 100 ulong 500 BM_ERR_ZERO_BASELINE
175ret false
176end
177note Throughput floor check
178if ne bm_check_throughput_floor ulong 1000 ulong 950 BM_OK
179ret false
180end
181if ne bm_check_throughput_floor ulong 949 ulong 950 BM_ERR_BELOW_FLOOR
182ret false
183end
184ret true
185end
186
187fn test_bundle_digest to bool
188m = new ulong 4 0
189put m 0 BM_CLASS_MEASURED
190put m 1 ulong 100
191put m 2 ulong 120
192put m 3 ulong 180
193d1 = new uchar 32 0
194d2 = new uchar 32 0
195bm_bundle_digest m t_sha40_ok d1
196bm_bundle_digest m t_sha40_ok d2
197if not bm_digest_eq d1 d2
198ret false
199end
200put m 0 BM_CLASS_MODELED
201bm_bundle_digest m t_sha40_ok d2
202if bm_digest_eq d1 d2
203ret false
204end
205ret true
206end
207
208fn main to int
209fail = int 0
210fail = add fail report_case t_c1 test_class_labels
211fail = add fail report_case t_c2 test_discriminator
212fail = add fail report_case t_c3 test_qualification_gate
213fail = add fail report_case t_c4 test_quantiles
214fail = add fail report_case t_c5 test_bundle_meta
215fail = add fail report_case t_c6 test_ceiling_and_regression
216fail = add fail report_case t_c7 test_bundle_digest
217if ne fail int 0
218ret int 1
219end
220ok = bm_write_all int 1 t_done
221if not ok
222ret int 1
223end
224ret int 0
225end