msgctl{08, 09, 10, 11}: cleanup
PATCH 1/1 msgctl{08, 09, 10, 11}: cleanup
In reply to a message not in the archive* Moved common functions, definitions to libmsgctl.h, libmsgctl.c.
* Changed tst_* in children with printf + exit (or return).
* Some cleanup.
--- testcases/kernel/syscalls/ipc/msgctl/Makefile | 9 + testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c | 148 +++++++++++++ testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h | 39 ++++ testcases/kernel/syscalls/ipc/msgctl/msgctl08.c | 201 ++++-------------- testcases/kernel/syscalls/ipc/msgctl/msgctl09.c | 252 ++++----------------- testcases/kernel/syscalls/ipc/msgctl/msgctl10.c | 196 ++++-------------- testcases/kernel/syscalls/ipc/msgctl/msgctl11.c | 245 ++++----------------- 7 files changed, 369 insertions(+), 721 deletions(-) create mode 100644 testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c create mode 100644 testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h
testcases/kernel/syscalls/ipc/msgctl/Makefile +9 -0
@@ -18,6 +18,15 @@ top_srcdir ?= ../../../../.. +FILTER_OUT_MAKE_TARGETS := libmsgctl + include $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc include $(top_srcdir)/include/mk/generic_leaf_target.mk + +SRCS ?= $(wildcard $(abs_srcdir)/*.c) +OBJS := $(notdir $(patsubst %.c,%.o,$(SRCS))) +.INTERMEDIATE: $(OBJS) + +$(MAKE_TARGETS): %: %.o libmsgctl.o +libmsgctl.o: libmsgctl.h
testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c new file +148 -0
148 lines not on this page · raw message
testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (c) International Business Machines Corp., 2002 +* Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef __LIBMSGCTL_H__ +#define __LIBMSGCTL_H__ + +#define FAIL 1 +#define PASS 0 + +struct mbuffer { +long type; +struct { +char len; +char pbytes[99 ]; + } data; +}; + +int doreader (long key,int tid,long type,int child,int nreps); +int dowriter (long key,int tid,long type,int child,int nreps); +int fill_buffer (char *buf,char val,int size); +int verify (char *buf,char val,int size,int child); + +#endif /*__LIBMSGCTL_H__ */
testcases/kernel/syscalls/ipc/msgctl/msgctl08.c +41 -160
302 lines not on this page · raw message
testcases/kernel/syscalls/ipc/msgctl/msgctl09.c +48 -204
395 lines not on this page · raw message
testcases/kernel/syscalls/ipc/msgctl/msgctl10.c +38 -158
294 lines not on this page · raw message
testcases/kernel/syscalls/ipc/msgctl/msgctl11.c +46 -199
378 lines not on this page · raw message
Signature · 13 lines
1.7.1 ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c
Quoted 23 lines
testcases/kernel/syscalls/ipc/msgctl/Makefile +9
-0@@ -18,6 +18,15 @@ top_srcdir ?= ../../../../.. +FILTER_OUT_MAKE_TARGETS := libmsgctl + include $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc include $(top_srcdir)/include/mk/generic_leaf_target.mk + +SRCS ?= $(wildcard $(abs_srcdir)/*.c) +OBJS := $(notdir $(patsubst %.c,%.o,$(SRCS))) +.INTERMEDIATE: $(OBJS) + +$(MAKE_TARGETS): %: %.o libmsgctl.o +libmsgctl.o: libmsgctl.htestcases/kernel/syscalls/ipc/msgctl/libmsgctl.c new file +0
-0
This is too hacky what about building .a library instead as it's done in testcases/kernel/mem/lib ?
I've looked into the lib.mk and it looks like you don't even have to put the lib in the separate directory if you set LIBSRC in the corresponding Makefile.
I should really make some time to write more documentation for the most common build system usages....
testcases/kernel/syscalls/ipc/msgctl/msgctl08.c line 57
Quoted 12 lines
testcases/kernel/syscalls/ipc/msgctl/msgctl08.c +1
-0@@ -51,6 +51,7 @@#include "test.h" #include "usctest.h" #include "ipcmsg.h" +#include "libmsgctl.h" void setup ();void cleanup ();
Can you add void to all functions that take no parameters? (Otherwise the compiler thinks that they take unspecified number of integer parameters...)
testcases/kernel/syscalls/ipc/msgctl/msgctl08.c void cleanup(); · line 63
Quoted 3 lines
testcases/kernel/syscalls/ipc/msgctl/msgctl08.c +0
-0@@ -61,38 +62,22 @@ void cleanup();char *TCID ="msgctl08" ;/* Test program identifier. */ int TST_TOTAL =1 ;/* Total number of test cases. */
Can you please also remove useless comments as:
/* Test program identifier. */
/* Total number of test cases. */
/*
* * * * These globals must be defined in the test.
* * * */
/*--------------------------------------------------------------------*/
And similar?
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 66 lines
Quoted 26 lines
testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c
Quoted 23 lines
testcases/kernel/syscalls/ipc/msgctl/Makefile +9
-0@@ -18,6 +18,15 @@ top_srcdir ?= ../../../../.. +FILTER_OUT_MAKE_TARGETS := libmsgctl + include $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc include $(top_srcdir)/include/mk/generic_leaf_target.mk + +SRCS ?= $(wildcard $(abs_srcdir)/*.c) +OBJS := $(notdir $(patsubst %.c,%.o,$(SRCS))) +.INTERMEDIATE: $(OBJS) + +$(MAKE_TARGETS): %: %.o libmsgctl.o +libmsgctl.o: libmsgctl.htestcases/kernel/syscalls/ipc/msgctl/libmsgctl.c new file +0
-0This is too hacky what about building .a library instead as it's done in testcases/kernel/mem/lib ?
Quoted 3 lines
I've looked into the lib.mk and it looks like you don't even have to put the lib in the separate directory if you set LIBSRC in the corresponding
Makefile.Cyril, could you show an example of doing this (placing test case sources and static libraries sources in the same directory), please?
I tried to do what you said but couldn't manage it :(
I used this
Makefile:
top_srcdir?= ../../../../..LIBSRCS := $(abs_srcdir)/libmsgctl.c
INTERNAL_LIB:= libmsgctl.ainclude $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc
include $(top_srcdir)/include/mk/generic_leaf_target.mk include $(top_srcdir)/include/mk/lib.mkAnd got error:
../../../../../include/mk/lib.mk:66: warning: overriding commands for target `../lib/libipc.a'/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl/../Makefile.inc:34:
warning: ignoring old commands for target `../lib/libipc.a'
make: Circular ../lib/libipc.a <- ../lib/libipc.a dependency dropped.if [ -z "../lib" ] ; then \ echo "Cowardly refusing to create empty archive"; \ exit 1; \ fiar -rc "../lib/libipc.a" ../lib
ar: ../lib/libipc.a: Error reading ../lib: Is a directory
make: *** [../lib/libipc.a] Error 1And I think that I found an another issue we should overcome - lib.mk defines
MAKE_TARGETS:
MAKE_TARGETS:= $(LIB)
Quoted 8 lines
generic_leaf_target.mk also does it.
So It should not be trivial to include both files (lib.mk and generic_leaf_target.mk) into one
Makefile.
I suppose that in that case we have to implicitly defineMAKE_TARGETSin ourMakefile.Not good :(
I will have a look, stay tuned.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 53 lines
Quoted 26 lines
testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c
Quoted 23 lines
testcases/kernel/syscalls/ipc/msgctl/Makefile +9
-0@@ -18,6 +18,15 @@ top_srcdir ?= ../../../../.. +FILTER_OUT_MAKE_TARGETS := libmsgctl + include $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc include $(top_srcdir)/include/mk/generic_leaf_target.mk + +SRCS ?= $(wildcard $(abs_srcdir)/*.c) +OBJS := $(notdir $(patsubst %.c,%.o,$(SRCS))) +.INTERMEDIATE: $(OBJS) + +$(MAKE_TARGETS): %: %.o libmsgctl.o +libmsgctl.o: libmsgctl.htestcases/kernel/syscalls/ipc/msgctl/libmsgctl.c new file +0
-0This is too hacky what about building .a library instead as it's done in testcases/kernel/mem/lib ?
Quoted 3 lines
I've looked into the lib.mk and it looks like you don't even have to put the lib in the separate directory if you set LIBSRC in the corresponding
Makefile.Cyril, could you show an example of doing this (placing test case sources and static libraries sources in the same directory), please?
I tried to do what you said but couldn't manage it :(
I used this
Makefile:
top_srcdir?= ../../../../..LIBSRCS := $(abs_srcdir)/libmsgctl.c
INTERNAL_LIB:= libmsgctl.ainclude $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc
include $(top_srcdir)/include/mk/generic_leaf_target.mk include $(top_srcdir)/include/mk/lib.mkAnd got error:
../../../../../include/mk/lib.mk:66: warning: overriding commands for target `../lib/libipc.a'/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl/../Makefile.inc:34:
warning: ignoring old commands for target `../lib/libipc.a'
make: Circular ../lib/libipc.a <- ../lib/libipc.a dependency dropped.
Quoted 7 lines
if [ -z "../lib" ] ; then \ echo "Cowardly refusing to create empty archive"; \ exit 1; \ fiar -rc "../lib/libipc.a" ../lib
ar: ../lib/libipc.a: Error reading ../lib: Is a directory
make: *** [../lib/libipc.a] Error 1
Ah, there is the include $(abs_srcdir)/../Makefile.inc that sets LIB to ../lib/libipc.a which breaks the lib.mk as there now there are two rules for making the library. One that runs make in ../lib/ from the Makefile.inc and second in lib.mk. Renaming the LIB to LIBIPC in Makefile.inc fixes this one.
Quoted 11 lines
And I think that I found an another issue we should overcome - lib.mk defines
MAKE_TARGETS:
MAKE_TARGETS:= $(LIB)generic_leaf_target.mk also does it.
So It should not be trivial to include both files (lib.mk and generic_leaf_target.mk) into one
Makefile.
I suppose that in that case we have to implicitly defineMAKE_TARGETSin ourMakefile.
Now this one is more complicated, but solvable.
First of all we need to change the part in lib.mk to
MAKE_TARGETS += $(LIB)
Then define MAKE_TARGETS explicitly in the Makefile (we need that anyway for lib: tests dependency) and add LDFLAGS and LDLIBS. The full Makefile looks like:
top_srcdir ?= ../../../../..
include $(top_srcdir)/include/mk/testcases.mk
LIBSRCS := libmsgctl.cINTERNAL_LIB := libmsgctl.aMAKE_TARGETS := $(patsubst %.c,%,$(wildcard msgctl??.c))
$(MAKE_TARGETS): $(INTERNAL_LIB)
LDFLAGS += -L$(abs_builddir)
LDLIBS += -lmsgctl
include $(abs_srcdir)/../Makefile.inc
include $(top_srcdir)/include/mk/lib.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
See also attached patch with all the changes and check if that works for you. If so I will commit change to the lib.mk as separate patch and ask you to include changes in Makefile.inc in your patchset.
Signature · 2 lines
Cyril Hrubis [email protected]
include/mk/lib.mk +1 -1
@@ -46,7 +46,7 @@ ifneq ($(MAKECMDGOALS),install) LIB ?= $(INTERNAL_LIB) endif -MAKE_TARGETS := $(LIB) +MAKE_TARGETS += $(LIB) LIBSRCS ?= $(wildcard $(abs_srcdir)/*.c)
testcases/kernel/syscalls/ipc/Makefile.inc +3 -3
@@ -25,15 +25,15 @@ LDLIBS += -lipc LIBDIR := ../lib -LIB := $(LIBDIR)/libipc.a +LIBIPC := $(LIBDIR)/libipc.a $(LIBDIR): mkdir -p "$@" -$(LIB): $(LIBDIR) +$(LIBIPC): $(LIBDIR) $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all -MAKE_DEPS := $(LIB) +MAKE_DEPS := $(LIBIPC) CPPFLAGS += -I$(abs_srcdir)/$(LIBDIR)
testcases/kernel/syscalls/ipc/msgctl/Makefile +11 -1
@@ -17,7 +17,17 @@ # top_srcdir ?= ../../../../.. - include $(top_srcdir)/include/mk/testcases.mk + +LIBSRCS := libmsgctl.c +INTERNAL_LIB := libmsgctl.a +MAKE_TARGETS := $(patsubst %.c,%,$(wildcard msgctl??.c)) + +$(MAKE_TARGETS): $(INTERNAL_LIB) + +LDFLAGS += -L$(abs_builddir) +LDLIBS += -lmsgctl + include $(abs_srcdir)/../Makefile.inc +include $(top_srcdir)/include/mk/lib.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 56 lines
Quoted 33 lines
Quoted 11 lines
And I think that I found an another issue we should overcome - lib.mk defines
MAKE_TARGETS:
MAKE_TARGETS:= $(LIB)generic_leaf_target.mk also does it.
So It should not be trivial to include both files (lib.mk and generic_leaf_target.mk) into one
Makefile.
I suppose that in that case we have to implicitly defineMAKE_TARGETSin ourMakefile.Now this one is more complicated, but solvable.
First of all we need to change the part in lib.mk to
MAKE_TARGETS+= $(LIB)Then define
MAKE_TARGETSexplicitly in theMakefile(we need that anyway for lib: tests dependency) and add LDFLAGS and LDLIBS. The fullMakefilelooks like:
top_srcdir?= ../../../../..
include $(top_srcdir)/include/mk/testcases.mkLIBSRCS :=
libmsgctl.cINTERNAL_LIB:= libmsgctl.aMAKE_TARGETS:= $(patsubst %.c,%,$(wildcard msgctl??.c))$(MAKE_TARGETS): $(INTERNAL_LIB)
LDFLAGS += -L$(abs_builddir)
LDLIBS += -lmsgctlQuoted 7 lines
include $(abs_srcdir)/../Makefile.inc
include $(top_srcdir)/include/mk/lib.mk include $(top_srcdir)/include/mk/generic_leaf_target.mkSee also attached patch with all the changes and check if that works for you. If so I will commit change to the lib.mk as separate patch and ask you to include changes in Makefile.inc in your patchset.
Yes, It works.
But the compilation is performed as follows:
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall
(quoted diff) +0
-8-I/home/stas/ltp/testcases/kernel/include -I/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl/../lib -I../../../../../include -I../../../../../include -I../../../../../include -I../../../../../include -L/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl -L/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl/../lib -L../../../../../lib -L../../../../../lib msgctl01.c libmsgctl.a -lltp -lmsgctl -lipc -o msgctl01
Quoted 2 lines
So gcc 'links'
msgctl01.cand libmsgctl.a at once (and additionally is passed -lmsgctl option).
Ah, this one. Let's fix this, the handling of static libraries is too fragile and this may posibly break on some distribution (from my memory Ubuntu was the most problematic one).
Quoted 25 lines
How do you think, maybe introduce my favourite .INTERMEDIATE target into
Makefile? :)Like this:
MAKE_TARGET_OBJS:= $(addsuffix .o,$(MAKE_TARGETS)) .INTERMEDIATE: $(MAKE_TARGET_OBJS)$(MAKE_TARGET_OBJS): $(INTERNAL_LIB)
#$(MAKE_TARGETS): $(INTERNAL_LIB)
With this option the compilation is as follows:
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall
(quoted diff) +0
-4-I/home/stas/ltp/testcases/kernel/include -I/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl/../lib -I../../../../../include -I../../../../../include -I../../../../../include -I../../../../../include -c -o msgctl01.o
msgctl01.c
gcc -L/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl(quoted diff) +0
-3-L/home/stas/ltp/testcases/kernel/syscalls/ipc/msgctl/../lib -L../../../../../lib -L../../../../../lib msgctl01.o -lltp -lmsgctl -lipc -o msgctl01
Quoted 2 lines
I can't find any reasonable arguments for this approach. Just feels that it's more 'correct'.
That looks a bit like a workaround, but let's go with this one for now.
I will take a closer look later and change it if I find a better way. (I have a better build system documentation on my TODO)
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Hi!
Quoted 3 lines
Could you commit the 'infrastructure' patches (lib.mk and etc) to master? After that I will send the updated patches to msgctl{08, 09, 10, 11} (with additional cleanup and this new
Makefile).
Sure, looking at the previous emails and patches there is this change in include/mk/lib.mk that I will commit ASAP, the rest can go with your fixes.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Could you commit the 'infrastructure' patches (lib.mk and etc) to master? After that I will send the updated patches to msgctl{08, 09, 10, 11} (with additional cleanup and this new
Makefile).Sure, looking at the previous emails and patches there is this change in
include/mk/lib.mkthat I will commit ASAP, the rest can go with your fixes.Hi!
Maybe finish this?
The change in include/mk/lib.mk is in git since Oct 31 see abaa46 and I've said that the change in Makefile.inc should go with your patches.
Is there anything that is still missing?
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list