qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC v4 5/7] tests: New make target check-source


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [RFC v4 5/7] tests: New make target check-source
Date: Fri, 24 May 2019 07:49:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 5/23/19 10:15 AM, Markus Armbruster wrote:
> Make target check-source is for checking the source code itself.  For
> now, there's just one such check, make target check-headers.  It
> checks basic header sanity: for each header "FOO.h", test whether
> 
>       #include "qemu/osdep.h"
>       #include "FOO.h"
>       #include "FOO.h"
> 
> compiles.
> 
> The test works only in a git tree, with git installed.  It is skipped
> unless $(SRC_PATH)/.git exists.
> 
> Third-party headers we don't intend to clean up are excluded from this
> test.  So are a few "funny" headers.  See make variable
> excluded-headers.
> 
> A large number of headers don't pass this test, by design or by
> accident.  To keep things more manageable, exclude all headers outside
> include/ for now.
> 
> Headers known to fail the test are marked with
> 
>     /* FIXME Does not pass make check-headers, yet! */
> 
> Headers known to work only in certain configurations are marked like
> 
>     /* FIXME Does not pass make check-headers without CONFIG_WIN32, yet! */
> 
> I tried to find and mark all of them by testing various
> configurations.  Still, "make check" might fail for configurations I
> didn't test.
> 
> Known issue: some of these don't actually need fixing; they're *meant*
> to work only in certain configurations.  We'll want to invent a
> suitable marker that doesn't claim FIXME.
> 
> Some headers may only be included into target-dependent code: they use
> identifiers poisoned by exec/poison.h, or include cpu.h.  These
> headers are marked with a comment
> 
>     /* NOTE: May only be included into target-dependent code */
> 
> The test treats them specially.
> 
> Known issue: some of these are intended for specific targets.  The
> test should skip them for other targets, but doesn't.  They're marked
> FIXME instead, which is wrong.
> 
> New make target check-bad-headers runs the test for headers expected
> to fail it.  This helps with examining the failures.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
[...]>
> diff --git a/Makefile b/Makefile
> index 59de8e2494..42f02c5ceb 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -416,6 +416,8 @@ dummy := $(call unnest-vars,, \
>                  audio-obj-m \
>                  trace-obj-y)
>  
> +RECURSIVE_TARGETS := all clean install
> +
>  include $(SRC_PATH)/tests/Makefile.include
>  
>  all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) 
> recurse-all modules
> @@ -436,7 +438,7 @@ config-host.h-timestamp: config-host.mak
>  qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
>       $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > 
> $@,"GEN","$@")
>  
> -TARGET_DIRS_RULES := $(foreach t, all clean install, $(addsuffix /$(t), 
> $(TARGET_DIRS)))
> +TARGET_DIRS_RULES:=$(foreach t, $(RECURSIVE_TARGETS), $(addsuffix /$(t), 
> $(TARGET_DIRS)))
>  
>  SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
>  $(SOFTMMU_ALL_RULES): $(authz-obj-y)
> diff --git a/Makefile.target b/Makefile.target
> index fdbe7c89f4..a46cfda580 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -41,6 +41,7 @@ STPFILES=
>  
>  # Makefile Tests
>  include $(SRC_PATH)/tests/tcg/Makefile.include
> +include $(SRC_PATH)/tests/check-headers.mak
>  
>  config-target.h: config-target.h-timestamp
>  config-target.h-timestamp: config-target.mak
> @@ -216,6 +217,22 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx 
> $(SRC_PATH)/scripts/hxtool
>  hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx 
> $(SRC_PATH)/scripts/hxtool
>       $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > 
> $@,"GEN","$(TARGET_DIR)$@")
>  
> +.PHONY: check-headers
> +ifeq ($(wildcard $(SRC_PATH)/.git),)
> +check-headers check-bad-headers:
> +     @echo "  SKIP  $@ (requires a git tree)"
> +else
> +check-headers: $(check-target-header-tests:.c=.o)
> +
> +# Expected to fail:
> +check-bad-headers: $(check-bad-target-header-tests:.c=.o)
> +
> +.SECONDARY: $(check-target-header-tests)
> +$(check-target-header-tests) $(check-bad-target-header-tests): 
> tests/header-test-template.c
> +     @mkdir -p $(dir $@)
> +     @sed 's,@header@,$(subst tests/headers/,,$(@:.c=.h)),' <$< >$@
> +endif
> +
>  clean: clean-target
>       rm -f *.a *~ $(PROGS)
>       rm -f $(shell find . -name '*.[od]')
> @@ -238,3 +255,5 @@ endif
>  
>  generated-files-y += config-target.h
>  Makefile: $(generated-files-y)
> +
> +-include $(check-target-header-tests:.c=.d) 
> $(check-bad-target-header-tests:.c=.d)

$ make microblazeel-softmmu/tests/headers/include/exec/user/abitypes.o
./include/exec/user/abitypes.h:6:10: fatal error: cpu.h: No such file or
directory
make: *** [./rules.mak:69:
microblazeel-softmmu/tests/headers/include/exec/user/abitypes.o] Error 1

^ this one looks legit, it's arch-specific, right?

$ make tests/headers/include/hw/net/lance.o
  CC      tests/headers/include/hw/net/lance.o
In file included from tests/headers/include/hw/net/lance.c:14:
./include/hw/net/lance.h:42:5: error: unknown type name ‘SysBusDevice’
     SysBusDevice parent_obj;
     ^~~~~~~~~~~~
make: *** [./rules.mak:69: tests/headers/include/hw/net/lance.o] Error 1

$ make tests/headers/include/hw/isa/vt82c686.o
  CC      tests/headers/include/hw/isa/vt82c686.o
In file included from tests/headers/include/hw/isa/vt82c686.c:14:
./include/hw/isa/vt82c686.h:13:27: error: unknown type name ‘qemu_irq’
                           qemu_irq sci_irq);
                           ^~~~~~~~
make: *** [./rules.mak:69: tests/headers/include/hw/isa/vt82c686.o]

Nice, I like it :)

The rule pattern is not obvious (in particular with arch-specific
targets), but it has probably always been like that.

Tested-by: Philippe Mathieu-Daudé <address@hidden>



reply via email to

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