Skip to content

Commit eb1a6c5

Browse files
committed
fix compilation / testing without libcheck
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent f040dbc commit eb1a6c5

File tree

13 files changed

+162
-38
lines changed

13 files changed

+162
-38
lines changed

test/Makefile.am

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,39 @@ AM_CFLAGS += -DUSE_ZLIB @ZLIB_CFLAGS@
2727
LIBADD += @ZLIB_LIBS@
2828
endif
2929

30-
noinst_HEADERS = helper.h
30+
noinst_HEADERS = \
31+
util.h \
32+
check_util.h
3133

32-
noinst_LTLIBRARIES = libtest.la
34+
LDADD = ${top_builddir}/src/libauth_openidc.la ${LIBADD}
3335

34-
libtest_la_CFLAGS = ${AM_CFLAGS} -fPIC
36+
noinst_PROGRAMS = test-cmd
3537

36-
libtest_la_SOURCES = \
37-
helper.c \
38+
TESTS = test
39+
40+
test_SOURCES = \
41+
test.c \
42+
util.c \
3843
stub.c
3944

40-
LDADD = ${top_builddir}/src/libauth_openidc.la libtest.la ${LIBADD}
45+
test_cmd_SOURCES = \
46+
test-cmd.c \
47+
util.c \
48+
stub.c
49+
50+
if HAVE_CHECK
4151

42-
noinst_PROGRAMS = test-cmd
52+
noinst_LTLIBRARIES = libtest.la
4353

44-
TESTS = test
54+
libtest_la_CFLAGS = ${AM_CFLAGS} -fPIC
4555

46-
if HAVE_CHECK
56+
libtest_la_SOURCES = \
57+
util.c \
58+
check_util.c \
59+
stub.c
4760

4861
AM_CFLAGS += @CHECK_CFLAGS@
49-
LDADD += @CHECK_LIBS@
62+
LDADD += libtest.la @CHECK_LIBS@
5063

5164
TESTS += \
5265
test_cfg \

