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/omega-mv/blob/main/seed/host/negative.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / host / negative.sh` 449 lines ยท 7992 bytes Raw Blame History 1 #!/bin/sh 2 set -eu 3 cd "$(dirname "$0")/../.." 4 root=$PWD 5 OMC=${OMC:-"$root/seed/out/omc"} 6 mkdir -p build/seed/host 7 stage=$(mktemp -d "$root/build/seed/host/negative.XXXXXX") 8 trap 'rm -rf "$stage"' EXIT HUP INT TERM 9 count=0 10 runtime() { 11 name=$1 12 cat > "$stage/$name.om" 13 "$OMC" < "$stage/$name.om" > "$stage/$name" 14 chmod +x "$stage/$name" 15 code=0 16 (cd "$stage"; "./$name") > "$stage/out" || code=$? 17 test "$code" = 103 && test ! -s "$stage/out" || { 18 echo "Wrong refusal: $name (exit $code)" >&2; exit 1; 19 } 20 count=$((count + 1)) 21 } 22 compile_error() { 23 name=$1 24 want=$2 25 code=0 26 cat > "$stage/$name.om" 27 "$OMC" < "$stage/$name.om" > "$stage/out" 2> "$stage/err" || code=$? 28 test "$code" = "$want" && test ! -s "$stage/out" || { 29 echo "Wrong compile refusal: $name (exit $code)" >&2; exit 1; 30 } 31 count=$((count + 1)) 32 } 33 runtime path-overflow <<'EOF' 34 text path "must-not-exist" 35 fn main to int 36 r = fopen path `18446744073709551615` 1 194 384 37 ret 1 38 end 39 EOF 40 runtime path-zero <<'EOF' 41 global path uchar 3 42 fn main to int 43 put path 0 97 44 put path 2 98 45 r = fopen path 0 3 194 384 46 ret 1 47 end 48 EOF 49 runtime path-length <<'EOF' 50 global path uchar 4096 51 fn main to int 52 r = fopen path 0 len path 194 384 53 ret 1 54 end 55 EOF 56 runtime stat-short <<'EOF' 57 global buf uchar 127 58 fn main to int 59 r = fstat 0 buf 0 len buf 60 ret 1 61 end 62 EOF 63 runtime pipe-short <<'EOF' 64 global buf uchar 7 65 fn main to int 66 r = pipefds buf 0 len buf 0 67 ret 1 68 end 69 EOF 70 runtime packet-empty <<'EOF' 71 global buf uchar 2 72 fn main to int 73 r = execprog buf 0 len buf 74 ret 1 75 end 76 EOF 77 runtime packet-count <<'EOF' 78 global buf uchar 4 79 fn main to int 80 put buf 0 65 81 r = execprog buf 0 len buf 82 ret 1 83 end 84 EOF 85 runtime packet-truncated <<'EOF' 86 global buf uchar 5 87 fn main to int 88 put buf 0 1 89 put buf 2 2 90 put buf 4 97 91 r = execprog buf 0 len buf 92 ret 1 93 end 94 EOF 95 runtime packet-zero <<'EOF' 96 global buf uchar 6 97 fn main to int 98 put buf 0 1 99 put buf 2 2 100 put buf 4 97 101 r = execprog buf 0 len buf 102 ret 1 103 end 104 EOF 105 runtime packet-extra <<'EOF' 106 global buf uchar 6 107 fn main to int 108 put buf 0 1 109 put buf 2 1 110 put buf 4 97 111 r = execprog buf 0 len buf 112 ret 1 113 end 114 EOF 115 runtime rename-count <<'EOF' 116 global buf uchar 5 117 fn main to int 118 put buf 0 1 119 put buf 2 1 120 put buf 4 97 121 r = renames buf 0 len buf 0 122 ret 1 123 end 124 EOF 125 runtime arg-index <<'EOF' 126 global buf uchar 4 127 fn main to int 128 r = argread ulong argcnt buf 0 len buf 129 ret 1 130 end 131 EOF 132 runtime negative-sleep <<'EOF' 133 fn main to int 134 r = sleepns neg long 1 135 ret 1 136 end 137 EOF 138 runtime poll-truncation <<'EOF' 139 fn main to int 140 r = waitio 0 65536 0 141 ret 1 142 end 143 EOF 144 compile_error read-only 20 <<'EOF' 145 text buf "abcd" 146 fn main to int 147 r = recv 0 buf 0 len buf 0 148 ret 0 149 end 150 EOF 151 compile_error array-type 7 <<'EOF' 152 global buf ulong 32 153 fn main to int 154 r = fstat 0 buf 0 128 155 ret 0 156 end 157 EOF 158 compile_error descriptor-type 7 <<'EOF' 159 fn main to int 160 r = fclose ulong 0 161 ret 0 162 end 163 EOF 164 compile_error function-mode 9 <<'EOF' 165 fn probe to long 166 ret monons 167 end 168 EOF 169 test ! -e "$stage/must-not-exist" 170 test ! -e "$stage/a" 171 printf 'PASS %s bounds, packet, mutability, type and function-mode negative controls\n' "$count" 172 runtime cwd-overflow <<'OM' 173 global buf uchar 8 174 fn main to int 175 r = cwd buf `18446744073709551615` 1 176 ret 1 177 end 178 OM 179 runtime cwd-capacity <<'OM' 180 global buf uchar 8 181 fn main to int 182 r = cwd buf 1 8 183 ret 1 184 end 185 OM 186 runtime readlnk-empty <<'OM' 187 text path "/proc/self/cwd" 188 global buf uchar 8 189 fn main to int 190 r = readlnk path 0 0 buf 0 8 191 ret 1 192 end 193 OM 194 runtime readlnk-zero <<'OM' 195 global path uchar 3 196 global buf uchar 8 197 fn main to int 198 put path 0 97 199 put path 2 98 200 r = readlnk path 0 3 buf 0 8 201 ret 1 202 end 203 OM 204 runtime readlnk-length <<'OM' 205 global path uchar 4096 206 global buf uchar 8 207 fn main to int 208 for i ulong len path 209 put path i 97 210 end 211 r = readlnk path 0 len path buf 0 8 212 ret 1 213 end 214 OM 215 runtime readlnk-path-bounds <<'OM' 216 text path "/proc/self/cwd" 217 global buf uchar 8 218 fn main to int 219 r = readlnk path `18446744073709551615` 1 buf 0 8 220 ret 1 221 end 222 OM 223 runtime readlnk-output-bounds <<'OM' 224 text path "/proc/self/cwd" 225 global buf uchar 8 226 fn main to int 227 r = readlnk path 0 len path buf 1 8 228 ret 1 229 end 230 OM 231 runtime sockopt-bounds <<'OM' 232 text buf "abcd" 233 fn main to int 234 r = sockopt neg int 1 1 2 buf 1 4 235 ret 1 236 end 237 OM 238 compile_error cwd-readonly 20 <<'OM' 239 text buf "abcd" 240 fn main to int 241 r = cwd buf 0 4 242 ret 0 243 end 244 OM 245 compile_error cwd-view 20 <<'OM' 246 fn probe buf view uchar 4 to long 247 ret cwd buf 0 4 248 end 249 fn main to int 250 ret 0 251 end 252 OM 253 compile_error cwd-type 7 <<'OM' 254 global buf uint 8 255 fn main to int 256 r = cwd buf 0 8 257 ret 0 258 end 259 OM 260 compile_error cwd-offset-type 7 <<'OM' 261 global buf uchar 8 262 fn main to int 263 r = cwd buf int 0 8 264 ret 0 265 end 266 OM 267 compile_error readlnk-readonly 20 <<'OM' 268 text path "/proc/self/cwd" 269 text buf "abcd" 270 fn main to int 271 r = readlnk path 0 len path buf 0 4 272 ret 0 273 end 274 OM 275 compile_error readlnk-view 20 <<'OM' 276 text path "/proc/self/cwd" 277 fn probe buf view uchar 4 to long 278 ret readlnk path 0 len path buf 0 4 279 end 280 fn main to int 281 ret 0 282 end 283 OM 284 compile_error readlnk-path-type 7 <<'OM' 285 global path ulong 8 286 global buf uchar 8 287 fn main to int 288 r = readlnk path 0 8 buf 0 8 289 ret 0 290 end 291 OM 292 compile_error readlnk-output-type 7 <<'OM' 293 text path "/proc/self/cwd" 294 global buf ulong 8 295 fn main to int 296 r = readlnk path 0 len path buf 0 8 297 ret 0 298 end 299 OM 300 compile_error sockopt-fd-type 7 <<'OM' 301 text buf "abcd" 302 fn main to int 303 r = sockopt long 0 1 2 buf 0 4 304 ret 0 305 end 306 OM 307 compile_error sockopt-level-type 7 <<'OM' 308 text buf "abcd" 309 fn main to int 310 r = sockopt 0 long 1 2 buf 0 4 311 ret 0 312 end 313 OM 314 compile_error sockopt-option-type 7 <<'OM' 315 text buf "abcd" 316 fn main to int 317 r = sockopt 0 1 long 2 buf 0 4 318 ret 0 319 end 320 OM 321 compile_error sockopt-array-type 7 <<'OM' 322 global buf uint 4 323 fn main to int 324 r = sockopt 0 1 2 buf 0 4 325 ret 0 326 end 327 OM 328 compile_error cwd-function-mode 9 <<'OM' 329 fn probe buf edit uchar 4096 to long 330 ret cwd buf 0 4096 331 end 332 OM 333 compile_error readlnk-function-mode 9 <<'OM' 334 fn probe path view uchar 4 buf edit uchar 8 to long 335 ret readlnk path 0 4 buf 0 8 336 end 337 OM 338 compile_error sockopt-function-mode 9 <<'OM' 339 fn probe buf view uchar 4 to long 340 ret sockopt 0 1 2 buf 0 4 341 end 342 OM 343 compile_error flock-fd-type 7 <<'OM' 344 fn main to int 345 r = flock long 0 2 346 ret 0 347 end 348 OM 349 compile_error flock-op-type 7 <<'OM' 350 fn main to int 351 r = flock 0 ulong 2 352 ret 0 353 end 354 OM 355 compile_error flock-arity 4 <<'OM' 356 fn main to int 357 r = flock 0 358 ret 0 359 end 360 OM 361 compile_error flock-name 16 <<'OM' 362 fn main to int 363 flock = int 1 364 ret 0 365 end 366 OM 367 compile_error flock-function-mode 9 <<'OM' 368 fn probe fd int to long 369 ret flock fd 2 370 end 371 OM 372 runtime pollfds-limit <<'OM' 373 global buf uchar 8200 374 fn main to int 375 ret int pollfds buf 0 len buf 0 376 end 377 OM 378 compile_error peercred-readonly 20 <<'OM' 379 text buf "abcdefghijkl" 380 fn main to int 381 ret int peercred 0 buf 0 12 382 end 383 OM 384 compile_error pollfds-readonly 20 <<'OM' 385 text buf "abcdefgh" 386 fn main to int 387 ret int pollfds buf 0 8 0 388 end 389 OM 390 compile_error sendmsg-array-type 7 <<'OM' 391 global buf uint 4 392 fn main to int 393 ret int sendmsg 0 buf 0 4 0 394 end 395 OM 396 compile_error peercred-function-mode 9 <<'OM' 397 fn probe buf edit uchar 16 to long 398 ret peercred 0 buf 0 12 399 end 400 OM 401 compile_error pollfds-function-mode 9 <<'OM' 402 fn probe buf edit uchar 16 to long 403 ret pollfds buf 0 8 0 404 end 405 OM 406 compile_error sendmsg-function-mode 9 <<'OM' 407 fn probe buf view uchar 16 to long 408 ret sendmsg 0 buf 0 8 0 409 end 410 OM 411 compile_error peername-readonly 20 <<'OM' 412 text buf "abcdefghijklmnop" 413 fn main to int 414 ret int peername 0 buf 0 16 415 end 416 OM 417 compile_error peername-array-type 7 <<'OM' 418 global buf uint 4 419 fn main to int 420 ret int peername 0 buf 0 4 421 end 422 OM 423 compile_error peername-descriptor-type 7 <<'OM' 424 global buf uchar 16 425 fn main to int 426 ret int peername ulong 0 buf 0 16 427 end 428 OM 429 compile_error peername-offset-type 7 <<'OM' 430 global buf uchar 16 431 fn main to int 432 ret int peername 0 buf int 0 16 433 end 434 OM 435 compile_error peername-view 20 <<'OM' 436 fn probe buf view uchar 16 to long 437 ret peername 0 buf 0 16 438 end 439 fn main to int 440 buf = new uchar 16 0 441 ret int probe buf 442 end 443 OM 444 compile_error peername-function-mode 9 <<'OM' 445 fn probe buf edit uchar 16 to long 446 ret peername 0 buf 0 16 447 end 448 OM 449 printf 'PASS %s total host negative controls, including cwd, readlnk, sockopt, flock and network\n' "$count"