Blame SOURCES/kvm-tests-crypto-Use-the-IEC-binary-prefix-definitions.patch

ae23c9
From f12961093254d12f8f7ccfd8feca7a32f558e12d Mon Sep 17 00:00:00 2001
ae23c9
From: "Daniel P. Berrange" <berrange@redhat.com>
ae23c9
Date: Wed, 24 Apr 2019 09:56:35 +0100
ae23c9
Subject: [PATCH 1/9] tests/crypto: Use the IEC binary prefix definitions
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: Daniel P. Berrange <berrange@redhat.com>
ae23c9
Message-id: <20190424095643.796-2-berrange@redhat.com>
ae23c9
Patchwork-id: 85878
ae23c9
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/9] tests/crypto: Use the IEC binary prefix definitions
ae23c9
Bugzilla: 1680231
ae23c9
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Eric Blake <eblake@redhat.com>
ae23c9
ae23c9
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
ae23c9
ae23c9
It eases code review, unit is explicit.
ae23c9
ae23c9
Patch generated using:
ae23c9
ae23c9
  $ git grep -n '[<>][<>]= ?[1-5]0'
ae23c9
ae23c9
and modified manually.
ae23c9
ae23c9
Suggested-by: Eric Blake <eblake@redhat.com>
ae23c9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
ae23c9
Message-Id: <20180625124238.25339-45-f4bug@amsat.org>
ae23c9
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
ae23c9
(cherry picked from commit 68dbb6d05db59fe39af0c192005490576d9f5b7c)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 tests/benchmark-crypto-cipher.c | 6 +++---
ae23c9
 tests/benchmark-crypto-hash.c   | 5 +++--
ae23c9
 tests/benchmark-crypto-hmac.c   | 6 +++---
ae23c9
 3 files changed, 9 insertions(+), 8 deletions(-)
ae23c9
ae23c9
diff --git a/tests/benchmark-crypto-cipher.c b/tests/benchmark-crypto-cipher.c
ae23c9
index cf98443..f5a0d0b 100644
ae23c9
--- a/tests/benchmark-crypto-cipher.c
ae23c9
+++ b/tests/benchmark-crypto-cipher.c
ae23c9
@@ -11,6 +11,7 @@
ae23c9
  * top-level directory.
ae23c9
  */
ae23c9
 #include "qemu/osdep.h"
ae23c9
+#include "qemu/units.h"
ae23c9
 #include "crypto/init.h"
ae23c9
 #include "crypto/cipher.h"
ae23c9
 
ae23c9
@@ -56,8 +57,7 @@ static void test_cipher_speed(const void *opaque)
ae23c9
         total += chunk_size;
ae23c9
     } while (g_test_timer_elapsed() < 5.0);
ae23c9
 
ae23c9
-    total /= 1024 * 1024; /* to MB */
ae23c9
-
ae23c9
+    total /= MiB;
ae23c9
     g_print("cbc(aes128): ");
ae23c9
     g_print("Testing chunk_size %zu bytes ", chunk_size);
ae23c9
     g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
ae23c9
@@ -78,7 +78,7 @@ int main(int argc, char **argv)
ae23c9
     g_test_init(&argc, &argv, NULL);
ae23c9
     g_assert(qcrypto_init(NULL) == 0);
ae23c9
 
ae23c9
-    for (i = 512; i <= (64 * 1204); i *= 2) {
ae23c9
+    for (i = 512; i <= 64 * KiB; i *= 2) {
ae23c9
         memset(name, 0 , sizeof(name));
ae23c9
         snprintf(name, sizeof(name), "/crypto/cipher/speed-%zu", i);
ae23c9
         g_test_add_data_func(name, (void *)i, test_cipher_speed);
ae23c9
diff --git a/tests/benchmark-crypto-hash.c b/tests/benchmark-crypto-hash.c
ae23c9
index 122bfb6..9b6f7a9 100644
ae23c9
--- a/tests/benchmark-crypto-hash.c
ae23c9
+++ b/tests/benchmark-crypto-hash.c
ae23c9
@@ -11,6 +11,7 @@
ae23c9
  * top-level directory.
ae23c9
  */
ae23c9
 #include "qemu/osdep.h"
ae23c9
+#include "qemu/units.h"
ae23c9
 #include "crypto/init.h"
ae23c9
 #include "crypto/hash.h"
ae23c9
 
ae23c9
@@ -39,7 +40,7 @@ static void test_hash_speed(const void *opaque)
ae23c9
         total += chunk_size;
ae23c9
     } while (g_test_timer_elapsed() < 5.0);
ae23c9
 
ae23c9
-    total /= 1024 * 1024; /* to MB */
ae23c9
+    total /= MiB;
ae23c9
     g_print("sha256: ");
ae23c9
     g_print("Testing chunk_size %zu bytes ", chunk_size);
ae23c9
     g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
ae23c9
@@ -57,7 +58,7 @@ int main(int argc, char **argv)
ae23c9
     g_test_init(&argc, &argv, NULL);
ae23c9
     g_assert(qcrypto_init(NULL) == 0);
ae23c9
 
ae23c9
-    for (i = 512; i <= (64 * 1204); i *= 2) {
ae23c9
+    for (i = 512; i <= 64 * KiB; i *= 2) {
ae23c9
         memset(name, 0 , sizeof(name));
ae23c9
         snprintf(name, sizeof(name), "/crypto/hash/speed-%zu", i);
ae23c9
         g_test_add_data_func(name, (void *)i, test_hash_speed);
ae23c9
diff --git a/tests/benchmark-crypto-hmac.c b/tests/benchmark-crypto-hmac.c
ae23c9
index c30250d..f1dfa24 100644
ae23c9
--- a/tests/benchmark-crypto-hmac.c
ae23c9
+++ b/tests/benchmark-crypto-hmac.c
ae23c9
@@ -11,6 +11,7 @@
ae23c9
  * top-level directory.
ae23c9
  */
ae23c9
 #include "qemu/osdep.h"
ae23c9
+#include "qemu/units.h"
ae23c9
 #include "crypto/init.h"
ae23c9
 #include "crypto/hmac.h"
ae23c9
 
ae23c9
@@ -53,8 +54,7 @@ static void test_hmac_speed(const void *opaque)
ae23c9
         total += chunk_size;
ae23c9
     } while (g_test_timer_elapsed() < 5.0);
ae23c9
 
ae23c9
-    total /= 1024 * 1024; /* to MB */
ae23c9
-
ae23c9
+    total /= MiB;
ae23c9
     g_print("hmac(sha256): ");
ae23c9
     g_print("Testing chunk_size %zu bytes ", chunk_size);
ae23c9
     g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
ae23c9
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
ae23c9
     g_test_init(&argc, &argv, NULL);
ae23c9
     g_assert(qcrypto_init(NULL) == 0);
ae23c9
 
ae23c9
-    for (i = 512; i <= (64 * 1204); i *= 2) {
ae23c9
+    for (i = 512; i <= 64 * KiB; i *= 2) {
ae23c9
         memset(name, 0 , sizeof(name));
ae23c9
         snprintf(name, sizeof(name), "/crypto/hmac/speed-%zu", i);
ae23c9
         g_test_add_data_func(name, (void *)i, test_hmac_speed);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9