2009/10/25 Jiří Paleček <[email protected]>:
> On Sun, 18 Oct 2009 20:22:00 +0200, Subrata Modak
> <[email protected]> wrote:
>
>> Jiri,
>>
>> Any further thoughts on this ?
>
> Yes, see the attachment.
>
> I created the directories for the different tests (rt_sigtimedwait,
> sigwaitinfo etc.), but to avoid copy-pasting the code, they share the same
> source. Please, tell me if that is OK.

I'm a bit confused by let me help analyze the Makefile and provide critiques:

The basic template for any Makefile now, is as follows:

# LICENSING TORT, e.g. GPLv2 License, etc.

# <TOP-SRCDIR DEFINITION>

# <PRE-INCLUDE>

# <ADDITIONAL MAKE LOGIC GOES HERE>

# <POST-INCLUDE>

The description of these components is as follows:

===========================================================
TOP-SRCDIR DEFINITION
===========================================================
top_srcdir ?= <relative path from current Makefile to the top of the
source tree>

Example 1 (say, from testcases/realtime):

top_srcdir ?= ../..

Example 2 (say, from lib):

top_srcdir ?= ..

The ?= is important, because this value can be redefined at ANY time
-- I've been considering making this assignment operator := though,
because it should be set just once per Makefile, and isn't being
exported anymore (it was a design mistake I made in the beginning that
Mike F. corrected me because I wasn't adhering to correct autotools
variable conventions).

===========================================================
PRE-INCLUDE
===========================================================
This is important, and may lead to potential confusion.

env_pre.mk is used for most includes outside of the testcases portion
of the tree. This has a minimal set of assumptions and dependent
targets, because it's designed to work with doc, lib, tools, and
utils. This can also be used in `trunk' situations (discussed below)
where no C-files need to be compiled, and/or linked in with libltp.a.
This also adds $(abs_top_srcdir)/include to the CPPFLAGS so you don't
need to add this to 300+ Makefiles (like it was before :)...].

testcases.mk is used for rest of the cases under testcases. It does
the following for you:
1. Everything in env_pre.mk.
2. Adds dependencies for libltp.a.
3. Adds -lltp to LDLIBS.
4. Adds dependencies for testcases/kernel/include/syscall_numbers.h
5. Adds an optional hook for the tst_res apps in tools/apicmds so you
can run your tests out of the local directory before install [assuming
they're coded properly :)...].

All of the additional steps are done for developer convenience, so
that running make install from testcases/kernel/syscalls/open doesn't
require that I manually go into lib/ and testcases/kernel/include
beforehand and run a make all, and have to duplicate a lot of
unnecessary logic in the Makefiles.

===========================================================
ADDITIONAL MAKE LOGIC GOES HERE
===========================================================

Whatever you want to put in here that isn't provided with the defaults
in env_post.mk, generic_leaf_target.inc, or generic_trunk_target.inc,
so feel free to `use your imagination' as to whatever you may put in
here, but the only cases that you should have to deal with are:

1. Multiple C files / objects -> one or more executables.
2. Items without implicit rule mappings, e.g. .c -> .o.

===========================================================
POST-INCLUDE:
===========================================================

- For all directory traversing Makefiles you include the `trunk
target' Makefile:

include $(top_srcdir)/include/mk/generic_trunk_target.mk

- For all non-directory traversing Makefiles, you include the `leaf
target' Makefile.

include $(top_srcdir)/include/mk/generic_leaf_target.mk

===========================================================

Now, to critique your proposed Makefiles...

testcases/kernel/syscalls/rt_sigtimedwait/Makefile:

+CFLAGS += -I../../../../include -Wall -O2 -DTEST_RT_SIGTIMEDWAIT
+LDLIBS += -L../../../../lib -lltp
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS)) rt_sigtimedwait01
+
+all: $(TARGETS)
+
+rt_sigtimedwait01.o: ../sigwaitinfo/sigwaitinfo01.c
+       $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $^
+
+install:
+       @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+       rm -f $(TARGETS)

Given the above explanation, I would write this like the following
(minus the licensing tort, and with improper indented vars -- bloody
GMail :(...):

=============================================
top_srcdir ?= ../../../..

include $(top_srcdir)/include/mk/testcases.mk

# NOTE: Placement doesn't matter, but for readability and consistency
it should go here.
CPPFLAGS += -DTEST_RT_SIGTIMEDWAIT

# NOTE: Placement for this Make target doesn't matter... just so long
as it's defined in the Makefile.
rt_sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
        $(COMPILE.o) $(OUTPUT_OPTION) $^

# NOTE: Don't modify MAKE_TARGETS here because it isn't set yet, and
the default is to pick up all existing C files in the
# current directory and make them into single-source executables, e.g.
# sigwaitinfo01.c -> sigwaitinfo01.o -> sigwaitinfo01 ;)...

include $(top_srcdir)/include/mk/generic_leaf_target.mk

MAKE_TARGETS += rt_sigtimedwait01
=============================================

Similar logic would be applied to your other Makefile, minus the
CPPFLAGS assignment.

Please note that your binary is no longer linked into
$(abs_top_builddir)/testcases/bin -- it's instead install(1)'ed
directly into $(DESTDIR)/$(prefix)/testcases/bin . This was done to
facilitate proper installation by using the correct mode, and also to
avoid broken/hacky symlinking operations.

Hope that helps describe things a bit better... let me know if I
should add this to a README or something...

Cheers!
-Garrett

>> On Tue, 2009-10-13 at 17:43 +0530, Subrata Modak wrote:
>>>
>>> Hey Jiri,
>>>
>>> On Tue, 2009-09-29 at 16:28 +0200, Jiří Paleček wrote:
>>> > Hello,
>>> >
>>> > I've decided to create a test for the rt_sigwaitinfo syscall. There are
>>> > other functions with similar interface (defined by POSIX) in libc -
>>> > particularly sigwait, sigtimedwait and sigwaitinfo. The rt_sigwaitinfo
>>>
>>> The sigwait, sigtimedwait and sigwaitinfo testcases are not in LTP.
>>>
>>> > test could easily tests these too, so I wonder whether we want to test
>>> > these too, and if yes, whether these tests can be located in the same
>>> > executable.
>>>
>>> If you already have the logic to write the above tests, then please
>>> create separate tests for sigwait, sigtimedwait and sigwaitinfo
>>> (separate directories as well), and separate for rt_sigwaitinfo syscall.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to