diff mbox

[2/3] Btrfs-progs: move test tools to tests/ subdir

Message ID 1370992519-21369-3-git-send-email-sandeen@redhat.com (mailing list archive)
State Under Review, archived
Headers show

Commit Message

Eric Sandeen June 11, 2013, 11:15 p.m. UTC
Move test tools to tests/

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 Makefile                                           |   23 +--------
 tests/Makefile                                     |   49 ++++++++++++++++++++
 .../btrfs-corrupt-block.c                          |    0
 dir-test.c => tests/dir-test.c                     |    0
 ioctl-test.c => tests/ioctl-test.c                 |    0
 quick-test.c => tests/quick-test.c                 |    0
 random-test.c => tests/random-test.c               |    0
 send-test.c => tests/send-test.c                   |    0
 8 files changed, 52 insertions(+), 20 deletions(-)
 create mode 100644 tests/Makefile
 rename btrfs-corrupt-block.c => tests/btrfs-corrupt-block.c (100%)
 rename dir-test.c => tests/dir-test.c (100%)
 rename ioctl-test.c => tests/ioctl-test.c (100%)
 rename quick-test.c => tests/quick-test.c (100%)
 rename random-test.c => tests/random-test.c (100%)
 rename send-test.c => tests/send-test.c (100%)

diff --git a/btrfs-corrupt-block.c b/tests/btrfs-corrupt-block.c
similarity index 100%
rename from btrfs-corrupt-block.c
rename to tests/btrfs-corrupt-block.c
diff --git a/dir-test.c b/tests/dir-test.c
similarity index 100%
rename from dir-test.c
rename to tests/dir-test.c
diff --git a/ioctl-test.c b/tests/ioctl-test.c
similarity index 100%
rename from ioctl-test.c
rename to tests/ioctl-test.c
diff --git a/quick-test.c b/tests/quick-test.c
similarity index 100%
rename from quick-test.c
rename to tests/quick-test.c
diff --git a/random-test.c b/tests/random-test.c
similarity index 100%
rename from random-test.c
rename to tests/random-test.c
diff --git a/send-test.c b/tests/send-test.c
similarity index 100%
rename from send-test.c
rename to tests/send-test.c

Comments

David Sterba Sept. 2, 2013, 2:43 p.m. UTC | #1
On Tue, Jun 11, 2013 at 06:15:18PM -0500, Eric Sandeen wrote:
> Move test tools to tests/

>  rename btrfs-corrupt-block.c => tests/btrfs-corrupt-block.c (100%)

IMO this is not a test by itself, so it should stay in the toplevel dir.

> --- /dev/null
> +++ b/tests/Makefile
> @@ -0,0 +1,49 @@
eg.
TOPLEVEL = ..

> +CFLAGS += -I..
CFLAGS += -I$(TOPLEVEL)

> +
> +objects := $(addprefix ../, $(objects))

etc. s/../$(TOPLEVEL)

> +
> +lib_LIBS = -lblkid -luuid
> +LIBS = $(lib_LIBS) $(addprefix ../, $(libs_static))
> +
> +# These last 2 don't actually build anymore
> +progs = btrfs-corrupt-block ioctl-test quick-test send-test # random-test dir-test
> +
> +libs_static = libbtrfs.a
> +libs = $(addprefix ../, $(libs_static))
> +headers = $(libbtrfs_headers)
> +

the default rule belongs here, ie
all: $(progs)

Otherwise 'make' in the tests/ subdir will try to execute the first .c
file it needs to build.

> +.c.o:
> +	$(Q)$(check) $<
> +	@echo "    [CC]     $@"
> +	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<

Until now we've had only man/ and it does not compile anything, now
tests/ duplicate the .c.o: rule. The rules are not exported to subdirs,
we need either to duplicate it in every subdir/Makefile or have
something like Makefile.rules or builddefs, and each Makefile has to
keep track back to the toplevel dir. We want to be able to 'make tests'
but also just 'make' in the tests/ directory -- which does not work
right now.

> +
> +all: $(progs)
> +

> +clean :
> +	$(Q)rm -f *.o .*.d $(progs)
> +
> +-include .*.d

This should probably look like the update in the toplevel makefile:

ifneq ($(MAKECMDGOALS),clean)
-include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
endif

and for the clean: rule a minor update: the .d files do not start with '.'.
(Both introduced in "btrfs-progs: Fix automatic prerequisite generation")

Let's start with moving just the tests, see how the makefiles work and
then proceed with cmds/ and the shared kernel files.


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Sandeen Sept. 3, 2013, 8:53 p.m. UTC | #2
On 9/2/13 9:43 AM, David Sterba wrote:
> On Tue, Jun 11, 2013 at 06:15:18PM -0500, Eric Sandeen wrote:
>> Move test tools to tests/
> 
>>  rename btrfs-corrupt-block.c => tests/btrfs-corrupt-block.c (100%)
> 
> IMO this is not a test by itself, so it should stay in the toplevel dir.

Hum, well, it has a main() - ok, not a test, but a tool used for testing?
Ok, fine.  Maybe misc/ someday ;)

> 
>> --- /dev/null
>> +++ b/tests/Makefile
>> @@ -0,0 +1,49 @@
> eg.
> TOPLEVEL = ..
> 
>> +CFLAGS += -I..
> CFLAGS += -I$(TOPLEVEL)
> 
>> +
>> +objects := $(addprefix ../, $(objects))
> 
> etc. s/../$(TOPLEVEL)

Ok, that's probably good.

