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 / aienux / allen / tests / scheduler.om
| 1 | note Native courier lifecycle regression. Clock values are injected milliseconds. |
| 2 | text Lineone "SAY 1 1/1 Model text." |
| 3 | note check writes through Outb; preserve the actual pending datagram around logging. |
| 4 | global SavedOut uchar 8192 |
| 5 | fn test ok bool to void |
| 6 | n = get Outlen 0 |
| 7 | e = get Err 0 |
| 8 | for i ulong n |
| 9 | put SavedOut i get Outb i |
| 10 | end |
| 11 | check ok add get Checks 0 1 |
| 12 | for i ulong n |
| 13 | put Outb i get SavedOut i |
| 14 | end |
| 15 | put Outlen 0 n |
| 16 | put Err 0 e |
| 17 | end |
| 18 | fn tcopy to void |
| 19 | put Inlen 0 get Outlen 0 |
| 20 | for i ulong get Outlen 0 |
| 21 | put In i get Outb i |
| 22 | end |
| 23 | end |
| 24 | fn control kind ulong seq ulong to void |
| 25 | put Inlen 0 0 |
| 26 | b = packet kind seq 0 0 0 |
| 27 | tcopy |
| 28 | end |
| 29 | fn linepkt part ulong to void |
| 30 | put Inlen 0 len Lineone |
| 31 | for i ulong len Lineone |
| 32 | put In i get Lineone i |
| 33 | end |
| 34 | b = packet 2 get Q 1 part 0 0 |
| 35 | tcopy |
| 36 | end |
| 37 | fn jobinput to void |
| 38 | put Inlen 0 1001 |
| 39 | for i ulong 1001 |
| 40 | put In i 120 |
| 41 | end |
| 42 | put In 999 10 |
| 43 | put In 1000 121 |
| 44 | end |
| 45 | fn main to int |
| 46 | test qstart 42 100 |
| 47 | test not qready 100 |
| 48 | test not qnext 100 false |
| 49 | test eq get T 3 0 |
| 50 | test qnext 100 true |
| 51 | test eq get T 10 5 |
| 52 | test not qnext 100 true |
| 53 | test qsent 100 false |
| 54 | test eq get T 3 0 |
| 55 | test qnext 101 true |
| 56 | test qsent 101 true |
| 57 | test eq get T 3 1 |
| 58 | test not qnext 2100 true |
| 59 | test qnext 2101 true |
| 60 | test qsent 2101 true |
| 61 | control 6 0 |
| 62 | test eq qincoming 2102 1 |
| 63 | test qready 2102 |
| 64 | test not qnext 12100 true |
| 65 | test qnext 12101 true |
| 66 | test eq get T 10 5 |
| 67 | test qsent 12101 true |
| 68 | test qready 32101 |
| 69 | test not qready 32102 |
| 70 | test qnext 32102 true |
| 71 | test qsent 32102 true |
| 72 | test not qnext 32101 true |
| 73 | test eq get T 0 32102 |
| 74 | jobinput |
| 75 | test qsubmit 32103 |
| 76 | test eq get Q 1 1 |
| 77 | test eq get JobOut 999 32 |
| 78 | test eq get JobOut 1000 121 |
| 79 | test not qsubmit 32103 |
| 80 | test qnext 32103 true |
| 81 | test eq get T 10 1 |
| 82 | test eq get T 11 1 |
| 83 | tcopy |
| 84 | test pkparse |
| 85 | test eq get N 6 1000 |
| 86 | test eq get In add get N 5 999 32 |
| 87 | test qsent 32103 false |
| 88 | test eq get T 9 1 |
| 89 | test qnext 32104 true |
| 90 | test eq get T 11 1 |
| 91 | test qsent 32104 true |
| 92 | test qnext 32104 true |
| 93 | test eq get T 11 2 |
| 94 | tcopy |
| 95 | test pkparse |
| 96 | test eq get N 6 1 |
| 97 | test eq get In get N 5 121 |
| 98 | test qsent 32104 true |
| 99 | test eq get T 9 0 |
| 100 | control 6 0 |
| 101 | test eq qincoming 32105 1 |
| 102 | test qready 32105 |
| 103 | test not qnext 34103 true |
| 104 | test qnext 34104 true |
| 105 | test eq get T 10 1 |
| 106 | test eq get T 11 1 |
| 107 | test qsent 34104 true |
| 108 | test qnext 34104 true |
| 109 | test eq get T 11 2 |
| 110 | test qsent 34104 true |
| 111 | control 4 2 |
| 112 | test eq qincoming 34105 0 |
| 113 | test eq get T 6 0 |
| 114 | control 4 1 |
| 115 | test eq qincoming 34105 1 |
| 116 | test eq get T 6 1 |
| 117 | test not qnext 36104 true |
| 118 | linepkt 1 |
| 119 | test eq qincoming 36105 1 |
| 120 | test eq get Q 4 1 |
| 121 | test eq get T 13 1 |
| 122 | test qnext 36105 true |
| 123 | test eq get T 10 3 |
| 124 | test qsent 36105 false |
| 125 | test eq get T 13 1 |
| 126 | linepkt 1 |
| 127 | test eq qincoming 36106 2 |
| 128 | test eq get Q 4 1 |
| 129 | test qnext 36106 true |
| 130 | test eq get T 10 3 |
| 131 | test qsent 36106 true |
| 132 | test eq get T 13 0 |
| 133 | test qtake |
| 134 | test eq get Inlen 0 len Lineone |
| 135 | test not qtake |
| 136 | linepkt 2 |
| 137 | test eq qincoming 36107 1 |
| 138 | linepkt 3 |
| 139 | test eq qincoming 36107 0 |
| 140 | test eq get Q 2 2 |
| 141 | test eq get Q 4 1 |
| 142 | test qnext 36108 true |
| 143 | test qsent 36108 true |
| 144 | linepkt 3 |
| 145 | test eq qincoming 36109 1 |
| 146 | test eq get Q 2 3 |
| 147 | qcancel |
| 148 | test eq get T 5 0 |
| 149 | linepkt 4 |
| 150 | test eq qincoming 36110 0 |
| 151 | jobinput |
| 152 | test qsubmit 36111 |
| 153 | test eq get Q 1 2 |
| 154 | test eq get Q 4 0 |
| 155 | control 6 0 |
| 156 | test eq qincoming 36112 1 |
| 157 | control 6 0 |
| 158 | put In 22 49 |
| 159 | test eq qincoming 36113 0 |
| 160 | test eq get T 2 36112 |
| 161 | control 4 2 |
| 162 | test eq qincoming 36110 0 |
| 163 | test eq get T 6 0 |
| 164 | qcancel |
| 165 | put Q 1 4294967295 |
| 166 | jobinput |
| 167 | test not qsubmit 36114 |
| 168 | test eq get Q 1 4294967295 |
| 169 | test not qstart 0 36114 |
| 170 | test eq get Q 0 42 |
| 171 | test qstart 43 0 |
| 172 | put Inlen 0 4097 |
| 173 | test not qsubmit 0 |
| 174 | test eq get Q 1 0 |
| 175 | put Inlen 0 0 |
| 176 | test not qsubmit 0 |
| 177 | test not qsent 0 true |
| 178 | note Maximum payload crosses all five datagrams, preserving every byte except CR/LF. |
| 179 | put Inlen 0 4096 |
| 180 | for i ulong 4096 |
| 181 | put In i uchar rem i 251 |
| 182 | end |
| 183 | test qsubmit 0 |
| 184 | test qnext 0 true |
| 185 | test eq get T 10 5 |
| 186 | test qsent 0 true |
| 187 | for k ulong 5 |
| 188 | test qnext 0 true |
| 189 | test eq get T 10 1 |
| 190 | tcopy |
| 191 | test pkparse |
| 192 | test eq get N 1 1 |
| 193 | test eq get N 2 add k 1 |
| 194 | test eq get N 3 5 |
| 195 | test eq get N 4 4096 |
| 196 | size = ulong 1000 |
| 197 | if eq k 4 |
| 198 | size = ulong 96 |
| 199 | end |
| 200 | test eq get N 6 size |
| 201 | bad = ulong 0 |
| 202 | for j ulong size |
| 203 | want = uchar rem add mul k 1000 j 251 |
| 204 | if or eq want 10 eq want 13 |
| 205 | want = uchar 32 |
| 206 | end |
| 207 | if ne get In add get N 5 j want |
| 208 | bad = add bad 1 |
| 209 | end |
| 210 | end |
| 211 | test eq bad 0 |
| 212 | test qsent 0 true |
| 213 | end |
| 214 | note A first LINE also stops job retries without a preceding ACK. |
| 215 | linepkt 1 |
| 216 | test eq qincoming 1 1 |
| 217 | test eq get T 6 1 |
| 218 | test qnext 1 true |
| 219 | test eq get T 10 3 |
| 220 | test qsent 1 true |
| 221 | control 6 0 |
| 222 | test eq qincoming 2 1 |
| 223 | test not qnext 2000 true |
| 224 | note Fill the eight-line queue; no GOT until a ninth line can actually be kept. |
| 225 | for k ulong 7 |
| 226 | linepkt add k 2 |
| 227 | test eq qincoming add k 2003 1 |
| 228 | test qnext add k 2003 true |
| 229 | test eq get T 10 3 |
| 230 | test qsent add k 2003 true |
| 231 | end |
| 232 | linepkt 9 |
| 233 | test eq qincoming 2010 0 |
| 234 | test eq get Q 2 8 |
| 235 | test eq get T 13 0 |
| 236 | test qtake |
| 237 | linepkt 9 |
| 238 | test eq qincoming 2011 1 |
| 239 | test eq get Q 2 9 |
| 240 | test qnext 2011 true |
| 241 | test not qsent 2010 true |
| 242 | test eq get T 10 3 |
| 243 | test qsent 2011 true |
| 244 | note Malformed ACK and wrong kinds cannot advance the accepted clock. |
| 245 | put Inlen 0 0 |
| 246 | b = packet 4 1 1 0 0 |
| 247 | tcopy |
| 248 | test eq qincoming 2012 0 |
| 249 | test eq get T 0 2011 |
| 250 | control 5 0 |
| 251 | test eq qincoming 2012 0 |
| 252 | test eq get T 0 2011 |
| 253 | qcancel |
| 254 | control 4 1 |
| 255 | test eq qincoming 2013 0 |
| 256 | test eq get Q 4 0 |
| 257 | ret int get Fails 0 |
| 258 | end |