]> git.proxmox.com Git - mirror_qemu.git/blobdiff - tests/test-crypto-block.c
migration/postcopy: enable random order target page arrival
[mirror_qemu.git] / tests / test-crypto-block.c
index cdbe09d4eddf872c259955885806b5f4182ea586..7c1ab07855415a0c2a884b8519e8fe99440bb83b 100644 (file)
  */
 
 #include "qemu/osdep.h"
+#include "qapi/error.h"
 #include "crypto/init.h"
 #include "crypto/block.h"
 #include "qemu/buffer.h"
+#include "qemu/module.h"
 #include "crypto/secret.h"
 #ifndef _WIN32
 #include <sys/resource.h>
 #endif
 
-#if defined(CONFIG_UUID) && (defined(_WIN32) || defined RUSAGE_THREAD)
+#if (defined(_WIN32) || defined RUSAGE_THREAD) && \
+    (defined(CONFIG_NETTLE) || defined(CONFIG_GCRYPT))
 #define TEST_LUKS
 #else
 #undef TEST_LUKS
@@ -189,8 +192,8 @@ static ssize_t test_block_read_func(QCryptoBlock *block,
                                     size_t offset,
                                     uint8_t *buf,
                                     size_t buflen,
-                                    Error **errp,
-                                    void *opaque)
+                                    void *opaque,
+                                    Error **errp)
 {
     Buffer *header = opaque;
 
@@ -204,8 +207,8 @@ static ssize_t test_block_read_func(QCryptoBlock *block,
 
 static ssize_t test_block_init_func(QCryptoBlock *block,
                                     size_t headerlen,
-                                    Error **errp,
-                                    void *opaque)
+                                    void *opaque,
+                                    Error **errp)
 {
     Buffer *header = opaque;
 
@@ -221,8 +224,8 @@ static ssize_t test_block_write_func(QCryptoBlock *block,
                                      size_t offset,
                                      const uint8_t *buf,
                                      size_t buflen,
-                                     Error **errp,
-                                     void *opaque)
+                                     void *opaque,
+                                     Error **errp)
 {
     Buffer *header = opaque;
 
@@ -280,7 +283,7 @@ static void test_block(gconstpointer opaque)
     memset(&header, 0, sizeof(header));
     buffer_init(&header, "header");
 
-    blk = qcrypto_block_create(data->create_opts,
+    blk = qcrypto_block_create(data->create_opts, NULL,
                                test_block_init_func,
                                test_block_write_func,
                                &header,
@@ -299,18 +302,20 @@ static void test_block(gconstpointer opaque)
     object_unparent(sec);
 
     /* Ensure we can't open without the secret */
-    blk = qcrypto_block_open(data->open_opts,
+    blk = qcrypto_block_open(data->open_opts, NULL,
                              test_block_read_func,
                              &header,
                              0,
+                             1,
                              NULL);
     g_assert(blk == NULL);
 
     /* Ensure we can't open without the secret, unless NO_IO */
-    blk = qcrypto_block_open(data->open_opts,
+    blk = qcrypto_block_open(data->open_opts, NULL,
                              test_block_read_func,
                              &header,
                              QCRYPTO_BLOCK_OPEN_NO_IO,
+                             1,
                              &error_abort);
 
     g_assert(qcrypto_block_get_cipher(blk) == NULL);
@@ -321,10 +326,11 @@ static void test_block(gconstpointer opaque)
 
     /* Now open for real with secret */
     sec = test_block_secret();
-    blk = qcrypto_block_open(data->open_opts,
+    blk = qcrypto_block_open(data->open_opts, NULL,
                              test_block_read_func,
                              &header,
                              0,
+                             1,
                              &error_abort);
     g_assert(blk);