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/aienux/blob/main/native/argus/tests/bench_argus_contain.c # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. 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 `aienux / native / argus / tests / bench_argus_contain.c` 49 lines ยท 7808 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 17 #define _GNU_SOURCE 18 #include "../argus_abi.h" 19 #include "../argus_core.h" 20 #include "../argus_contain.h" 21 #include "stub_state.h" 22 #include "../../capability/aienos_capability.h" 23 #include "../../capability/aienos_contain.h" 24 #include 25 #include 26 #include 27 #include 28 29 #define CORPUS_N 5000u 30 #define BATCH_N 100u 31 #define ROUNDS 5u 32 #define SAMPLE_N ((CORPUS_N/BATCH_N)*ROUNDS) 33 static int failures; 34 #define CHECK(x) do { if(!(x)){failures++;fprintf(stderr,"FAIL %s:%d: %s\n",__FILE__,__LINE__,#x);} } while(0) 35 typedef struct { ArgusCore *core; ArgusContain *contain; void *cmem,*smem; } State; 36 typedef struct { uint32_t calls; } Obs; 37 static uint64_t now_ns(void){struct timespec t;if(clock_gettime(CLOCK_MONOTONIC_RAW,&t))abort();return(uint64_t)t.tv_sec*1000000000u+t.tv_nsec;} 38 static void obs(void *p,uint32_t op,const AienosCapEntry *e,int rc){(void)op;(void)e;(void)rc;((Obs*)p)->calls++;} 39 static int init(State*s,int contain){memset(s,0,sizeof *s);s->cmem=calloc(1,argus_core_footprint());if(!s->cmem||argus_core_init(&s->core,s->cmem,argus_core_footprint()))return-1;if(contain){s->smem=calloc(1,argus_contain_footprint());if(!s->smem||argus_contain_init(&s->contain,s->smem,argus_contain_footprint()))return-1;}return 0;} 40 static void fini(State*s){free(s->smem);free(s->cmem);} 41 static int replay(State*s,const ArgusEvent*ev,size_t n,int attached,uint64_t*samples,size_t*ns,size_t*proposals){ArgusFinding cf[ARGUS_CORE_MAX_FINDINGS],xf[ARGUS_CORE_MAX_FINDINGS],all[ARGUS_CORE_MAX_FINDINGS*2];ArgusContainmentRequest rq[ARGUS_CONTAIN_WINDOW_MAX];ArgusEvent pe[ARGUS_CONTAIN_WINDOW_MAX];for(size_t b=0;bcore,&ev[i],cf,ARGUS_CORE_MAX_FINDINGS,&nc);if(rc!=ARGUS_OK&&rc!=ARGUS_ERR_FULL)return rc;if(attached){size_t nx=0,na=0,np=0;rc=argus_contain_observe(s->contain,s->core,&ev[i],xf,ARGUS_CORE_MAX_FINDINGS,&nx);if(rc)return rc;for(size_t j=0;jcontain,s->core,all,na,&ev[i],rq,ARGUS_CONTAIN_WINDOW_MAX,pe,ARGUS_CONTAIN_WINDOW_MAX,&np);if(rc)return rc;*proposals+=np;}}if(samples&&*nsy)-(x0);CHECK(feed(ev,n,g,&proposals,&decisions,&executions)==ARGUS_OK);events+=n;free(ev);}CHECK(proposals==0&&decisions==0&&executions==0);CHECK(o.calls==baseline);printf("GATE ARGUS1_FALSE_POSITIVE_PASS %s events=%zu proposals=%zu decisions=%zu executions=%zu authority_calls=%u\n",failures?"FAIL":"PASS",events,proposals,decisions,executions,o.calls-baseline);aienos_cap_set_observer(a,NULL,NULL);aienos_contain_destroy(g);aienos_cap_stop(a,v);free(gm);} 47 static void one_bench(int attached,uint64_t*vals,size_t*nvals){ArgusEvent*ev=calloc(CORPUS_N,sizeof *ev);if(!ev)abort();if(argus_corpus_benign(ev,CORPUS_N,77)!=CORPUS_N)abort();State s;if(init(&s,attached))abort();size_t props=0;int rc=replay(&s,ev,CORPUS_N,attached,vals,nvals,&props);if(rc||props){fprintf(stderr,"bench replay rc=%d proposals=%zu\n",rc,props);failures++;}fini(&s);free(ev);} 48 static void bench_g8(void){uint64_t b[SAMPLE_N],a[SAMPLE_N];size_t nb=0,na=0;for(size_t i=0;i3.0)failures++;} 49 int main(int argc,char**argv){int gate_only=argc>1&&!strcmp(argv[1],"--gate-only");gate10();if(!gate_only)bench_g8();printf("ARGUS-1 F: %s\n",failures?"FAIL":"PASS");return failures?1:0;}