>> +
>> +lib_LIBS = -lblkid -luuid
>> +LIBS = $(lib_LIBS) $(addprefix ../, $(libs_static))
>> +
>> +# These last 2 don't actually build anymore
>> +progs = btrfs-corrupt-block ioctl-test quick-test send-test # random-test dir-test
>> +
>> +libs_static = libbtrfs.a
>> +libs = $(addprefix ../, $(libs_static))
>> +headers = $(libbtrfs_headers)
>> +
> 
> the default rule belongs here, ie
> all: $(progs)
> 
> Otherwise 'make' in the tests/ subdir will try to execute the first .c
> file it needs to build.
> 
>> +.c.o:
>> +	$(Q)$(check) $<
>> +	@echo "    [CC]     $@"
>> +	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
> 
> Until now we've had only man/ and it does not compile anything, now
> tests/ duplicate the .c.o: rule. The rules are not exported to subdirs,
> we need either to duplicate it in every subdir/Makefile or have
> something like Makefile.rules or builddefs, and each Makefile has to
> keep track back to the toplevel dir. We want to be able to 'make tests'
> but also just 'make' in the tests/ directory -- which does not work
> right now.

*nod* ok.  It's been a while since I did make hacking, sorry.

>> +
>> +all: $(progs)
>> +
> 
>> +clean :
>> +	$(Q)rm -f *.o .*.d $(progs)
>> +
>> +-include .*.d
> 
> This should probably look like the update in the toplevel makefile:
> 
> ifneq ($(MAKECMDGOALS),clean)
> -include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
> endif
> 
> and for the clean: rule a minor update: the .d files do not start with '.'.
> (Both introduced in "btrfs-progs: Fix automatic prerequisite generation")
> 
> Let's start with moving just the tests, see how the makefiles work and
> then proceed with cmds/ and the shared kernel files.

Sounds like a plan.

thanks for the review,
-Eric

> 
> david
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 5411ad9..01b71ec 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@  btrfs_convert_libs = -lext2fs -lcom_err
 btrfs_image_libs = -lpthread
 btrfs_fragment_libs = -lgd -lpng -ljpeg -lfreetype
 
-SUBDIRS = man
+SUBDIRS = man tests
 BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
 INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
 CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
@@ -102,7 +102,7 @@  endif
 
 all: version.h $(progs) $(BUILDDIRS)
 $(SUBDIRS): $(BUILDDIRS)
-$(BUILDDIRS):
+$(BUILDDIRS): $(libs)
 	@echo "Making all in $(patsubst build-%,%,$@)"
 	$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
 
@@ -178,30 +178,13 @@  btrfstune: $(objects) $(libs) btrfstune.o
 	@echo "    [LD]     $@"
 	$(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
 
-dir-test: $(objects) $(libs) dir-test.o
-	@echo "    [LD]     $@"
-	$(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
-
-quick-test: $(objects) $(libs) quick-test.o
-	@echo "    [LD]     $@"
-	$(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
-
-ioctl-test: $(objects) $(libs) ioctl-test.o
-	@echo "    [LD]     $@"
-	$(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
-
-send-test: $(objects) $(libs) send-test.o
-	@echo "    [LD]     $@"
-	$(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread
-
 manpages:
 	$(Q)$(MAKE) $(MAKEOPTS) -C man
 
 clean: $(CLEANDIRS)
 	@echo "Cleaning"
 	$(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \
-	      btrfs-zero-log btrfstune dir-test ioctl-test quick-test send-test btrfsck \
-	      btrfs.static mkfs.btrfs.static btrfs-calc-size \
+	      btrfs-zero-log btrfstune btrfsck btrfs.static mkfs.btrfs.static btrfs-calc-size \
 	      version.h \
 	      $(libs) $(lib_links)
 
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..198de0d
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,49 @@ 
+CFLAGS += -I..
+
+objects := $(addprefix ../, $(objects))
+
+lib_LIBS = -lblkid -luuid
+LIBS = $(lib_LIBS) $(addprefix ../, $(libs_static))
+
+# These last 2 don't actually build anymore
+progs = btrfs-corrupt-block ioctl-test quick-test send-test # random-test dir-test
+
+libs_static = libbtrfs.a
+libs = $(addprefix ../, $(libs_static))
+headers = $(libbtrfs_headers)
+
+.c.o:
+	$(Q)$(check) $<
+	@echo "    [CC]     $@"
+	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
+
+all: $(progs)
+
+btrfs-corrupt-block: $(objects) $(libs) btrfs-corrupt-block.o
+	@echo "    [LD]     $@"
+	$(Q)$(CC) $(CFLAGS) -o btrfs-corrupt-block $(objects) btrfs-corrupt-block.o $(LDFLAGS) $(LIBS)
+
+dir-test: $(objects) $(libs) dir-test.o
+	@echo "    [LD]     $@"
+	$(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
+
+ioctl-test: $(objects) $(libs) ioctl-test.o
+	@echo "    [LD]     $@"
+	$(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
+
+quick-test: $(objects) $(libs) quick-test.o
+	@echo "    [LD]     $@"
+	$(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
+
+random-test: $(objects) $(libs) random-test.o
+	@echo "    [LD]     $@"
+	$(Q)$(CC) $(CFLAGS) -o random-test $(objects) random-test.o $(LDFLAGS) $(LIBS)
+
+send-test: $(objects) $(libs) send-test.o
+	@echo "    [LD]     $@"
+	$(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread
+
+clean :
+	$(Q)rm -f *.o .*.d $(progs)
+
+-include .*.d