1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Unit tests for rangesets.
4  *
5  * Copyright (C) 2025 Cloud Software Group
6  */
7 
8 #ifndef _TEST_HARNESS_
9 #define _TEST_HARNESS_
10 
11 #include <assert.h>
12 #include <errno.h>
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #include <xen-tools/common-macros.h>
21 
22 #define smp_wmb()
23 #define __must_check __attribute__((__warn_unused_result__))
24 #define cf_check
25 
26 #define BUG_ON(x) assert(!(x))
27 #define ASSERT(x) assert(x)
28 
29 #include "list.h"
30 #include "rangeset.h"
31 
32 typedef bool rwlock_t;
33 typedef bool spinlock_t;
34 
35 struct domain {
36     unsigned int     domain_id;
37     struct list_head rangesets;
38     spinlock_t       rangesets_lock;
39 };
40 
41 /* For rangeset_domain_{initialize,printk}() */
42 #define spin_lock_init(l) (*(l) = false)
43 #define spin_lock(l)      (*(l) = true)
44 #define spin_unlock(l)    (*(l) = false)
45 
46 /* For rangeset->lock */
47 #define rwlock_init(l)    (*(l) = false)
48 #define read_lock(l)      (*(l) = true)
49 #define read_unlock(l)    (*(l) = false)
50 #define write_lock(l)     (*(l) = true)
51 #define write_unlock(l)   (*(l) = false)
52 
53 #define xmalloc(type) ((type *)malloc(sizeof(type)))
54 #define xfree free
55 
56 #define unlikely
57 
58 #define safe_strcpy strcpy
59 
60 #define printk printf
61 
62 #endif
63 
64 /*
65  * Local variables:
66  * mode: C
67  * c-file-style: "BSD"
68  * c-basic-offset: 4
69  * indent-tabs-mode: nil
70  * End:
71  */
72