From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/, lib/portage/tests/util/
Date: Sat, 31 Dec 2022 13:33:09 +0000 (UTC) [thread overview]
Message-ID: <1672493584.98f984875251f86d3a5c367765c7d6e249277a26.sam@gentoo> (raw)
commit: 98f984875251f86d3a5c367765c7d6e249277a26
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 10:44:10 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 13:33:04 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=98f98487
Test C whirlpool implementation separately from Python impl
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/tests/util/test_whirlpool.py | 17 +++++++++++------
lib/portage/util/whirlpool.py | 2 ++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/portage/tests/util/test_whirlpool.py b/lib/portage/tests/util/test_whirlpool.py
index d93467b21..ac156abf3 100644
--- a/lib/portage/tests/util/test_whirlpool.py
+++ b/lib/portage/tests/util/test_whirlpool.py
@@ -2,26 +2,31 @@
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
-from portage.util.whirlpool import Whirlpool
+from portage.util.whirlpool import CWhirlpool, PyWhirlpool
class WhirlpoolTestCase(TestCase):
- def testBundledWhirlpool(self):
+ def testBundledWhirlpool(self, cls=PyWhirlpool):
self.assertEqual(
- Whirlpool(b"The quick brown fox jumps over the lazy dog").hexdigest(),
+ cls(b"The quick brown fox jumps over the lazy dog").hexdigest(),
"b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35",
)
self.assertEqual(
- Whirlpool(b"The quick brown fox jumps over the lazy eog").hexdigest(),
+ cls(b"The quick brown fox jumps over the lazy eog").hexdigest(),
"c27ba124205f72e6847f3e19834f925cc666d0974167af915bb462420ed40cc50900d85a1f923219d832357750492d5c143011a76988344c2635e69d06f2d38c",
)
self.assertEqual(
- Whirlpool(b"").hexdigest(),
+ cls(b"").hexdigest(),
"19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3",
)
- w = Whirlpool()
+ w = cls()
w.update(b"")
self.assertEqual(
w.hexdigest(),
"19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3",
)
+
+ def testCWhirlpool(self):
+ if not CWhirlpool.is_available:
+ self.skipTest("C Whirlpool extension is not importable")
+ self.testBundledWhirlpool(CWhirlpool)
diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
index 1431c18fb..7caa20f6e 100644
--- a/lib/portage/util/whirlpool.py
+++ b/lib/portage/util/whirlpool.py
@@ -83,6 +83,8 @@ class CWhirlpool:
may be provided; if present, this string will be automatically
hashed."""
+ is_available = WhirlpoolExt is not None
+
def __init__(self, arg=b""):
self.obj = WhirlpoolExt()
self.dig = None
next reply other threads:[~2022-12-31 13:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-31 13:33 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-22 15:36 [gentoo-commits] proj/portage:master commit in: lib/portage/util/, lib/portage/tests/util/ Zac Medico
2022-06-07 23:48 Mike Gilbert
2022-06-07 23:48 Mike Gilbert
2022-06-07 23:48 Mike Gilbert
2022-06-07 23:48 Mike Gilbert
2019-01-16 8:33 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1672493584.98f984875251f86d3a5c367765c7d6e249277a26.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox