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-display-mutants.om
| 1 | note Native exact-line mutant construction; selector0 raw-ASK,1 raw-RECV,2 raw-RESET. |
| 2 | global Mutbuf uchar 262144 |
| 3 | global Mutrep uchar 128 |
| 4 | global Mutmode uchar 1 |
| 5 | text Mutold0 "\nif not dask now\n" |
| 6 | text Mutnew0 "\nif not appask now\n" |
| 7 | text Mutold1 "\nif not drecv now\n" |
| 8 | text Mutnew1 "\nif not appreceive now\n" |
| 9 | text Mutold2 "\ndreset\nret 1\n" |
| 10 | text Mutnew2 "\nappreset\nret 1\n" |
| 11 | fn mutmatch at ulong mode uchar to bool |
| 12 | if eq mode 48 |
| 13 | for i ulong len Mutold0 |
| 14 | if ne get Mutbuf add at i get Mutold0 i |
| 15 | ret false |
| 16 | end |
| 17 | end |
| 18 | else |
| 19 | if eq mode 49 |
| 20 | for i ulong len Mutold1 |
| 21 | if ne get Mutbuf add at i get Mutold1 i |
| 22 | ret false |
| 23 | end |
| 24 | end |
| 25 | else |
| 26 | for i ulong len Mutold2 |
| 27 | if ne get Mutbuf add at i get Mutold2 i |
| 28 | ret false |
| 29 | end |
| 30 | end |
| 31 | end |
| 32 | end |
| 33 | ret true |
| 34 | end |
| 35 | fn mutwrite at ulong size ulong to bool |
| 36 | p = ulong 0 |
| 37 | while lt p size |
| 38 | n = write 1 Mutbuf add at p sub size p |
| 39 | if le n 0 |
| 40 | ret false |
| 41 | end |
| 42 | p = add p ulong n |
| 43 | end |
| 44 | ret true |
| 45 | end |
| 46 | fn mutout n ulong mode uchar to int |
| 47 | old = len Mutold0 |
| 48 | size = len Mutnew0 |
| 49 | if eq mode 49 |
| 50 | old = len Mutold1 |
| 51 | size = len Mutnew1 |
| 52 | end |
| 53 | if eq mode 50 |
| 54 | old = len Mutold2 |
| 55 | size = len Mutnew2 |
| 56 | end |
| 57 | if lt n old |
| 58 | ret 65 |
| 59 | end |
| 60 | found = ulong 0 |
| 61 | at = ulong 0 |
| 62 | for i ulong add sub n old 1 |
| 63 | if mutmatch i mode |
| 64 | found = add found 1 |
| 65 | at = i |
| 66 | end |
| 67 | end |
| 68 | if ne found 1 |
| 69 | ret 65 |
| 70 | end |
| 71 | for i ulong size |
| 72 | if eq mode 48 |
| 73 | put Mutrep i get Mutnew0 i |
| 74 | else |
| 75 | if eq mode 49 |
| 76 | put Mutrep i get Mutnew1 i |
| 77 | else |
| 78 | put Mutrep i get Mutnew2 i |
| 79 | end |
| 80 | end |
| 81 | end |
| 82 | if not mutwrite 0 at |
| 83 | ret 74 |
| 84 | end |
| 85 | p = ulong 0 |
| 86 | while lt p size |
| 87 | r = write 1 Mutrep p sub size p |
| 88 | if le r 0 |
| 89 | ret 74 |
| 90 | end |
| 91 | p = add p ulong r |
| 92 | end |
| 93 | if not mutwrite add at old sub n add at old |
| 94 | ret 74 |
| 95 | end |
| 96 | ret 0 |
| 97 | end |
| 98 | fn main to int |
| 99 | r = read 0 Mutmode 0 1 |
| 100 | if ne r 1 |
| 101 | ret 65 |
| 102 | end |
| 103 | mode = get Mutmode 0 |
| 104 | if or lt mode 48 gt mode 50 |
| 105 | ret 65 |
| 106 | end |
| 107 | n = ulong 0 |
| 108 | while lt n len Mutbuf |
| 109 | r = read 0 Mutbuf n sub len Mutbuf n |
| 110 | if lt r 0 |
| 111 | ret 74 |
| 112 | end |
| 113 | if eq r 0 |
| 114 | ret mutout n mode |
| 115 | end |
| 116 | n = add n ulong r |
| 117 | end |
| 118 | ret 65 |
| 119 | end |