summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-16 19:19:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-16 19:19:09 +0000
commit24db9ba8bb65aae0cd7cccb05054320e021f0741 (patch)
tree1777855aca92504b73a4e49e887350594e8c99b0 /testsuites/psxtests
parent2010-07-16 Bharath Suri <bharath.s.jois@gmail.com> (diff)
downloadrtems-24db9ba8bb65aae0cd7cccb05054320e021f0741.tar.bz2
2010-07-17 Bharath Suri <bharath.s.jois@gmail.com>
PR 1622/testing * psxchroot01/test.c, psxchroot01/psxchroot01.scn: Added two test cases to completely cover chroot().
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/ChangeLog6
-rw-r--r--testsuites/psxtests/psxchroot01/psxchroot01.scn4
-rw-r--r--testsuites/psxtests/psxchroot01/test.c29
3 files changed, 35 insertions, 4 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index b181221453..5706a429d7 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-17 Bharath Suri <bharath.s.jois@gmail.com>
+
+ PR 1622/testing
+ * psxchroot01/test.c, psxchroot01/psxchroot01.scn: Added two test
+ cases to completely cover chroot().
+
2010-07-16 Sebastian Huber <Sebastian.Huber@embedded-brains.de>
* psxfile01/test.c: Avoid NULL pointer access.
diff --git a/testsuites/psxtests/psxchroot01/psxchroot01.scn b/testsuites/psxtests/psxchroot01/psxchroot01.scn
index 519f2735b8..df79f8bb0f 100644
--- a/testsuites/psxtests/psxchroot01/psxchroot01.scn
+++ b/testsuites/psxtests/psxchroot01/psxchroot01.scn
@@ -1,6 +1,8 @@
-
*** CHROOT01 TEST ***
+allocate most of memory - attempt to fail chroot - expect ENOTSUP
+freeing the allocated memory
+chroot with bad path - expect EFAULT
SUCCESS on /one/one.test
SUCCESS on /two/two.test
Reset the private environment
diff --git a/testsuites/psxtests/psxchroot01/test.c b/testsuites/psxtests/psxchroot01/test.c
index 61045f7ce6..25105567fa 100644
--- a/testsuites/psxtests/psxchroot01/test.c
+++ b/testsuites/psxtests/psxchroot01/test.c
@@ -15,7 +15,7 @@
* implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1)
* record where DIRENT_SIZE seems to be 12 bytes.
*
- * COPYRIGHT (c) 1989-2009.
+ * COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -34,6 +34,7 @@
#include <rtems/libio.h>
#include <rtems/userenv.h>
#include <pmacros.h>
+#include <rtems/score/heap.h>
void touch( char *file )
{
@@ -63,6 +64,8 @@ int fileexists( char *file )
}
#if defined(__rtems__)
+extern Heap_Control *RTEMS_Malloc_Heap;
+
int test_main(void)
#else
int main(
@@ -72,13 +75,16 @@ int main(
#endif
{
int status;
-
+ void *alloc_ptr = (void *)0;
+ Heap_Information_block Info;
/*
* This test is the C equivalent of this sequence.
#mkdir /one
#mkdir /one/one
#touch /one/one.test
#touch /one/two/two.test
+# an error case to ENOTSUP from chroot
+# chroot
#chroot /one
#if !fileexists(/one/one.test) echo "SUCCESSFUL"
#if fileexists(/two/two.test) echo "SUCCESSFUL"
@@ -101,8 +107,25 @@ int main(
touch( "/one/one.test" );
touch( "/one/two/two.test" );
+ puts( "allocate most of memory - attempt to fail chroot - expect ENOTSUP" );
+ _Heap_Get_information(RTEMS_Malloc_Heap, &Info);
+ alloc_ptr = malloc( Info.Free.largest - 4 );
+ rtems_test_assert( alloc_ptr != NULL );
+
status = chroot( "/one" );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == ENOTSUP );
+
+ puts( "freeing the allocated memory" );
+ free( alloc_ptr );
+
+ puts( "chroot with bad path - expect EFAULT" );
+ status = chroot( NULL );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EFAULT );
+
+ status = chroot( "/one" );
+ rtems_test_assert( status == 0 );
status = fileexists( "/one/one.test" );
printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" );