From fd554736d9b0e909acfcdf1aa5358423beefbe91 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek@redhat.com>
Date: Wed, 25 Mar 2015 10:03:43 +0100
Subject: [PATCH 02/13] tests: Move N_ELEMENTS definition to tests/common.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Avoids code duplication
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
---
src/tests/cmocka/test_nested_groups.c | 3 ---
src/tests/cmocka/test_nss_srv.c | 3 ---
src/tests/common.h | 2 ++
src/tests/sbus_codegen_tests.c | 3 ---
4 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/tests/cmocka/test_nested_groups.c b/src/tests/cmocka/test_nested_groups.c
index eef9df2dc25c231cb81243f48b759e2fced1a85d..8081ff26102e53b2e453838c3a18e4560ac5317e 100644
--- a/src/tests/cmocka/test_nested_groups.c
+++ b/src/tests/cmocka/test_nested_groups.c
@@ -48,9 +48,6 @@
#define GROUP_BASE_DN "cn=groups," OBJECT_BASE_DN
#define USER_BASE_DN "cn=users," OBJECT_BASE_DN
-#define N_ELEMENTS(arr) \
- (sizeof(arr) / sizeof(arr[0]))
-
struct nested_groups_test_ctx {
struct sss_test_ctx *tctx;
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index d1a4c16851427a36b123f04cecee5fe5ae2d333d..3ab8d39c44a8bb8cacae20f534dcbeb6ca7dec08 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -41,9 +41,6 @@
#define TEST_ID_PROVIDER "ldap"
#define TEST_DOM_SID "S-1-5-21-444379608-1639770488-2995963434"
-#define N_ELEMENTS(arr) \
- (sizeof(arr) / sizeof(arr[0]))
-
struct nss_test_ctx {
struct sss_test_ctx *tctx;
struct sss_domain_info *subdom;
diff --git a/src/tests/common.h b/src/tests/common.h
index 0b351f5d647a8f72bdbc399c6fe02579d4b4e1be..1c6de2c3d6eb924ba7306bd350f8546d61f30751 100644
--- a/src/tests/common.h
+++ b/src/tests/common.h
@@ -30,6 +30,8 @@
#include "providers/data_provider.h"
#include "providers/ldap/sdap.h"
+#define N_ELEMENTS(arr) (sizeof(arr) / sizeof(arr[0]))
+
extern TALLOC_CTX *global_talloc_context;
#define check_leaks(ctx, bytes) _check_leaks((ctx), (bytes), __location__)
diff --git a/src/tests/sbus_codegen_tests.c b/src/tests/sbus_codegen_tests.c
index 9e9be52e84672eb3ee3afa4e13d5f60047150e98..4637b92b84459041806bb5950e969e988716bec8 100644
--- a/src/tests/sbus_codegen_tests.c
+++ b/src/tests/sbus_codegen_tests.c
@@ -33,9 +33,6 @@
#include "tests/sbus_codegen_tests_generated.h"
#include "util/util_errors.h"
-#define N_ELEMENTS(arr) \
- (sizeof(arr) / sizeof(arr[0]))
-
/* The following 2 macros were taken from check's project source files (0.9.10)
* http://check.sourceforge.net/
*/
--
2.4.3