Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1488704

Re: [PATCH 1/7] selftest: sync: basic tests for sw_sync framework

From Michael Ellerman <mpe@ellerman.id.au>
Newsgroups linux.kernel
Subject Re: [PATCH 1/7] selftest: sync: basic tests for sw_sync framework
Date 2016-09-22 11:50 +0200
Message-ID <sk8NI-4AG-33@gated-at.bofh.it> (permalink)
References <sjX5T-5Jq-9@gated-at.bofh.it> <sjX5T-5Jq-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Emilio López <emilio.lopez@collabora.co.uk> writes:

> These tests are based on the libsync test suite from Android.
> This commit lays the ground for future tests, as well as includes
> tests for a variety of basic allocation commands.

Hi Emilio,

Just a few comments on the Makefile.

> diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile
> new file mode 100644
> index 0000000..f67827f
> --- /dev/null
> +++ b/tools/testing/selftests/sync/Makefile
> @@ -0,0 +1,24 @@
> +CC = $(CROSS_COMPILE)gcc

lib.mk does that for you.

> +CFLAGS := -O2 -g -std=gnu89 -pthread -Wall -Wextra

It's more polite to just add to CFLAGS rather than defining it from
scratch. That way a user can add CFLAGS via setting them in the
environment.

ie. this would be:

CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra

or:

CFLAGS := -O2 -g -std=gnu89 -pthread -Wall -Wextra $(CFLAGS)


> +CFLAGS += -I../../../../include/uapi/

Please don't include the unprocessed uapi headers, they are not meant to
be directly included in userspace programs.

They even say so:

include/uapi/linux/types.h:#warning "Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders"

> +CFLAGS += -I../../../../include/

Please don't include the *kernel* headers, they're really not meant to
be used in userspace programs :)

> +CFLAGS += -I../../../../usr/include/

That is the correct place to get them from. They'll have been put there
by 'make headers_install'.

> +CFLAGS += -I../../../../drivers/dma-buf/

That's also a bit fishy.

> +LDFLAGS += -pthread
> +
> +TEST_PROGS = sync_test
> +
> +all: $(TEST_PROGS)
> +
> +include ../lib.mk
> +
> +SRC = sync_test.o sync.o

SRC would usually point to .c files, .o's would be in OBJS or something
similar. Though it's not that important obviously.

Just listing the .c files in SRC should work, make knows how to turn
them into .o's for you.

> +TESTS += sync_alloc.o

And similarly there.

So I think you could just use:

SRC := sync_test.c sync.c sync_alloc.c

Or if you actually just want to list all the .c files in the directory
then this would also work:

SRC := $(wildcard *.c)

> +sync_test: $(SRC) $(TESTS)
> +
> +.PHONY: clean

lib.mk did that for you.

> +
> +clean:
> +	$(RM) sync_test $(SRC) $(TESTS)

If you redefined SRC above to be the actual sources then you obviously
don't want to clean them, so here you would just use *.o.

cheers

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] Tests for sync infrastructure Emilio López <emilio.lopez@collabora.co.uk> - 2016-09-21 23:20 +0200
  [PATCH 3/7] selftest: sync: merge tests for sw_sync framework Emilio López <emilio.lopez@collabora.co.uk> - 2016-09-21 23:20 +0200
  [PATCH 5/7] selftest: sync: stress test for parallelism Emilio López <emilio.lopez@collabora.co.uk> - 2016-09-21 23:20 +0200
  [PATCH 1/7] selftest: sync: basic tests for sw_sync framework Emilio López <emilio.lopez@collabora.co.uk> - 2016-09-21 23:20 +0200
    Re: [PATCH 1/7] selftest: sync: basic tests for sw_sync framework Michael Ellerman <mpe@ellerman.id.au> - 2016-09-22 11:50 +0200
      Re: [PATCH 1/7] selftest: sync: basic tests for sw_sync framework Emilio López <emilio.lopez@collabora.co.uk> - 2016-09-22 16:30 +0200

csiph-web