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-bridge/blob/main/tests/native/x86/failed-cleanup.c # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings 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 `omega-bridge / tests / native / x86 / failed-cleanup.c` 39 lines ยท 1798 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #define _GNU_SOURCE 3 #include "omega_native.h" 4 #include 5 #include 6 #include 7 #include 8 #include 9 /* Same CPU VA and Wolfram receipt as ../v2/dev/context.c. */ 10 int main(void) 11 { 12 omega_native_context *c = 0; 13 uint64_t h = 99, r = 99; 14 assert(omega_native_context_create(1, &c) == OMEGA_OK); 15 assert(omega2_ctx_reserve(c, &h, UINT64_C(`68719484928`), 4096) == OMEGA_OK); 16 assert((int64_t)h > 0); 17 /* The conductor forces cleanup munmap to fail after the real mmap EBADF. */ 18 assert(omega2_ctx_attach(c, &r, h, (uint64_t)-1) == 3 && r == 99); 19 assert(omega2_ctx_address(c, &r, h) == OMEGA_OK && r == UINT64_C(`68719484928`)); 20 r = 99; 21 assert(omega2_ctx_rd(c, &r, h) == 3 && r == 99); 22 assert(omega2_ctx_fetch(c, &r, h) == 3 && r == 99); 23 assert(omega2_ctx_publish(c, &r, h, 1) == 3 && r == 99); 24 assert(omega2_ctx_store(c, &r, h) == 3 && r == 99); 25 /* An invalid fd alone cannot distinguish quarantine from a live reservation: 26 both would trap on the conductor's forced cleanup error. A valid memfd 27 would bind successfully if access=0 were incorrectly left behind. */ 28 int fd = memfd_create("quarantine-control", 0); 29 assert(fd >= 0 && ftruncate(fd, 4096) == 0); 30 assert(omega2_ctx_attach(c, &r, h, (uint64_t)fd) == 3 && r == 99); 31 assert(close(fd) == 0); 32 assert(omega_native_context_destroy(c) == OMEGA_CONTEXT_BUSY); 33 assert(omega2_ctx_drop(c, &r, h) == OMEGA_OK && r == 0); 34 r = 99; 35 assert(omega2_ctx_address(c, &r, h) == 3 && r == 99); 36 assert(omega_native_context_destroy(c) == OMEGA_OK); 37 puts("NATIVE-X86-CLEANUP PASS quarantine before failing cleanup, access refused, drop retry"); 38 return 0; 39 }