summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/devfs01/init.c33
-rw-r--r--testsuites/libtests/devfs02/init.c65
-rw-r--r--testsuites/libtests/devfs03/init.c41
3 files changed, 57 insertions, 82 deletions
diff --git a/testsuites/libtests/devfs01/init.c b/testsuites/libtests/devfs01/init.c
index aa7b146824..27dc8d3f97 100644
--- a/testsuites/libtests/devfs01/init.c
+++ b/testsuites/libtests/devfs01/init.c
@@ -22,39 +22,10 @@ rtems_task Init(
rtems_task_argument argument
)
{
- int sc;
- int size;
- rtems_filesystem_location_info_t *temp_loc;
- rtems_device_name_t *device_name_table;
-
puts( "\n\n*** TEST DEVFS01 ***" );
- puts( "devFS_Show - OK" );
- sc = devFS_Show();
- rtems_test_assert( sc == 0 );
-
- /* save original node access information */
- temp_loc = &rtems_filesystem_root;
- device_name_table = (rtems_device_name_t *)temp_loc->node_access;
- temp_loc->node_access = NULL;
-
- puts( "devFS_Show - no device table - EFAULT" );
- sc = devFS_Show();
- rtems_test_assert( sc == -1 );
- rtems_test_assert( errno == EFAULT );
-
- /* restore node access information */
- temp_loc->node_access = device_name_table;
-
- /* save original device table size information */
- size = rtems_device_table_size;
- rtems_device_table_size = 0;
- puts( "devFS_Show - devices - OK" );
- sc = devFS_Show();
- rtems_test_assert( sc == 0 );
-
- /* restore original device table size information */
- rtems_device_table_size = size;
+ puts( "devFS_Show" );
+ devFS_Show();
puts( "*** END OF TEST DEVFS01 ***" );
diff --git a/testsuites/libtests/devfs02/init.c b/testsuites/libtests/devfs02/init.c
index f648a177cf..96febbf974 100644
--- a/testsuites/libtests/devfs02/init.c
+++ b/testsuites/libtests/devfs02/init.c
@@ -2,6 +2,9 @@
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
+ * Modifications to support reference counting in the file system are
+ * Copyright (c) 2012 embedded brains GmbH.
+ *
* 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.
@@ -10,74 +13,62 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <tmacros.h>
#include "test_support.h"
-#include <rtems/devfs.h>
+
+#include <tmacros.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <rtems/devfs.h>
+#include <rtems/malloc.h>
+
rtems_task Init(
rtems_task_argument argument
)
{
int status;
- rtems_filesystem_location_info_t *temp_loc;
- rtems_device_name_t *device_name_table;
- int temp_size = 0;
- struct stat statbuf;
+ rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
+ const devFS_data *data = rootloc->mt_entry->immutable_fs_info;
+ devFS_data zero_count_data = {
+ .nodes = data->nodes,
+ .count = 0
+ };
+ void *opaque;
puts( "\n\n*** TEST DEVFS02 ***" );
- puts( "Init - attempt to create a fifo - expect EINVAL" );
+ puts( "Init - attempt to create a fifo - expect ENOTSUP" );
status = mkfifo( "/fifo01", 0 );
rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EINVAL );
-
- /* Manipulate the root */
- puts( "Init - set the device name table to NULL" );
- temp_loc = &rtems_filesystem_root;
- device_name_table = (rtems_device_name_t *)temp_loc->node_access;
- temp_loc->node_access = NULL;
-
- puts(" Init - attempt to create a node - expect EFAULT" );
- status = mknod( "/node", S_IFBLK, 0LL );
- rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EFAULT );
+ rtems_test_assert( errno == ENOTSUP );
- /* This case actually stops at evaluation of path */
- puts( "Init - attempt to stat a node - expect EFAULT" );
- status = stat( "/", &statbuf );
- rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EFAULT );
+ /* Manipulate the device table size */
+ puts( "Init - set device table size to zero" );
+ rootloc->mt_entry->immutable_fs_info = &zero_count_data;
- puts( "Init - attempt to open a node" );
- status = open( "/node", O_RDWR );
+ puts( "Init - attempt to create a node - expect ENOSPC" );
+ status = mknod( "/node", S_IFBLK, 0LL );
rtems_test_assert( status == -1 );
- rtems_test_assert( errno == EFAULT );
+ rtems_test_assert( errno == ENOSPC );
/* Now restore */
- puts( "Init - restore the device name table" );
- temp_loc->node_access = device_name_table;
+ puts( "Init - restore device table size" );
+ rootloc->mt_entry->immutable_fs_info = data;
- /* Manipulate the device table size */
- puts( "Init - set device table size to zero" );
- temp_size = rtems_device_table_size;
- rtems_device_table_size = 0;
+ opaque = rtems_heap_greedy_allocate( 0 );
puts( "Init - attempt to create a node - expect ENOMEM" );
status = mknod( "/node", S_IFBLK, 0LL );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == ENOMEM );
- /* Now restore */
- puts( "Init - restore device table size" );
- rtems_device_table_size = temp_size;
+ rtems_heap_greedy_free( opaque );
puts( "Init - attempt to create /node -- OK" );
status = mknod( "/node", S_IFBLK, 0LL );
diff --git a/testsuites/libtests/devfs03/init.c b/testsuites/libtests/devfs03/init.c
index 07e29263c5..7660227009 100644
--- a/testsuites/libtests/devfs03/init.c
+++ b/testsuites/libtests/devfs03/init.c
@@ -2,6 +2,9 @@
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
+ * Modifications to support reference counting in the file system are
+ * Copyright (c) 2012 embedded brains GmbH.
+ *
* 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.
@@ -21,15 +24,17 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <rtems/score/heap.h>
rtems_task Init(
rtems_task_argument argument
)
{
int status;
- void *alloc_ptr = (void *)0;
- Heap_Information_block Info;
+ devFS_node nodes [1];
+ devFS_data data = {
+ .nodes = nodes,
+ .count = 1
+ };
puts( "\n\n*** TEST DEVFS03 ***" );
@@ -37,24 +42,31 @@ rtems_task Init(
status = mkdir( "/dir01", S_IRWXU );
rtems_test_assert( status == 0 );
- puts( "Init - allocating most of workspace memory" );
- status = rtems_workspace_get_information( &Info );
- rtems_test_assert( status == true );
- status = rtems_workspace_allocate( Info.Free.largest - 4, &alloc_ptr );
- rtems_test_assert( status == true );
-
- puts( "Init - mount a new fs at /dir01 - expect ENOMEM" );
+ puts( "Init - mount a new fs at /dir01 - expect EINVAL" );
status = mount( NULL,
"/dir01",
"devfs",
RTEMS_FILESYSTEM_READ_WRITE,
NULL );
rtems_test_assert( status == -1 );
- rtems_test_assert( errno == ENOMEM );
+ rtems_test_assert( errno == EINVAL );
- puts( "Init - freeing the workspace memory" );
- status = rtems_workspace_free( alloc_ptr );
- rtems_test_assert( status == true );
+ puts( "Init - mount a new fs at /dir01 - OK" );
+ status = mount( NULL,
+ "/dir01",
+ "devfs",
+ RTEMS_FILESYSTEM_READ_WRITE,
+ &data );
+ rtems_test_assert( status == 0 );
+
+ puts( "Init - make file /dir01/dev -- expect ENOTSUP" );
+ status = creat( "/dir01/dev", S_IRWXU );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == ENOTSUP );
+
+ puts( "Init - unmount fs at /dir01 - OK" );
+ status = unmount( "/dir01" );
+ rtems_test_assert( status == 0 );
status = rmdir( "/dir01" );
rtems_test_assert( status == 0 );
@@ -69,6 +81,7 @@ rtems_task Init(
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE