Ejemplo n.º 1
0
def test_meta_strings_with_different_lengths():
    ets1 = ets_format.read_ths_from_ets_file(
        filename='tests/samples/test_str_meta_1.ets')
    ets2 = ets_format.read_ths_from_ets_file(
        filename='tests/samples/test_str_meta_2.ets')
    ets = concat_format.read_ths_from_multiple_ths(ets1, ets2)

    str_stack = np.concatenate((ets1.str_meta[:], ets2.str_meta[:]), axis=0)
    np_str_stack = np.concatenate((ets1.np_str_meta[:], ets2.np_str_meta[:]),
                                  axis=0)

    assert np.array_equal(ets.str_meta[:], str_stack)
    assert np.array_equal(ets.np_str_meta[:], np_str_stack)
Ejemplo n.º 2
0
def load_data():
    ets = ets_format.read_ths_from_ets_file(filename=path)
    samples = ets.samples[:].copy()
    plaintext = ets.plaintext[:].copy()
    foo_bar = ets.foo_bar[:].copy()
    ciphertext = ets.ciphertext[:].copy()
    return samples, plaintext, foo_bar, ciphertext
Ejemplo n.º 3
0
def test_read_from_incorrect_ets_file_raises_type_error():
    with pytest.raises(TypeError):
        ets_format.read_ths_from_ets_file(
            filename='tests/samples/AESEncrypt.500MSs.cur.00000')
Ejemplo n.º 4
0
def test_read_from_ets_raise_exception_if_file_does_not_exist():
    with pytest.raises(AttributeError):
        ets_format.read_ths_from_ets_file(filename='doesnotexist')
Ejemplo n.º 5
0
def test_open_ets_file_with_path():
    ets1 = ets_format.read_ths_from_ets_file(filename=Path(path))
    assert isinstance(ets1, estraces.TraceHeaderSet)
    assert 200 == len(ets1)
Ejemplo n.º 6
0
def ets1():
    return ets_format.read_ths_from_ets_file(filename=path)
Ejemplo n.º 7
0
    assert [10, 11, 12, 13] == sub2.samples[1, 0:4].tolist()
    assert [12, 13, 14, 15] == sub2.samples[2, 0:4].tolist()


def bench_func(ets):
    for t in ets:
        t.plaintext


def ref_func(ets):
    plaintext = ets.plaintext[:]
    for t in range(len(ets)):
        plaintext[t]


ets2 = ets_format.read_ths_from_ets_file(filename=path)
ets3 = ets_format.read_ths_from_ets_file(filename=path)


def test_fetch_samples_execution_time(ets1):
    # See issue https://gitlab.eshard.int/esdynamic/estraces/issues/26
    # Here we mesure execution time of bench_func versus an arbitrary ref time given by ref_func execution.
    # Initial ratio before issue #26 ~175
    t_ref = timeit.timeit('ref_func(ets2)', number=100, globals=globals())
    t = timeit.timeit('bench_func(ets3)', number=100, globals=globals())
    assert 200 > abs(t - t_ref) / t_ref


PATH = 'tests/samples/'

Ejemplo n.º 8
0
def ets2(request):
    path = 'tests/samples/' + request.param
    return ets_format.read_ths_from_ets_file(filename=path)
Ejemplo n.º 9
0
def concat1():
    ets1 = ets_format.read_ths_from_ets_file(filename=path)
    ets2 = ets_format.read_ths_from_ets_file(filename=path)
    return concat_format.read_ths_from_multiple_ths(ets1, ets2)