From 87db9ea84cb72ef9be3779e94407ccee7f8f2a4a Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 6 Apr 2023 13:18:04 +0000 Subject: [PATCH] unit tests: include an OpenSSL header before including cmocka.h OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a redefined malloc in cmocka.h. As a workaround, include an OpenSSL header file before including cmocka.h in the unit tests where OpenSSL is used. --- tests/dns/dst_test.c | 7 +++++++ tests/dns/rsa_test.c | 7 +++++++ tests/isc/doh_test.c | 7 +++++++ tests/isc/hmac_test.c | 7 +++++++ tests/isc/netmgr_common.c | 7 +++++++ tests/isc/tcp_test.c | 7 +++++++ tests/isc/tcpdns_test.c | 7 +++++++ tests/isc/tls_test.c | 7 +++++++ tests/isc/tlsdns_test.c | 7 +++++++ tests/isc/udp_test.c | 7 +++++++ 10 files changed, 70 insertions(+) diff --git a/tests/dns/dst_test.c b/tests/dns/dst_test.c index 570c19c876..15b89d9d4a 100644 --- a/tests/dns/dst_test.c +++ b/tests/dns/dst_test.c @@ -19,6 +19,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/dns/rsa_test.c b/tests/dns/rsa_test.c index 587dc4ea3e..f19105fb01 100644 --- a/tests/dns/rsa_test.c +++ b/tests/dns/rsa_test.c @@ -20,6 +20,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index bb19298df9..112b827257 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -21,6 +21,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/hmac_test.c b/tests/isc/hmac_test.c index b4438a2853..9984cc7208 100644 --- a/tests/isc/hmac_test.c +++ b/tests/isc/hmac_test.c @@ -20,6 +20,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/netmgr_common.c b/tests/isc/netmgr_common.c index b8988b9154..fa8faedbbf 100644 --- a/tests/isc/netmgr_common.c +++ b/tests/isc/netmgr_common.c @@ -18,6 +18,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/tcp_test.c b/tests/isc/tcp_test.c index 1095fb66e0..4239e17899 100644 --- a/tests/isc/tcp_test.c +++ b/tests/isc/tcp_test.c @@ -18,6 +18,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/tcpdns_test.c b/tests/isc/tcpdns_test.c index 7006add141..8005f537b2 100644 --- a/tests/isc/tcpdns_test.c +++ b/tests/isc/tcpdns_test.c @@ -18,6 +18,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/tls_test.c b/tests/isc/tls_test.c index 6ba6269336..e6c76aa07a 100644 --- a/tests/isc/tls_test.c +++ b/tests/isc/tls_test.c @@ -18,6 +18,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/tlsdns_test.c b/tests/isc/tlsdns_test.c index e42be5e6bb..7c000687e2 100644 --- a/tests/isc/tlsdns_test.c +++ b/tests/isc/tlsdns_test.c @@ -18,6 +18,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include diff --git a/tests/isc/udp_test.c b/tests/isc/udp_test.c index ab6742d77b..e88d7d4f2f 100644 --- a/tests/isc/udp_test.c +++ b/tests/isc/udp_test.c @@ -18,6 +18,13 @@ #include #include +/* + * As a workaround, include an OpenSSL header file before including cmocka.h, + * because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a + * redefined malloc in cmocka.h. + */ +#include + #define UNIT_TESTING #include