Exemplo n.º 1
0
// -------------------------------------------------------------------------- //
//
void Test_PCFData::testConstructionFail3()
{
    // Setup input.
    const double rmin  = 0.0;
    const double rmax  = 5.0;
    const double dr    = 0.02;
    const double sigma = 0.01;
    const double numberdensity = 0.3;
    const std::pair<double, double> fit_inteval(0.2, 1.0);
    const int nbins = 250;
    const std::pair<int,int> partial(0,1);

    // Error with wrong file name.
    std::string reference_data("NOTANAME");
    CPPUNIT_ASSERT_THROW( PCFData(rmin, rmax, dr, sigma, numberdensity, fit_inteval, nbins, partial, reference_data), IOException );

    // Error with truncated file.
    reference_data = "./testfiles/gr_ref.data_trunc";
    CPPUNIT_ASSERT_THROW( PCFData(rmin, rmax, dr, sigma, numberdensity, fit_inteval, nbins, partial, reference_data), IOException );

}
Exemplo n.º 2
0
/************************************************************************
 *									*
 * mmap_read_data() - Read and optionally verify memory mapped data.	*
 *									*
 * Inputs:	dip = The device information pointer.			*
 *									*
 * Outputs:	Returns SUCCESS/FAILURE = Ok/Error.			*
 *									*
 ************************************************************************/
int
mmap_read_data (struct dinfo *dip)
{
	ssize_t count;
	size_t bsize, dsize;
	int status = SUCCESS;
	u_int32 lba = lbdata_addr;
	struct dtfuncs *dtf = dip->di_funcs;

	/*
	 * For variable length records, initialize to minimum record size.
	 */
	if (min_size) {
            if (variable_flag) {
                dsize = get_variable (dip);
            } else {
                dsize = min_size;
            }
	} else {
	    dsize = block_size;
	}

	/*
	 * Now read and optionally verify the input records.
	 */
	while ( (error_count < error_limit) &&
		(dip->di_fbytes_read < data_limit) &&
		(dip->di_records_read < record_limit) ) {

	    if (rdelay_count) {			/* Optional read delay.	*/
		mySleep (rdelay_count);
	    }

	    /*
	     * If data limit was specified, ensure we don't exceed it.
	     */
	    if ( (dip->di_fbytes_read + dsize) > data_limit) {
		bsize = (data_limit - dip->di_fbytes_read);
		if (debug_flag) {
		    Printf ("Reading partial record of %d bytes...\n", bsize);
		}
	    } else {
		bsize = dsize;
	    }

	    count = bsize;			/* Paged in by system.	*/

	    if ((io_mode == TEST_MODE) && compare_flag) {
		if (iot_pattern) {
		    lba = init_iotdata (count, lba, lbdata_size);
		}
	    }

	    /*
	     * Stop reading when end of file is reached.
	     */
	    if (count == (ssize_t) 0) {		/* Pseudo end of file. */
		if (debug_flag) {
		    Printf ("End of memory mapped file detected...\n");
		}
		end_of_file = TRUE;
		exit_status = END_OF_FILE;
		break;
	    } else {
		dip->di_dbytes_read += count;
		dip->di_fbytes_read += count;
	        if ((status = check_read (dip, count, bsize)) == FAILURE) {
		    break;
		}
	    }

	    if (count == dsize) {
		records_processed++;
	    } else {
		partial_records++;
	    }

	    /*
	     * Verify the data (unless disabled).
	     */
	    if (compare_flag) {
		status = (*dtf->tf_verify_data)(dip, mmap_bufptr, count, pattern, &lba);
	    } else {
		/*
		 * Must reference the data to get it paged in.
		 */
		reference_data (mmap_bufptr, count);
	    }
	    mmap_bufptr += count;

	    /*
	     * For variable length records, adjust the next record size.
	     */
	    if (min_size) {
		if (variable_flag) {
		    dsize = get_variable (dip);
		} else {
		    dsize += incr_count;
		    if (dsize > max_size) dsize = min_size;
		}
	    }

	    if ( (dip->di_fbytes_read >= data_limit) ||
		 (++dip->di_records_read >= record_limit) ) {
		break;
	    }

#ifdef notdef
	/*
	 * Can't do this right now... if it's not mapped via mmap(), you'll
	 * get a "Segmentation Fault" and core dump.  Need more logic...
	 */
	    if (step_offset) mmap_bufptr += step_offset;
#endif
	}
	return (status);
}