test/check_util.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/***************************************************************************
21+
* Copyright (C) 2017-2025 ZmartZone Holding BV
22+
* All rights reserved.
23+
*
24+
* DISCLAIMER OF WARRANTIES:
25+
*
26+
* THE SOFTWARE PROVIDED HEREUNDER IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
27+
* ANY WARRANTIES OR REPRESENTATIONS EXPRESS, IMPLIED OR STATUTORY; INCLUDING,
28+
* WITHOUT LIMITATION, WARRANTIES OF QUALITY, PERFORMANCE, NONINFRINGEMENT,
29+
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NOR ARE THERE ANY
30+
* WARRANTIES CREATED BY A COURSE OR DEALING, COURSE OF PERFORMANCE OR TRADE
31+
* USAGE. FURTHERMORE, THERE ARE NO WARRANTIES THAT THE SOFTWARE WILL MEET
32+
* YOUR NEEDS OR BE FREE FROM ERRORS, OR THAT THE OPERATION OF THE SOFTWARE
33+
* WILL BE UNINTERRUPTED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
34+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF
36+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39+
*
40+
* @Author: Hans Zandbelt - [email protected]
41+
*
42+
**************************************************************************/
43+
44+
#include "check_util.h"
45+
#include <openssl/evp.h>
46+
47+
int oidc_test_suite_run(Suite *s) {
48+
int n_failed = 0;
49+
50+
SRunner *sr = srunner_create(s);
51+
srunner_run_all(sr, CK_VERBOSE);
52+
n_failed = srunner_ntests_failed(sr);
53+
srunner_free(sr);
54+
55+
return (n_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
56+
}

test/helper.h renamed to test/check_util.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,10 @@
4040
* @Author: Hans Zandbelt - [email protected]
4141
*/
4242

43-
#ifndef _MOD_AUTH_OPENIDC_TEST_COMMON_H_
44-
#define _MOD_AUTH_OPENIDC_TEST_COMMON_H_
43+
#ifndef _MOD_AUTH_OPENIDC_TEST_CHECK_UTIL_H_
44+
#define _MOD_AUTH_OPENIDC_TEST_CHECK_UTIL_H_
4545

46-
#include "const.h" // for the PACKAGE_* defines
47-
#include <apr_pools.h>
4846
#include <check.h>
49-
#include <httpd.h>
50-
#include <stdbool.h>
51-
#include <stdlib.h>
52-
53-
#include "cfg/cfg.h"
54-
55-
void oidc_test_setup(void);
56-
void oidc_test_teardown(void);
57-
int oidc_test_suite_run(Suite *s);
58-
apr_pool_t *oidc_test_pool_get(void);
59-
request_rec *oidc_test_request_get(void);
60-
oidc_cfg_t *oidc_test_cfg_get(void);
61-
cmd_parms *oidc_test_cmd_get(const char *primitive);
6247

6348
#ifndef _ck_assert_ptr_null
6449
#define _ck_assert_ptr_null(X, OP) \
@@ -82,4 +67,6 @@ cmd_parms *oidc_test_cmd_get(const char *primitive);
8267
#define ck_assert_ptr_eq(X, Y) _ck_assert_ptr(X, ==, Y)
8368
#endif
8469

85-
#endif // _MOD_AUTH_OPENIDC_TEST_COMMON_H_
70+
int oidc_test_suite_run(Suite *s);
71+
72+
#endif // _MOD_AUTH_OPENIDC_TEST_CHECK_UTIL_H_

test/test-cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
#include "cfg/cfg_int.h"
4747
#include "cfg/dir.h"
4848
#include "cfg/provider.h"
49-
#include "helper.h"
5049
#include "jose.h"
5150
#include "session.h"
51+
#include "util.h"
5252
#include "util/util.h"
5353
#include <apr_base64.h>
5454
#include <openssl/pem.h>

test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include <openssl/evp.h>
5353
#include <openssl/hmac.h>
5454

55-
#include "helper.h"
55+
#include "util.h"
5656

5757
static int test_nr_run = 0;
5858
static char TST_ERR_MSG[4096];

test/test_cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
#include "cfg/cache.h"
4545
#include "cfg/cfg_int.h"
4646
#include "cfg/provider.h"
47-
#include "helper.h"
47+
#include "check_util.h"
48+
#include "util.h"
4849
#include "util/util.h"
4950

5051
START_TEST(test_cache_mutex_and_status2str) {

test/test_cfg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
#include "cfg/cache.h"
4545
#include "cfg/cfg_int.h"
4646
#include "cfg/provider.h"
47-
#include "helper.h"
47+
#include "check_util.h"
48+
#include "util.h"
4849

4950
// provider
5051

test/test_http.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
#include "cfg/cache.h"
4545
#include "cfg/cfg_int.h"
4646
#include "cfg/provider.h"
47-
#include "helper.h"
47+
#include "check_util.h"
4848
#include "http.h"
49+
#include "util.h"
4950
#include <curl/curl.h>
5051

5152
START_TEST(test_http_accept) {
@@ -321,4 +322,4 @@ int main(void) {
321322
suite_add_tcase(s, accept);
322323

323324
return oidc_test_suite_run(s);
324-
}
325+
}

test/test_jose.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
*
4242
**************************************************************************/
4343

44-
#include "helper.h"
44+
#include "check_util.h"
4545
#include "jose.h"
46+
#include "util.h"
4647

4748
// supported
4849

test/test_proto.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@
4444
#include <openssl/evp.h>
4545
#include <openssl/hmac.h>
4646

47+
#include "check_util.h"
4748
#include "handle/handle.h"
48-
#include "helper.h"
4949
#include "mod_auth_openidc.h"
5050
#include "proto/proto.h"
51+
#include "util.h"
5152
#include "util/util.h"
5253

5354
START_TEST(test_proto_validate_access_token) {

0 commit comments

Comments
 (0)