[3/3] bcrypt/tests: Add tests for BCryptGenRandom (try 2)
Bruno Jesus
00cpxxx at gmail.com
Mon Feb 3 12:24:48 CST 2014
-------------- next part --------------
---
configure | 1 +
configure.ac | 1 +
dlls/bcrypt/tests/Makefile.in | 5 +++
dlls/bcrypt/tests/bcrypt.c | 76 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
create mode 100644 dlls/bcrypt/tests/Makefile.in
create mode 100644 dlls/bcrypt/tests/bcrypt.c
diff --git a/configure b/configure
index 6f5652a..2ca4a02 100755
--- a/configure
+++ b/configure
@@ -16618,6 +16618,7 @@ wine_fn_config_test dlls/avifil32/tests avifil32_test
wine_fn_config_dll avifile.dll16 enable_win16
wine_fn_config_dll avrt enable_avrt implib
wine_fn_config_dll bcrypt enable_bcrypt
+wine_fn_config_test dlls/bcrypt/tests bcrypt_test
wine_fn_config_dll browseui enable_browseui clean,po
wine_fn_config_test dlls/browseui/tests browseui_test
wine_fn_config_dll cabinet enable_cabinet implib
diff --git a/configure.ac b/configure.ac
index 9a8393c..fc9d177 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2661,6 +2661,7 @@ WINE_CONFIG_TEST(dlls/avifil32/tests)
WINE_CONFIG_DLL(avifile.dll16,enable_win16)
WINE_CONFIG_DLL(avrt,,[implib])
WINE_CONFIG_DLL(bcrypt)
+WINE_CONFIG_TEST(dlls/bcrypt/tests)
WINE_CONFIG_DLL(browseui,,[clean,po])
WINE_CONFIG_TEST(dlls/browseui/tests)
WINE_CONFIG_DLL(cabinet,,[implib])
diff --git a/dlls/bcrypt/tests/Makefile.in b/dlls/bcrypt/tests/Makefile.in
new file mode 100644
index 0000000..b193519
--- /dev/null
+++ b/dlls/bcrypt/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = bcrypt.dll
+IMPORTS = user32
+
+C_SRCS = \
+ bcrypt.c
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
new file mode 100644
index 0000000..3bd2464a2
--- /dev/null
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -0,0 +1,76 @@
+/*
+ * Unit test for bcrypt functions
+ *
+ * Copyright 2014 The Wine Project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <ntstatus.h>
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <bcrypt.h>
+
+#include "wine/test.h"
+
+static NTSTATUS (WINAPI *pBCryptGenRandom)(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer,
+ ULONG cbBuffer, ULONG dwFlags);
+
+static BOOL Init(void)
+{
+ HMODULE hbcrypt = LoadLibraryA("bcrypt.dll");
+ if (!hbcrypt)
+ {
+ win_skip("bcrypt library not available\n");
+ return FALSE;
+ }
+
+ pBCryptGenRandom = (void *)GetProcAddress(hbcrypt, "BCryptGenRandom");
+
+ return TRUE;
+}
+
+static void test_BCryptGenRandom(void)
+{
+ NTSTATUS ret;
+ UCHAR buffer[256];
+
+ if (!pBCryptGenRandom)
+ {
+ win_skip("BCryptGenRandom is not available\n");
+ return;
+ }
+
+ todo_wine {
+ ret = pBCryptGenRandom(NULL, NULL, 0, 0);
+ ok(ret == STATUS_INVALID_HANDLE, "Expected 0xC0000008, got 0x%X\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, 0, 0);
+ ok(ret == STATUS_INVALID_HANDLE, "Expected 0xC0000008, got 0x%X\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, sizeof(buffer), 0);
+ ok(ret == STATUS_INVALID_HANDLE, "Expected 0xC0000008, got 0x%X\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, sizeof(buffer), BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ok(ret == STATUS_SUCCESS, "Expected success, got 0x%X\n", ret);
+ ret = pBCryptGenRandom(NULL, NULL, sizeof(buffer), BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ok(ret == STATUS_INVALID_PARAMETER, "Expected 0xC000000D, got 0x%X\n", ret);
+ }
+}
+
+START_TEST(bcrypt)
+{
+ if (!Init())
+ return;
+
+ test_BCryptGenRandom();
+}
--
1.8.3.2
More information about the wine-patches
mailing list