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 / vfiocheck.om
| 1 | note Native compiler refusal driver for VFIO words. argv[1] names the exact compiler under test. |
| 2 | text infile "case.om" |
| 3 | text outfile "case.elf" |
| 4 | text errfile "case.err" |
| 5 | text passed "PASS 16 VFIO compiler refusals\n" |
| 6 | text a "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15209 a 0 0\nret 0\nend\n" |
| 7 | text b "global a uchar 32\nfn main to int\nq = uint 15207\nr = vfioctl neg int 1 q a 0 8\nret 0\nend\n" |
| 8 | text c "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15216 a 0 32\nret 0\nend\n" |
| 9 | text d "text a \"readonly\"\nfn main to int\nr = vfioctl neg int 1 uint 15207 a 0 8\nret 0\nend\n" |
| 10 | text e "global a uint 32\nfn main to int\nr = vfioctl neg int 1 uint 15212 a 0 32\nret 0\nend\n" |
| 11 | text f "global a uchar 32\nfn main to int\nr = vfioctl long 1 uint 15207 a 0 8\nret 0\nend\n" |
| 12 | text g "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 ulong 15207 a 0 8\nret 0\nend\n" |
| 13 | text h "fn test a edit uchar 32 to long\nret vfioctl neg int 1 uint 15207 a 0 8\nend\n" |
| 14 | text j "global a uint 32\nfn main to int\nr = vfiomap neg int 1 a 0 32\nret 0\nend\n" |
| 15 | text k "fn test a edit uchar 32 to long\nret vfiomap neg int 1 a 0 32\nend\n" |
| 16 | text m "global a uchar 32\nfn main to int\nr = vfiomap long 1 a 0 32\nret 0\nend\n" |
| 17 | text n "global a uint 32\nfn main to int\nr = vfioctl neg int 1 uint 15210 a 0 8\nret 0\nend\n" |
| 18 | text o "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15215 a 0 0\nret 0\nend\n" |
| 19 | text p "global a uint 32\nfn main to int\nr = vfiomapw neg int 1 a 0 32\nret 0\nend\n" |
| 20 | text s "fn test a edit uchar 32 to long\nret vfiomapw neg int 1 a 0 32\nend\n" |
| 21 | text t "global a uchar 32\nfn main to int\nr = vfioctl neg int 1 uint 15219 a 0 32\nret 0\nend\n" |
| 22 | global packet uchar 4096 |
| 23 | global status uchar 4 |
| 24 | global tmp uchar 1 |
| 25 | fn expect yes bool to void |
| 26 | if not yes |
| 27 | exit int 80 |
| 28 | end |
| 29 | end |
| 30 | fn source num int fd int to int |
| 31 | r = long 0 |
| 32 | want = int 9 |
| 33 | if eq num 0 |
| 34 | r = write fd a 0 len a |
| 35 | end |
| 36 | if eq num 1 |
| 37 | r = write fd b 0 len b |
| 38 | end |
| 39 | if eq num 2 |
| 40 | r = write fd c 0 len c |
| 41 | end |
| 42 | if eq num 3 |
| 43 | r = write fd d 0 len d |
| 44 | want = 20 |
| 45 | end |
| 46 | if eq num 4 |
| 47 | r = write fd e 0 len e |
| 48 | want = 7 |
| 49 | end |
| 50 | if eq num 5 |
| 51 | r = write fd f 0 len f |
| 52 | want = 7 |
| 53 | end |
| 54 | if eq num 6 |
| 55 | r = write fd g 0 len g |
| 56 | want = 7 |
| 57 | end |
| 58 | if eq num 7 |
| 59 | r = write fd h 0 len h |
| 60 | end |
| 61 | if eq num 8 |
| 62 | r = write fd j 0 len j |
| 63 | want = 7 |
| 64 | end |
| 65 | if eq num 9 |
| 66 | r = write fd k 0 len k |
| 67 | end |
| 68 | if eq num 10 |
| 69 | r = write fd m 0 len m |
| 70 | want = 7 |
| 71 | end |
| 72 | if eq num 11 |
| 73 | r = write fd n 0 len n |
| 74 | want = 7 |
| 75 | end |
| 76 | if eq num 12 |
| 77 | r = write fd o 0 len o |
| 78 | end |
| 79 | if eq num 13 |
| 80 | r = write fd p 0 len p |
| 81 | want = 7 |
| 82 | end |
| 83 | if eq num 14 |
| 84 | r = write fd s 0 len s |
| 85 | end |
| 86 | if eq num 15 |
| 87 | r = write fd t 0 len t |
| 88 | end |
| 89 | expect gt r 0 |
| 90 | ret want |
| 91 | end |
| 92 | fn main to int |
| 93 | expect eq argcnt 2 |
| 94 | size = argread 1 packet 4 4092 |
| 95 | expect and gt size 0 le size 4092 |
| 96 | put packet 0 1 |
| 97 | put packet 2 uchar and size 255 |
| 98 | put packet 3 uchar shr size 8 |
| 99 | for num int 16 |
| 100 | input = fopen infile 0 len infile 524482 384 |
| 101 | output = fopen outfile 0 len outfile 524482 384 |
| 102 | errors = fopen errfile 0 len errfile 524482 384 |
| 103 | expect ge input 0 |
| 104 | expect ge output 0 |
| 105 | expect ge errors 0 |
| 106 | want = source num int input |
| 107 | expect eq fseek int input 0 0 0 |
| 108 | pid = fork |
| 109 | expect ge pid 0 |
| 110 | if eq pid 0 |
| 111 | expect eq dupfd int input 0 0 0 |
| 112 | expect eq dupfd int output 1 0 1 |
| 113 | expect eq dupfd int errors 2 0 2 |
| 114 | r = execprog packet 0 add ulong size 4 |
| 115 | exit int 81 |
| 116 | end |
| 117 | expect eq waitpid int pid status 0 4 0 pid |
| 118 | if ne get status 0 0 |
| 119 | ret add num 1 |
| 120 | end |
| 121 | if ne get status 1 uchar want |
| 122 | ret add num 1 |
| 123 | end |
| 124 | expect eq fseek int output 0 0 0 |
| 125 | expect eq read int output tmp 0 1 0 |
| 126 | expect eq fseek int errors 0 0 0 |
| 127 | expect eq read int errors tmp 0 1 1 |
| 128 | expect eq fclose int input 0 |
| 129 | expect eq fclose int output 0 |
| 130 | expect eq fclose int errors 0 |
| 131 | expect eq unlink infile 0 len infile 0 |
| 132 | expect eq unlink outfile 0 len outfile 0 |
| 133 | expect eq unlink errfile 0 len errfile 0 |
| 134 | end |
| 135 | expect eq write 1 passed 0 len passed long len passed |
| 136 | ret 0 |
| 137 | end |