Changeset 8f1b6cde in rtems


Ignore:
Timestamp:
Nov 12, 2012, 1:58:13 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
8f548ce
Parents:
b5b1f44
git-author:
Sebastian Huber <sebastian.huber@…> (11/12/12 13:58:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/13/12 08:38:03)
Message:

fstests/fsrfsbitmap01: Fix NULL pointer access

Move test files into one directory.

Location:
testsuites/fstests
Files:
1 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • testsuites/fstests/Makefile.am

    rb5b1f44 r8f1b6cde  
    3030SUBDIRS += mrfs_fstime
    3131SUBDIRS += mrfs_fsfpathconf
    32 SUBDIRS += mrfs_fsrfsbitmap01
     32SUBDIRS += fsrfsbitmap01
    3333SUBDIRS += fsnofs01
    3434SUBDIRS += fsimfsgeneric01
  • testsuites/fstests/configure.ac

    rb5b1f44 r8f1b6cde  
    106106mrfs_fstime/Makefile
    107107mrfs_fsfpathconf/Makefile
    108 mrfs_fsrfsbitmap01/Makefile
     108fsrfsbitmap01/Makefile
    109109fsnofs01/Makefile
    110110fsimfsgeneric01/Makefile
  • testsuites/fstests/fsrfsbitmap01/fsrfsbitmap01.scn

    rb5b1f44 r8f1b6cde  
    130130 34. Clear all bits in the map.
    131131
    132  Testing bitmap_map functions with NULL bitmap control pointer
     132 Testing bitmap_map functions with zero initialized bitmap control pointer
    133133
    134134 Allocate most of memory - attempt to fail while open bitmap - expect ENOMEM
  • testsuites/fstests/fsrfsbitmap01/test.c

    rb5b1f44 r8f1b6cde  
    447447static void nullpointer_test(void){
    448448
    449   rtems_rfs_bitmap_control* control=NULL;
    450   rtems_rfs_bitmap_control  notnullcontrol;
     449  rtems_rfs_bitmap_control control;
    451450  rtems_rfs_bitmap_bit  bit = 0;
    452451  rtems_rfs_bitmap_bit  seed_bit = 0;
     
    454453  bool result;
    455454
    456   printf("\n Testing bitmap_map functions with NULL bitmap control "
    457          "pointer\n");
    458   /* Invoke all functions with NULL control */
    459   rc = rtems_rfs_bitmap_map_set(control, bit);
    460   rtems_test_assert(rc>0);
    461   rc = rtems_rfs_bitmap_map_clear(control, bit);
    462   rtems_test_assert(rc>0);
    463   rc = rtems_rfs_bitmap_map_test(control, bit, &result);
    464   rtems_test_assert(rc>0);
    465   rc = rtems_rfs_bitmap_map_set_all(control);
    466   rtems_test_assert(rc>0);
    467   rc = rtems_rfs_bitmap_map_clear_all(control);
    468   rtems_test_assert(rc>0);
    469   rc = rtems_rfs_bitmap_create_search(control);
    470   rtems_test_assert(rc>0);
    471   rc = rtems_rfs_bitmap_map_alloc(control, seed_bit, &result, &bit);
     455  memset(&control, 0, sizeof(control));
     456
     457  printf ("\n Testing bitmap_map functions with zero "
     458            "initialized bitmap control pointer\n");
     459
     460  /* Invoke all functions with control initialized to zero */
     461  rc = rtems_rfs_bitmap_map_set(&control, bit);
     462  rtems_test_assert(rc == ENXIO);
     463  rc = rtems_rfs_bitmap_map_clear(&control, bit);
     464  rtems_test_assert(rc == ENXIO);
     465  rc = rtems_rfs_bitmap_map_test(&control, bit, &result);
     466  rtems_test_assert(rc == ENXIO);
     467  rc = rtems_rfs_bitmap_map_set_all(&control);
     468  rtems_test_assert(rc == ENXIO);
     469  rc = rtems_rfs_bitmap_map_clear_all(&control);
     470  rtems_test_assert(rc == ENXIO);
     471  rc = rtems_rfs_bitmap_create_search(&control);
     472  rtems_test_assert(rc == ENXIO);
     473  rc = rtems_rfs_bitmap_map_alloc(&control, seed_bit, &result, &bit);
     474  rtems_test_assert(rc == 0);
    472475  rtems_test_assert(!result);
    473   /*
    474    * Invoke map_alloc with not-null pointer to control, but with
    475    * control uninitialized. It is to cover check in rtems_rfs_bitmap_load_map.
    476    * We can't check directly if it goes this path, but we will see this in
    477    * coverage
    478    */
    479   rc = rtems_rfs_bitmap_map_set(&notnullcontrol, bit);
    480   rtems_test_assert(rc > 0);
     476  rc = rtems_rfs_bitmap_map_set(&control, bit);
     477  rtems_test_assert(rc == ENXIO);
    481478}
    482479
    483480static void open_failure(void){
    484481
    485   rtems_rfs_file_system    fs;
    486   rtems_rfs_bitmap_control control;
    487   rtems_rfs_buffer_handle  handle;
    488   rtems_rfs_buffer         buffer;
    489   size_t                   bytes;
    490   int                      rc;
     482  rtems_rfs_file_system     fs;
     483  rtems_rfs_bitmap_control  control;
     484  rtems_rfs_buffer_handle   handle;
     485  int                       rc;
     486  void                     *opaque;
    491487
    492488  /* Attempt to get ENOMEM while open bitmap */
    493489  printf("\n Allocate most of memory - attempt to fail while open bitmap - expect ENOMEM\n" );
    494   void *opaque;
    495   static const uintptr_t location_size [] = {
    496     sizeof(rtems_filesystem_global_location_t)
    497   };
    498 
    499   size_t size = location_size[0]*rtems_rfs_bitmap_search_element_bits();
    500   bytes = (rtems_rfs_bitmap_elements (size) *
    501            sizeof (rtems_rfs_bitmap_element));
    502 
    503   opaque = rtems_heap_greedy_allocate( location_size, 1 );
     490
     491  opaque = rtems_heap_greedy_allocate( NULL, 0 );
    504492
    505493  memset (&fs, 0, sizeof (fs));
    506   memset (&buffer, 0, sizeof (buffer));
    507 
    508   buffer.buffer = malloc (bytes);
    509   buffer.block = 1;
    510 
    511 #if RTEMS_RFS_BITMAP_CLEAR_ZERO
    512   memset (buffer.buffer, 0, bytes);
    513 #else
    514   memset (buffer.buffer, 0xff, bytes);
    515 #endif
    516494
    517495  rc = rtems_rfs_buffer_handle_open (&fs, &handle);
    518   handle.buffer = &buffer;
    519   handle.bnum = 1;
    520 
    521   rc = rtems_rfs_bitmap_open (&control, &fs, &handle, size, 1);
     496  rtems_test_assert( rc == 0 );
     497
     498  rc = rtems_rfs_bitmap_open (&control, &fs, &handle, 0, 0);
    522499  rtems_test_assert( rc == ENOMEM );
    523500  printf( " Attempt to open bitmap returned: %s\n", strerror(rc));
Note: See TracChangeset for help on using the changeset viewer.