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 / seed / authority / store-test.om

85 lines · 1692 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Store checks: exact read/write, torn file refusal, generation mismatch and atomic replace.
3global checks ulong 1
4global fails ulong 1
5global report uchar 64
6text title "store checks="
7text dir "build/authority-store"
8fn check got ulong want ulong to void
9put checks 0 add get checks 0 1
10if ne got want
11put fails 0 add get fails 0 1
12end
13end
14fn fill r edit ulong 32 seed ulong gen ulong to void
15for i ulong 32
16put r i add seed i
17end
18put r 0 1
19put r 1 1
20put r 3 8
21put r 4 gen
22end
23fn summary to int
24for i ulong len title
25put report i get title i
26end
27n = get checks 0
28at = len title
29put report at uchar add 48 div n 100
30put report add at 1 uchar add 48 rem div n 10 10
31put report add at 2 uchar add 48 rem n 10
32put report add at 3 32
33put report add at 4 uchar add 48 div get fails 0 100
34put report add at 5 uchar add 48 rem div get fails 0 10 10
35put report add at 6 uchar add 48 rem get fails 0 10
36put report add at 7 10
37w = write 1 report 0 add at 8
38if ne w long add at 8
39ret 2
40end
41if ne get fails 0 0
42ret 1
43end
44ret 0
45end
46fn main to int
47if ne makedir dir 0 len dir 448 0
48put sb 0 0
49end
50r = new ulong 32 0
51q = new ulong 32 0
52fill r 100 1
53check writerec r 0
54fill q 0 0
55check readrec q 0
56for i ulong 32
57check get q i get r i
58end
59check storevalid q 1 0
60check writegen 1 0
61check readgen 1
62check storevalid q 2 52
63setrec
64fd = fopen spath 0 get splen 0 577 384
65if lt fd 0
66check 0 1
67else
68n = write int fd sb 0 3
69if ne fclose int fd 0
70check 0 1
71end
72check readrec q 22
73end
74check writerec r 0
75check writegen 2 0
76check readgen 2
77fill r 200 2
78check writerec r 0
79check readrec q 0
80for i ulong 32
81check get q i get r i
82end
83check storevalid q 2 0
84ret summary
85end