diff options
| author | J08nY | 2018-12-11 21:24:35 +0100 |
|---|---|---|
| committer | J08nY | 2019-03-21 11:00:14 +0100 |
| commit | 0c740f412626f33f08d6bb9857f0c5619b9ea79c (patch) | |
| tree | c2313faaf8bc878d3d72acf2fd7c830b9512a529 /test/sca/utils.py | |
| parent | cbeca585d5787e8cab35fb5207339e7b22eab382 (diff) | |
| download | pyecsca-0c740f412626f33f08d6bb9857f0c5619b9ea79c.tar.gz pyecsca-0c740f412626f33f08d6bb9857f0c5619b9ea79c.tar.zst pyecsca-0c740f412626f33f08d6bb9857f0c5619b9ea79c.zip | |
Diffstat (limited to 'test/sca/utils.py')
| -rw-r--r-- | test/sca/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/sca/utils.py b/test/sca/utils.py new file mode 100644 index 0000000..1083b87 --- /dev/null +++ b/test/sca/utils.py @@ -0,0 +1,24 @@ +import matplotlib.pyplot as plt +from unittest import TestCase +from pyecsca.sca import Trace +from os.path import join, exists +from os import mkdir, getenv + + +def slow(func): + func.slow = 1 + return func + + +def plot(case: TestCase, *traces: Trace): + if getenv("PYECSCA_TEST_PLOTS") is None: + return + fig = plt.figure() + ax = fig.add_subplot(111) + for i, trace in enumerate(traces): + ax.plot(trace.samples, label=str(i)) + ax.legend(loc="best") + directory = join("test", "plots") + if not exists(directory): + mkdir(directory) + plt.savefig(join(directory, case.id() + ".png")) |
