2
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.
9
# This code is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
# version 2 for more details (a copy is included in the LICENSE file that
13
# accompanied this code).
15
# You should have received a copy of the GNU General Public License version
16
# 2 along with this work; if not, write to the Free Software Foundation,
17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
# or visit www.oracle.com if you need additional information or have any
25
###############################################################################
27
# Unit tests for the configure script
29
###############################################################################
31
AC_DEFUN([TEST_STRING_OPS],
33
FEW="ninja banan pepparkaka"
34
MANY="banan antarktis pepparkaka ninjamask bana"
36
EXPECTED_NON_MATCHING="antarktis ninjamask bana"
37
UTIL_GET_NON_MATCHING_VALUES(ACTUAL, $MANY, $FEW)
38
UTIL_ASSERT_STRING_EQUALS($ACTUAL, $EXPECTED_NON_MATCHING, \
39
[UTIL_GET_NON_MATCHING_VALUES failed])
41
EXPECTED_MATCHING="banan pepparkaka"
42
UTIL_GET_MATCHING_VALUES(ACTUAL, $FEW, $MANY)
43
UTIL_ASSERT_STRING_EQUALS($ACTUAL, $EXPECTED_MATCHING, \
44
[UTIL_GET_MATCHING_VALUES failed])
47
AC_DEFUN([TEST_ARG_ENABLE],
49
# fake '--enable-default-false=yes' on the command line
50
enable_default_false=yes
51
UTIL_ARG_ENABLE(NAME: default-false, DEFAULT: false, RESULT: TEST_RESULT)
52
UTIL_ASSERT_TRUE($TEST_RESULT)
54
# assume '--enable-default-true-but-unavailable=yes' not set
55
UTIL_ARG_ENABLE(NAME: default-true-but-unavailable, DEFAULT: auto, RESULT: TEST_RESULT, AVAILABLE: false)
56
UTIL_ASSERT_NOT_TRUE($TEST_RESULT)
58
enable_test_given_yes=yes
62
UTIL_ARG_ENABLE(NAME: test-given-yes, DEFAULT: false,
63
IF_GIVEN: [ given=true ], IF_ENABLED: [ enabled=true ],
64
IF_DISABLED: [ disabled=true ])
65
UTIL_ASSERT_TRUE($given)
66
UTIL_ASSERT_TRUE($enabled)
67
UTIL_ASSERT_NOT_TRUE($disabled)
69
enable_test_given_default=no
73
UTIL_ARG_ENABLE(NAME: test-given-default, DEFAULT: true,
74
IF_GIVEN: [ given=true ], IF_ENABLED: [ enabled=true ],
75
IF_DISABLED: [ disabled=true ])
76
UTIL_ASSERT_TRUE($given)
77
UTIL_ASSERT_NOT_TRUE($enabled)
78
UTIL_ASSERT_TRUE($disabled)
80
# assume '--enable-test-given-no' not set
84
UTIL_ARG_ENABLE(NAME: test-given-no, DEFAULT: true,
85
IF_GIVEN: [ given=true ], IF_ENABLED: [ enabled=true ],
86
IF_DISABLED: [ disabled=true ])
87
UTIL_ASSERT_NOT_TRUE($given)
88
UTIL_ASSERT_TRUE($enabled)
89
UTIL_ASSERT_NOT_TRUE($disabled)
92
# Use the CUSTOM_EARLY_HOOK to inject our test after basic init is done.
93
AC_DEFUN_ONCE([CUSTOM_EARLY_HOOK],
95
$PRINTF "\nStarting configure tests\n"
96
$PRINTF "==============================\n"
101
# If no assertions failed, report success
102
$PRINTF "==============================\n"
103
$PRINTF "Configure tests finished successfully\n\n"