diff options
author | Rob Austein <sra@hactrn.net> | 2016-11-04 01:41:59 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-11-04 01:41:59 -0400 |
commit | 203b8af55d66d825b6268d8a97cd76fb66cda38f (patch) | |
tree | b207dc425be60314114822e20a9645894575d9f9 | |
parent | 7f0f3b7d2b3640bfa041768a2ad1dc1007b96725 (diff) |
More attribute bloat tests, pinwheel to monitor progress.
Watching the pinwheel makes it clear that the painfully slow execution
of test_attribute_bloat_flash_many() isn't a single hidously long
delay anywhere, rather it's a long steady stream of slow operations
and it's the cumulative time that's hurting us. Most likely this is
entirely dominated by flash write time, and suggests that it may be
worth the additional API and implementation complexity to handle
setting a complete set of attributes in a single operation, so that we
only have to pay the flash write toll once.
Will probably require further testing before we can make an informed
decision.
-rw-r--r-- | unit-tests.py | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/unit-tests.py b/unit-tests.py index 7074c6d..dc13265 100644 --- a/unit-tests.py +++ b/unit-tests.py @@ -512,8 +512,7 @@ class TestPKeyList(TestCaseLoggedIn): def load_keys(self, flags): for obj in PreloadedKey.db.itervalues(): with hsm.pkey_load(obj.keytype, obj.curve, obj.der, flags) as k: - self.addCleanup(lambda uuid: hsm.pkey_find(uuid, flags = flags).delete(), - k.uuid) + self.addCleanup(lambda uuid: hsm.pkey_find(uuid, flags = flags).delete(), k.uuid) for i, a in enumerate((str(obj.keytype), str(obj.fn2))): k.set_attribute(i, a) @@ -583,21 +582,29 @@ class TestPKeyAttribute(TestCaseLoggedIn): Attribute creation/lookup/deletion tests. """ - def load_and_fill(self, flags, n_keys = 1, n_attrs = 2): + def load_and_fill(self, flags, n_keys = 1, n_attrs = 2, n_fill = 0): + pinwheel = Pinwheel() for i in xrange(n_keys): for obj in PreloadedKey.db.itervalues(): with hsm.pkey_load(obj.keytype, obj.curve, obj.der, flags) as k: - self.addCleanup(lambda uuid: hsm.pkey_find(uuid, flags = flags).delete(), - k.uuid) + pinwheel() + self.addCleanup(lambda uuid: hsm.pkey_find(uuid, flags = flags).delete(), k.uuid) for j in xrange(n_attrs): - k.set_attribute(j, "Attribute {}".format(j)) + k.set_attribute(j, "Attribute {}{}".format(j, "*" * n_fill)) + pinwheel() - def test_attribute_bloat_volatile(self): + def test_attribute_bloat_volatile_many(self): self.load_and_fill(0, n_attrs = 192) - def test_attribute_bloat_token(self): + def test_attribute_bloat_volatile_big(self): + self.load_and_fill(0, n_attrs = 6, n_fill = 512) + + def test_attribute_bloat_token_many(self): self.load_and_fill(HAL_KEY_FLAG_TOKEN, n_attrs = 128) + def test_attribute_bloat_token_big(self): + self.load_and_fill(HAL_KEY_FLAG_TOKEN, n_attrs = 16, n_fill = 1024) + @unittest.skipUnless(ecdsa_loaded, "Requires Python ECDSA package") class TestPkeyECDSAVerificationNIST(TestCaseLoggedIn): @@ -647,6 +654,28 @@ class TestPkeyECDSAVerificationNIST(TestCaseLoggedIn): +class Pinwheel(object): + """ + Activity pinwheel, as needed. + """ + + def __init__(self): + self.pinwheel = tuple("\b\b{} ".format(c) for c in "-/|\\") + self.modulo = len(self.pinwheel) + self.position = 0 + if not args.quiet: + from sys import stdout + stdout.write(". ") + stdout.flush() + + def __call__(self): + if not args.quiet: + from sys import stdout + stdout.write(self.pinwheel[self.position]) + stdout.flush() + self.position = (self.position + 1) % self.modulo + + class PreloadedKey(object): """ Keys for preload tests, here at the end because they're large. |