On Tue, 2008-08-26 at 19:20 +0900, Masatake YAMATO wrote:
> Hi,
> 
> I've extended setgroup test cases can test setgroups16 old system calls.
> 
> To test, please put attached compat_16.h to
> ltp/testcases/kernel/syscalls/setgroups; and apply the patch.
> 
> 
> Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]>

Thanks Yamato. I have added and merged them. The following are the
results on my 2.6.18-92.el5, i386 machine:

<<<test_start>>>
tag=setgroups01 stime=1219838249
cmdline="setgroups01"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups01    1  PASS  :  setgroups(65536, list) returned 0
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=1
<<<test_end>>>

<<<test_start>>>
tag=setgroups01_16 stime=1219838249
cmdline="setgroups01_16"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups01_16    1  PASS  :  setgroups(65536, list) returned 0
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=2
<<<test_end>>>

<<<test_start>>>
tag=setgroups02 stime=1219838249
cmdline="setgroups02"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups02    1  PASS  :  Functionality of setgroups(65536,
groups_list) successful
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=2
<<<test_end>>>

<<<test_start>>>
tag=setgroups02_16 stime=1219838249
cmdline="setgroups02_16"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups02_16    1  PASS  :  Functionality of setgroups(65536,
groups_list) successful
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=1
<<<test_end>>>

<<<test_start>>>
tag=setgroups03 stime=1219838249
cmdline="setgroups03"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups03    1  PASS  :  setgroups(65537) fails, Size is >
sysconf(_SC_NGROUPS_MAX), errno=22
setgroups03    2  PASS  :  setgroups(65536) fails, Permission denied,
not super-user, errno=1
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=0
<<<test_end>>>

<<<test_start>>>
tag=setgroups03_16 stime=1219838249
cmdline="setgroups03_16"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups03_16    1  PASS  :  setgroups(65537) fails, Size is >
sysconf(_SC_NGROUPS_MAX), errno=22
setgroups03_16    2  PASS  :  setgroups(65536) fails, Permission denied,
not super-user, errno=1
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=0
<<<test_end>>>

<<<test_start>>>
tag=setgroups04 stime=1219838249
cmdline="setgroups04"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
setgroups04    1  PASS  :  setgroups() fails with expected error EFAULT
errno:14
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=0
<<<test_end>>>

<<<test_start>>>
tag=setgroups04_16 stime=1219838249
cmdline="setgroups04_16"
contacts=""
analysis=exit
initiation_status="ok"
<<<test_output>>>
incrementing stop
setgroups04_16    1  PASS  :  setgroups() fails with expected error
EFAULT errno:14
<<<execution_status>>>
duration=0 termination_type=exited termination_id=0 corefile=no
cutime=0 cstime=1
<<<test_end>>>

Regards--
Subrata

> 
> 
> Index: runtest/syscalls
> ===================================================================
> RCS file: /cvsroot/ltp/ltp/runtest/syscalls,v
> retrieving revision 1.210
> diff -u -r1.210 syscalls
> --- runtest/syscalls  22 Aug 2008 21:09:58 -0000      1.210
> +++ runtest/syscalls  26 Aug 2008 09:59:15 -0000
> @@ -765,9 +765,13 @@
>  setegid01 setegid01
> 
>  setgroups01 setgroups01
> +setgroups01_16 setgroups01_16
>  setgroups02 setgroups02
> +setgroups02_16 setgroups02_16
>  setgroups03 setgroups03
> +setgroups03_16 setgroups03_16
>  setgroups04 setgroups04
> +setgroups04_16 setgroups04_16
> 
>  sethostname01 sethostname01
>  sethostname02 sethostname02
> Index: testcases/kernel/syscalls/setgroups/Makefile
> ===================================================================
> RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/Makefile,v
> retrieving revision 1.7
> diff -u -r1.7 Makefile
> --- testcases/kernel/syscalls/setgroups/Makefile      21 Aug 2006 06:58:45 
> -0000      1.7
> +++ testcases/kernel/syscalls/setgroups/Makefile      26 Aug 2008 09:59:26 
> -0000
> @@ -19,8 +19,10 @@
>  CFLAGS += -I../../../../include -Wall
>  LDLIBS += -L../../../../lib -lltp
> 
> +include ../utils/compat_16.mk
> +
>  SRCS    = $(wildcard *.c)
> -TARGETS = $(patsubst %.c,%,$(SRCS))
> +TARGETS += $(patsubst %.c,%,$(SRCS))
> 
>  all: $(TARGETS)
> 
> Index: testcases/kernel/syscalls/setgroups/setgroups01.c
> ===================================================================
> RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/setgroups01.c,v
> retrieving revision 1.1
> diff -u -r1.1 setgroups01.c
> --- testcases/kernel/syscalls/setgroups/setgroups01.c 27 Aug 2001 22:15:15 
> -0000      1.1
> +++ testcases/kernel/syscalls/setgroups/setgroups01.c 26 Aug 2008 09:59:26 
> -0000
> @@ -119,17 +119,19 @@
>  #include "test.h"
>  #include "usctest.h"
> 
> +#include "compat_16.h"
> +
>  void setup();
>  void cleanup();
> 
> 
> 
> -char *TCID="setgroups01";    /* Test program identifier.    */
> +TCID_DEFINE(setgroups01);    /* Test program identifier.    */
>  int TST_TOTAL=1;             /* Total number of test cases. */
>  extern int Tst_count;                /* Test Case counter for tst_* routines 
> */
> 
>  int len = NGROUPS; 
> -gid_t list[NGROUPS];
> +GID_T list[NGROUPS];
> 
>  int
>  main(int ac, char **av)
> @@ -161,7 +163,7 @@
>       /* 
>        * Call setgroups(2) 
>        */
> -     TEST(setgroups(len, list));
> +     TEST(SETGROUPS(len, list));
>       
>       /* check return code */
>       if ( TEST_RETURN == -1 ) {
> @@ -203,7 +205,7 @@
>      /* Pause if that option was specified */
>      TEST_PAUSE;
> 
> -    if (getgroups(len, list) == -1) {
> +    if (GETGROUPS(len, list) == -1) {
>         tst_brkm(TBROK, cleanup,
>               "getgroups(%d, list) Failure. errno=%d : %s",
>               len, errno, strerror(errno));
> Index: testcases/kernel/syscalls/setgroups/setgroups02.c
> ===================================================================
> RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/setgroups02.c,v
> retrieving revision 1.4
> diff -u -r1.4 setgroups02.c
> --- testcases/kernel/syscalls/setgroups/setgroups02.c 2 Mar 2004 19:22:08 
> -0000       1.4
> +++ testcases/kernel/syscalls/setgroups/setgroups02.c 26 Aug 2008 09:59:26 
> -0000
> @@ -73,12 +73,14 @@
>  #include "test.h"
>  #include "usctest.h"
> 
> +#include "compat_16.h"
> +
>  #define TESTUSER     "nobody"
> 
> -char *TCID="setgroups02";    /* Test program identifier.    */
> +TCID_DEFINE(setgroups02);    /* Test program identifier.    */
>  int TST_TOTAL=1;             /* Total number of test conditions */
>  extern int Tst_count;                /* Test Case counter for tst_* routines 
> */
> -gid_t groups_list[NGROUPS];  /* Array to hold gids for getgroups() */
> +GID_T groups_list[NGROUPS];  /* Array to hold gids for getgroups() */
> 
>  struct passwd *user_info;    /* struct. to hold test user info */
>  void setup();                        /* setup function for the test */
> @@ -111,7 +113,7 @@
>                * Call setgroups() to set supplimentary group IDs of
>                * the calling super-user process to gid of TESTUSER.
>                */
> -             TEST(setgroups(gidsetsize, groups_list));
> +             TEST(SETGROUPS(gidsetsize, groups_list));
>       
>               /* check return code of setgroups(2) */
>               if (TEST_RETURN == -1) {
> @@ -132,7 +134,7 @@
>                        * supp. gids of TESTUSER.
>                        */
>                       groups_list[0] = '\0';
> -                     if (getgroups(gidsetsize, groups_list) < 0) {
> +                     if (GETGROUPS(gidsetsize, groups_list) < 0) {
>                               tst_brkm(TFAIL, cleanup, "getgroups() Fails, "
>                                        "error=%d", errno);
>                       }
> @@ -185,6 +187,12 @@
>               tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
>       }
> 
> +     if (!COMPAT_SIZE_CHECK(user_info->pw_gid)) {
> +             tst_brkm(TBROK,
> +                      cleanup,
> +                      "gid returned from getpwnam is too large for testing 
> setgroups16");
> +     }
> +       
>       groups_list[0] = user_info->pw_gid;
>  }
> 
> Index: testcases/kernel/syscalls/setgroups/setgroups03.c
> ===================================================================
> RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/setgroups03.c,v
> retrieving revision 1.9
> diff -u -r1.9 setgroups03.c
> --- testcases/kernel/syscalls/setgroups/setgroups03.c 11 Feb 2006 04:46:38 
> -0000      1.9
> +++ testcases/kernel/syscalls/setgroups/setgroups03.c 26 Aug 2008 09:59:26 
> -0000
> @@ -75,19 +75,21 @@
>  #include "test.h"
>  #include "usctest.h"
> 
> +#include "compat_16.h"
> +
>  #define TESTUSER     "nobody"
> 
>  char nobody_uid[] = "nobody";
>  struct passwd *ltpuser;
> 
> 
> -char *TCID="setgroups03";    /* Test program identifier.    */
> +TCID_DEFINE(setgroups03);    /* Test program identifier.    */
>  int TST_TOTAL=2;             /* Total number of test conditions */
>  extern int Tst_count;                /* Test Case counter for tst_* routines 
> */
> 
>  int exp_enos[] = {EINVAL, EPERM, 0};
> 
> -gid_t *groups_list;          /* Array to hold gids for getgroups() */
> +GID_T *groups_list;          /* Array to hold gids for getgroups() */
>       
>  int setup1();                        /* setup function to test error EPERM */
>  void setup();                        /* setup function for the test */
> @@ -120,10 +122,10 @@
>               tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
>       }
>       
> -     groups_list = malloc(ngroups_max * sizeof(gid_t));
> +     groups_list = malloc(ngroups_max * sizeof(GID_T));
>       if (groups_list == NULL) {
>               tst_brkm(TBROK, NULL, "malloc failed to alloc %d errno "
> -                      " %d ", ngroups_max * sizeof(gid_t), errno);
> +                      " %d ", ngroups_max * sizeof(GID_T), errno);
>       }
> 
>       /* Perform global setup for test */
> @@ -151,7 +153,7 @@
>                        * verify that it fails with -1 return value and
>                        * sets appropriate errno.
>                        */ 
> -                      TEST(setgroups(gidsetsize, groups_list));
> +                      TEST(SETGROUPS(gidsetsize, groups_list));
>       
>                       /* check return code of setgroups(2) */
>                       if (TEST_RETURN != -1) {
> @@ -229,6 +231,12 @@
>       if ((user_info = getpwnam(TESTUSER)) == NULL) {
>               tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed", TESTUSER);
>       }
> +
> +     if (!COMPAT_SIZE_CHECK(user_info->pw_gid)) {
> +             tst_brkm(TBROK,
> +                      cleanup,
> +                      "gid returned from getpwnam is too large for testing 
> setgroups16");
> +     }
>       groups_list[0] = user_info->pw_gid;
>       return 0;
>  }
> Index: testcases/kernel/syscalls/setgroups/setgroups04.c
> ===================================================================
> RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/setgroups/setgroups04.c,v
> retrieving revision 1.5
> diff -u -r1.5 setgroups04.c
> --- testcases/kernel/syscalls/setgroups/setgroups04.c 27 Feb 2006 04:29:22 
> -0000      1.5
> +++ testcases/kernel/syscalls/setgroups/setgroups04.c 26 Aug 2008 09:59:26 
> -0000
> @@ -70,11 +70,13 @@
>  #include "test.h"
>  #include "usctest.h"
> 
> -char *TCID="setgroups04";    /* Test program identifier.    */
> +#include "compat_16.h"
> +
> +TCID_DEFINE(setgroups04);    /* Test program identifier.    */
>  int TST_TOTAL = 1;
>  extern int Tst_count;                /* Test Case counter for tst_* routines 
> */
> 
> -gid_t groups_list[NGROUPS];  /* Array to hold gids for getgroups() */
> +GID_T groups_list[NGROUPS];  /* Array to hold gids for getgroups() */
>  int exp_enos[] = {EFAULT, 0};
> 
>  void setup();                        /* setup function for the test */
> @@ -116,7 +118,7 @@
>                * verify that it fails with -1 return value and
>                * sets appropriate errno.
>                */ 
> -              TEST(setgroups(gidsetsize,sbrk(0)));
> +              TEST(SETGROUPS(gidsetsize,sbrk(0)));
>               /* check return code of setgroups */
>               if (TEST_RETURN != -1) {
>                       tst_resm(TFAIL, "setgroups() returned %d, "
> plain text document attachment (compat_16.h)
> /*
>  *
>  *   Copyright (c) Red Hat Inc., 2008
>  *
>  *   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 will 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 to the Free Software
>  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>  */
> 
> /* Author: Masatake YAMATO <[EMAIL PROTECTED]> */
> 
> #ifndef __SETGROUPS_COMPAT_16_H__
> #define __SETGROUPS_COMPAT_16_H__
> 
> #include <asm/posix_types.h>
> #include "linux_syscall_numbers.h"
> 
> /* For avoiding circular dependency. */
> extern void cleanup(void);
> 
> #ifdef TST_USE_COMPAT16_SYSCALL
> typedef __kernel_old_gid_t GID_T;
> 
> int 
> COMPAT_SIZE_CHECK(gid_t gid)
> {
>       /* See high2lowgid in linux/highuid.h
>          Return 0 if gid is too large to store
>          it to __kernel_old_gid_t. */
>       return ((gid) & ~0xFFFF)? 0: 1;
> }
> 
> long
> SETGROUPS(int gidsetsize, GID_T *list)
> {
>       return syscall(__NR_setgroups, gidsetsize, list);
> }
> 
> int
> GETGROUPS(size_t size16, GID_T *list16)
> {
>       int r;
>       int i;
> 
>       gid_t *list32;
> 
>       list32 = malloc(size16 * sizeof(gid_t));
>       if (list32 == NULL)
>         tst_brkm(TBROK, NULL, "malloc failed to alloc %d errno "
>                  " %d ", size16 * sizeof(gid_t), errno);
> 
>       r = getgroups(size16, list32);
>       if (r < 0)
>         goto out;
>   
>       for (i = 0; i < size16; i++) {
>               if (!COMPAT_SIZE_CHECK(list32[i]))
>                 tst_brkm(TBROK,
>                          cleanup,
>                          "gid returned from getgroups is too large for 
> testing setgroups32");
>               list16[i] = (GID_T)list32[i];
>       }
> 
>  out:
>       free(list32);
>       return r;
> }
> 
> #else
> typedef gid_t GID_T;
> 
> int
> SETGROUPS(size_t size, const GID_T *list)
> {
>       return setgroups(size, list);
> }
> 
> int
> GETGROUPS(size_t size, GID_T *list)
> {
>       return getgroups(size, list);
> }
> 
> int 
> COMPAT_SIZE_CHECK(gid_t gid)
> {
>   return 1;
> }
> #endif        /* TST_USE_COMPAT16_SYSCALL */
> 
> #endif /* __SETGROUPS_COMPAT_16_H__ */
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________ Ltp-list mailing list 
> [email protected] 
> https://lists.sourceforge.net/lists/listinfo/ltp-list


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to