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 / memcheck.om
| 1 | note Native compiler refusal driver. 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 36 device/mapping compiler refusals\n" |
| 6 | text a "global b uint 4\nfn main to int\nr = devctl int 0 uint 21531 b 0 4\nret 0\nend\n" |
| 7 | text b "global b uchar 4\nfn main to int\nq = uint 21531\nr = devctl int 0 q b 0 4\nret 0\nend\n" |
| 8 | text c "global b uchar 4\nfn main to int\nr = devctl int 0 uint 1 b 0 4\nret 0\nend\n" |
| 9 | text d "text b \"four\"\nfn main to int\nr = devctl int 0 uint 21531 b 0 4\nret 0\nend\n" |
| 10 | text e "global b uchar 4\nfn main to int\nr = devctl long 0 uint 21531 b 0 4\nret 0\nend\n" |
| 11 | text f "global b uchar 4\nfn main to int\nr = devctl int 0 ulong 21531 b 0 4\nret 0\nend\n" |
| 12 | text g "fn main to int\nr = mapnew neg int 1 0 4096 7 34\nret 0\nend\n" |
| 13 | text h "fn main to int\nr = mapnew neg int 1 0 4096 3 50\nret 0\nend\n" |
| 14 | text j "fn main to int\nm = int 34\nr = mapnew neg int 1 0 4096 3 m\nret 0\nend\n" |
| 15 | text k "fn main to int\na = int 3\nr = mapnew neg int 1 0 4096 a 34\nret 0\nend\n" |
| 16 | text m "fn main to int\nr = mapdrop ulong 257\nret 0\nend\n" |
| 17 | text n "text a \"four\"\nfn main to int\nr = mapread long 257 0 a 0 4\nret 0\nend\n" |
| 18 | text p "global a uint 4\nfn main to int\nr = mapwrite long 257 0 a 0 4\nret 0\nend\n" |
| 19 | text q "fn test to long\nret mapnew neg int 1 0 4096 3 34\nend\n" |
| 20 | text s "global b uchar 4\nfn main to int\nr = devctl int 0 uint 3221243393 b 0 4\nret 0\nend\n" |
| 21 | text t "fn main to int\nr = mapnew long 0 0 4096 1 2\nret 0\nend\n" |
| 22 | text u "global a uchar 32\nglobal b uchar 32\nfn main to int\nr = devcall neg int 1 uint 21531 a 0 32 b 0 32\nret 0\nend\n" |
| 23 | text v "global a uchar 32\nglobal b uchar 32\nfn main to int\nq = uint 3223340587\nr = devcall neg int 1 q a 0 32 b 0 32\nret 0\nend\n" |
| 24 | text w "global a uchar 32\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 a 0 32\nret 0\nend\n" |
| 25 | text x "text a \"readonly\"\nglobal b uchar 32\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 b 0 32\nret 0\nend\n" |
| 26 | text y "global a uchar 32\ntext b \"readonly\"\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 b 0 8\nret 0\nend\n" |
| 27 | text z "global a uchar 32\nglobal b uint 32\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 b 0 32\nret 0\nend\n" |
| 28 | text aa "global a uchar 32\nfn main to int\nr = uvmctl neg int 1 uint 1 a 0 32\nret 0\nend\n" |
| 29 | text ab "global a uchar 32\nfn main to int\nq = uint 25\nr = uvmctl neg int 1 q a 0 32\nret 0\nend\n" |
| 30 | text ac "text a \"readonly\"\nfn main to int\nr = uvmctl neg int 1 uint 75 a 0 8\nret 0\nend\n" |
| 31 | text ad "global a uint 32\nfn main to int\nr = uvmctl neg int 1 uint 25 a 0 32\nret 0\nend\n" |
| 32 | text ae "fn test a edit uchar 32 b edit uchar 32 to long\nret devcall neg int 1 uint 3223340587 a 0 32 b 0 32\nend\n" |
| 33 | text af "fn test a edit uchar 32 to long\nret uvmctl neg int 1 uint 25 a 0 32\nend\n" |
| 34 | text ag "fn main to int\nr = mapget long 257 0 2\nret 0\nend\n" |
| 35 | text ah "fn main to int\nw = int 4\nr = mapset long 257 0 w 0\nret 0\nend\n" |
| 36 | text aj "fn main to int\nr = mapaddr ulong 257\nret 0\nend\n" |
| 37 | text ak "fn main to int\nr = maphold long 68719476736 4096\nret 0\nend\n" |
| 38 | text am "fn main to int\nr = mapbind long 257 int 3 0 7\nret 0\nend\n" |
| 39 | text an "fn main to int\nr = mapbind long 257 long 3 0 3\nret 0\nend\n" |
| 40 | text ap "fn test to ulong\nret mapaddr long 257\nend\n" |
| 41 | text aq "fn test to long\nret maphold 68719476736 4096\nend\n" |
| 42 | global packet uchar 4096 |
| 43 | global status uchar 4 |
| 44 | global tmp uchar 1 |
| 45 | fn expect yes bool to void |
| 46 | if not yes |
| 47 | exit int 80 |
| 48 | end |
| 49 | end |
| 50 | fn source num int fd int to int |
| 51 | r = long 0 |
| 52 | want = int 9 |
| 53 | if eq num 0 |
| 54 | r = write fd a 0 len a |
| 55 | want = 7 |
| 56 | end |
| 57 | if eq num 1 |
| 58 | r = write fd b 0 len b |
| 59 | end |
| 60 | if eq num 2 |
| 61 | r = write fd c 0 len c |
| 62 | end |
| 63 | if eq num 3 |
| 64 | r = write fd d 0 len d |
| 65 | want = 20 |
| 66 | end |
| 67 | if eq num 4 |
| 68 | r = write fd e 0 len e |
| 69 | want = 7 |
| 70 | end |
| 71 | if eq num 5 |
| 72 | r = write fd f 0 len f |
| 73 | want = 7 |
| 74 | end |
| 75 | if eq num 6 |
| 76 | r = write fd g 0 len g |
| 77 | end |
| 78 | if eq num 7 |
| 79 | r = write fd h 0 len h |
| 80 | end |
| 81 | if eq num 8 |
| 82 | r = write fd j 0 len j |
| 83 | end |
| 84 | if eq num 9 |
| 85 | r = write fd k 0 len k |
| 86 | end |
| 87 | if eq num 10 |
| 88 | r = write fd m 0 len m |
| 89 | want = 7 |
| 90 | end |
| 91 | if eq num 11 |
| 92 | r = write fd n 0 len n |
| 93 | want = 20 |
| 94 | end |
| 95 | if eq num 12 |
| 96 | r = write fd p 0 len p |
| 97 | want = 7 |
| 98 | end |
| 99 | if eq num 13 |
| 100 | r = write fd q 0 len q |
| 101 | end |
| 102 | if eq num 14 |
| 103 | r = write fd s 0 len s |
| 104 | end |
| 105 | if eq num 15 |
| 106 | r = write fd t 0 len t |
| 107 | want = 7 |
| 108 | end |
| 109 | if eq num 16 |
| 110 | r = write fd u 0 len u |
| 111 | end |
| 112 | if eq num 17 |
| 113 | r = write fd v 0 len v |
| 114 | end |
| 115 | if eq num 18 |
| 116 | r = write fd w 0 len w |
| 117 | want = 19 |
| 118 | end |
| 119 | if eq num 19 |
| 120 | r = write fd x 0 len x |
| 121 | want = 20 |
| 122 | end |
| 123 | if eq num 20 |
| 124 | r = write fd y 0 len y |
| 125 | want = 20 |
| 126 | end |
| 127 | if eq num 21 |
| 128 | r = write fd z 0 len z |
| 129 | want = 7 |
| 130 | end |
| 131 | if eq num 22 |
| 132 | r = write fd aa 0 len aa |
| 133 | end |
| 134 | if eq num 23 |
| 135 | r = write fd ab 0 len ab |
| 136 | end |
| 137 | if eq num 24 |
| 138 | r = write fd ac 0 len ac |
| 139 | want = 20 |
| 140 | end |
| 141 | if eq num 25 |
| 142 | r = write fd ad 0 len ad |
| 143 | want = 7 |
| 144 | end |
| 145 | if eq num 26 |
| 146 | r = write fd ae 0 len ae |
| 147 | end |
| 148 | if eq num 27 |
| 149 | r = write fd af 0 len af |
| 150 | end |
| 151 | if eq num 28 |
| 152 | r = write fd ag 0 len ag |
| 153 | end |
| 154 | if eq num 29 |
| 155 | r = write fd ah 0 len ah |
| 156 | end |
| 157 | if eq num 30 |
| 158 | r = write fd aj 0 len aj |
| 159 | want = 7 |
| 160 | end |
| 161 | if eq num 31 |
| 162 | r = write fd ak 0 len ak |
| 163 | want = 7 |
| 164 | end |
| 165 | if eq num 32 |
| 166 | r = write fd am 0 len am |
| 167 | end |
| 168 | if eq num 33 |
| 169 | r = write fd an 0 len an |
| 170 | want = 7 |
| 171 | end |
| 172 | if eq num 34 |
| 173 | r = write fd ap 0 len ap |
| 174 | end |
| 175 | if eq num 35 |
| 176 | r = write fd aq 0 len aq |
| 177 | end |
| 178 | expect gt r 0 |
| 179 | ret want |
| 180 | end |
| 181 | fn main to int |
| 182 | expect eq argcnt 2 |
| 183 | size = argread 1 packet 4 4092 |
| 184 | expect and gt size 0 le size 4092 |
| 185 | put packet 0 1 |
| 186 | put packet 2 uchar and size 255 |
| 187 | put packet 3 uchar shr size 8 |
| 188 | for num int 36 |
| 189 | input = fopen infile 0 len infile 524482 384 |
| 190 | output = fopen outfile 0 len outfile 524482 384 |
| 191 | errors = fopen errfile 0 len errfile 524482 384 |
| 192 | expect ge input 0 |
| 193 | expect ge output 0 |
| 194 | expect ge errors 0 |
| 195 | want = source num int input |
| 196 | expect eq fseek int input 0 0 0 |
| 197 | pid = fork |
| 198 | expect ge pid 0 |
| 199 | if eq pid 0 |
| 200 | expect eq dupfd int input 0 0 0 |
| 201 | expect eq dupfd int output 1 0 1 |
| 202 | expect eq dupfd int errors 2 0 2 |
| 203 | r = execprog packet 0 add ulong size 4 |
| 204 | exit int 81 |
| 205 | end |
| 206 | expect eq waitpid int pid status 0 4 0 pid |
| 207 | if ne get status 0 0 |
| 208 | ret add num 1 |
| 209 | end |
| 210 | if ne get status 1 uchar want |
| 211 | ret add num 1 |
| 212 | end |
| 213 | expect eq fseek int output 0 0 0 |
| 214 | expect eq read int output tmp 0 1 0 |
| 215 | expect eq fseek int errors 0 0 0 |
| 216 | expect eq read int errors tmp 0 1 1 |
| 217 | expect eq fclose int input 0 |
| 218 | expect eq fclose int output 0 |
| 219 | expect eq fclose int errors 0 |
| 220 | expect eq unlink infile 0 len infile 0 |
| 221 | expect eq unlink outfile 0 len outfile 0 |
| 222 | expect eq unlink errfile 0 len errfile 0 |
| 223 | end |
| 224 | expect eq write 1 passed 0 len passed long len passed |
| 225 | ret 0 |
| 226 | end |