diff options
| author | J08nY | 2023-09-28 17:31:33 +0200 |
|---|---|---|
| committer | J08nY | 2023-09-28 17:31:33 +0200 |
| commit | f2a0476c778dd5f752bf522f28563ec7a01f186e (patch) | |
| tree | ce1566ffa0478131236cb603774f88222173f98b /test/test_render.py | |
| parent | edae0ca0627926772045c105ae4551c18f872653 (diff) | |
| download | pyecsca-codegen-f2a0476c778dd5f752bf522f28563ec7a01f186e.tar.gz pyecsca-codegen-f2a0476c778dd5f752bf522f28563ec7a01f186e.tar.zst pyecsca-codegen-f2a0476c778dd5f752bf522f28563ec7a01f186e.zip | |
Move to pytest.
Diffstat (limited to 'test/test_render.py')
| -rw-r--r-- | test/test_render.py | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/test/test_render.py b/test/test_render.py index b8d6075..b190e35 100644 --- a/test/test_render.py +++ b/test/test_render.py @@ -1,34 +1,49 @@ import tempfile -from unittest import TestCase -from pyecsca.ec.configuration import (HashType, RandomMod, Multiplication, Squaring, Reduction, - Inversion) -from pyecsca.ec.params import get_params +from pyecsca.ec.configuration import ( + HashType, + RandomMod, + Multiplication, + Squaring, + Reduction, + Inversion, +) from pyecsca.ec.mult import LTRMultiplier from pyecsca.codegen.common import Platform, DeviceConfiguration from pyecsca.codegen.render import render_and_build -class RenderTests(TestCase): - - def test_basic_build(self): - platform = Platform.HOST - hash_type = HashType.SHA1 - mod_rand = RandomMod.REDUCE - mult = Multiplication.BASE - sqr = Squaring.BASE - red = Reduction.BASE - inv = Inversion.GCD - params = get_params("secg", "secp128r1", "projective") - model = params.curve.model - coords = params.curve.coordinate_model - add = coords.formulas["add-1998-cmo"] - dbl = coords.formulas["dbl-1998-cmo"] - scl = coords.formulas["z"] - formulas = [add, dbl, scl] - scalarmult = LTRMultiplier(add, dbl, scl) - config = DeviceConfiguration(model, coords, formulas, scalarmult, hash_type, mod_rand, mult, - sqr, red, inv, platform, True, True, True) - temp = tempfile.mkdtemp() - render_and_build(config, temp, True) +def test_basic_build(secp128r1, tmp_path): + platform = Platform.HOST + hash_type = HashType.SHA1 + mod_rand = RandomMod.REDUCE + mult = Multiplication.BASE + sqr = Squaring.BASE + red = Reduction.BASE + inv = Inversion.GCD + model = secp128r1.curve.model + coords = secp128r1.curve.coordinate_model + add = coords.formulas["add-1998-cmo"] + dbl = coords.formulas["dbl-1998-cmo"] + scl = coords.formulas["z"] + formulas = [add, dbl, scl] + scalarmult = LTRMultiplier(add, dbl, scl) + config = DeviceConfiguration( + model, + coords, + formulas, + scalarmult, + hash_type, + mod_rand, + mult, + sqr, + red, + inv, + platform, + True, + True, + True, + ) + dir, elf_file, hex_file, res = render_and_build(config, str(tmp_path), True) + assert res.returncode == 0 |
