Example #1
0
def run_writetest_N_times(func, n):
    """Run each test N times.
    @param  func:   function for test
    @param  n:      times to repeat.
    @return:        (median time, times list)
    """
    assert n > 0
    times = []
    for i in range_g(n):
        sio = StringIO()
        times.append(run_test(func, sio))
        sio.close()
    t = median(times)
    return t, times
Example #2
0
def run_writetest_N_times(func, n):
    """Run each test N times.
    @param  func:   function for test
    @param  n:      times to repeat.
    @return:        (median time, times list)
    """
    assert n > 0
    times = []
    for i in range_g(n):
        sio = StringIO()
        times.append(run_test(func, sio))
        sio.close()
    t = median(times)
    return t, times
Example #3
0
def run_readtest_N_times(func, hexstr, n):
    """Run each test N times.
    @param  func:   function for test
    @param  hexstr: string with content of hex file to read
    @param  n:      times to repeat.
    @return:        (median time, times list)
    """
    assert n > 0
    times = []
    for i in range_g(n):
        sio = StringIO(hexstr)
        times.append(run_test(func, sio))
        sio.close()
    t = median(times)
    return t, times
Example #4
0
def run_readtest_N_times(func, hexstr, n):
    """Run each test N times.
    @param  func:   function for test
    @param  hexstr: string with content of hex file to read
    @param  n:      times to repeat.
    @return:        (median time, times list)
    """
    assert n > 0
    times = []
    for i in range_g(n):
        sio = StringIO(hexstr)
        times.append(run_test(func, sio))
        sio.close()
    t = median(times)
    return t, times
Example #5
0
def get_test_data(n1, offset, n2):
    """Create test data on given pattern.
    @param  n1:     size of first part of array at base address 0.
    @param  offset: offset for second part of array.
    @param  n2:     size of second part of array at given offset.
    @return:        (overall size, hex file, IntelHex object)
    """
    # make IntelHex object
    ih = intelhex.IntelHex()
    addr = 0
    for i in range_g(n1):
        ih[addr] = addr % 256
        addr += 1
    addr += offset
    for i in range_g(n2):
        ih[addr] = addr % 256
        addr += 1
    # make hex file
    sio = StringIO()
    ih.write_hex_file(sio)
    hexstr = sio.getvalue()
    sio.close()
    #
    return n1+n2, hexstr, ih
Example #6
0
def get_test_data(n1, offset, n2):
    """Create test data on given pattern.
    @param  n1:     size of first part of array at base address 0.
    @param  offset: offset for second part of array.
    @param  n2:     size of second part of array at given offset.
    @return:        (overall size, hex file, IntelHex object)
    """
    # make IntelHex object
    ih = intelhex.IntelHex()
    addr = 0
    for i in range_g(n1):
        ih[addr] = addr % 256
        addr += 1
    addr += offset
    for i in range_g(n2):
        ih[addr] = addr % 256
        addr += 1
    # make hex file
    sio = StringIO()
    ih.write_hex_file(sio)
    hexstr = sio.getvalue()
    sio.close()
    #
    return n1+n2, hexstr, ih
Example #7
0
 def prepare_lines(ih):
     sio = StringIO()
     ih.dump(sio)
     dump = sio.getvalue()
     lines = dump.splitlines()
     return lines
Example #8
0
 def prepare_lines(ih):
     sio = StringIO()
     ih.dump(sio)
     dump = sio.getvalue()
     lines = dump.splitlines()
     return lines