Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/omega/allen/tests/context.om # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / omega / allen / tests / context.om` 359 lines ยท 6557 bytes Raw Blame History 1 text Who "Drake" 2 text Selfname "Allen" 3 text Fkey "gate code" 4 text Fval "4471" 5 text Note0 "Meet at noon." 6 text Note1 "Old private note." 7 text Note3 "Bring tools." 8 text MetaWant "\tself=Allen\tname=Drake\tstarts=7\tfact gate code is 4471\tnote Bring tools.\tnote Meet at noon." 9 text NewOnly "\tself=Allen\tname=Drake\tstarts=7\tfact gate code is 4471\tnote Bring tools." 10 text Emptyctx "\tself=Allen\tstarts=0" 11 text Lastsix "\tself=Allen\tstarts=0\tnote N9\tnote N8\tnote N7\tnote N6\tnote N5\tnote N4" 12 text Plural "\tself=Allen\tname=Drake\tstarts=`4294967295`\tfact gate code are 4471" 13 global Unitsave uchar 8192 14 global Saveout uchar 8192 15 global Saveos ulong 2 16 fn test ok bool to void 17 put Saveos 0 get Outlen 0 18 put Saveos 1 get Err 0 19 for i ulong get Outlen 0 20 put Saveout i get Outb i 21 end 22 check ok add get Checks 0 1 23 for i ulong get Saveos 0 24 put Outb i get Saveout i 25 end 26 put Outlen 0 get Saveos 0 27 put Err 0 get Saveos 1 28 end 29 fn fixture index ulong gone ulong to void 30 put Ns 0 len Note0 31 put Ns 1 index 32 put Ns 2 7 33 put Ns 3 gone 34 for i ulong len Note0 35 put Note i get Note0 i 36 end 37 if eq index 1 38 put Ns 0 len Note1 39 for i ulong len Note1 40 put Note i get Note1 i 41 end 42 end 43 if eq index 3 44 put Ns 0 len Note3 45 for i ulong len Note3 46 put Note i get Note3 i 47 end 48 end 49 test noteenc 50 for i ulong 4096 51 put Unit i get Enc i 52 end 53 end 54 fn memsetup to void 55 for i ulong 3692 56 put Mem i 0 57 end 58 mset32 0 7 59 mset32 32 1 60 mset32 36 4 61 for i ulong len Who 62 put Mem add i 8 get Who i 63 end 64 for i ulong len Fkey 65 put Mem add i 40 get Fkey i 66 end 67 for i ulong len Fval 68 put Mem add i 88 get Fval i 69 end 70 for i ulong len Selfname 71 put Mem add i 153 get Selfname i 72 end 73 end 74 fn prompt to void 75 put Inlen 0 2 76 put In 0 104 77 put In 1 105 78 end 79 fn main to int 80 test appinit 123 0 81 test ctxmeta 6 82 test eq get Mx 0 len Emptyctx 83 same = true 84 for i ulong len Emptyctx 85 if ne get Meta i get Emptyctx i 86 same = false 87 end 88 end 89 test same 90 memsetup 91 test memenc 100 92 for i ulong 4096 93 put Unit i get Enc i 94 end 95 loadbeg 96 test loadcopy 0 97 test eq get St 0 100 98 test ctxbegin 99 test eq get Cx 0 4 100 test eq get Cx 1 0 101 test eq get Cx 2 0 102 test not ctxmeta 6 103 prompt 104 test not appask 0 105 test eq get R 0 0 106 test eq get Q 1 0 107 appcancel 108 fixture 3 0 109 test eq ctxtake 3 1 110 test eq get Ctxlen 3 len Note3 111 test eq get Ctxstart 3 7 112 test eq ctxtake 3 0 113 test eq get Cx 1 1 114 fixture 1 1 115 test eq ctxtake 1 1 116 test eq get Ctxgone 1 1 117 fixture 2 0 118 put Unit 64 33 119 test eq ctxtake 2 2 120 test eq get Cx 3 1 121 test eq get Ctxgone 2 1 122 test not ctxmeta 6 123 fixture 0 0 124 test eq ctxtake 0 1 125 test eq get Cx 1 4 126 test eq get Cx 2 1 127 test eq get Cx 4 0 128 test eq ctxtake 4 0 129 test ctxmeta 6 130 test eq get Mx 0 len MetaWant 131 same = true 132 for i ulong len MetaWant 133 if ne get Meta i get MetaWant i 134 same = false 135 end 136 end 137 test same 138 test ctxmeta 1 139 test eq get Mx 0 len NewOnly 140 same = true 141 for i ulong len NewOnly 142 if ne get Meta i get NewOnly i 143 same = false 144 end 145 end 146 test same 147 test not ctxmeta 513 148 test not ctxappend 149 test ctxmeta 6 150 outreset 151 emitb 120 152 test ctxappend 153 test eq get Outlen 0 add 1 len MetaWant 154 test eq get Outb 0 120 155 same = true 156 for i ulong len MetaWant 157 if ne get Outb add i 1 get MetaWant i 158 same = false 159 end 160 end 161 test same 162 note Exercise the actual appask -> qsubmit job snapshot, not only metadata helpers. 163 prompt 164 test appask 1 165 test eq get R 0 1 166 test eq get Q 1 1 167 test eq get R 9 1 168 n = get T 8 169 test ge n len MetaWant 170 same = ge n len MetaWant 171 if same 172 for i ulong len MetaWant 173 if ne get JobOut add sub n len MetaWant i get MetaWant i 174 same = false 175 end 176 end 177 end 178 test same 179 test not ctxbegin 180 test eq ctxtake 0 0 181 appcancel 182 note Exact append capacity and one byte above, preserving Outb/length/error on refusal. 183 test ctxmeta 6 184 n = sub ulong 4096 get Mx 0 185 put Outlen 0 n 186 for i ulong n 187 put Outb i 90 188 end 189 test ctxappend 190 test eq get Outlen 0 4096 191 put Outlen 0 add n 1 192 put Outb n 88 193 test not ctxappend 194 test eq get Outlen 0 add n 1 195 test eq get Outb n 88 196 put Err 0 5 197 test not ctxappend 198 test eq get Err 0 5 199 outreset 200 mset32 36 5 201 test not ctxmeta 6 202 mset32 36 4 203 mset32 32 33 204 prompt 205 test not appask 2 206 test eq get R 0 1 207 test eq get Q 1 1 208 mset32 32 1 209 note Deliberately full valid facts make metadata fit but the whole JOB exceed4096. 210 for i ulong 3692 211 put Mem i 0 212 end 213 mset32 32 32 214 for k ulong 32 215 off = add 40 mul k 113 216 for i ulong 47 217 put Mem add off i 107 218 end 219 for i ulong 63 220 put Mem add add off 48 i 118 221 end 222 end 223 test ctxmeta 6 224 test le get Mx 0 4096 225 prompt 226 test not appask 2 227 test eq get R 0 1 228 test eq get Q 1 1 229 test eq get R 9 1 230 note Catalog capacity and transaction exclusion. 231 mset32 36 512 232 test ctxbegin 233 test eq get Cx 0 512 234 test eq ctxtake 512 0 235 fixture 511 0 236 test eq ctxtake 511 1 237 test eq get Ctxlen 511 len Note0 238 test not ctxmeta 6 239 put Tx 0 1 240 test not ctxbegin 241 test eq ctxtake 0 0 242 put Tx 0 0 243 put Nt 0 1 244 test not ctxbegin 245 test eq ctxtake 0 0 246 put Nt 0 0 247 mset32 36 513 248 test not ctxbegin 249 test eq get Cx 0 512 250 note Load ten real records, select exactly the newest six, and allow zero selected. 251 for i ulong 3692 252 put Mem i 0 253 end 254 mset32 36 10 255 test ctxbegin 256 for k ulong 10 257 put Ns 0 2 258 put Ns 1 k 259 put Ns 2 7 260 put Ns 3 0 261 put Note 0 78 262 put Note 1 uchar add 48 k 263 test noteenc 264 for i ulong 4096 265 put Unit i get Enc i 266 end 267 test eq ctxtake k 1 268 end 269 test ctxmeta 6 270 test eq get Mx 0 len Lastsix 271 same = true 272 for i ulong len Lastsix 273 if ne get Meta i get Lastsix i 274 same = false 275 end 276 end 277 test same 278 test ctxmeta 0 279 test eq get Mx 0 len Emptyctx 280 note Context construction cannot overwrite a staged memory/note transaction image. 281 for i ulong 4096 282 put Unitsave i get Unit i 283 put Unitsave add i 4096 get Enc i 284 end 285 test ctxmeta 6 286 same = true 287 for i ulong 4096 288 if ne get Unit i get Unitsave i 289 same = false 290 end 291 if ne get Enc i get Unitsave add i 4096 292 same = false 293 end 294 end 295 test same 296 memsetup 297 mset32 36 0 298 mset32 0 `4294967295` 299 put Mem 152 1 300 test ctxmeta 6 301 test eq get Mx 0 len Plural 302 same = true 303 for i ulong len Plural 304 if ne get Meta i get Plural i 305 same = false 306 end 307 end 308 test same 309 put Mem 40 9 310 test not ctxmeta 6 311 test not ctxappend 312 put Mem 40 103 313 for i ulong 48 314 put Mem add i 40 107 315 end 316 test not ctxmeta 6 317 note Thirty-two full facts and six full notes overflow metadata itself, not only JOB. 318 for i ulong 3692 319 put Mem i 0 320 end 321 mset32 32 32 322 mset32 36 6 323 for k ulong 32 324 off = add 40 mul k 113 325 for i ulong 47 326 put Mem add off i 107 327 end 328 for i ulong 63 329 put Mem add add off 48 i 118 330 end 331 end 332 test ctxbegin 333 for k ulong 6 334 put Ns 0 127 335 put Ns 1 k 336 put Ns 2 7 337 put Ns 3 0 338 for i ulong 127 339 put Note i 110 340 end 341 test noteenc 342 for i ulong 4096 343 put Unit i get Enc i 344 end 345 test eq ctxtake k 1 346 end 347 test not ctxmeta 6 348 test eq get Mx 1 1 349 outreset 350 emitb 90 351 test not ctxappend 352 test eq get Outlen 0 1 353 test eq get Outb 0 90 354 prompt 355 test not appask 2 356 test eq get R 0 1 357 test eq get Q 1 1 358 ret int get Fails 0 359 end