From: Denis Mukhin <dmukhin@ford.com>
Introduce some basic infrastructure for doing domain ID allocation unit tests,
and add a few tests that ensure correctness of the domain ID allocator.
Use <xen-tools/bitops.h> and xen/lib/find-next-bit.c in test hardness code.
Adjust find-next-bit.c to be compiled with __XEN_TOOLS__.
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
---
Changes since v15:
- fixed generating harness dependencies on the fly during the test build
- kept Julien's R-b
---
tools/include/xen-tools/bitops.h | 10 ++++
tools/tests/Makefile | 1 +
tools/tests/domid/.gitignore | 3 ++
tools/tests/domid/Makefile | 84 +++++++++++++++++++++++++++++
tools/tests/domid/harness.h | 54 +++++++++++++++++++
tools/tests/domid/test-domid.c | 93 ++++++++++++++++++++++++++++++++
xen/lib/find-next-bit.c | 5 ++
7 files changed, 250 insertions(+)
create mode 100644 tools/tests/domid/.gitignore
create mode 100644 tools/tests/domid/Makefile
create mode 100644 tools/tests/domid/harness.h
create mode 100644 tools/tests/domid/test-domid.c
diff --git a/tools/include/xen-tools/bitops.h b/tools/include/xen-tools/bitops.h
index 681482f6759f..3b98fba6d74c 100644
--- a/tools/include/xen-tools/bitops.h
+++ b/tools/include/xen-tools/bitops.h
@@ -12,6 +12,16 @@
#define BITS_PER_LONG 32
#endif
+#define ffsl(x) __builtin_ffsl(x)
+
+#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+
+#define BITS_TO_LONGS(bits) \
+ (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG)
+
+#define DECLARE_BITMAP(name, bits) \
+ unsigned long name[BITS_TO_LONGS(bits)]
+
#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr) / 8]
#define BITMAP_SHIFT(_nr) ((_nr) % 8)
diff --git a/tools/tests/Makefile b/tools/tests/Makefile
index 97ba2a13894d..ac5737364623 100644
--- a/tools/tests/Makefile
+++ b/tools/tests/Makefile
@@ -2,6 +2,7 @@ XEN_ROOT = $(CURDIR)/../..
include $(XEN_ROOT)/tools/Rules.mk
SUBDIRS-y :=
+SUBDIRS-y += domid
SUBDIRS-y += resource
SUBDIRS-$(CONFIG_X86) += cpu-policy
SUBDIRS-$(CONFIG_X86) += tsx
diff --git a/tools/tests/domid/.gitignore b/tools/tests/domid/.gitignore
new file mode 100644
index 000000000000..0e02715159c2
--- /dev/null
+++ b/tools/tests/domid/.gitignore
@@ -0,0 +1,3 @@
+*.o
+generated
+test-domid
diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile
new file mode 100644
index 000000000000..0a124a8bfc76
--- /dev/null
+++ b/tools/tests/domid/Makefile
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Unit tests for domain ID allocator.
+#
+# Copyright 2025 Ford Motor Company
+
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+TESTS := test-domid
+
+strip-list = $(sort $(strip $(foreach x,$(1),$(strip $(x)))))
+
+define list-c-headers
+$(shell sed -n -r \
+ 's/^[ \t]*# *include[ \t]*[<"]([^">]+)[">].*/\1/p' $(1) 2>/dev/null)
+endef
+
+define emit-harness-nested-rule
+$(1): $(CURDIR)/harness.h
+ mkdir -p $$(dir $$@)
+ ln -sf $$^ $$@
+endef
+
+define emit-harness-rules
+ifneq ($(strip $(3)),)
+$(foreach h,$(3),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(h)))
+vpath $(1) $(2)
+$(1:.c=.o): $(addprefix $(CURDIR)/generated/,$(3))
+endif
+endef
+
+define vpath-with-harness-deps
+$(call emit-harness-rules,$(1),$(2),\
+ $(call strip-list,$(call list-c-headers,$(2)$(1))))
+endef
+
+.PHONY: all
+all: $(TESTS)
+
+.PHONY: run
+run: $(TESTS)
+ $(foreach t,$(TESTS),./$(t);)
+
+.PHONY: clean
+clean:
+ $(RM) -rf $(CURDIR)/generated
+ $(RM) -- *.o $(TESTS) $(DEPS_RM)
+
+.PHONY: distclean
+distclean: clean
+ $(RM) -- *~
+
+.PHONY: install
+install: all
+ $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests
+ $(INSTALL_PROG) test-domid $(DESTDIR)$(LIBEXEC)/tests
+
+.PHONY: uninstall
+uninstall:
+ $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/test-domid
+
+CFLAGS += -D__XEN_TOOLS__
+# find-next-bit.c
+CFLAGS += '-DEXPORT_SYMBOL(x)=' \
+ -Dfind_first_bit \
+ -Dfind_first_zero_bit \
+ -Dfind_next_bit \
+ -Dfind_next_bit_le \
+ -Dfind_next_zero_bit_le
+CFLAGS += $(APPEND_CFLAGS)
+CFLAGS += $(CFLAGS_xeninclude)
+CFLAGS += -I./generated/
+
+LDFLAGS += $(APPEND_LDFLAGS)
+
+vpath find-next-bit.c $(XEN_ROOT)/xen/lib/
+# Ubuntu {16,18}.04 need single eval at the call site.
+$(eval $(call vpath-with-harness-deps,domid.c,$(XEN_ROOT)/xen/common/))
+
+test-domid: domid.o find-next-bit.o test-domid.o
+ $(CC) $^ -o $@ $(LDFLAGS)
+
+-include $(DEPS_INCLUDE)
diff --git a/tools/tests/domid/harness.h b/tools/tests/domid/harness.h
new file mode 100644
index 000000000000..17eb22a9a854
--- /dev/null
+++ b/tools/tests/domid/harness.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Unit test harness for domain ID allocator.
+ *
+ * Copyright 2025 Ford Motor Company
+ */
+
+#ifndef _TEST_HARNESS_
+#define _TEST_HARNESS_
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include <xen-tools/common-macros.h>
+#include <xen-tools/bitops.h>
+
+typedef bool spinlock_t;
+typedef uint16_t domid_t;
+
+extern domid_t domid_alloc(domid_t domid);
+extern void domid_free(domid_t domid);
+
+extern unsigned long find_next_zero_bit(const unsigned long *addr,
+ unsigned long size,
+ unsigned long offset);
+
+#define __test_and_set_bit(nr, addr) test_and_set_bit(nr, addr)
+#define __test_and_clear_bit(nr, addr) test_and_clear_bit(nr, addr)
+#define __set_bit(nr, addr) set_bit(nr, addr)
+
+#define BUG_ON(x) assert(!(x))
+#define ASSERT(x) assert(x)
+
+#define DEFINE_SPINLOCK(l) spinlock_t l
+#define spin_lock(l) (assert(!*(l)), *(l) = true)
+#define spin_unlock(l) (assert(*(l)), *(l) = false)
+
+#define printk printf
+
+#define DOMID_FIRST_RESERVED (100)
+#define DOMID_INVALID (101)
+
+#endif /* _TEST_HARNESS_ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/tests/domid/test-domid.c b/tools/tests/domid/test-domid.c
new file mode 100644
index 000000000000..51a88a6a9550
--- /dev/null
+++ b/tools/tests/domid/test-domid.c
@@ -0,0 +1,93 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Unit tests for domain ID allocator.
+ *
+ * Copyright 2025 Ford Motor Company
+ */
+
+#include "harness.h"
+
+#define verify(exp, fmt, args...) do { \
+ if ( !(exp) ) \
+ printf(fmt, ## args); \
+ assert(exp); \
+} while (0);
+
+/*
+ * Fail on the first error, since tests are dependent on each other.
+ */
+int main(int argc, char **argv)
+{
+ domid_t expected, allocated;
+
+ /* Test ID cannot be allocated twice. */
+ for ( expected = 0; expected < DOMID_FIRST_RESERVED; expected++ )
+ {
+ allocated = domid_alloc(expected);
+ verify(allocated == expected,
+ "TEST 1: expected %u allocated %u\n", expected, allocated);
+ }
+ for ( expected = 0; expected < DOMID_FIRST_RESERVED; expected++ )
+ {
+ allocated = domid_alloc(expected);
+ verify(allocated == DOMID_INVALID,
+ "TEST 2: expected %u allocated %u\n", DOMID_INVALID, allocated);
+ }
+
+ /* Ensure all IDs, including ID#0 are not allocated. */
+ for ( expected = 0; expected < DOMID_FIRST_RESERVED; expected++ )
+ domid_free(expected);
+
+ /*
+ * Test that that two consecutive calls of domid_alloc(DOMID_INVALID)
+ * will never return the same ID.
+ * NB: ID#0 is reserved and shall not be allocated by
+ * domid_alloc(DOMID_INVALID).
+ */
+ for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
+ {
+ allocated = domid_alloc(DOMID_INVALID);
+ verify(allocated == expected,
+ "TEST 3: expected %u allocated %u\n", expected, allocated);
+ }
+ for ( expected = 1; expected < DOMID_FIRST_RESERVED; expected++ )
+ {
+ allocated = domid_alloc(DOMID_INVALID);
+ verify(allocated == DOMID_INVALID,
+ "TEST 4: expected %u allocated %u\n", DOMID_INVALID, allocated);
+ }
+
+ /* Re-allocate first ID from [1..DOMID_FIRST_RESERVED/2]. */
+ for ( expected = 1; expected < DOMID_FIRST_RESERVED / 2; expected++ )
+ domid_free(expected);
+ for ( expected = 1; expected < DOMID_FIRST_RESERVED / 2; expected++ )
+ {
+ allocated = domid_alloc(DOMID_INVALID);
+ verify(allocated == expected,
+ "TEST 5: expected %u allocated %u\n", expected, allocated);
+ }
+
+ /* Re-allocate last ID from [1..DOMID_FIRST_RESERVED - 1]. */
+ expected = DOMID_FIRST_RESERVED - 1;
+ domid_free(DOMID_FIRST_RESERVED - 1);
+ allocated = domid_alloc(DOMID_INVALID);
+ verify(allocated == expected,
+ "TEST 6: expected %u allocated %u\n", expected, allocated);
+
+ /* Allocate an invalid ID. */
+ expected = DOMID_INVALID;
+ allocated = domid_alloc(DOMID_FIRST_RESERVED);
+ verify(allocated == expected,
+ "TEST 7: expected %u allocated %u\n", expected, allocated);
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/lib/find-next-bit.c b/xen/lib/find-next-bit.c
index 9b8d7814f20c..539c7f2022b0 100644
--- a/xen/lib/find-next-bit.c
+++ b/xen/lib/find-next-bit.c
@@ -8,8 +8,13 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
+
+#ifdef __XEN_TOOLS__
+#include <xen-tools/bitops.h>
+#else
#include <xen/bitops.h>
#include <xen/byteorder.h>
+#endif
#define __ffs(x) (ffsl(x) - 1)
#define ffz(x) __ffs(~(x))
--
2.34.1
On Tue, Aug 12, 2025 at 10:30:50PM +0000, dmkhn@proton.me wrote:
> diff --git a/tools/tests/domid/.gitignore b/tools/tests/domid/.gitignore
> new file mode 100644
> index 000000000000..0e02715159c2
> --- /dev/null
> +++ b/tools/tests/domid/.gitignore
> @@ -0,0 +1,3 @@
> +*.o
"*.o" is already in the .gitignore at the root of the project. I don't
think it's useful here.
> +generated
> +test-domid
> diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile
> new file mode 100644
> index 000000000000..0a124a8bfc76
> --- /dev/null
> +++ b/tools/tests/domid/Makefile
> @@ -0,0 +1,84 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Unit tests for domain ID allocator.
> +#
> +# Copyright 2025 Ford Motor Company
> +
> +XEN_ROOT=$(CURDIR)/../../..
> +include $(XEN_ROOT)/tools/Rules.mk
> +
> +TESTS := test-domid
> +
> +strip-list = $(sort $(strip $(foreach x,$(1),$(strip $(x)))))
What's that macro for? Also, what's a "list"?
> +define list-c-headers
> +$(shell sed -n -r \
Could you use "-E" instead of "-r"? (-r might not work on FreeBSD)
> + 's/^[ \t]*# *include[ \t]*[<"]([^">]+)[">].*/\1/p' $(1) 2>/dev/null)
> +endef
> +
> +define emit-harness-nested-rule
> +$(1): $(CURDIR)/harness.h
> + mkdir -p $$(dir $$@)
You can use $(@D) instead of $(dir $@). The only difference is a /
not present at the end.
> + ln -sf $$^ $$@
This should use $<, I don't think the command is going to work if
there's multiple prerequisite.
> +endef
> +
> +define emit-harness-rules
> +ifneq ($(strip $(3)),)
How many time do you need to call $(strip) ?
Also, I think I would prefer to have $(if $(strip $(3)), [the rest])
rather than actually evaluating code and generating code that we already
know is isn't going to be executed.
> +$(foreach h,$(3),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(h)))
> +vpath $(1) $(2)
> +$(1:.c=.o): $(addprefix $(CURDIR)/generated/,$(3))
> +endif
> +endef
This macro fails if there's more than one "#include" in "domid.c".
And if there's no "#include" in "domid.c", then Make doesn't know how to
make "domid.o" for "test-domid".
> +
> +define vpath-with-harness-deps
> +$(call emit-harness-rules,$(1),$(2),\
> + $(call strip-list,$(call list-c-headers,$(2)$(1))))
> +endef
> +
> +.PHONY: all
> +all: $(TESTS)
> +
> +.PHONY: run
> +run: $(TESTS)
> + $(foreach t,$(TESTS),./$(t);)
This recipe doesn't work as expected. You need `set -e` or only the last
tests count.
> +
> +.PHONY: clean
> +clean:
> + $(RM) -rf $(CURDIR)/generated
$(RM) already contain the '-f' option, no need to add it a second time.
Also, we expected Make to run all commands in recipe from $(CURDIR), so
adding $(CURDIR) is unnecessary, could potentially be an issue.
> + $(RM) -- *.o $(TESTS) $(DEPS_RM)
> +
> +.PHONY: distclean
> +distclean: clean
> + $(RM) -- *~
> +
> +.PHONY: install
> +install: all
> + $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests
> + $(INSTALL_PROG) test-domid $(DESTDIR)$(LIBEXEC)/tests
> +
> +.PHONY: uninstall
> +uninstall:
> + $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/test-domid
> +
> +CFLAGS += -D__XEN_TOOLS__
> +# find-next-bit.c
> +CFLAGS += '-DEXPORT_SYMBOL(x)=' \
> + -Dfind_first_bit \
> + -Dfind_first_zero_bit \
> + -Dfind_next_bit \
> + -Dfind_next_bit_le \
> + -Dfind_next_zero_bit_le
> +CFLAGS += $(APPEND_CFLAGS)
> +CFLAGS += $(CFLAGS_xeninclude)
> +CFLAGS += -I./generated/
> +
> +LDFLAGS += $(APPEND_LDFLAGS)
> +
> +vpath find-next-bit.c $(XEN_ROOT)/xen/lib/
> +# Ubuntu {16,18}.04 need single eval at the call site.
I'd rather see a comment about what's the macro is about rather that a
comment some Linux distribution. Our target is GNU Make 3.80, without
regards to a particular distribution. (Also I don't think it's useful to
point out that `eval` is needed for older version of Make, at least in
our project.)
> +$(eval $(call vpath-with-harness-deps,domid.c,$(XEN_ROOT)/xen/common/))
> +
> +test-domid: domid.o find-next-bit.o test-domid.o
> + $(CC) $^ -o $@ $(LDFLAGS)
> +
> +-include $(DEPS_INCLUDE)
> diff --git a/tools/tests/domid/test-domid.c b/tools/tests/domid/test-domid.c
> new file mode 100644
> index 000000000000..51a88a6a9550
> --- /dev/null
> +++ b/tools/tests/domid/test-domid.c
> @@ -0,0 +1,93 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Unit tests for domain ID allocator.
> + *
> + * Copyright 2025 Ford Motor Company
> + */
> +
> +#include "harness.h"
> +
> +#define verify(exp, fmt, args...) do { \
> + if ( !(exp) ) \
> + printf(fmt, ## args); \
> + assert(exp); \
Relying on assert() for the test isn't wise. It's useful for developing
and debugging because it calls abort(), but they can easily be get rid of,
by simply building with -DNDEBUG. Could you maybe replace it with exit()
since you already check the condition?
Thanks,
--
Anthony PERARD
On Mon, Aug 25, 2025 at 03:47:39PM +0200, Anthony PERARD wrote:
Thanks for review!
Will address in the next revision.
Please see some responses below.
> On Tue, Aug 12, 2025 at 10:30:50PM +0000, dmkhn@proton.me wrote:
> > diff --git a/tools/tests/domid/.gitignore b/tools/tests/domid/.gitignore
> > new file mode 100644
> > index 000000000000..0e02715159c2
> > --- /dev/null
> > +++ b/tools/tests/domid/.gitignore
> > @@ -0,0 +1,3 @@
> > +*.o
>
> "*.o" is already in the .gitignore at the root of the project. I don't
> think it's useful here.
Ack.
>
> > +generated
> > +test-domid
> > diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile
> > new file mode 100644
> > index 000000000000..0a124a8bfc76
> > --- /dev/null
> > +++ b/tools/tests/domid/Makefile
> > @@ -0,0 +1,84 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +#
> > +# Unit tests for domain ID allocator.
> > +#
> > +# Copyright 2025 Ford Motor Company
> > +
> > +XEN_ROOT=$(CURDIR)/../../..
> > +include $(XEN_ROOT)/tools/Rules.mk
> > +
> > +TESTS := test-domid
> > +
> > +strip-list = $(sort $(strip $(foreach x,$(1),$(strip $(x)))))
>
> What's that macro for? Also, what's a "list"?
>
> > +define list-c-headers
> > +$(shell sed -n -r \
>
> Could you use "-E" instead of "-r"? (-r might not work on FreeBSD)
re: FreeBSD: I've found there's a dedicated pipeline for Xen on FreeBSD
(cirrus CI), but I did not figure how to trigger it, will appreciate help
with that.
>
> > + 's/^[ \t]*# *include[ \t]*[<"]([^">]+)[">].*/\1/p' $(1) 2>/dev/null)
> > +endef
> > +
> > +define emit-harness-nested-rule
> > +$(1): $(CURDIR)/harness.h
> > + mkdir -p $$(dir $$@)
>
> You can use $(@D) instead of $(dir $@). The only difference is a /
> not present at the end.
>
> > + ln -sf $$^ $$@
>
> This should use $<, I don't think the command is going to work if
> there's multiple prerequisite.
>
> > +endef
> > +
> > +define emit-harness-rules
> > +ifneq ($(strip $(3)),)
>
> How many time do you need to call $(strip) ?
> Also, I think I would prefer to have $(if $(strip $(3)), [the rest])
> rather than actually evaluating code and generating code that we already
> know is isn't going to be executed.
>
> > +$(foreach h,$(3),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(h)))
> > +vpath $(1) $(2)
> > +$(1:.c=.o): $(addprefix $(CURDIR)/generated/,$(3))
> > +endif
> > +endef
>
> This macro fails if there's more than one "#include" in "domid.c".
>
> And if there's no "#include" in "domid.c", then Make doesn't know how to
> make "domid.o" for "test-domid".
>
> > +
> > +define vpath-with-harness-deps
> > +$(call emit-harness-rules,$(1),$(2),\
> > + $(call strip-list,$(call list-c-headers,$(2)$(1))))
> > +endef
> > +
> > +.PHONY: all
> > +all: $(TESTS)
> > +
> > +.PHONY: run
> > +run: $(TESTS)
> > + $(foreach t,$(TESTS),./$(t);)
>
> This recipe doesn't work as expected. You need `set -e` or only the last
> tests count.
>
> > +
> > +.PHONY: clean
> > +clean:
> > + $(RM) -rf $(CURDIR)/generated
>
> $(RM) already contain the '-f' option, no need to add it a second time.
>
> Also, we expected Make to run all commands in recipe from $(CURDIR), so
> adding $(CURDIR) is unnecessary, could potentially be an issue.
>
> > + $(RM) -- *.o $(TESTS) $(DEPS_RM)
> > +
> > +.PHONY: distclean
> > +distclean: clean
> > + $(RM) -- *~
> > +
> > +.PHONY: install
> > +install: all
> > + $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests
> > + $(INSTALL_PROG) test-domid $(DESTDIR)$(LIBEXEC)/tests
> > +
> > +.PHONY: uninstall
> > +uninstall:
> > + $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/test-domid
> > +
> > +CFLAGS += -D__XEN_TOOLS__
> > +# find-next-bit.c
> > +CFLAGS += '-DEXPORT_SYMBOL(x)=' \
> > + -Dfind_first_bit \
> > + -Dfind_first_zero_bit \
> > + -Dfind_next_bit \
> > + -Dfind_next_bit_le \
> > + -Dfind_next_zero_bit_le
> > +CFLAGS += $(APPEND_CFLAGS)
> > +CFLAGS += $(CFLAGS_xeninclude)
> > +CFLAGS += -I./generated/
> > +
> > +LDFLAGS += $(APPEND_LDFLAGS)
> > +
> > +vpath find-next-bit.c $(XEN_ROOT)/xen/lib/
> > +# Ubuntu {16,18}.04 need single eval at the call site.
>
> I'd rather see a comment about what's the macro is about rather that a
> comment some Linux distribution. Our target is GNU Make 3.80, without
> regards to a particular distribution. (Also I don't think it's useful to
> point out that `eval` is needed for older version of Make, at least in
> our project.)
Ack.
>
> > +$(eval $(call vpath-with-harness-deps,domid.c,$(XEN_ROOT)/xen/common/))
> > +
> > +test-domid: domid.o find-next-bit.o test-domid.o
> > + $(CC) $^ -o $@ $(LDFLAGS)
> > +
> > +-include $(DEPS_INCLUDE)
> > diff --git a/tools/tests/domid/test-domid.c b/tools/tests/domid/test-domid.c
> > new file mode 100644
> > index 000000000000..51a88a6a9550
> > --- /dev/null
> > +++ b/tools/tests/domid/test-domid.c
> > @@ -0,0 +1,93 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +/*
> > + * Unit tests for domain ID allocator.
> > + *
> > + * Copyright 2025 Ford Motor Company
> > + */
> > +
> > +#include "harness.h"
> > +
> > +#define verify(exp, fmt, args...) do { \
> > + if ( !(exp) ) \
> > + printf(fmt, ## args); \
> > + assert(exp); \
>
> Relying on assert() for the test isn't wise. It's useful for developing
> and debugging because it calls abort(), but they can easily be get rid of,
> by simply building with -DNDEBUG. Could you maybe replace it with exit()
> since you already check the condition?
Yep, will do.
>
>
> Thanks,
>
> --
> Anthony PERARD
>
© 2016 - 2025 Red Hat, Inc.