aaee84
From c2e22d5b55fdc17cd51bf77980892e147c2b2ea1 Mon Sep 17 00:00:00 2001
e5f6b8
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
e5f6b8
Date: Tue, 2 Jan 2018 18:13:07 +0100
e5f6b8
Subject: [PATCH] Fix pkcs11 variants atf tests
e5f6b8
e5f6b8
Add dns-pkcs11 tests Makefile to configure
e5f6b8
e5f6b8
Add pkcs11 Kyuafile, fix dh_test to pass in pkcs11 mode
e5f6b8
---
1e4169
 configure.ac                     |  1 +
e5f6b8
 lib/Kyuafile                     |  2 ++
df81e8
 lib/dns-pkcs11/tests/Makefile.in | 12 ++++++------
e5f6b8
 lib/dns-pkcs11/tests/dh_test.c   |  3 ++-
e5f6b8
 lib/isc-pkcs11/tests/Makefile.in |  6 +++---
df81e8
 5 files changed, 14 insertions(+), 10 deletions(-)
e5f6b8
1e4169
diff --git a/configure.ac b/configure.ac
aaee84
index 0f7c850..0532e5f 100644
1e4169
--- a/configure.ac
1e4169
+++ b/configure.ac
aaee84
@@ -3032,6 +3032,7 @@ AC_CONFIG_FILES([
e5f6b8
 	lib/dns-pkcs11/include/Makefile
e5f6b8
 	lib/dns-pkcs11/include/dns/Makefile
e5f6b8
 	lib/dns-pkcs11/include/dst/Makefile
e5f6b8
+	lib/dns-pkcs11/tests/Makefile
e5f6b8
 	lib/irs/Makefile
e5f6b8
 	lib/irs/include/Makefile
e5f6b8
 	lib/irs/include/irs/Makefile
e5f6b8
diff --git a/lib/Kyuafile b/lib/Kyuafile
df81e8
index 39ce986..dcfb139 100644
e5f6b8
--- a/lib/Kyuafile
e5f6b8
+++ b/lib/Kyuafile
1e4169
@@ -2,8 +2,10 @@ syntax(2)
e5f6b8
 test_suite('bind9')
e5f6b8
 
e5f6b8
 include('dns/Kyuafile')
e5f6b8
+include('dns-pkcs11/Kyuafile')
e5f6b8
 include('irs/Kyuafile')
e5f6b8
 include('isc/Kyuafile')
e5f6b8
+include('isc-pkcs11/Kyuafile')
1e4169
 include('isccc/Kyuafile')
e5f6b8
 include('isccfg/Kyuafile')
df81e8
 include('ns/Kyuafile')
e5f6b8
diff --git a/lib/dns-pkcs11/tests/Makefile.in b/lib/dns-pkcs11/tests/Makefile.in
df81e8
index 7b35b93..c95d1c8 100644
e5f6b8
--- a/lib/dns-pkcs11/tests/Makefile.in
e5f6b8
+++ b/lib/dns-pkcs11/tests/Makefile.in
df81e8
@@ -15,14 +15,14 @@ VERSION=@BIND9_VERSION@
e5f6b8
 
df81e8
 @BIND9_MAKE_INCLUDES@
df81e8
 
df81e8
-CINCLUDES =	-I. -Iinclude ${DNS_INCLUDES} ${ISC_INCLUDES} \
df81e8
+CINCLUDES =	-I. -Iinclude ${DNS_PKCS11_INCLUDES} ${ISC_PKCS11_INCLUDES} \
df81e8
 		@OPENSSL_INCLUDES@ @CMOCKA_CFLAGS@
df81e8
-CDEFINES =	-DTESTS="\"${top_builddir}/lib/dns/tests/\""
df81e8
+CDEFINES =	-DTESTS="\"${top_builddir}/lib/dns-pkcs11/tests/\""
e5f6b8
 
df81e8
-ISCLIBS =	../../isc/libisc.@A@ @OPENSSL_LIBS@
e5f6b8
-ISCDEPLIBS =	../../isc/libisc.@A@
df81e8
-DNSLIBS =	../libdns.@A@ @DNS_CRYPTO_LIBS@
e5f6b8
-DNSDEPLIBS =	../libdns.@A@
e5f6b8
+ISCLIBS =	../../isc-pkcs11/libisc-pkcs11.@A@
e5f6b8
+ISCDEPLIBS =	../../isc-pkcs11/libisc-pkcs11.@A@
df81e8
+DNSLIBS =	../libdns-pkcs11.@A@ @DNS_CRYPTO_LIBS@
e5f6b8
+DNSDEPLIBS =	../libdns-pkcs11.@A@
e5f6b8
 
1e4169
 LIBS =		@LIBS@ @CMOCKA_LIBS@
df81e8
 
e5f6b8
diff --git a/lib/dns-pkcs11/tests/dh_test.c b/lib/dns-pkcs11/tests/dh_test.c
df81e8
index d83d9f5..d5bda29 100644
e5f6b8
--- a/lib/dns-pkcs11/tests/dh_test.c
e5f6b8
+++ b/lib/dns-pkcs11/tests/dh_test.c
df81e8
@@ -85,7 +85,8 @@ dh_computesecret(void **state) {
1e4169
 	result = dst_key_computesecret(key, key, &buf;;
1e4169
 	assert_int_equal(result, DST_R_NOTPRIVATEKEY);
1e4169
 	result = key->func->computesecret(key, key, &buf;;
1e4169
-	assert_int_equal(result, DST_R_COMPUTESECRETFAILURE);
e5f6b8
+	/* PKCS11 variant gives different result, accept both */
1e4169
+	assert_true(result == DST_R_COMPUTESECRETFAILURE || result == DST_R_INVALIDPRIVATEKEY);
e5f6b8
 
e5f6b8
 	dst_key_free(&key);
1e4169
 }
e5f6b8
diff --git a/lib/isc-pkcs11/tests/Makefile.in b/lib/isc-pkcs11/tests/Makefile.in
aaee84
index 7e62737..e91cd67 100644
e5f6b8
--- a/lib/isc-pkcs11/tests/Makefile.in
e5f6b8
+++ b/lib/isc-pkcs11/tests/Makefile.in
aaee84
@@ -15,11 +15,11 @@ VERSION=@BIND9_VERSION@
aaee84
 
e5f6b8
 @BIND9_MAKE_INCLUDES@
e5f6b8
 
aaee84
-CINCLUDES =	-I. -Iinclude ${ISC_INCLUDES} @OPENSSL_INCLUDES@ @CMOCKA_CFLAGS@
df81e8
-CDEFINES =	-DTESTS="\"${top_builddir}/lib/isc/tests/\""
aaee84
+CINCLUDES =	-I. -Iinclude ${ISC_PKCS11_INCLUDES} @OPENSSL_INCLUDES@ @CMOCKA_CFLAGS@
df81e8
+CDEFINES =	-DTESTS="\"${top_builddir}/lib/isc-pkcs11/tests/\""
e5f6b8
 
aaee84
 ISCLIBS =	../libisc-pkcs11.@A@ @OPENSSL_LIBS@
e5f6b8
-ISCDEPLIBS =	../libisc.@A@
e5f6b8
+ISCDEPLIBS =	../libisc-pkcs11.@A@
e5f6b8
 
1e4169
 LIBS =		@LIBS@ @CMOCKA_LIBS@
e5f6b8
 
e5f6b8
-- 
1e4169
2.20.1
e5f6b8