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 / kernel / tests / test_osc_admit.c
| 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 | |
| 17 | /* test_osc_admit.c -- host test for the kernel reporting in core/osc_admit.c. |
| 18 | * Covers the one case the QEMU gate cannot build: a Store entry over the Store size limit is never read |
| 19 | * (the Store writer refuses to make one), so the loader cannot tell whether it is an OSCUNIT. It must |
| 20 | * still say, on the osc_unit: channel, that it was refused RESOURCE_UNAVAILABLE, and count it as oversize. |
| 21 | * ck_printf is replaced by a buffer so the exact lines can be checked. */ |
| 22 | #include <stdarg.h> |
| 23 | #include <stdio.h> |
| 24 | #include <string.h> |
| 25 | #include "ck_test.h" |
| 26 | #include "osc_admit.h" |
| 27 | |
| 28 | static char out[4096]; |
| 29 | static size_t outn; |
| 30 | |
| 31 | void ck_printf(const char *fmt, ...) |
| 32 | { |
| 33 | va_list ap; |
| 34 | va_start(ap, fmt); |
| 35 | int n = vsnprintf(out + outn, sizeof out - outn, fmt, ap); |
| 36 | va_end(ap); |
| 37 | if (n > 0) outn += (size_t)n; |
| 38 | } |
| 39 | |
| 40 | int main(void) |
| 41 | { |
| 42 | ck_osc_oversize("big.unit", 667648); |
| 43 | CHECK(strstr(out, "osc_unit: big.unit REFUSED code=30 name=RESOURCE_UNAVAILABLE reason=staging_too_large " |
| 44 | "bytes=667648 limit=655360 ") != NULL); |
| 45 | outn = 0; out[0] = 0; |
| 46 | ck_osc_summary(); |
| 47 | CHECK(strstr(out, "osc_units: seen=0 accepted=0 refused=0 oversize=1 (admission only, nothing launched)\n") != NULL); |
| 48 | return ck_t_verdict("test_osc_admit"); |
| 49 | } |