interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-runtime / tests / support / home_guard.rs

48 lines · 2260 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Test-only guard for tests that open a compose home (an `rxc_host` handle).
17//!
18//! omega's `rxc_host` allows `RXC_HOST_MAX_HANDLES` (4) open handles per
19//! process (omega `src/runtime/rxc_host_abi.h`); a fifth open is refused with
20//! `E_FULL (-5)`. Rust runs the tests of one test binary on parallel threads in
21//! one process, so five tests that each hold a home at the same moment fail
22//! with a refusal that has nothing to do with what they check.
23//!
24//! Every test that opens a home, directly or through a `ComposeBridge`, takes
25//! the slot first and keeps it until it ends. One slot for the whole process:
26//! those tests run one after another, and a single test may hold up to
27//! `RXC_HOST_MAX_HANDLES` homes. More than 4 concurrent homes in one process is
28//! not qualified here; that limit belongs to omega.
29//!
30//! Include with `#[path = "support/home_guard.rs"] mod home_guard;`. Each test
31//! binary gets its own copy, so the slot is per process, the same scope as the
32//! handle table.
33#![allow(dead_code)]
34
35use std::sync::{Mutex, MutexGuard};
36
37static SLOT: Mutex<()> = Mutex::new(());
38
39/// Holds the process-wide compose-home slot until dropped. A wrapper, not the
40/// bare `MutexGuard`, so an async test may keep it across an `.await`
41/// (clippy::await_holding_lock only looks at the bare guard).
42pub struct HomeSlot(MutexGuard<'static, ()>);
43
44/// Wait for the slot. A test that panicked while holding it does not wedge the
45/// others: the poison flag is cleared, the slot guards no data.
46pub fn home_slot() -> HomeSlot {
47 HomeSlot(SLOT.lock().unwrap_or_else(|e| e.into_inner()))
48}