All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [RFC v4 5/7] tests: New make target check-source
Date: Fri, 24 May 2019 07:49:39 +0200	[thread overview]
Message-ID: <b7370040-3076-5ff5-3b51-b96b0d84184f@redhat.com> (raw)
In-Reply-To: <20190523081538.2291-6-armbru@redhat.com>

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 <armbru@redhat.com>
> ---
[...]>
> 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é <philmd@redhat.com>


  parent reply	other threads:[~2019-05-24  5:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  8:15 [Qemu-devel] [RFC v4 0/7] Baby steps towards saner headers Markus Armbruster
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 1/7] Makefile: Remove code to smooth transition to config.status Markus Armbruster
2019-05-23 13:54   ` Richard Henderson
2019-05-24  5:15   ` Philippe Mathieu-Daudé
2019-05-24 11:50     ` Markus Armbruster
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 2/7] Makefile: Drop bogus cleaning of $(ALL_SUBDIRS)/qemu-options.def Markus Armbruster
2019-05-23 13:56   ` Richard Henderson
2019-05-24  5:17   ` Philippe Mathieu-Daudé
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 3/7] Makefile: Rename targets for make recursion Markus Armbruster
2019-05-23 14:10   ` Richard Henderson
2019-05-24  5:28   ` Philippe Mathieu-Daudé
2019-05-24 12:34     ` Markus Armbruster
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 4/7] Makefile: Reuse all's recursion machinery for clean and install Markus Armbruster
2019-05-23 14:14   ` Richard Henderson
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 5/7] tests: New make target check-source Markus Armbruster
2019-05-23 16:51   ` Paolo Bonzini
2019-05-23 19:57     ` Markus Armbruster
2019-05-24 16:25       ` Paolo Bonzini
2019-05-27  5:10         ` Markus Armbruster
2019-05-27  9:58           ` Paolo Bonzini
2019-05-24  5:49   ` Philippe Mathieu-Daudé [this message]
2019-05-24 12:36     ` Markus Armbruster
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 6/7] tests: Don't limit check-headers to include/ Markus Armbruster
2019-05-24  7:24   ` Thomas Huth
2019-05-24  7:32     ` Philippe Mathieu-Daudé
2019-05-24 11:52     ` Markus Armbruster
2019-05-24  9:11   ` Peter Maydell
2019-05-24 12:25     ` Markus Armbruster
2019-05-24 12:29       ` Peter Maydell
2019-05-23  8:15 ` [Qemu-devel] [RFC v4 7/7] tests: Make check-source cover generated headers Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7370040-3076-5ff5-3b51-b96b0d84184f@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.