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 / irqcheck.om
| 1 | note Exact compile refusal conductor; follows vfiocheck's native fork/exec convention. |
| 2 | text infile "case.om" |
| 3 | text outfile "case.elf" |
| 4 | text errfile "case.err" |
| 5 | text passed "PASS 10 typed IRQ and eventfd compiler refusals\n" |
| 6 | text a "fn main to int\nr = eventfd int 0\nret 0\nend\n" |
| 7 | text b "fn test to long\nret eventfd uint 0\nend\n" |
| 8 | text c "global a uchar 32\nfn main to int\nr = vfioirq int 1 uint 15215 a 0 16\nret 0\nend\n" |
| 9 | text d "global a uchar 32\nfn main to int\nq = uint 15213\nr = vfioirq int 1 q a 0 16\nret 0\nend\n" |
| 10 | text e "global a uint 32\nfn main to int\nr = vfioirq int 1 uint 15213 a 0 16\nret 0\nend\n" |
| 11 | text f "text a \"readonly buffer!\"\nfn main to int\nr = vfioirq int 1 uint 15213 a 0 16\nret 0\nend\n" |
| 12 | text g "global a uchar 32\nfn main to int\nr = vfioirq long 1 uint 15213 a 0 16\nret 0\nend\n" |
| 13 | text h "global a uchar 32\nfn main to int\nr = vfioirq int 1 ulong 15213 a 0 16\nret 0\nend\n" |
| 14 | text j "fn test a edit uchar 32 to long\nret vfioirq int 1 uint 15213 a 0 16\nend\n" |
| 15 | text k "om2\nfn main to int\nrequires eq eventfd uint 0 0\nret 0\nend\n" |
| 16 | global packet uchar 4096 |
| 17 | global status uchar 4 |
| 18 | fn expect yes bool to void |
| 19 | if not yes |
| 20 | exit int 80 |
| 21 | end |
| 22 | end |
| 23 | fn source num int fd int to int |
| 24 | r = long 0 |
| 25 | want = int 7 |
| 26 | if eq num 0 |
| 27 | r = write fd a 0 len a |
| 28 | end |
| 29 | if eq num 1 |
| 30 | r = write fd b 0 len b |
| 31 | want = 9 |
| 32 | end |
| 33 | if eq num 2 |
| 34 | r = write fd c 0 len c |
| 35 | want = 9 |
| 36 | end |
| 37 | if eq num 3 |
| 38 | r = write fd d 0 len d |
| 39 | want = 9 |
| 40 | end |
| 41 | if eq num 4 |
| 42 | r = write fd e 0 len e |
| 43 | end |
| 44 | if eq num 5 |
| 45 | r = write fd f 0 len f |
| 46 | want = 20 |
| 47 | end |
| 48 | if eq num 6 |
| 49 | r = write fd g 0 len g |
| 50 | end |
| 51 | if eq num 7 |
| 52 | r = write fd h 0 len h |
| 53 | end |
| 54 | if eq num 8 |
| 55 | r = write fd j 0 len j |
| 56 | want = 9 |
| 57 | end |
| 58 | if eq num 9 |
| 59 | r = write fd k 0 len k |
| 60 | want = 30 |
| 61 | end |
| 62 | expect gt r 0 |
| 63 | ret want |
| 64 | end |
| 65 | fn main to int |
| 66 | expect eq argcnt 2 |
| 67 | size = argread 1 packet 4 4092 |
| 68 | expect and gt size 0 le size 4092 |
| 69 | put packet 0 1 |
| 70 | put packet 2 uchar and size 255 |
| 71 | put packet 3 uchar shr size 8 |
| 72 | for num int 10 |
| 73 | input = fopen infile 0 len infile 524482 384 |
| 74 | output = fopen outfile 0 len outfile 524482 384 |
| 75 | errors = fopen errfile 0 len errfile 524482 384 |
| 76 | expect ge input 0 |
| 77 | expect ge output 0 |
| 78 | expect ge errors 0 |
| 79 | want = source num int input |
| 80 | expect eq fseek int input 0 0 0 |
| 81 | pid = fork |
| 82 | expect ge pid 0 |
| 83 | if eq pid 0 |
| 84 | expect eq dupfd int input 0 0 0 |
| 85 | expect eq dupfd int output 1 0 1 |
| 86 | expect eq dupfd int errors 2 0 2 |
| 87 | r = execprog packet 0 add ulong size 4 |
| 88 | exit int 81 |
| 89 | end |
| 90 | expect eq waitpid int pid status 0 4 0 pid |
| 91 | if ne get status 0 0 |
| 92 | ret add num 1 |
| 93 | end |
| 94 | if ne get status 1 uchar want |
| 95 | ret add num 1 |
| 96 | end |
| 97 | expect eq fclose int input 0 |
| 98 | expect eq fclose int output 0 |
| 99 | expect eq fclose int errors 0 |
| 100 | expect eq unlink infile 0 len infile 0 |
| 101 | expect eq unlink outfile 0 len outfile 0 |
| 102 | expect eq unlink errfile 0 len errfile 0 |
| 103 | end |
| 104 | expect eq write 1 passed 0 len passed long len passed |
| 105 | ret 0 |
| 106 | end |