qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 26/26] qidl: unit tests and build infrastructure


From: Michael Roth
Subject: Re: [Qemu-devel] [PATCH 26/26] qidl: unit tests and build infrastructure
Date: Thu, 25 Oct 2012 16:27:50 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Oct 18, 2012 at 09:42:20PM -0500, Michael Roth wrote:
> 
> Signed-off-by: Michael Roth <address@hidden>
> ---
>  Makefile                     |    3 +
>  configure                    |    1 +
>  rules.mak                    |   27 ++-
>  tests/Makefile               |    8 +-
>  tests/test-qidl-included.h   |   25 +++
>  tests/test-qidl-linked.c     |  101 +++++++++++
>  tests/test-qidl-pub-linked.c |   18 ++
>  tests/test-qidl-pub-linked.h |   29 ++++
>  tests/test-qidl.c            |  393 
> ++++++++++++++++++++++++++++++++++++++++++
>  tests/test-qidl.h            |   36 ++++
>  10 files changed, 638 insertions(+), 3 deletions(-)
>  create mode 100644 tests/test-qidl-included.h
>  create mode 100644 tests/test-qidl-linked.c
>  create mode 100644 tests/test-qidl-pub-linked.c
>  create mode 100644 tests/test-qidl-pub-linked.h
>  create mode 100644 tests/test-qidl.c
>  create mode 100644 tests/test-qidl.h
> 
> diff --git a/Makefile b/Makefile
> index da4360f..0332f41 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -236,6 +236,8 @@ clean:
>       if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
>       rm -f $$d/qemu-options.def; \
>          done
> +     find -name '*.qidl.c' -exec rm -f {} \;
> +     find -name '*.qidl.schema' -exec rm -f {} \;
>  
>  VERSION ?= $(shell cat VERSION)
>  
> @@ -405,6 +407,7 @@ qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
>  # rebuilt before other object files
>  Makefile: $(GENERATED_HEADERS)
>  
> +
>  # Include automatically generated dependency files
>  # Dependencies in Makefile.objs files come from our recursive subdir rules
>  -include $(wildcard *.d tests/*.d)
> diff --git a/configure b/configure
> index 353d788..c547b79 100755
> --- a/configure
> +++ b/configure
> @@ -3235,6 +3235,7 @@ if test "$debug_tcg" = "yes" ; then
>  fi
>  if test "$debug" = "yes" ; then
>    echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
> +  echo "CONFIG_DEBUG_QIDL=y" >> $config_host_mak
>  fi
>  if test "$strip_opt" = "yes" ; then
>    echo "STRIP=${strip}" >> $config_host_mak
> diff --git a/rules.mak b/rules.mak
> index 1b173aa..ce04aeb 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -14,8 +14,33 @@ MAKEFLAGS += -rR
>  # Flags for dependency generation
>  QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
>  
> +# Debug options for QIDL
> +ifdef CONFIG_DEBUG_QIDL
> +QIDL_FLAGS = --schema-filepath=$(*D)/$(*F).qidl.schema
> +endif
> +
> +.SECONDARY:
> +
>  %.o: %.c
> -     $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) 
> $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> +
> +%.qidl.c: %.c $(SRC_PATH)/qidl.h $(addprefix $(SRC_PATH)/scripts/,lexer.py 
> qidl.py qidl_parser.py qapi.py qapi_visit.py)
> +     @rm -f $(*D)/$(*F).qidl.*
> +     $(if $(strip $(shell grep "QIDL_ENABLE()" $< 1>/dev/null && echo 
> "true")), \
> +       $(call quiet-command, \
> +         $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(CFLAGS) -E -c -DQIDL_GEN $< 
> | \
> +         $(PYTHON) $(SRC_PATH)/scripts/qidl.py $(QIDL_FLAGS) \
> +         --output-filepath=$(*D)/$(*F).qidl.c || [ "$$?" -eq 2 ], \
> +         "qidl PP $(*D)/$(*F).c"),)
> +
> +%.o: %.c %.qidl.c
> +     $(if $(strip $(shell test -f $(*D)/$(*F).qidl.c && echo "true")), \
> +       $(call quiet-command, \
> +         $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c \
> +             -DQIDL_ENABLED -include $< -o $@ $(*D)/$(*F).qidl.c, \
> +             "qidl CC $@"), \
> +       $(call quiet-command, \
> +         $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c \
> +           -o $@ $<,"  CC    $@"))

*sigh*, there seems to be a problem here with gcc-generated deps not
being pulled in for qidl CC'd files:

address@hidden:~/w/qemu-build$ rm -rf * && ../qemu.git/configure
--target-list=x86_64-softmmu

address@hidden:~/w/qemu-build$ make -j4 && make check

If you then modify tests/test-qidl.h, which is pulled in by tests/test-qidl.c,
tests/test-qidl.o and tests/test-qidl are not regenerated. So need to
look into this more before this can go in.

>  
>  ifeq ($(LIBTOOL),)
>  %.lo: %.c
> diff --git a/tests/Makefile b/tests/Makefile
> index e10aaed..0c8eceb 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -15,6 +15,7 @@ check-unit-y += tests/test-string-output-visitor$(EXESUF)
>  check-unit-y += tests/test-coroutine$(EXESUF)
>  check-unit-y += tests/test-visitor-serialization$(EXESUF)
>  check-unit-y += tests/test-iov$(EXESUF)
> +check-unit-y += tests/test-qidl$(EXESUF)
>  
>  check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
>  
> @@ -34,11 +35,12 @@ test-obj-y = tests/check-qint.o tests/check-qstring.o 
> tests/check-qdict.o \
>       tests/test-coroutine.o tests/test-string-output-visitor.o \
>       tests/test-string-input-visitor.o tests/test-qmp-output-visitor.o \
>       tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \
> -     tests/test-qmp-commands.o tests/test-visitor-serialization.o
> +     tests/test-qmp-commands.o tests/test-visitor-serialization.o \
> +     tests/test-qidl.o
>  
>  test-qapi-obj-y =  $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y)
>  test-qapi-obj-y += tests/test-qapi-visit.o tests/test-qapi-types.o
> -test-qapi-obj-y += module.o
> +test-qapi-obj-y += module.o $(qom-obj-y)
>  
>  $(test-obj-y): QEMU_INCLUDES += -Itests
>  
> @@ -84,6 +86,8 @@ check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), 
> $(check-qtest-$(TARGET)
>  qtest-obj-y = tests/libqtest.o $(oslib-obj-y) $(tools-obj-y)
>  $(check-qtest-y): $(qtest-obj-y)
>  
> +tests/test-qidl$(EXESUF): tests/test-qidl.o tests/test-qidl-linked.o 
> tests/test-qidl-pub-linked.o $(test-qapi-obj-y) qapi/misc-qapi-visit.o
> +
>  .PHONY: check-help
>  check-help:
>       @echo "Regression testing targets:"
> diff --git a/tests/test-qidl-included.h b/tests/test-qidl-included.h
> new file mode 100644
> index 0000000..3ee8487
> --- /dev/null
> +++ b/tests/test-qidl-included.h
> @@ -0,0 +1,25 @@
> +/*
> + * Unit-tests for QIDL-generated visitors/code
> + *
> + * Copyright IBM, Corp. 2012
> + *
> + * Authors:
> + *  Michael Roth <address@hidden>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#ifndef TEST_QIDL_INCLUDED_H
> +#define TEST_QIDL_INCLUDED_H
> +
> +#include "qidl.h"
> +#include "test-qidl.h"
> +
> +typedef struct TestStructIncluded TestStructIncluded;
> +
> +QIDL_DECLARE(TestStructIncluded) {
> +    TEST_QIDL_STRUCT_BODY
> +};
> +
> +#endif
> diff --git a/tests/test-qidl-linked.c b/tests/test-qidl-linked.c
> new file mode 100644
> index 0000000..0499bc1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]