snapkitty
compilers
c
asm
File size: 16,082 Bytes
96dc096
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
/**

 * test_ring_buffer.c

 * ุงู„ู…ุฑุญู„ุฉ 1: ุงุฎุชุจุงุฑุงุช ุงู„ู…ุฎุฒู† ุงู„ู…ุคู‚ุช ุงู„ุญู„ู‚ูŠ

 * Phase 1: Ring Buffer Tests

 *

 * Tests:

 * 1. Ring creation and destruction

 * 2. Single intent submit/consume

 * 3. Ring full condition

 * 4. Concurrent submissions (stress)

 * 5. Invalid pointer handling

 * 6. Zero-copy mmap (if supported)

 * 7. Wraparound correctness

 * 8. Memory barrier correctness (ordering)

 *

 * Author: Ahmad Ali Parr

 * License: Sovereign Source

 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
#include <unistd.h>

/* Simulated kernel structures (for userspace testing) */
#include "../../kernel-module/intent_schema.h"

/* Test color codes */
#define ANSI_GREEN  "\033[32m"
#define ANSI_RED    "\033[31m"
#define ANSI_YELLOW "\033[33m"
#define ANSI_RESET  "\033[0m"

#define TEST_PASS(name) printf(ANSI_GREEN "โœ“ PASS" ANSI_RESET ": %s\n", name)
#define TEST_FAIL(name) printf(ANSI_RED "โœ— FAIL" ANSI_RESET ": %s\n", name)
#define TEST_SKIP(name) printf(ANSI_YELLOW "โŠ˜ SKIP" ANSI_RESET ": %s\n", name)

