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
omega-mv / seed / host / tests / files.om
| 1 | note Native host file and monotonic clock checks. Paths belong to the gate's isolated working directory. |
| 2 | text path "probe.bin" |
| 3 | text data "Omega host test\n" |
| 4 | global bytes uchar 32 |
| 5 | fn main to int |
| 6 | if lt realns 1700000000000000000 |
| 7 | ret 16 |
| 8 | end |
| 9 | start = monons |
| 10 | if lt start 0 |
| 11 | ret 1 |
| 12 | end |
| 13 | fd = fopen path 0 len path 194 384 |
| 14 | if lt fd 0 |
| 15 | ret 2 |
| 16 | end |
| 17 | dup = fopen path 0 len path 194 384 |
| 18 | if ne dup neg long 17 |
| 19 | ret 3 |
| 20 | end |
| 21 | n = write int fd data 0 len data |
| 22 | if ne n long len data |
| 23 | ret 4 |
| 24 | end |
| 25 | r = fsync int fd |
| 26 | if ne r 0 |
| 27 | ret 5 |
| 28 | end |
| 29 | r = fchmod int fd 256 |
| 30 | if ne r 0 |
| 31 | ret 6 |
| 32 | end |
| 33 | r = fseek int fd 0 0 |
| 34 | if ne r 0 |
| 35 | ret 7 |
| 36 | end |
| 37 | n = read int fd bytes 0 len bytes |
| 38 | if ne n long len data |
| 39 | ret 8 |
| 40 | end |
| 41 | for i ulong len data |
| 42 | if ne get bytes i get data i |
| 43 | ret 9 |
| 44 | end |
| 45 | end |
| 46 | r = fclose int fd |
| 47 | if ne r 0 |
| 48 | ret 10 |
| 49 | end |
| 50 | r = fclose int fd |
| 51 | if ne r neg long 9 |
| 52 | ret 11 |
| 53 | end |
| 54 | r = unlink path 0 len path |
| 55 | if ne r 0 |
| 56 | ret 12 |
| 57 | end |
| 58 | r = fopen path 0 len path 0 0 |
| 59 | if ne r neg long 2 |
| 60 | ret 13 |
| 61 | end |
| 62 | last = start |
| 63 | for i ulong 10000 |
| 64 | now = monons |
| 65 | if lt now last |
| 66 | ret 14 |
| 67 | end |
| 68 | last = now |
| 69 | end |
| 70 | if le last start |
| 71 | ret 15 |
| 72 | end |
| 73 | ret 0 |
| 74 | end |