qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] build-sys: generate tests/.gitignore
@ 2016-09-22 21:11 Marc-André Lureau
  2016-10-27 18:36 ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2016-09-22 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: eblake, peter.maydell, Marc-André Lureau

It's too easy to forget about updating the .gitignore, so this is an
attempt at generating it instead.

This approach assumes that the files to clean are the one to put in
the .gitignore.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
v2:
 - fix make check-clean
 - improve adding $(QEMU_IOTESTS_HELPERS-y) in cleanfiles (it needs a patsubst because tests/ is present 2 times)
 - use quiet-command
 - fix cleanfiles +=

 tests/Makefile.include | 26 +++++++++++++---
 tests/.gitignore       | 82 --------------------------------------------------
 2 files changed, 22 insertions(+), 86 deletions(-)
 delete mode 100644 tests/.gitignore

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 6052a38..cf81fd7 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -782,8 +782,21 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
 	@perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff -q $(SRC_PATH)/$*.err -
 	@diff -q $(SRC_PATH)/$*.exit $*.test.exit
 
-# Consolidated targets
+tests-cleanfiles = *.o
+tests-cleanfiles += .gitignore
+tests-cleanfiles += qht-bench$(EXESUF)
+tests-cleanfiles += qapi-schema/*.test.*
+tests-cleanfiles += test-qapi-event.[ch]
+tests-cleanfiles += test-qapi-types.[ch]
+tests-cleanfiles += test-qapi-visit.[ch]
+tests-cleanfiles += test-qmp-introspect.[ch]
+tests-cleanfiles += test-qmp-commands.h
+tests-cleanfiles += test-qmp-marshal.c
+tests-cleanfiles += $(subst tests/,,$(check-unit-y))
+tests-cleanfiles += $(subst tests/,,$(check-qtest-y))
+tests-cleanfiles += $(patsubst tests/%,%,$(QEMU_IOTESTS_HELPERS-y))
 
+# Consolidated targets
 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y))
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
@@ -792,14 +805,19 @@ check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-qapi-schema check-unit check-qtest
 check-clean:
 	$(MAKE) -C tests/tcg clean
-	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
-	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
-
+	(cd tests && rm -rf $(tests-cleanfiles))
 clean: check-clean
 
 # Build the help program automatically
 
 all: $(QEMU_IOTESTS_HELPERS-y)
 
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+$(SRC_PATH)/tests/.gitignore:
+	$(call quiet-command, echo "$(tests-cleanfiles)" | xargs -n1 | sort > $@, \
+	  " GEN $(@F)")
+Makefile: $(SRC_PATH)/tests/.gitignore
+endif
+
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
diff --git a/tests/.gitignore b/tests/.gitignore
deleted file mode 100644
index b4a9cfc..0000000
--- a/tests/.gitignore
+++ /dev/null
@@ -1,82 +0,0 @@
-check-qdict
-check-qfloat
-check-qint
-check-qjson
-check-qlist
-check-qnull
-check-qstring
-check-qom-interface
-check-qom-proplist
-qht-bench
-rcutorture
-test-aio
-test-base64
-test-bitops
-test-blockjob-txn
-test-clone-visitor
-test-coroutine
-test-crypto-afsplit
-test-crypto-block
-test-crypto-cipher
-test-crypto-hash
-test-crypto-ivgen
-test-crypto-pbkdf
-test-crypto-secret
-test-crypto-tlscredsx509
-test-crypto-tlscredsx509-work/
-test-crypto-tlscredsx509-certs/
-test-crypto-tlssession
-test-crypto-tlssession-work/
-test-crypto-tlssession-client/
-test-crypto-tlssession-server/
-test-crypto-xts
-test-cutils
-test-hbitmap
-test-int128
-test-iov
-test-io-channel-buffer
-test-io-channel-command
-test-io-channel-command.fifo
-test-io-channel-file
-test-io-channel-file.txt
-test-io-channel-socket
-test-io-channel-tls
-test-io-task
-test-logging
-test-mul64
-test-opts-visitor
-test-qapi-event.[ch]
-test-qapi-types.[ch]
-test-qapi-visit.[ch]
-test-qdev-global-props
-test-qemu-opts
-test-qdist
-test-qga
-test-qht
-test-qht-par
-test-qmp-commands
-test-qmp-commands.h
-test-qmp-event
-test-qmp-input-strict
-test-qmp-input-visitor
-test-qmp-introspect.[ch]
-test-qmp-marshal.c
-test-qmp-output-visitor
-test-rcu-list
-test-replication
-test-rfifolock
-test-string-input-visitor
-test-string-output-visitor
-test-thread-pool
-test-throttle
-test-timed-average
-test-visitor-serialization
-test-vmstate
-test-write-threshold
-test-x86-cpuid
-test-xbzrle
-test-netfilter
-test-filter-mirror
-test-filter-redirector
-*-test
-qapi-schema/*.test.*
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] build-sys: generate tests/.gitignore
  2016-09-22 21:11 [Qemu-devel] [PATCH v2] build-sys: generate tests/.gitignore Marc-André Lureau
@ 2016-10-27 18:36 ` Eric Blake
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-10-27 18:36 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: peter.maydell, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 3325 bytes --]

On 09/22/2016 04:11 PM, Marc-André Lureau wrote:
> It's too easy to forget about updating the .gitignore, so this is an
> attempt at generating it instead.
> 
> This approach assumes that the files to clean are the one to put in
> the .gitignore.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> v2:
>  - fix make check-clean
>  - improve adding $(QEMU_IOTESTS_HELPERS-y) in cleanfiles (it needs a patsubst because tests/ is present 2 times)
>  - use quiet-command
>  - fix cleanfiles +=
> 
>  tests/Makefile.include | 26 +++++++++++++---
>  tests/.gitignore       | 82 --------------------------------------------------
>  2 files changed, 22 insertions(+), 86 deletions(-)
>  delete mode 100644 tests/.gitignore
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 6052a38..cf81fd7 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -782,8 +782,21 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
>  	@perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff -q $(SRC_PATH)/$*.err -
>  	@diff -q $(SRC_PATH)/$*.exit $*.test.exit
>  
> -# Consolidated targets
> +tests-cleanfiles = *.o
> +tests-cleanfiles += .gitignore
> +tests-cleanfiles += qht-bench$(EXESUF)
> +tests-cleanfiles += qapi-schema/*.test.*
> +tests-cleanfiles += test-qapi-event.[ch]
> +tests-cleanfiles += test-qapi-types.[ch]
> +tests-cleanfiles += test-qapi-visit.[ch]
> +tests-cleanfiles += test-qmp-introspect.[ch]
> +tests-cleanfiles += test-qmp-commands.h
> +tests-cleanfiles += test-qmp-marshal.c
> +tests-cleanfiles += $(subst tests/,,$(check-unit-y))
> +tests-cleanfiles += $(subst tests/,,$(check-qtest-y))
> +tests-cleanfiles += $(patsubst tests/%,%,$(QEMU_IOTESTS_HELPERS-y))
>  
> +# Consolidated targets
>  .PHONY: check-qapi-schema check-qtest check-unit check check-clean
>  check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y))
>  check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
> @@ -792,14 +805,19 @@ check-block: $(patsubst %,check-%, $(check-block-y))
>  check: check-qapi-schema check-unit check-qtest
>  check-clean:
>  	$(MAKE) -C tests/tcg clean
> -	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
> -	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
> -
> +	(cd tests && rm -rf $(tests-cleanfiles))

Why the subshell?

>  clean: check-clean
>  
>  # Build the help program automatically
>  
>  all: $(QEMU_IOTESTS_HELPERS-y)
>  
> +ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
> +$(SRC_PATH)/tests/.gitignore:
> +	$(call quiet-command, echo "$(tests-cleanfiles)" | xargs -n1 | sort > $@, \
> +	  " GEN $(@F)")

Incorrect usage of $(call quiet-command), now that 0bdb12c7 has landed.

> +Makefile: $(SRC_PATH)/tests/.gitignore
> +endif
> +
>  -include $(wildcard tests/*.d)
>  -include $(wildcard tests/libqos/*.d)

Otherwise it appears to work, and looks like you've addressed many of my
v1 findings.  I still think that Paolo may be a better GNU make expert
to give a review on this, so I've cc'd him.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH v2] build-sys: generate tests/.gitignore
@ 2017-09-11 15:11 Marc-André Lureau
  0 siblings, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2017-09-11 15:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: eblake, thuth, armbru, Marc-André Lureau

tests/.gitignore is often out of date. Let's generate it based on the
files and directories to clean. Generate it by default only when doing
in-tree build.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 Makefile                   |  9 ++++-
 tests/.gitignore           | 97 ----------------------------------------------
 tests/Makefile.include     | 38 ++++++++++++++++--
 tests/migration/.gitignore |  2 -
 4 files changed, 42 insertions(+), 104 deletions(-)
 delete mode 100644 tests/.gitignore
 delete mode 100644 tests/migration/.gitignore


v2:
 - only generate when doing in-tree builds
 - fix wrong ignore of tests/qemu-iotests-quick.sh

diff --git a/Makefile b/Makefile
index 81447b1f08..2ccb98cd64 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR)
 # Before including a proper config-host.mak, assume we are in the source tree
 SRC_PATH=.
 
-UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-%
+UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-% gitignore
 
 # All following code might depend on configuration variables
 ifneq ($(wildcard config-host.mak),)
@@ -14,6 +14,13 @@ ifneq ($(wildcard config-host.mak),)
 all:
 include config-host.mak
 
+.PHONY: gitignore
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+ifeq ($(BUILD_DIR),$(SRC_PATH))
+all $(MAKECMDGOALS): gitignore
+endif
+endif
+
 # Check that we're not trying to do an out-of-tree build from
 # a tree that's been used for an in-tree build.
 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
diff --git a/tests/.gitignore b/tests/.gitignore
deleted file mode 100644
index fed0189a5a..0000000000
--- a/tests/.gitignore
+++ /dev/null
@@ -1,97 +0,0 @@
-atomic_add-bench
-benchmark-crypto-cipher
-benchmark-crypto-hash
-benchmark-crypto-hmac
-check-qdict
-check-qnum
-check-qjson
-check-qlist
-check-qnull
-check-qstring
-check-qom-interface
-check-qom-proplist
-qht-bench
-rcutorture
-test-aio
-test-aio-multithread
-test-arm-mptimer
-test-base64
-test-bitops
-test-bitcnt
-test-blockjob
-test-blockjob-txn
-test-bufferiszero
-test-char
-test-clone-visitor
-test-coroutine
-test-crypto-afsplit
-test-crypto-block
-test-crypto-cipher
-test-crypto-hash
-test-crypto-hmac
-test-crypto-ivgen
-test-crypto-pbkdf
-test-crypto-secret
-test-crypto-tlscredsx509
-test-crypto-tlscredsx509-work/
-test-crypto-tlscredsx509-certs/
-test-crypto-tlssession
-test-crypto-tlssession-work/
-test-crypto-tlssession-client/
-test-crypto-tlssession-server/
-test-crypto-xts
-test-cutils
-test-hbitmap
-test-hmp
-test-int128
-test-iov
-test-io-channel-buffer
-test-io-channel-command
-test-io-channel-command.fifo
-test-io-channel-file
-test-io-channel-file.txt
-test-io-channel-socket
-test-io-channel-tls
-test-io-task
-test-keyval
-test-logging
-test-mul64
-test-opts-visitor
-test-qapi-event.[ch]
-test-qapi-types.[ch]
-test-qapi-util
-test-qapi-visit.[ch]
-test-qdev-global-props
-test-qemu-opts
-test-qdist
-test-qga
-test-qht
-test-qht-par
-test-qmp-commands
-test-qmp-commands.h
-test-qmp-event
-test-qobject-input-strict
-test-qobject-input-visitor
-test-qmp-introspect.[ch]
-test-qmp-marshal.c
-test-qobject-output-visitor
-test-rcu-list
-test-replication
-test-shift128
-test-string-input-visitor
-test-string-output-visitor
-test-thread-pool
-test-throttle
-test-timed-average
-test-uuid
-test-visitor-serialization
-test-vmstate
-test-write-threshold
-test-x86-cpuid
-test-x86-cpuid-compat
-test-xbzrle
-test-netfilter
-test-filter-mirror
-test-filter-redirector
-*-test
-qapi-schema/*.test.*
diff --git a/tests/Makefile.include b/tests/Makefile.include
index f08b7418f0..29d8e4ebf4 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -901,8 +901,33 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
 check-tests/qapi-schema/doc-good.texi: tests/qapi-schema/doc-good.test.texi
 	@diff -q $(SRC_PATH)/tests/qapi-schema/doc-good.texi $<
 
-# Consolidated targets
+tests-cleanfiles = *.o
+tests-cleanfiles += .gitignore
+tests-cleanfiles += qht-bench$(EXESUF)
+tests-cleanfiles += qapi-schema/*.test.*
+tests-cleanfiles += test-qapi-event.[ch]
+tests-cleanfiles += test-qapi-types.[ch]
+tests-cleanfiles += test-qapi-visit.[ch]
+tests-cleanfiles += test-qmp-introspect.[ch]
+tests-cleanfiles += test-qmp-commands.h
+tests-cleanfiles += test-qmp-marshal.c
+tests-cleanfiles += $(subst tests/,,$(check-unit-y))
+tests-cleanfiles += $(subst tests/,,$(check-speed-y))
+tests-cleanfiles += $(subst tests/,,$(check-qtest-y))
+tests-cleanfiles += $(subst tests/,,$(QEMU_IOTESTS_HELPERS-y))
+tests-cleanfiles += migration/initrd-stress.img
+tests-cleanfiles += migration/stress$(EXESUF)
+tests-cleanfiles += atomic_add-bench$(EXESUF)
+tests-cleanfiles += test-io-channel-file.txt
+tests-cleanfiles += test-io-channel-command.fifo
+
+tests-cleandirs += test-crypto-tlscredsx509-certs/
+tests-cleandirs += test-crypto-tlscredsx509-work/
+tests-cleandirs += test-crypto-tlssession-client/
+tests-cleandirs += test-crypto-tlssession-server/
+tests-cleandirs += test-crypto-tlssession-work/
 
+# Consolidated targets
 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y)) check-tests/qapi-schema/doc-good.texi
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
@@ -912,15 +937,20 @@ check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-qapi-schema check-unit check-qtest
 check-clean:
 	$(MAKE) -C tests/tcg clean
-	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
-	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
-
+	rm -f $(addprefix tests/, $(tests-cleanfiles))
+	rm -rf $(addprefix tests/, $(tests-cleandirs))
 clean: check-clean
 
 # Build the help program automatically
 
 all: $(QEMU_IOTESTS_HELPERS-y)
 
+$(SRC_PATH)/tests/.gitignore: $(MAKEFILE_LIST)
+	$(call quiet-command, echo "$(tests-cleanfiles)" "$(tests-cleandirs)" | \
+		xargs -n1 | sort | uniq | sed -e s:^:/: > $@,"GEN","$(@F)")
+
+gitignore: $(SRC_PATH)/tests/.gitignore
+
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
 
diff --git a/tests/migration/.gitignore b/tests/migration/.gitignore
deleted file mode 100644
index 84f37552e4..0000000000
--- a/tests/migration/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-initrd-stress.img
-stress
-- 
2.14.1.146.gd35faa819

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-11 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 21:11 [Qemu-devel] [PATCH v2] build-sys: generate tests/.gitignore Marc-André Lureau
2016-10-27 18:36 ` Eric Blake
  -- strict thread matches above, loose matches on Subject: below --
2017-09-11 15:11 Marc-André Lureau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).