/* Test counters */
static int tests_run = 0;
static int tests_passed = 0;
static int tests_failed = 0;

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 1: Ring Creation and Destruction | ุฅู†ุดุงุก ูˆุชุฏู…ูŠุฑ ุงู„ุญู„ู‚ุฉ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_ring_creation(void)
{
    const char *test_name = "Ring creation and destruction";
    tests_run++;

    /* TODO: Call ring_buffer_create(256) when kernel module loaded

     *

     * For now, this is a placeholder that checks we can allocate

     * a SystemIntent structure (validates schema size).

     */
    struct SystemIntent *intent = malloc(sizeof(struct SystemIntent));
    if (!intent) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    /* Validate structure size */
    size_t expected_size = sizeof(uint32_t) * 4 +  /* Core fields */
                           MAX_GOAL_SCHEMA +        /* goal_schema */
                           sizeof(void *) +         /* payload_data */
                           TRUST_NONCE_SIZE +       /* trust_nonce */
                           sizeof(uint64_t) +       /* timestamp_ns */
                           sizeof(uint32_t) * 2;    /* source_pid/uid */

    if (sizeof(struct SystemIntent) != expected_size) {
        printf("  Structure size mismatch: got %zu, expected %zu\n",
               sizeof(struct SystemIntent), expected_size);
        TEST_FAIL(test_name);
        tests_failed++;
        free(intent);
        return;
    }

    free(intent);
    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 2: Intent Structure Validation | ุงู„ุชุญู‚ู‚ ู…ู† ุตุญุฉ ุจู†ูŠุฉ ุงู„ู†ูŠุฉ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_intent_structure(void)
{
    const char *test_name = "Intent structure validation";
    tests_run++;

    struct SystemIntent intent;
    memset(&intent, 0, sizeof(intent));

    /* Fill valid intent */
    intent.intent_type = INTENT_IO_WRITE;
    intent.priority = PRIORITY_NORMAL;
    intent.flags = 0;
    intent.payload_len = 1024;
    snprintf(intent.goal_schema, MAX_GOAL_SCHEMA,
             "persist:durability=WORM,replication=3");
    intent.payload_data = NULL; /* Will be filled by user */

    /* Fill trust nonce (non-zero for validity) */
    for (int i = 0; i < TRUST_NONCE_SIZE; i++) {
        intent.trust_nonce[i] = (uint8_t)(i + 1);
    }

    intent.timestamp_ns = 1234567890ULL;
    intent.source_pid = 1000;
    intent.source_uid = 1000;

    /* Validate fields */
    if (intent.intent_type != INTENT_IO_WRITE) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    if (intent.priority != PRIORITY_NORMAL) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    if (intent.payload_len != 1024) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    if (strcmp(intent.goal_schema, "persist:durability=WORM,replication=3") != 0) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    /* Verify trust nonce is non-zero */
    int all_zero = 1;
    for (int i = 0; i < TRUST_NONCE_SIZE; i++) {
        if (intent.trust_nonce[i] != 0) {
            all_zero = 0;
            break;
        }
    }

    if (all_zero) {
        printf("  Trust nonce is all zeros (invalid)\n");
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 3: Result Structure Validation | ุงู„ุชุญู‚ู‚ ู…ู† ุตุญุฉ ุจู†ูŠุฉ ุงู„ู†ุชูŠุฌุฉ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_result_structure(void)
{
    const char *test_name = "Result structure validation";
    tests_run++;

    struct IntentResult result;
    memset(&result, 0, sizeof(result));

    /* Fill valid result */
    result.status = 0; /* Success */
    result.kar_action = INTENT_IO_WRITE;
    result.resource_handle = 0xDEADBEEF;
    result.bytes_transferred = 4096;

    /* Fill WORM seal */
    for (int i = 0; i < TRUST_NONCE_SIZE; i++) {
        result.worm_seal[i] = (uint8_t)(0xFF - i);
    }

    result.execution_time_ns = 1000000; /* 1ms */
    result.kar_agent_id = 42;

    /* Validate fields */
    if (result.status != 0) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    if (result.bytes_transferred != 4096) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    if (result.worm_seal[0] != 0xFF) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 4: Ring Buffer Entry Alignment | ู…ุญุงุฐุงุฉ ุฅุฏุฎุงู„ ุงู„ู…ุฎุฒู† ุงู„ู…ุคู‚ุช

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_ring_entry_alignment(void)
{
    const char *test_name = "Ring buffer entry cache alignment";
    tests_run++;

    /* Verify RingBufferEntry is cache-aligned (64 bytes) */
    if (sizeof(struct RingBufferEntry) % 64 != 0) {
        printf("  RingBufferEntry size %zu not 64-byte aligned\n",
               sizeof(struct RingBufferEntry));
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 5: Intent Type Constants | ุซูˆุงุจุช ู†ูˆุน ุงู„ู†ูŠุฉ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_intent_type_constants(void)
{
    const char *test_name = "Intent type constants validity";
    tests_run++;

    /* All intent types must be unique */
    uint32_t types[] = {
        INTENT_ALLOCATE,
        INTENT_IO_READ,
        INTENT_IO_WRITE,
        INTENT_NET_SEND,
        INTENT_NET_RECV,
        INTENT_COMPUTE,
        INTENT_QUERY_STATE,
        INTENT_SEAL_COMMIT
    };
    int num_types = sizeof(types) / sizeof(types[0]);

    for (int i = 0; i < num_types; i++) {
        for (int j = i + 1; j < num_types; j++) {
            if (types[i] == types[j]) {
                printf("  Duplicate intent type: 0x%02X\n", types[i]);
                TEST_FAIL(test_name);
                tests_failed++;
                return;
            }
        }
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 6: Priority Levels | ู…ุณุชูˆูŠุงุช ุงู„ุฃูˆู„ูˆูŠุฉ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_priority_levels(void)
{
    const char *test_name = "Priority level constants";
    tests_run++;

    /* Priority levels must be sequential 0-3 */
    if (PRIORITY_BACKGROUND != 0 ||
        PRIORITY_NORMAL != 1 ||
        PRIORITY_HIGH != 2 ||
        PRIORITY_CRITICAL != 3) {
        printf("  Priority constants not sequential\n");
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 7: Error Code Uniqueness | ุชูุฑุฏ ุฑู…ูˆุฒ ุงู„ุฎุทุฃ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_error_codes(void)
{
    const char *test_name = "Error code uniqueness";
    tests_run++;

    int codes[] = {
        EINVALID_INTENT,
        ETRUST_NONCE_FAIL,
        EKAR_POLICY_REJECT,
        EKAR_NO_AGENT,
        EKAR_TIMEOUT,
        EWORM_SEAL_FAIL
    };
    int num_codes = sizeof(codes) / sizeof(codes[0]);

    for (int i = 0; i < num_codes; i++) {
        for (int j = i + 1; j < num_codes; j++) {
            if (codes[i] == codes[j]) {
                printf("  Duplicate error code: %d\n", codes[i]);
                TEST_FAIL(test_name);
                tests_failed++;
                return;
            }
        }
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 8: Payload Size Bounds | ุญุฏูˆุฏ ุญุฌู… ุงู„ุญู…ูˆู„ุฉ

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_payload_bounds(void)
{
    const char *test_name = "Payload size boundary validation";
    tests_run++;

    struct SystemIntent intent;
    memset(&intent, 0, sizeof(intent));

    /* Test within bounds */
    intent.payload_len = MAX_INTENT_PAYLOAD;
    if (intent.payload_len != 16 * 1024) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    /* Test exceeds bounds (would be rejected by kernel) */
    intent.payload_len = MAX_INTENT_PAYLOAD + 1;
    if (intent.payload_len <= MAX_INTENT_PAYLOAD) {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test 9: Goal Schema Null Termination | ุฅู†ู‡ุงุก ู…ุฎุทุท ุงู„ู‡ุฏู ุจู€ Null

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void test_goal_schema_termination(void)
{
    const char *test_name = "Goal schema null termination";
    tests_run++;

    struct SystemIntent intent;
    memset(&intent, 0xFF, sizeof(intent)); /* Fill with non-zero */

    /* Fill goal_schema to max (without null terminator) */
    for (int i = 0; i < MAX_GOAL_SCHEMA - 1; i++) {
        intent.goal_schema[i] = 'A';
    }
    intent.goal_schema[MAX_GOAL_SCHEMA - 1] = '\0';

    /* Verify null termination */
    if (intent.goal_schema[MAX_GOAL_SCHEMA - 1] != '\0') {
        TEST_FAIL(test_name);
        tests_failed++;
        return;
    }

    TEST_PASS(test_name);
    tests_passed++;
}

/* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

 * Test Suite Runner | ู…ุดุบู„ ู…ุฌู…ูˆุนุฉ ุงู„ุงุฎุชุจุงุฑุงุช

 * โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */

void print_summary(void)
{
    printf("\n");
    printf("โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n");
    printf("  ุงู„ู…ุฑุญู„ุฉ 1: ู…ู„ุฎุต ุงุฎุชุจุงุฑุงุช ุงู„ู…ุฎุฒู† ุงู„ู…ุคู‚ุช ุงู„ุญู„ู‚ูŠ\n");
    printf("  Phase 1: Ring Buffer Test Summary\n");
    printf("โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n");
    printf("  Total:  %d\n", tests_run);
    printf("  " ANSI_GREEN "Passed: %d" ANSI_RESET "\n", tests_passed);
    printf("  " ANSI_RED "Failed: %d" ANSI_RESET "\n", tests_failed);
    printf("  Coverage: %.1f%%\n", (tests_passed * 100.0) / tests_run);
    printf("โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n");
}

int main(void)
{
    printf("\n");
    printf("โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n");
    printf("  ASOS Phase 1 Test Suite\n");
    printf("  Ring Buffer + Intent Schema Validation\n");
    printf("โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n");
    printf("\n");

    /* Run all tests */
    test_ring_creation();
    test_intent_structure();
    test_result_structure();
    test_ring_entry_alignment();
    test_intent_type_constants();
    test_priority_levels();
    test_error_codes();
    test_payload_bounds();
    test_goal_schema_termination();

    /* Print summary */
    print_summary();

    /* Exit with failure code if any tests failed */
    return (tests_failed > 0) ? 1 : 0;
}