diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-11-12 14:58:13 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-11-13 09:38:03 +0100 |
commit | 8f1b6cdef5e06caedf9615f70180606394f928bb (patch) | |
tree | 07ca123f08707f4ba60625fc297028f443949e9a /testsuites/fstests | |
parent | samples/fileio: Add DOSFS and RFS on demand (diff) | |
download | rtems-8f1b6cdef5e06caedf9615f70180606394f928bb.tar.bz2 |
fstests/fsrfsbitmap01: Fix NULL pointer access
Move test files into one directory.
Diffstat (limited to 'testsuites/fstests')
-rw-r--r-- | testsuites/fstests/Makefile.am | 2 | ||||
-rw-r--r-- | testsuites/fstests/configure.ac | 2 | ||||
-rw-r--r-- | testsuites/fstests/fsrfsbitmap01/Makefile.am | 33 | ||||
-rw-r--r-- | testsuites/fstests/fsrfsbitmap01/fsrfsbitmap01.scn | 2 | ||||
-rw-r--r-- | testsuites/fstests/fsrfsbitmap01/test.c | 85 | ||||
-rw-r--r-- | testsuites/fstests/mrfs_fsrfsbitmap01/Makefile.am | 33 |
6 files changed, 67 insertions, 90 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am index 386f221e66..9bba757b5a 100644 --- a/testsuites/fstests/Makefile.am +++ b/testsuites/fstests/Makefile.am @@ -29,7 +29,7 @@ SUBDIRS += mrfs_fsrdwr SUBDIRS += mrfs_fssymlink SUBDIRS += mrfs_fstime SUBDIRS += mrfs_fsfpathconf -SUBDIRS += mrfs_fsrfsbitmap01 +SUBDIRS += fsrfsbitmap01 SUBDIRS += fsnofs01 SUBDIRS += fsimfsgeneric01 SUBDIRS += fsbdpart01 diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac index 8473c15df9..6dd15acddc 100644 --- a/testsuites/fstests/configure.ac +++ b/testsuites/fstests/configure.ac @@ -105,7 +105,7 @@ mrfs_fsrdwr/Makefile mrfs_fssymlink/Makefile mrfs_fstime/Makefile mrfs_fsfpathconf/Makefile -mrfs_fsrfsbitmap01/Makefile +fsrfsbitmap01/Makefile fsnofs01/Makefile fsimfsgeneric01/Makefile fsbdpart01/Makefile diff --git a/testsuites/fstests/fsrfsbitmap01/Makefile.am b/testsuites/fstests/fsrfsbitmap01/Makefile.am new file mode 100644 index 0000000000..b52fa9903b --- /dev/null +++ b/testsuites/fstests/fsrfsbitmap01/Makefile.am @@ -0,0 +1,33 @@ + +rtems_tests_PROGRAMS = fsrfsbitmap01 +fsrfsbitmap01_SOURCES = test.c +fsrfsbitmap01_SOURCES += ../support/ramdisk_support.c +fsrfsbitmap01_SOURCES += ../support/fstest_support.c +fsrfsbitmap01_SOURCES += ../support/fstest_support.h +fsrfsbitmap01_SOURCES += ../support/ramdisk_support.h +fsrfsbitmap01_SOURCES += ../support/fstest.h +fsrfsbitmap01_SOURCES += ../../psxtests/include/pmacros.h +fsrfsbitmap01_SOURCES += ../mrfs_support/fs_support.c +fsrfsbitmap01_SOURCES += ../mrfs_support/fs_config.h + +dist_rtems_tests_DATA = fsrfsbitmap01.scn +dist_rtems_tests_DATA += fsrfsbitmap01.doc + +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)/support +AM_CPPFLAGS += -I$(top_srcdir)/mrfs_support +AM_CPPFLAGS += -I$(top_srcdir)/../support/include +AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include + +LINK_OBJS = $(fsrfsbitmap01_OBJECTS) +LINK_LIBS = $(fsrfsbitmap01_LDLIBS) + +fsrfsbitmap01$(EXEEXT): $(fsrfsbitmap01_OBJECTS) $(fsrfsbitmap01_DEPENDENCIES) + @rm -f fsrfsbitmap01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/fstests/fsrfsbitmap01/fsrfsbitmap01.scn b/testsuites/fstests/fsrfsbitmap01/fsrfsbitmap01.scn index d76fa1e2f8..ec944c527d 100644 --- a/testsuites/fstests/fsrfsbitmap01/fsrfsbitmap01.scn +++ b/testsuites/fstests/fsrfsbitmap01/fsrfsbitmap01.scn @@ -129,7 +129,7 @@ RFS Bitmap Test : size = 420 (14) 33. Attempt to find bit when all bits are set (expected FAILED): FAILED 34. Clear all bits in the map. - Testing bitmap_map functions with NULL bitmap control pointer + Testing bitmap_map functions with zero initialized bitmap control pointer Allocate most of memory - attempt to fail while open bitmap - expect ENOMEM Attempt to open bitmap returned: Not enough space diff --git a/testsuites/fstests/fsrfsbitmap01/test.c b/testsuites/fstests/fsrfsbitmap01/test.c index dcd96df7a5..df6e47882d 100644 --- a/testsuites/fstests/fsrfsbitmap01/test.c +++ b/testsuites/fstests/fsrfsbitmap01/test.c @@ -446,79 +446,56 @@ static void rtems_rfs_bitmap_unit_test (void) static void nullpointer_test(void){ - rtems_rfs_bitmap_control* control=NULL; - rtems_rfs_bitmap_control notnullcontrol; + rtems_rfs_bitmap_control control; rtems_rfs_bitmap_bit bit = 0; rtems_rfs_bitmap_bit seed_bit = 0; int rc; bool result; - printf("\n Testing bitmap_map functions with NULL bitmap control " - "pointer\n"); - /* Invoke all functions with NULL control */ - rc = rtems_rfs_bitmap_map_set(control, bit); - rtems_test_assert(rc>0); - rc = rtems_rfs_bitmap_map_clear(control, bit); - rtems_test_assert(rc>0); - rc = rtems_rfs_bitmap_map_test(control, bit, &result); - rtems_test_assert(rc>0); - rc = rtems_rfs_bitmap_map_set_all(control); - rtems_test_assert(rc>0); - rc = rtems_rfs_bitmap_map_clear_all(control); - rtems_test_assert(rc>0); - rc = rtems_rfs_bitmap_create_search(control); - rtems_test_assert(rc>0); - rc = rtems_rfs_bitmap_map_alloc(control, seed_bit, &result, &bit); + memset(&control, 0, sizeof(control)); + + printf ("\n Testing bitmap_map functions with zero " + "initialized bitmap control pointer\n"); + + /* Invoke all functions with control initialized to zero */ + rc = rtems_rfs_bitmap_map_set(&control, bit); + rtems_test_assert(rc == ENXIO); + rc = rtems_rfs_bitmap_map_clear(&control, bit); + rtems_test_assert(rc == ENXIO); + rc = rtems_rfs_bitmap_map_test(&control, bit, &result); + rtems_test_assert(rc == ENXIO); + rc = rtems_rfs_bitmap_map_set_all(&control); + rtems_test_assert(rc == ENXIO); + rc = rtems_rfs_bitmap_map_clear_all(&control); + rtems_test_assert(rc == ENXIO); + rc = rtems_rfs_bitmap_create_search(&control); + rtems_test_assert(rc == ENXIO); + rc = rtems_rfs_bitmap_map_alloc(&control, seed_bit, &result, &bit); + rtems_test_assert(rc == 0); rtems_test_assert(!result); - /* - * Invoke map_alloc with not-null pointer to control, but with - * control uninitialized. It is to cover check in rtems_rfs_bitmap_load_map. - * We can't check directly if it goes this path, but we will see this in - * coverage - */ - rc = rtems_rfs_bitmap_map_set(¬nullcontrol, bit); - rtems_test_assert(rc > 0); + rc = rtems_rfs_bitmap_map_set(&control, bit); + rtems_test_assert(rc == ENXIO); } static void open_failure(void){ - rtems_rfs_file_system fs; - rtems_rfs_bitmap_control control; - rtems_rfs_buffer_handle handle; - rtems_rfs_buffer buffer; - size_t bytes; - int rc; + rtems_rfs_file_system fs; + rtems_rfs_bitmap_control control; + rtems_rfs_buffer_handle handle; + int rc; + void *opaque; /* Attempt to get ENOMEM while open bitmap */ printf("\n Allocate most of memory - attempt to fail while open bitmap - expect ENOMEM\n" ); - void *opaque; - static const uintptr_t location_size [] = { - sizeof(rtems_filesystem_global_location_t) - }; - - size_t size = location_size[0]*rtems_rfs_bitmap_search_element_bits(); - bytes = (rtems_rfs_bitmap_elements (size) * - sizeof (rtems_rfs_bitmap_element)); - opaque = rtems_heap_greedy_allocate( location_size, 1 ); + opaque = rtems_heap_greedy_allocate( NULL, 0 ); memset (&fs, 0, sizeof (fs)); - memset (&buffer, 0, sizeof (buffer)); - - buffer.buffer = malloc (bytes); - buffer.block = 1; - -#if RTEMS_RFS_BITMAP_CLEAR_ZERO - memset (buffer.buffer, 0, bytes); -#else - memset (buffer.buffer, 0xff, bytes); -#endif rc = rtems_rfs_buffer_handle_open (&fs, &handle); - handle.buffer = &buffer; - handle.bnum = 1; + rtems_test_assert( rc == 0 ); - rc = rtems_rfs_bitmap_open (&control, &fs, &handle, size, 1); + rc = rtems_rfs_bitmap_open (&control, &fs, &handle, 0, 0); rtems_test_assert( rc == ENOMEM ); printf( " Attempt to open bitmap returned: %s\n", strerror(rc)); puts( " Freeing the allocated memory" ); diff --git a/testsuites/fstests/mrfs_fsrfsbitmap01/Makefile.am b/testsuites/fstests/mrfs_fsrfsbitmap01/Makefile.am deleted file mode 100644 index c4063c1b3f..0000000000 --- a/testsuites/fstests/mrfs_fsrfsbitmap01/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ - -rtems_tests_PROGRAMS = mrfs_fsrfsbitmap01 -mrfs_fsrfsbitmap01_SOURCES = ../fsrfsbitmap01/test.c -mrfs_fsrfsbitmap01_SOURCES += ../support/ramdisk_support.c -mrfs_fsrfsbitmap01_SOURCES += ../support/fstest_support.c -mrfs_fsrfsbitmap01_SOURCES += ../support/fstest_support.h -mrfs_fsrfsbitmap01_SOURCES += ../support/ramdisk_support.h -mrfs_fsrfsbitmap01_SOURCES += ../support/fstest.h -mrfs_fsrfsbitmap01_SOURCES += ../../psxtests/include/pmacros.h -mrfs_fsrfsbitmap01_SOURCES += ../mrfs_support/fs_support.c -mrfs_fsrfsbitmap01_SOURCES += ../mrfs_support/fs_config.h - -#dist_rtems_tests_DATA = mrfs_fsrfsbitmap01.scn -#dist_rtems_tests_DATA += mrfs_fsrfsbitmap01.doc - -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)/support -AM_CPPFLAGS += -I$(top_srcdir)/mrfs_support -AM_CPPFLAGS += -I$(top_srcdir)/../support/include -AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include - -LINK_OBJS = $(mrfs_fsrfsbitmap01_OBJECTS) -LINK_LIBS = $(mrfs_fsrfsbitmap01_LDLIBS) - -mrfs_fsrfsbitmap01$(EXEEXT): $(mrfs_fsrfsbitmap01_OBJECTS) $(mrfs_fsrfsbitmap01_DEPENDENCIES) - @rm -f mrfs_fsrfsbitmap01$(EXEEXT) - $(make-exe) - -include $(top_srcdir)/../automake/local.am |