diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-01 17:26:37 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-01 17:26:37 +0000 |
commit | 1fe4042000bb5daea3b4914106869e53c79d3671 (patch) | |
tree | f6a016403b5621d3b7f39a4d63fddca4700b0218 /testsuites/psxtests | |
parent | 2010-07-01 Vinu Rajashekhar <vinutheraj@gmail.com> (diff) | |
download | rtems-1fe4042000bb5daea3b4914106869e53c79d3671.tar.bz2 |
2010-07-01 Bharath Suri <bharath.s.jois@gmail.com>
PR 1598/testing
* Makefile.am, configure.ac, psxpasswd01/init.c,
psxpasswd01/psxpasswd01.doc, psxpasswd01/psxpasswd01.scn: Add testing
for POSIX user database (e.g. /etc/group and /etc/passwd) access
routines which are implemented in libcsupport/src/getpwent.c.
* psxpasswd02/.cvsignore, psxpasswd02/Makefile.am, psxpasswd02/init.c,
psxpasswd02/psxpasswd02.doc, psxpasswd02/psxpasswd02.scn: New files.
Diffstat (limited to '')
-rw-r--r-- | testsuites/psxtests/ChangeLog | 10 | ||||
-rw-r--r-- | testsuites/psxtests/Makefile.am | 2 | ||||
-rw-r--r-- | testsuites/psxtests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd01/init.c | 112 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd01/psxpasswd01.doc | 6 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd01/psxpasswd01.scn | 79 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd02/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd02/Makefile.am | 27 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd02/init.c | 182 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd02/psxpasswd02.doc | 26 | ||||
-rw-r--r-- | testsuites/psxtests/psxpasswd02/psxpasswd02.scn | 24 |
11 files changed, 462 insertions, 9 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 8ae2d19f23..b904392104 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,13 @@ +2010-07-01 Bharath Suri <bharath.s.jois@gmail.com> + + PR 1598/testing + * Makefile.am, configure.ac, psxpasswd01/init.c, + psxpasswd01/psxpasswd01.doc, psxpasswd01/psxpasswd01.scn: Add testing + for POSIX user database (e.g. /etc/group and /etc/passwd) access + routines which are implemented in libcsupport/src/getpwent.c. + * psxpasswd02/.cvsignore, psxpasswd02/Makefile.am, psxpasswd02/init.c, + psxpasswd02/psxpasswd02.doc, psxpasswd02/psxpasswd02.scn: New files. + 2010-07-01 Vinu Rajashekhar <vinutheraj@gmail.com> PR 1597/cpukit diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 46aea8d8db..625d6eadc9 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -20,7 +20,7 @@ endif ## File IO tests SUBDIRS += psxfile01 psxfile02 psxfilelock01 psxid01 psximfs01 psxreaddir \ - psxstat psxmount psx13 psxchroot01 psxpasswd01 + psxstat psxmount psx13 psxchroot01 psxpasswd01 psxpasswd02 ## Until sys/uio.h is moved to libcsupport, we have to have networking ## enabled to support readv and writev. Hopefully this is a temporary diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index ef5c35911d..fa157e8387 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -105,6 +105,7 @@ psxmsgq04/Makefile psxmutexattr01/Makefile psxobj01/Makefile psxpasswd01/Makefile +psxpasswd02/Makefile psxreaddir/Makefile psxrdwrv/Makefile psxrwlock01/Makefile diff --git a/testsuites/psxtests/psxpasswd01/init.c b/testsuites/psxtests/psxpasswd01/init.c index 6652681b63..f11c3f469c 100644 --- a/testsuites/psxtests/psxpasswd01/init.c +++ b/testsuites/psxtests/psxpasswd01/init.c @@ -60,19 +60,100 @@ rtems_task Init( struct passwd *pw; struct group *gr; - puts( "*** PASSWORD/GROUP TEST ***" ); + puts( "*** PASSWORD/GROUP TEST - 01 ***" ); + + /* getpwent */ + puts( "Init - getpwent() -- OK, result should be NULL" ); + pw = getpwent(); + rtems_test_assert( !pw ); + + /* getgrent */ + puts( "Init - getgrent() -- OK, result should be NULL" ); + gr = getgrent(); + rtems_test_assert( !gr ); + + /* setpwent */ + + puts( "Init - setpwent() -- OK" ); + setpwent(); + + /* setgrent */ + + puts( "Init - setgrent() -- OK" ); + setgrent(); + + /* getpwent */ + + puts( "Init - getpwent() (1) -- OK" ); + pw = getpwent(); + rtems_test_assert( pw ); + print_passwd( pw ); + + puts( "Init - getpwent() (2) -- OK" ); + pw = getpwent(); + rtems_test_assert( pw ); + print_passwd( pw ); + + puts( "Init - getpwent() (3) -- OK" ); + pw = getpwent(); + rtems_test_assert( pw ); + print_passwd( pw ); + + puts( "Init - getpwent() (4) -- result should be NULL" ); + pw = getpwent(); + rtems_test_assert( !pw ); + + /* getgrent */ + + puts( "Init - getgrent() (1) -- OK" ); + gr = getgrent(); + rtems_test_assert( gr ); + print_group( gr ); + + puts( "Init - getgrent() (2) -- OK" ); + gr = getgrent(); + rtems_test_assert( gr ); + print_group( gr ); + + puts( "Init - getgrent() (3) -- OK" ); + gr = getgrent(); + rtems_test_assert( gr ); + print_group( gr ); + + puts( "Init - getgrent() (4) -- result should be NULL" ); + gr = getgrent(); + rtems_test_assert( !gr ); /* getpwnam */ puts( "Init - getpwnam(\"root\") -- OK" ); - pw = getpwnam("root"); + pw = getpwnam( "root" ); rtems_test_assert( pw ); print_passwd( pw ); puts( "Init - getpwnam(\"rtems\") -- OK" ); - pw = getpwnam("rtems"); + pw = getpwnam( "rtems" ); + rtems_test_assert( pw ); + print_passwd( pw ); + + puts( "Init - getpwnam(\"suser\") -- result should be NULL" ); + pw = getpwnam( "suser" ); + rtems_test_assert( !pw ); + + /* getpwuid */ + puts( "Init - getpwuid(0) -- OK" ); + pw = getpwuid( 0 ); + rtems_test_assert( pw ); + print_passwd( pw ); + + puts( "Init - getpwuid(1) -- OK" ); + pw = getpwuid( 1 ); rtems_test_assert( pw ); print_passwd( pw ); + puts( "Init - getpwuid(4) -- result should be NULL" ); + pw = getpwuid( 4 ); + rtems_test_assert( !pw ); + /* getgrnam */ puts( "Init - getgrnam(\"root\") -- OK" ); gr = getgrnam("root"); @@ -84,7 +165,30 @@ rtems_task Init( rtems_test_assert( gr ); print_group( gr ); - puts( "*** END OF PASSWORD/GROUP TEST ***" ); + /* getgrgid */ + puts( "Init - getgrgid(0) -- OK" ); + gr = getgrgid(0); + rtems_test_assert( gr ); + print_group( gr ); + + puts( "Init - getgrgid(1) -- OK" ); + gr = getgrgid(1); + rtems_test_assert( gr ); + print_group( gr ); + + puts( "Init - getgrgid(4) -- result should be NULL"); + gr = getgrgid( 4 ); + rtems_test_assert( !gr ); + + /* endpwent */ + puts( "Init - endpwent() -- OK" ); + endpwent(); + + /* endgrent */ + puts( "Init - endgrent() -- OK" ); + endgrent(); + + puts( "*** END OF PASSWORD/GROUP TEST - 01 ***" ); rtems_test_exit( 0 ); } diff --git a/testsuites/psxtests/psxpasswd01/psxpasswd01.doc b/testsuites/psxtests/psxpasswd01/psxpasswd01.doc index f35bac76a2..a0c85a0553 100644 --- a/testsuites/psxtests/psxpasswd01/psxpasswd01.doc +++ b/testsuites/psxtests/psxpasswd01/psxpasswd01.doc @@ -18,11 +18,17 @@ directives: getpwuid getpwnam_r getpwuid_r + getpwent + setpwent + endpwent getgrnam getgrgid getgrnam_r getgrgid_r + getgrent + setgrent + endgrent concepts: diff --git a/testsuites/psxtests/psxpasswd01/psxpasswd01.scn b/testsuites/psxtests/psxpasswd01/psxpasswd01.scn index 80128cc6f1..a0d0a647ad 100644 --- a/testsuites/psxtests/psxpasswd01/psxpasswd01.scn +++ b/testsuites/psxtests/psxpasswd01/psxpasswd01.scn @@ -1,4 +1,48 @@ -*** PASSWORD/GROUP TEST *** +Initialized console on port COM1 9600-8-N-1 + +*** PASSWORD/GROUP TEST - 01 *** +Init - getpwent() -- OK, result should be NULL +Init - getgrent() -- OK, result should be NULL +Init - setpwent() -- OK +Init - setgrent() -- OK +Init - getpwent() (1) -- OK + username: root + user password: * + user ID: 0 + group ID: 0 + real name: + home directory: / + shell program: /bin/sh +Init - getpwent() (2) -- OK + username: rtems + user password: * + user ID: 1 + group ID: 1 + real name: + home directory: / + shell program: /bin/sh +Init - getpwent() (3) -- OK + username: tty + user password: ! + user ID: 2 + group ID: 2 + real name: + home directory: / + shell program: /bin/false +Init - getpwent() (4) -- result should be NULL +Init - getgrent() (1) -- OK + group name: root + group password: x + group ID: 0 +Init - getgrent() (2) -- OK + group name: rtems + group password: x + group ID: 1 +Init - getgrent() (3) -- OK + group name: tty + group password: x + group ID: 2 +Init - getgrent() (4) -- result should be NULL Init - getpwnam("root") -- OK username: root user password: * @@ -15,7 +59,24 @@ Init - getpwnam("rtems") -- OK real name: home directory: / shell program: /bin/sh - +Init - getpwnam("suser") -- result should be NULL +Init - getpwuid(0) -- OK + username: root + user password: * + user ID: 0 + group ID: 0 + real name: + home directory: / + shell program: /bin/sh +Init - getpwuid(1) -- OK + username: rtems + user password: * + user ID: 1 + group ID: 1 + real name: + home directory: / + shell program: /bin/sh +Init - getpwuid(4) -- result should be NULL Init - getgrnam("root") -- OK group name: root group password: x @@ -24,5 +85,15 @@ Init - getgrnam("rtems") -- OK group name: rtems group password: x group ID: 1 -*** END OF PASSWORD/GROUP TEST *** - +Init - getgrgid(0) -- OK + group name: root + group password: x + group ID: 0 +Init - getgrgid(1) -- OK + group name: rtems + group password: x + group ID: 1 +Init - getgrgid(4) -- result should be NULL +Init - endpwent() -- OK +Init - endgrent() -- OK +*** END OF PASSWORD/GROUP TEST - 01 *** diff --git a/testsuites/psxtests/psxpasswd02/.cvsignore b/testsuites/psxtests/psxpasswd02/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psxpasswd02/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psxpasswd02/Makefile.am b/testsuites/psxtests/psxpasswd02/Makefile.am new file mode 100644 index 0000000000..22f179c1e1 --- /dev/null +++ b/testsuites/psxtests/psxpasswd02/Makefile.am @@ -0,0 +1,27 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxpasswd02 +psxpasswd02_SOURCES = init.c ../include/pmacros.h + +dist_rtems_tests_DATA = psxpasswd02.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxpasswd02_OBJECTS) $(psxpasswd02_LDADD) +LINK_LIBS = $(psxpasswd02_LDLIBS) + +psxpasswd02$(EXEEXT): $(psxpasswd02_OBJECTS) $(psxpasswd02_DEPENDENCIES) + @rm -f psxpasswd02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxpasswd02/init.c b/testsuites/psxtests/psxpasswd02/init.c new file mode 100644 index 0000000000..48b66196b1 --- /dev/null +++ b/testsuites/psxtests/psxpasswd02/init.c @@ -0,0 +1,182 @@ +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include <bsp.h> +#include <pmacros.h> +#include <sys/types.h> +#include <pwd.h> +#include <grp.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> + +void print_passwd( + struct passwd *pw +) +{ + printf( + " username: %s\n" + " user password: %s\n" + " user ID: %d\n" + " group ID: %d\n" + " real name: %s\n" + " home directory: %s\n" + " shell program: %s\n", + pw->pw_name, + pw->pw_passwd, + pw->pw_uid, + pw->pw_gid, + pw->pw_gecos, + pw->pw_dir, + pw->pw_shell + ); +} + +void print_group( + struct group *gr +) +{ + printf( + " group name: %s\n" + " group password: %s\n" + " group ID: %d\n", + gr->gr_name, + gr->gr_passwd, + gr->gr_gid + ); + + /* TBD print users in group */ +} + +rtems_task Init( + rtems_task_argument ignored +) +{ + struct passwd *pw; + struct group *gr; + int status = -1; + + FILE *fp = NULL; + + puts( "*** PASSWORD/GROUP TEST - 02 ***" ); + + puts( "Init - Creating /etc" ); + status = mkdir( "/etc", 0777 ); + rtems_test_assert( status == 0 ); + + puts( "Init - Creating /etc/passwd" ); + status = mknod( "/etc/passwd", (S_IFREG | S_IRWXU), 0LL ); + rtems_test_assert( status != -1 ); + + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, "bharath:x:-1:-a:Dummy::/:/bin/bash\n" ); + fclose( fp ); + + puts( "Init - Creating /etc/group" ); + status = mknod( "/etc/group", (S_IFREG | S_IRWXU), 0LL ); + rtems_test_assert( status != -1); + + fp = fopen( "/etc/group", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, "admin::1:root,su,super-user\n" ); + fclose( fp ); + + puts( "Init - setpwent() -- OK" ); + setpwent(); + + puts( "Init - setpwent() -- OK" ); + setpwent(); + + puts( "Init - setgrent() -- OK" ); + setgrent(); + + puts( "Init - setgrent() -- OK" ); + setgrent(); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, "rtems:x:1:1:dummy::/:/bin/bash:" ); + fclose( fp ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + + fp = fopen( "/etc/passwd", "w" ); + rtems_test_assert( fp != NULL ); + fprintf( fp, "user\n:x:2:2:dummy::/:/bin/sh\n" ); + fclose( fp ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + + puts( "Init - getgrent() -- OK" ); + gr = getgrent(); + rtems_test_assert( gr != NULL ); + print_group( gr ); + + puts( "Init - endpwent() -- OK" ); + endpwent(); + + puts( "Init - endpwent() -- OK" ); + endpwent(); + + puts( "Init - endgrent() -- OK" ); + endgrent(); + + puts( "Init - endgrent() -- OK" ); + endgrent(); + + puts( "Removing /etc/passwd" ); + status = unlink( "/etc/passwd" ); + rtems_test_assert( status == 0 ); + + puts( "Removing /etc/group" ); + status = unlink( "/etc/group" ); + rtems_test_assert( status == 0 ); + + puts( "Init - getpwnam(\"root\") -- expected EINVAL" ); + pw = getpwnam( "root" ); + rtems_test_assert( !pw ); + rtems_test_assert( errno == EINVAL ); + + puts( "Init - getgrnam(\"root\") -- expected EINVAL" ); + gr = getgrnam( "root" ); + rtems_test_assert( !gr ); + rtems_test_assert( errno == EINVAL ); + + puts( "*** END OF PASSWORD/GROUP TEST - 02 ***" ); + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6 + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT +#include <rtems/confdefs.h> +/* end of file */ diff --git a/testsuites/psxtests/psxpasswd02/psxpasswd02.doc b/testsuites/psxtests/psxpasswd02/psxpasswd02.doc new file mode 100644 index 0000000000..4322eabace --- /dev/null +++ b/testsuites/psxtests/psxpasswd02/psxpasswd02.doc @@ -0,0 +1,26 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2010. +# On-Line Applications Research Corporation (OAR). +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: POSIX PASSWD/GROUP TEST + +directives: + ++ setpwent ++ setgrent ++ getpwnam ++ endpwent ++ endgrent + +concepts: + ++ Exercise error paths in /etc/passwd and /etc/group. diff --git a/testsuites/psxtests/psxpasswd02/psxpasswd02.scn b/testsuites/psxtests/psxpasswd02/psxpasswd02.scn new file mode 100644 index 0000000000..21b661d391 --- /dev/null +++ b/testsuites/psxtests/psxpasswd02/psxpasswd02.scn @@ -0,0 +1,24 @@ +*** PASSWORD/GROUP TEST - 02 *** +Init - Creating /etc +Init - Creating /etc/passwd +Init - Creating /etc/group +Init - setpwent() -- OK +Init - setpwent() -- OK +Init - setgrent() -- OK +Init - setgrent() -- OK +Init - getpwnam("root") -- expected EINVAL +Init - getpwnam("root") -- expected EINVAL +Init - getpwnam("root") -- expected EINVAL +Init - getgrent() -- OK + group name: admin + group password: + group ID: 1 +Init - endpwent() -- OK +Init - endpwent() -- OK +Init - endgrent() -- OK +Init - endgrent() -- OK +Removing /etc/passwd +Removing /etc/group +Init - getpwnam("root") -- expected EINVAL +Init - getgrnam("root") -- expected EINVAL +*** END OF PASSWORD/GROUP TEST - 02 *** |