aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / omega / allen / tests / provider-output.om
| 1 | note Independent stream-output assertions, not a captured/blessed output fixture. |
| 2 | global Vbuf uchar 65536 |
| 3 | text Vmagic "ALNPRV01" |
| 4 | text Ops "1234345343" |
| 5 | text Hello "ALLEN-COURIER v=1 run=000000000000004d kind=HELLO seq=0 part=0/0 bytes=0\n" |
| 6 | text Got "ALLEN-COURIER v=1 run=000000000000004d kind=GOT seq=1 part=1/0 bytes=0\n" |
| 7 | text Jobtail "hi\tself=Allen\tstarts=0" |
| 8 | text Wordsout "hello" |
| 9 | fn test ok bool to void |
| 10 | check ok add get Checks 0 1 |
| 11 | end |
| 12 | fn vword off ulong to ulong |
| 13 | v = ulong 0 |
| 14 | for i ulong 8 |
| 15 | v = or v shl ulong get Vbuf add off i mul i 8 |
| 16 | end |
| 17 | ret v |
| 18 | end |
| 19 | fn vbyte at ulong expected uchar to void |
| 20 | test eq get Vbuf at expected |
| 21 | end |
| 22 | fn verify n ulong to int |
| 23 | p = ulong 0 |
| 24 | count = ulong 0 |
| 25 | while lt p n |
| 26 | if or lt sub n p 40 ge count 10 |
| 27 | ret 65 |
| 28 | end |
| 29 | for i ulong 8 |
| 30 | vbyte add p i get Vmagic i |
| 31 | end |
| 32 | op = vword add p 8 |
| 33 | status = vword add p 16 |
| 34 | event = vword add p 24 |
| 35 | size = vword add p 32 |
| 36 | p = add p 40 |
| 37 | if gt size sub n p |
| 38 | ret 65 |
| 39 | end |
| 40 | test eq op sub ulong get Ops count 48 |
| 41 | wanted = ulong 1 |
| 42 | if or eq count 2 eq count 4 |
| 43 | wanted = 3 |
| 44 | end |
| 45 | if eq count 7 |
| 46 | wanted = 3 |
| 47 | end |
| 48 | test eq status wanted |
| 49 | if eq count 6 |
| 50 | test eq event 1 |
| 51 | test eq size len Wordsout |
| 52 | for i ulong len Wordsout |
| 53 | vbyte add p i get Wordsout i |
| 54 | end |
| 55 | else |
| 56 | test eq event 0 |
| 57 | end |
| 58 | if eq count 2 |
| 59 | test eq size len Hello |
| 60 | for i ulong len Hello |
| 61 | vbyte add p i get Hello i |
| 62 | end |
| 63 | end |
| 64 | if eq count 7 |
| 65 | test eq size len Got |
| 66 | for i ulong len Got |
| 67 | vbyte add p i get Got i |
| 68 | end |
| 69 | end |
| 70 | if eq count 4 |
| 71 | test ge size len Jobtail |
| 72 | if ge size len Jobtail |
| 73 | at = add p sub size len Jobtail |
| 74 | for i ulong len Jobtail |
| 75 | vbyte add at i get Jobtail i |
| 76 | end |
| 77 | end |
| 78 | end |
| 79 | if and ne wanted 3 ne count 6 |
| 80 | test eq size 0 |
| 81 | end |
| 82 | p = add p size |
| 83 | count = add count 1 |
| 84 | end |
| 85 | test eq count 10 |
| 86 | if ne get Fails 0 0 |
| 87 | ret 1 |
| 88 | end |
| 89 | ret 0 |
| 90 | end |
| 91 | fn main to int |
| 92 | n = ulong 0 |
| 93 | while lt n len Vbuf |
| 94 | r = read 0 Vbuf n sub len Vbuf n |
| 95 | if lt r 0 |
| 96 | ret 74 |
| 97 | end |
| 98 | if eq r 0 |
| 99 | ret verify n |
| 100 | end |
| 101 | n = add n ulong r |
| 102 | end |
| 103 | ret 65 |
| 104 | end |