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

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