summaryrefslogtreecommitdiff
path: root/test/tx/cmake/module_qemu/src/harness.h
blob: 9145531b0f1562f1220fe1745a7b900088757c7a (plain)
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
/***************************************************************************
 * Copyright (c) 2026 Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * AI Disclosure: This file was largely AI-generated by Claude Code (Opus 5.5).
 * The AI-generated portions may be considered public domain (CC0-1.0)
 * and not subject to the project's licence. The human contributor has
 * reviewed and verified that the code is correct.
 *
 * SPDX-License-Identifier: MIT and CC0-1.0
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** ThreadX Test                                                          */
/**                                                                       */
/**   Module execution harness: manager-side reporting                    */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/

#ifndef HARNESS_H
#define HARNESS_H

#include "tx_api.h"
#include "txm_module.h"

/* Record one expectation; a failed one is printed and makes the image fail.  */
VOID    harness_expect(const CHAR *description, ULONG actual, ULONG expected);

/* Print a line, or a labelled value, over semihosting.  */
VOID    harness_print(const CHAR *text);
VOID    harness_value(const CHAR *label, ULONG value);

/* Print the verdict and end the simulation; never returns.  */
VOID    harness_finish(VOID);

/* Wait, in ticks, until a module writes the done word or the limit passes.
   Returns TX_TRUE if the module finished.  */
UINT    harness_wait_for_module(ULONG limit_ticks);

/* Clear the shared area and grant it to a module.  */
VOID    harness_shared_clear(VOID);
UINT    harness_shared_grant(TXM_MODULE_INSTANCE *module_instance);

/* What the memory fault notification has seen.  */
extern volatile ULONG                   harness_fault_count;
extern TX_THREAD * volatile             harness_fault_thread;
extern TXM_MODULE_INSTANCE * volatile   harness_fault_module;
extern volatile ULONG                   harness_fault_address;
extern volatile ULONG                   harness_fault_status;

VOID    harness_fault_notify(TX_THREAD *thread_ptr, TXM_MODULE_INSTANCE *module_instance);

/* The memory handed to the Module Manager, shared by every test image.  */
extern UCHAR    harness_module_memory[];
extern UCHAR    harness_object_memory[];

#define HARNESS_MODULE_MEMORY_SIZE  ((ULONG) 65536UL)
#define HARNESS_OBJECT_MEMORY_SIZE  ((ULONG) 16384UL)

/* Each test image defines this; it runs on the manager thread.  */
VOID    harness_test(VOID);

#endif