yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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