From 716e573514b723fd835097fd5a7b80d6b7b3ce2f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 2 Mar 2020 14:25:45 -0400 Subject: [PATCH] split up quickcheck tests for hashes and macs So when one fais, it's clear which one is the problem. --- Test.hs | 11 +-- Utility/Hash.hs | 68 +++++++++---------- ..._3932b6954cc42d2c376f48a6cdf0f879._comment | 22 ++++++ 3 files changed, 63 insertions(+), 38 deletions(-) create mode 100644 doc/bugs/__34__Illegal_instruction__34___when_running_certain_tests_on_AMD_Phenom_II/comment_1_3932b6954cc42d2c376f48a6cdf0f879._comment diff --git a/Test.hs b/Test.hs index a589f02907..7b784d661d 100644 --- a/Test.hs +++ b/Test.hs @@ -161,7 +161,7 @@ tests crippledfilesystem adjustedbranchok opts = | otherwise = Nothing properties :: TestTree -properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck" +properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck" $ [ testProperty "prop_encode_decode_roundtrip" Git.Filename.prop_encode_decode_roundtrip , testProperty "prop_encode_c_decode_c_roundtrip" Utility.Format.prop_encode_c_decode_c_roundtrip , testProperty "prop_isomorphic_key_encode" Key.prop_isomorphic_key_encode @@ -185,8 +185,6 @@ properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck" , testProperty "prop_parse_build_contentidentifier_log" Logs.ContentIdentifier.prop_parse_build_contentidentifier_log , testProperty "prop_read_show_TrustLevel" Types.TrustLevel.prop_read_show_TrustLevel , testProperty "prop_parse_build_TrustLevelLog" Logs.Trust.prop_parse_build_TrustLevelLog - , testProperty "prop_hashes_stable" Utility.Hash.prop_hashes_stable - , testProperty "prop_mac_stable" Utility.Hash.prop_mac_stable , testProperty "prop_schedule_roundtrips" Utility.Scheduled.QuickCheck.prop_schedule_roundtrips , testProperty "prop_past_sane" Utility.Scheduled.prop_past_sane , testProperty "prop_duration_roundtrips" Utility.HumanTime.prop_duration_roundtrips @@ -198,7 +196,12 @@ properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck" , testProperty "prop_viewedFile_rountrips" Annex.View.ViewedFile.prop_viewedFile_roundtrips , testProperty "prop_b64_roundtrips" Utility.Base64.prop_b64_roundtrips , testProperty "prop_standardGroups_parse" Logs.PreferredContent.prop_standardGroups_parse - ] + ] ++ map (uncurry testProperty) combos + where + combos = concat + [ Utility.Hash.props_hashes_stable + , Utility.Hash.props_macs_stable + ] {- These tests set up the test environment, but also test some basic parts - of git-annex. They are always run before the unitTests. -} diff --git a/Utility/Hash.hs b/Utility/Hash.hs index 397ada5d35..732009a8d1 100644 --- a/Utility/Hash.hs +++ b/Utility/Hash.hs @@ -25,10 +25,10 @@ module Utility.Hash ( blake2bp_512, md5, md5s, - prop_hashes_stable, + props_hashes_stable, Mac(..), calcMac, - prop_mac_stable, + props_macs_stable, ) where import qualified Data.ByteString as S @@ -111,31 +111,31 @@ md5s :: S.ByteString -> Digest MD5 md5s = hash {- Check that all the hashes continue to hash the same. -} -prop_hashes_stable :: Bool -prop_hashes_stable = all (\(hasher, result) -> hasher foo == result) - [ (show . sha1, "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33") - , (show . sha2_224, "0808f64e60d58979fcb676c96ec938270dea42445aeefcd3a4e6f8db") - , (show . sha2_256, "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae") - , (show . sha2_384, "98c11ffdfdd540676b1a137cb1a22b2a70350c9a44171d6b1180c6be5cbb2ee3f79d532c8a1dd9ef2e8e08e752a3babb") - , (show . sha2_512, "f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7") - , (show . skein256, "a04efd9a0aeed6ede40fe5ce0d9361ae7b7d88b524aa19917b9315f1ecf00d33") - , (show . skein512, "fd8956898113510180aa4658e6c0ac85bd74fb47f4a4ba264a6b705d7a8e8526756e75aecda12cff4f1aca1a4c2830fbf57f458012a66b2b15a3dd7d251690a7") - , (show . sha3_224, "f4f6779e153c391bbd29c95e72b0708e39d9166c7cea51d1f10ef58a") - , (show . sha3_256, "76d3bc41c9f588f7fcd0d5bf4718f8f84b1c41b20882703100b9eb9413807c01") - , (show . sha3_384, "665551928d13b7d84ee02734502b018d896a0fb87eed5adb4c87ba91bbd6489410e11b0fbcc06ed7d0ebad559e5d3bb5") - , (show . sha3_512, "4bca2b137edc580fe50a88983ef860ebaca36c857b1f492839d6d7392452a63c82cbebc68e3b70a2a1480b4bb5d437a7cba6ecf9d89f9ff3ccd14cd6146ea7e7") - , (show . blake2s_160, "52fb63154f958a5c56864597273ea759e52c6f00") - , (show . blake2s_224, "9466668503ac415d87b8e1dfd7f348ab273ac1d5e4f774fced5fdb55") - , (show . blake2s_256, "08d6cad88075de8f192db097573d0e829411cd91eb6ec65e8fc16c017edfdb74") - , (show . blake2sp_224, "8492d356fbac99f046f55e114301f7596649cb590e5b083d1a19dcdb") - , (show . blake2sp_256, "050dc5786037ea72cb9ed9d0324afcab03c97ec02e8c47368fc5dfb4cf49d8c9") - , (show . blake2b_160, "983ceba2afea8694cc933336b27b907f90c53a88") - , (show . blake2b_224, "853986b3fe231d795261b4fb530e1a9188db41e460ec4ca59aafef78") - , (show . blake2b_256, "b8fe9f7f6255a6fa08f668ab632a8d081ad87983c77cd274e48ce450f0b349fd") - , (show . blake2b_384, "e629ee880953d32c8877e479e3b4cb0a4c9d5805e2b34c675b5a5863c4ad7d64bb2a9b8257fac9d82d289b3d39eb9cc2") - , (show . blake2b_512, "ca002330e69d3e6b84a46a56a6533fd79d51d97a3bb7cad6c2ff43b354185d6dc1e723fb3db4ae0737e120378424c714bb982d9dc5bbd7a0ab318240ddd18f8d") - , (show . blake2bp_512, "8ca9ccee7946afcb686fe7556628b5ba1bf9a691da37ca58cd049354d99f37042c007427e5f219b9ab5063707ec6823872dee413ee014b4d02f2ebb6abb5f643") - , (show . md5, "acbd18db4cc2f85cedef654fccc4a4d8") +props_hashes_stable :: [(String, Bool)] +props_hashes_stable = map (\(desc, hasher, result) -> (desc ++ " stable", hasher foo == result)) + [ ("sha1", show . sha1, "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33") + , ("sha2_224", show . sha2_224, "0808f64e60d58979fcb676c96ec938270dea42445aeefcd3a4e6f8db") + , ("sha2_256", show . sha2_256, "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae") + , ("sha2_384", show . sha2_384, "98c11ffdfdd540676b1a137cb1a22b2a70350c9a44171d6b1180c6be5cbb2ee3f79d532c8a1dd9ef2e8e08e752a3babb") + , ("sha2_512", show . sha2_512, "f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7") + , ("skein256", show . skein256, "a04efd9a0aeed6ede40fe5ce0d9361ae7b7d88b524aa19917b9315f1ecf00d33") + , ("skein512", show . skein512, "fd8956898113510180aa4658e6c0ac85bd74fb47f4a4ba264a6b705d7a8e8526756e75aecda12cff4f1aca1a4c2830fbf57f458012a66b2b15a3dd7d251690a7") + , ("sha3_224", show . sha3_224, "f4f6779e153c391bbd29c95e72b0708e39d9166c7cea51d1f10ef58a") + , ("sha3_256", show . sha3_256, "76d3bc41c9f588f7fcd0d5bf4718f8f84b1c41b20882703100b9eb9413807c01") + , ("sha3_384", show . sha3_384, "665551928d13b7d84ee02734502b018d896a0fb87eed5adb4c87ba91bbd6489410e11b0fbcc06ed7d0ebad559e5d3bb5") + , ("sha3_512", show . sha3_512, "4bca2b137edc580fe50a88983ef860ebaca36c857b1f492839d6d7392452a63c82cbebc68e3b70a2a1480b4bb5d437a7cba6ecf9d89f9ff3ccd14cd6146ea7e7") + , ("blake2s_160", show . blake2s_160, "52fb63154f958a5c56864597273ea759e52c6f00") + , ("blake2s_224", show . blake2s_224, "9466668503ac415d87b8e1dfd7f348ab273ac1d5e4f774fced5fdb55") + , ("blake2s_256", show . blake2s_256, "08d6cad88075de8f192db097573d0e829411cd91eb6ec65e8fc16c017edfdb74") + , ("blake2sp_224", show . blake2sp_224, "8492d356fbac99f046f55e114301f7596649cb590e5b083d1a19dcdb") + , ("blake2sp_256", show . blake2sp_256, "050dc5786037ea72cb9ed9d0324afcab03c97ec02e8c47368fc5dfb4cf49d8c9") + , ("blake2b_160", show . blake2b_160, "983ceba2afea8694cc933336b27b907f90c53a88") + , ("blake2b_224", show . blake2b_224, "853986b3fe231d795261b4fb530e1a9188db41e460ec4ca59aafef78") + , ("blake2b_256", show . blake2b_256, "b8fe9f7f6255a6fa08f668ab632a8d081ad87983c77cd274e48ce450f0b349fd") + , ("blake2b_384", show . blake2b_384, "e629ee880953d32c8877e479e3b4cb0a4c9d5805e2b34c675b5a5863c4ad7d64bb2a9b8257fac9d82d289b3d39eb9cc2") + , ("blake2b_512", show . blake2b_512, "ca002330e69d3e6b84a46a56a6533fd79d51d97a3bb7cad6c2ff43b354185d6dc1e723fb3db4ae0737e120378424c714bb982d9dc5bbd7a0ab318240ddd18f8d") + , ("blake2bp_512", show . blake2bp_512, "8ca9ccee7946afcb686fe7556628b5ba1bf9a691da37ca58cd049354d99f37042c007427e5f219b9ab5063707ec6823872dee413ee014b4d02f2ebb6abb5f643") + , ("md5", show . md5, "acbd18db4cc2f85cedef654fccc4a4d8") ] where foo = L.fromChunks [T.encodeUtf8 $ T.pack "foo"] @@ -165,13 +165,13 @@ calcMac mac = case mac of hmacWitnessAlg _ = hmac -- Check that all the MACs continue to produce the same. -prop_mac_stable :: Bool -prop_mac_stable = all (\(mac, result) -> calcMac mac key msg == result) - [ (HmacSha1, "46b4ec586117154dacd49d664e5d63fdc88efb51") - , (HmacSha224, "4c1f774863acb63b7f6e9daa9b5c543fa0d5eccf61e3ffc3698eacdd") - , (HmacSha256, "f9320baf0249169e73850cd6156ded0106e2bb6ad8cab01b7bbbebe6d1065317") - , (HmacSha384, "3d10d391bee2364df2c55cf605759373e1b5a4ca9355d8f3fe42970471eca2e422a79271a0e857a69923839015877fc6") - , (HmacSha512, "114682914c5d017dfe59fdc804118b56a3a652a0b8870759cf9e792ed7426b08197076bf7d01640b1b0684df79e4b67e37485669e8ce98dbab60445f0db94fce") +props_macs_stable :: [(String, Bool)] +props_macs_stable = map (\(desc, mac, result) -> (desc ++ " stable", calcMac mac key msg == result)) + [ ("HmacSha1", HmacSha1, "46b4ec586117154dacd49d664e5d63fdc88efb51") + , ("HmacSha224", HmacSha224, "4c1f774863acb63b7f6e9daa9b5c543fa0d5eccf61e3ffc3698eacdd") + , ("HmacSha256", HmacSha256, "f9320baf0249169e73850cd6156ded0106e2bb6ad8cab01b7bbbebe6d1065317") + , ("HmacSha384", HmacSha384, "3d10d391bee2364df2c55cf605759373e1b5a4ca9355d8f3fe42970471eca2e422a79271a0e857a69923839015877fc6") + , ("HmacSha512", HmacSha512, "114682914c5d017dfe59fdc804118b56a3a652a0b8870759cf9e792ed7426b08197076bf7d01640b1b0684df79e4b67e37485669e8ce98dbab60445f0db94fce") ] where key = T.encodeUtf8 $ T.pack "foo" diff --git a/doc/bugs/__34__Illegal_instruction__34___when_running_certain_tests_on_AMD_Phenom_II/comment_1_3932b6954cc42d2c376f48a6cdf0f879._comment b/doc/bugs/__34__Illegal_instruction__34___when_running_certain_tests_on_AMD_Phenom_II/comment_1_3932b6954cc42d2c376f48a6cdf0f879._comment new file mode 100644 index 0000000000..e1ea388d83 --- /dev/null +++ b/doc/bugs/__34__Illegal_instruction__34___when_running_certain_tests_on_AMD_Phenom_II/comment_1_3932b6954cc42d2c376f48a6cdf0f879._comment @@ -0,0 +1,22 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2020-03-02T17:48:17Z" + content=""" +The failing test case is testing all the hashes that git-annex uses. +Quite likely what has happened is that the hash implementation has been +built with a CPU-specific optimisation that is not available on your AMD. + +The hash implementations are in http://hackage.haskell.org/package/cryptonite + +While cryptonite has build flags for CPU-specific features, +there are also, in its C code, some checks of gcc defines that indicate +specific CPU features. I found #defines checking `__SSE2__` and `__SSE4__` +and `__AVX__` (mostly in blake2) and there might be others. That seems +likely to be a bug in cryptonite, if its build flags are not fully +controlling use of things like SSE. + +I've made a change to git-annex's test suite to narrow down the problem; +it now tests each hash individually, so you'll see which specific ones +fail. +"""]]