On 11/29/2013 04:35 PM, Peng Haitao wrote:
> The binary file of msgctl is installed in /opt/ltp/lib/. When execute msgctl,
> "pan(23126): execvp of 'msgctl01' (tag msgctl01) failed.  errno:2  No such 
> file or directory"
> will be outputed.

This fixed a wrong cleanup. Thank you.

Acked-by: Wanlong Gao <[email protected]>


> 
> Signed-off-by: Peng Haitao <[email protected]>
> ---
>  testcases/kernel/syscalls/ipc/Makefile           |    2 +-
>  testcases/kernel/syscalls/ipc/lib/Makefile       |    2 +-
>  testcases/kernel/syscalls/ipc/lib/libmsgctl.c    |  147 +++++++++++++++++++++
>  testcases/kernel/syscalls/ipc/lib/libmsgctl.h    |   39 ++++++
>  testcases/kernel/syscalls/ipc/msgctl/Makefile    |   13 +--
>  testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c |  148 
> ----------------------
>  testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h |   39 ------
>  testcases/kernel/syscalls/ipc/msgctl/msgctl08.c  |    2 +-
>  testcases/kernel/syscalls/ipc/msgctl/msgctl09.c  |    2 +-
>  testcases/kernel/syscalls/ipc/msgctl/msgctl10.c  |    2 +-
>  testcases/kernel/syscalls/ipc/msgctl/msgctl11.c  |    2 +-
>  11 files changed, 194 insertions(+), 204 deletions(-)
>  create mode 100644 testcases/kernel/syscalls/ipc/lib/libmsgctl.c
>  create mode 100644 testcases/kernel/syscalls/ipc/lib/libmsgctl.h
>  delete mode 100644 testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c
>  delete mode 100644 testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h
> 
> diff --git a/testcases/kernel/syscalls/ipc/Makefile 
> b/testcases/kernel/syscalls/ipc/Makefile
> index 69c6e8c..42492db 100644
> --- a/testcases/kernel/syscalls/ipc/Makefile
> +++ b/testcases/kernel/syscalls/ipc/Makefile
> @@ -22,7 +22,7 @@ include $(top_srcdir)/include/mk/env_pre.mk
>  
>  LIBDIR                       := lib
>  FILTER_OUT_DIRS              := $(LIBDIR)
> -LIB                  := $(LIBDIR)/libipc.a
> +LIB                  := $(LIBDIR)/libipc.a $(LIBDIR)/libmsgctl.a
>  
>  $(LIBDIR):
>       mkdir -p "$@"
> diff --git a/testcases/kernel/syscalls/ipc/lib/Makefile 
> b/testcases/kernel/syscalls/ipc/lib/Makefile
> index 9de2274..0333d48 100644
> --- a/testcases/kernel/syscalls/ipc/lib/Makefile
> +++ b/testcases/kernel/syscalls/ipc/lib/Makefile
> @@ -20,6 +20,6 @@ top_srcdir          ?= ../../../../..
>  
>  include $(top_srcdir)/include/mk/env_pre.mk
>  
> -LIB                  := libipc.a
> +LIB                  := libipc.a libmsgctl.a
>  
>  include $(top_srcdir)/include/mk/lib.mk
> diff --git a/testcases/kernel/syscalls/ipc/lib/libmsgctl.c 
> b/testcases/kernel/syscalls/ipc/lib/libmsgctl.c
> new file mode 100644
> index 0000000..ae459d4
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ipc/lib/libmsgctl.c
> @@ -0,0 +1,147 @@
> +/*
> + * 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
> + */
> +
> +#include <errno.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +#include <sys/types.h>
> +#include <sys/ipc.h>
> +#include <sys/msg.h>
> +#include "libmsgctl.h"
> +
> +int doreader(long key, int tid, long type, int child, int nreps)
> +{
> +     int i, size;
> +     int id;
> +     struct mbuffer buffer;
> +
> +     id = msgget(key, 0);
> +     if (id < 0) {
> +             printf("msgget() error in the reader of child group %d: %s\n",
> +                     child, strerror(errno));
> +
> +             return FAIL;
> +     }
> +     if (id != tid) {
> +             printf("Message queue mismatch in the reader of child group %d 
> for message queue id %d\n",
> +                     child, id);
> +
> +             return FAIL;
> +     }
> +     for (i = 0; i < nreps; i++) {
> +             memset(&buffer, 0, sizeof(buffer));
> +
> +             size = msgrcv(id, &buffer, 100, type, 0);
> +             if (size < 0) {
> +                     printf("msgrcv() error in child %d, read # = %d: %s\n",
> +                             child, (i + 1), strerror(errno));
> +
> +                     return FAIL;
> +             }
> +             if (buffer.type != type) {
> +                     printf("Type mismatch in child %d, read #d = %d: ",
> +                             child, (i + 1));
> +                     printf("for message got %ld, expected - %ld\n",
> +                             buffer.type, type);
> +
> +                     return FAIL;
> +             }
> +             if (buffer.data.len + 1 != size) {
> +                     printf("Size mismatch in child %d, read # = %d: ",
> +                             child, (i + 1));
> +                     printf("for message got %d, expected - %d\n",
> +                             buffer.data.len + 1, size);
> +
> +                     return FAIL;
> +             }
> +             if (verify(buffer.data.pbytes, (key % 255), size - 1, child)) {
> +                     printf("Verify failed in child %d read # = %d, key = 
> %lx\n",
> +                             child, (i + 1), key);
> +
> +                     return FAIL;
> +             }
> +             key++;
> +     }
> +     return PASS;
> +}
> +
> +int dowriter(long key, int tid, long type, int child, int nreps)
> +{
> +     int i, size;
> +     int id;
> +     struct mbuffer buffer;
> +
> +     id = msgget(key, 0);
> +     if (id < 0) {
> +             printf("msgget() error in the writer of child group %d: %s\n",
> +                     child, strerror(errno));
> +
> +             return FAIL;
> +     }
> +     if (id != tid) {
> +             printf("Message queue mismatch in the reader of child group %d 
> for message queue id %d\n",
> +                     child, id);
> +
> +             return FAIL;
> +     }
> +
> +     for (i = 0; i < nreps; i++) {
> +             memset(&buffer, 0, sizeof(buffer));
> +
> +             do {
> +                     size = (lrand48() % 99);
> +             } while (size == 0);
> +             fill_buffer(buffer.data.pbytes, (key % 255), size);
> +             buffer.data.len = size;
> +             buffer.type = type;
> +             if (msgsnd(id, &buffer, size + 1, 0) < 0) {
> +                     printf("msgsnd() error in child %d, write # = %d, key = 
> %lx: %s\n",
> +                             child, nreps, key, strerror(errno));
> +
> +                     return FAIL;
> +             }
> +             key++;
> +     }
> +     return PASS;
> +}
> +
> +int fill_buffer(char *buf, char val, int size)
> +{
> +     int i;
> +
> +     for (i = 0; i < size; i++)
> +             buf[i] = val;
> +     return 0;
> +}
> +
> +/* Check a buffer for correct values */
> +int verify(char *buf, char val, int size, int child)
> +{
> +     while (size-- > 0) {
> +             if (*buf++ != val) {
> +                     printf("Verify error in child %d, *buf = %x, val = %x, 
> size = %d\n",
> +                             child, *buf, val, size);
> +
> +                     return FAIL;
> +             }
> +     }
> +     return PASS;
> +}
> diff --git a/testcases/kernel/syscalls/ipc/lib/libmsgctl.h 
> b/testcases/kernel/syscalls/ipc/lib/libmsgctl.h
> new file mode 100644
> index 0000000..e1afeab
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ipc/lib/libmsgctl.h
> @@ -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__ */
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/Makefile 
> b/testcases/kernel/syscalls/ipc/msgctl/Makefile
> index aedfda6..e2396e9 100644
> --- a/testcases/kernel/syscalls/ipc/msgctl/Makefile
> +++ b/testcases/kernel/syscalls/ipc/msgctl/Makefile
> @@ -20,19 +20,10 @@ top_srcdir              ?= ../../../../..
>  
>  include $(top_srcdir)/include/mk/testcases.mk
>  
> -LIBSRCS := libmsgctl.c
> -INTERNAL_LIB := libmsgctl.a
> -
> -LDFLAGS += -L$(abs_builddir)
> +LIBMSGCTL               := $(LIBDIR)/libmsgctl.a
>  LDLIBS += -lmsgctl
>  
> -MAKE_TARGETS := $(patsubst %.c,%,$(wildcard msgctl??.c))
> -MAKE_TARGET_OBJS := $(addsuffix .o,$(MAKE_TARGETS))
> -
> -$(MAKE_TARGET_OBJS): $(INTERNAL_LIB)
> -
> -.INTERMEDIATE: $(MAKE_TARGET_OBJS)
> +MAKE_DEPS               := $(LIBMSGCTL)
>  
>  include $(abs_srcdir)/../Makefile.inc
> -include $(top_srcdir)/include/mk/lib.mk
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c 
> b/testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c
> deleted file mode 100644
> index fa77b56..0000000
> --- a/testcases/kernel/syscalls/ipc/msgctl/libmsgctl.c
> +++ /dev/null
> @@ -1,148 +0,0 @@
> -/*
> - * 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
> - */
> -
> -#include <errno.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -#include <sys/types.h>
> -#include <sys/ipc.h>
> -#include <sys/msg.h>
> -#include "libmsgctl.h"
> -
> -int doreader(long key, int tid, long type, int child, int nreps)
> -{
> -     int i, size;
> -     int id;
> -     struct mbuffer buffer;
> -
> -     id = msgget(key, 0);
> -     if (id < 0) {
> -             printf("msgget() error in the reader of child group %d: %s\n",
> -                     child, strerror(errno));
> -
> -             return FAIL;
> -     }
> -     if (id != tid) {
> -             printf("Message queue mismatch in the reader of child group %d 
> for message queue id %d\n",
> -                     child, id);
> -
> -             return FAIL;
> -     }
> -     for (i = 0; i < nreps; i++) {
> -             memset(&buffer, 0, sizeof(buffer));
> -
> -             size = msgrcv(id, &buffer, 100, type, 0);
> -             if (size < 0) {
> -                     printf("msgrcv() error in child %d, read # = %d: %s\n",
> -                             child, (i + 1), strerror(errno));
> -
> -                     return FAIL;
> -             }
> -             if (buffer.type != type) {
> -                     printf("Type mismatch in child %d, read #d = %d: ",
> -                             child, (i + 1));
> -                     printf("for message got %ld, expected - %ld\n",
> -                             buffer.type, type);
> -
> -                     return FAIL;
> -             }
> -             if (buffer.data.len + 1 != size) {
> -                     printf("Size mismatch in child %d, read # = %d: ",
> -                             child, (i + 1));
> -                     printf("for message got %d, expected - %d\n",
> -                             buffer.data.len + 1, size);
> -
> -                     return FAIL;
> -             }
> -             if (verify(buffer.data.pbytes, (key % 255), size - 1, child)) {
> -                     printf("Verify failed in child %d read # = %d, key = 
> %lx\n",
> -                             child, (i + 1), key);
> -
> -                     return FAIL;
> -             }
> -             key++;
> -     }
> -     return PASS;
> -}
> -
> -int dowriter(long key, int tid, long type, int child, int nreps)
> -{
> -     int i, size;
> -     int id;
> -     struct mbuffer buffer;
> -
> -     id = msgget(key, 0);
> -     if (id < 0) {
> -             printf("msgget() error in the writer of child group %d: %s\n",
> -                     child, strerror(errno));
> -
> -             return FAIL;
> -     }
> -     if (id != tid) {
> -             printf("Message queue mismatch in the reader of child group %d 
> for message queue id %d\n",
> -                     child, id);
> -
> -             return FAIL;
> -     }
> -
> -     for (i = 0; i < nreps; i++) {
> -             memset(&buffer, 0, sizeof(buffer));
> -
> -             do {
> -                     size = (lrand48() % 99);
> -             } while (size == 0);
> -             fill_buffer(buffer.data.pbytes, (key % 255), size);
> -             buffer.data.len = size;
> -             buffer.type = type;
> -             if (msgsnd(id, &buffer, size + 1, 0) < 0) {
> -                     printf("msgsnd() error in child %d, write # = %d, key = 
> %lx: %s\n",
> -                             child, nreps, key, strerror(errno));
> -
> -                     return FAIL;
> -             }
> -             key++;
> -     }
> -     return PASS;
> -}
> -
> -int fill_buffer(char *buf, char val, int size)
> -{
> -     int i;
> -
> -     for (i = 0; i < size; i++)
> -             buf[i] = val;
> -     return 0;
> -}
> -
> -/* Check a buffer for correct values */
> -int verify(char *buf, char val, int size, int child)
> -{
> -     while (size-- > 0) {
> -             if (*buf++ != val) {
> -                     printf("Verify error in child %d, *buf = %x, val = %x, 
> size = %d\n",
> -                             child, *buf, val, size);
> -
> -                     return FAIL;
> -             }
> -     }
> -     return PASS;
> -}
> -
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h 
> b/testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h
> deleted file mode 100644
> index e1afeab..0000000
> --- a/testcases/kernel/syscalls/ipc/msgctl/libmsgctl.h
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/*
> - * 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__ */
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c 
> b/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
> index 0999059..2d96d8a 100644
> --- a/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
> +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
> @@ -40,7 +40,7 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "ipcmsg.h"
> -#include "libmsgctl.h"
> +#include "../lib/libmsgctl.h"
>  
>  char *TCID = "msgctl08";
>  int TST_TOTAL = 1;
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c 
> b/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
> index c019226..a41ae88 100644
> --- a/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
> +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
> @@ -38,7 +38,7 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "ipcmsg.h"
> -#include "libmsgctl.h"
> +#include "../lib/libmsgctl.h"
>  
>  char *TCID = "msgctl09";
>  int TST_TOTAL = 1;
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c 
> b/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c
> index 860419f..cfb0ef3 100644
> --- a/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c
> +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c
> @@ -41,7 +41,7 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "ipcmsg.h"
> -#include "libmsgctl.h"
> +#include "../lib/libmsgctl.h"
>  
>  char *TCID = "msgctl10";
>  int TST_TOTAL = 1;
> diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c 
> b/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c
> index 9b21df8..57f4ae0 100644
> --- a/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c
> +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c
> @@ -39,7 +39,7 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "ipcmsg.h"
> -#include "libmsgctl.h"
> +#include "../lib/libmsgctl.h"
>  #include "system_specific_process_info.h"
>  
>  char *TCID = "msgctl11";
> 


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to