summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxpasswd02
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-08-07 00:22:46 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-08-07 00:22:46 +0000
commit99e6fb5244c6c99341fed54bbc4cfbd2fcc4d8f5 (patch)
tree9ef3d6c56d179b4b9703f45d6fd9298cbba04d01 /testsuites/psxtests/psxpasswd02
parent2010-08-06 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-99e6fb5244c6c99341fed54bbc4cfbd2fcc4d8f5.tar.bz2
2010-08-06 Bharath Suri <bharath.s.jois@gmail.com>
PR 1654/testing * psx13/test.c, psx13/psx13.scn: Test case to improve testing of dup2 routine. * psxfile01/test.c, psxfile01/psxfile01.scn: New test to improve testing of fcntl routine. * psximfs01/init.c, psximfs01/psximfs01.scn: Improve testing of imfs routines. * psximfs02/init.c, psximfs02/psximfs02.scn: Improve coverage of imfs routines. * psxpasswd02/init.c, psxpasswd02/psxpasswd02.scn: New tests to improve coverage of getpwent.c.
Diffstat (limited to 'testsuites/psxtests/psxpasswd02')
-rw-r--r--testsuites/psxtests/psxpasswd02/init.c26
-rw-r--r--testsuites/psxtests/psxpasswd02/psxpasswd02.scn2
2 files changed, 28 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxpasswd02/init.c b/testsuites/psxtests/psxpasswd02/init.c
index 48b66196b1..2a78becfaf 100644
--- a/testsuites/psxtests/psxpasswd02/init.c
+++ b/testsuites/psxtests/psxpasswd02/init.c
@@ -17,6 +17,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <limits.h>
void print_passwd(
struct passwd *pw
@@ -63,6 +64,9 @@ rtems_task Init(
struct passwd *pw;
struct group *gr;
int status = -1;
+ char str[100] = {0};
+ int max_int = INT_MAX;
+ int limit_value = 0;
FILE *fp = NULL;
@@ -127,6 +131,28 @@ rtems_task Init(
rtems_test_assert( !pw );
rtems_test_assert( errno == EINVAL );
+ fp = fopen( "/etc/passwd", "w" );
+ rtems_test_assert( fp != NULL );
+ fprintf( fp, "user:x:999999999999:1:dummy::/:/bin/sh\n" );
+ fclose( fp );
+
+ puts( "Init - getpwnam(\"root\") -- expected EINVAL" );
+ pw = getpwnam( "root" );
+ rtems_test_assert( !pw );
+ rtems_test_assert( errno == EINVAL );
+
+ sprintf( str, "user:x:%d%d:1:dummy::/:/bin/sh\n", max_int/10, max_int%10+1 );
+
+ fp = fopen( "/etc/passwd", "w" );
+ rtems_test_assert( fp != NULL );
+ fprintf( fp, str );
+ 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 );
diff --git a/testsuites/psxtests/psxpasswd02/psxpasswd02.scn b/testsuites/psxtests/psxpasswd02/psxpasswd02.scn
index 21b661d391..99d2be5635 100644
--- a/testsuites/psxtests/psxpasswd02/psxpasswd02.scn
+++ b/testsuites/psxtests/psxpasswd02/psxpasswd02.scn
@@ -9,6 +9,8 @@ Init - setgrent() -- OK
Init - getpwnam("root") -- expected EINVAL
Init - getpwnam("root") -- expected EINVAL
Init - getpwnam("root") -- expected EINVAL
+Init - getpwnam("root") -- expected EINVAL
+Init - getpwnam("root") -- expected EINVAL
Init - getgrent() -- OK
group name: admin
group password: