Blame sofort/cfgtest/cfgtest.sh

456fed
# cfgtest.sh: sofort's config test framework,
456fed
# for use from within a project's custom cfgdefs.sh.
456fed
456fed
# this file is covered by COPYING.SOFORT.
456fed
456fed
# in the common scenario, host-specific tests are preceded
456fed
# by a single invocation of cfgtest_host_section, whereas
456fed
# native (build) system tests are preceded by the invocation
456fed
# of cfgtest_native_section.
456fed
456fed
# cfgdefs fraework variables:
456fed
# mb_cfgtest_cc:      the compiler used for the current test
456fed
# mb_cfgtest_cflags:  the compiler flags used for the current test
456fed
# mb_cfgtest_cfgtype: the type of the current test (host/native)
456fed
# mb_cfgtest_makevar: the make variable affected by the current test
456fed
# mb_cfgtest_headers: headers for ad-hoc inclusion with the current test
456fed
456fed
456fed
cfgtest_newline()
456fed
{
456fed
	printf '\n' >> $mb_pwd/cfgdefs.mk
456fed
}
456fed
456fed
456fed
cfgtest_comment()
456fed
{
456fed
	mb_internal_str='#'
456fed
456fed
	for mb_internal_arg ; do
456fed
		mb_internal_str="$mb_internal_str $mb_internal_arg"
456fed
	done
456fed
456fed
	printf '%s\n' "$mb_internal_str" >> $mb_pwd/cfgdefs.mk
456fed
}
456fed
456fed
456fed
cfgtest_host_section()
456fed
{
456fed
	mb_cfgtest_cc="$ccenv_host_cc"
456fed
	mb_cfgtest_cfgtype='host'
68c6c9
68c6c9
	mb_cfgtest_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
68c6c9
		OS_DSO_EXRULES=default                              \
68c6c9
		OS_SONAME=symlink                                   \
68c6c9
		OS_ARCHIVE_EXT='.a'                                 \
68c6c9
		.cflags-host)
68c6c9
456fed
	mb_cfgtest_cflags="${mb_cfgtest_cflags#*: }"
456fed
456fed
	mb_cfgtest_ldflags="$mb_ldflags_cmdline"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_debug"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_common"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_strict"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_config"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_sysroot"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_path"
456fed
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_last"
456fed
}
456fed
456fed
456fed
cfgtest_native_section()
456fed
{
68c6c9
	mb_cfgtest_cc="$ccenv_native_cc"
456fed
	mb_cfgtest_cfgtype='native'
68c6c9
68c6c9
	mb_cfgtest_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
68c6c9
		OS_DSO_EXRULES=default                              \
68c6c9
		OS_SONAME=symlink                                   \
68c6c9
		OS_ARCHIVE_EXT='.a'                                 \
68c6c9
		.cflags-native)
68c6c9
456fed
	mb_cfgtest_cflags="${mb_cfgtest_cflags#*: }"
456fed
	mb_cfgtest_ldflags="$mb_native_ldflags"
456fed
}
456fed
456fed
456fed
cfgtest_prolog()
456fed
{
456fed
	cfgtest_line_dots='.......................'
456fed
	cfgtest_line_dots="${cfgtest_line_dots}${cfgtest_line_dots}"
456fed
	cfgtest_tool_desc=" == trying ${mb_cfgtest_cfgtype} ${1}: ${2}"
456fed
	cfgtest_tool_dlen="${#cfgtest_line_dots}"
456fed
456fed
	printf '\n%s\n' '________________________' >&3
456fed
	printf "cfgtest: probing for ${mb_cfgtest_cfgtype} ${1}: ${2}\n\n" >&3
456fed
	printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s" \
456fed
		"${cfgtest_tool_desc}  ${mb_line_dots}"
456fed
}
456fed
456fed
456fed
cfgtest_epilog()
456fed
{
456fed
	cfgtest_line_dots='.......................'
456fed
	cfgtest_tool_dlen="$((${#cfgtest_line_dots} - ${#2}))"
456fed
456fed
	printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s  %s.\n" \
456fed
		"${cfgtest_line_dots}" "${2}"
456fed
70cfc2
	if [ "${1}" = 'snippet' ] && [ -f 'a.out' ]; then
456fed
		rm -f 'a.out'
456fed
	fi
456fed
456fed
	if [ "${1}" = 'snippet' ] && [ "${2}" = '(error)' ]; then
456fed
		printf '\n\ncfgtest: the %s compiler %s %s.\n' \
456fed
			"$mb_cfgtest_cfgtype"                 \
456fed
			'failed to compile the above code'   \
456fed
			"${1}" >&3
456fed
		printf '%s\n' '------------------------' >&3
456fed
		return 1
456fed
	fi
456fed
456fed
	if [ "${2}" = '-----' ]; then
456fed
		printf '\n\ncfgtest: %s %s is missing or cannot be found.\n' "${1}" "${3}" >&3
456fed
		printf '%s\n' '------------------------' >&3
456fed
		return 1
456fed
	elif [ "${1}" = 'size-of-type' ] && [ "${2}" = '(error)' ]; then
456fed
		printf '\n\ncfgtest: could not determine size of type `%s.\n' "${3}'" >&3
456fed
		printf '%s\n' '------------------------' >&3
456fed
		return 1
99b9ff
	elif [ "${1}" = 'switch' ] && [ "${2}" = '(error)' ]; then
99b9ff
		printf '\n\ncfgtest: the switch `%s is not supported by the %s compiler.\n' \
99b9ff
			"${3}'" "$mb_cfgtest_cfgtype" >&3
99b9ff
		printf '%s\n' '------------------------' >&3
99b9ff
		return 1
456fed
	elif [ "${2}" = '(error)' ]; then
456fed
		printf '\n\ncfgtest: %s `%s is not defined or cannot be used.\n' "${1}" "${3}'" >&3
456fed
		printf '%s\n' '------------------------' >&3
456fed
		return 1
456fed
	fi
456fed
}
456fed
456fed
456fed
cfgtest_entity_size_prolog()
456fed
{
456fed
	cfgtest_line_dots='.......................'
456fed
	cfgtest_line_dots="${cfgtest_line_dots}${cfgtest_line_dots}"
456fed
	cfgtest_tool_desc=" == checking size of ${mb_cfgtest_cfgtype} type: ${@}"
456fed
	cfgtest_tool_dlen="${#cfgtest_line_dots}"
456fed
456fed
	printf '\n%s\n' '________________________' >&3
456fed
	printf "cfgtest: checking size of ${mb_cfgtest_cfgtype} type: ${@}\n\n" >&3
456fed
456fed
	printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s" \
456fed
		"${cfgtest_tool_desc}  ${mb_line_dots}"
456fed
}
456fed
456fed
456fed
cfgtest_makevar_append()
456fed
{
456fed
	mb_internal_str='+='
456fed
456fed
	for mb_internal_arg ; do
456fed
		if ! [ -z "$mb_internal_arg" ]; then
456fed
			mb_internal_str="$mb_internal_str $mb_internal_arg"
456fed
		fi
456fed
	done
456fed
456fed
	printf '%-24s%s\n' "$mb_cfgtest_makevar" "$mb_internal_str" \
456fed
		>> $mb_pwd/cfgdefs.mk
456fed
456fed
	unset cfgtest_internal_unit_test
456fed
}
456fed
456fed
456fed
cfgtest_cflags_append()
456fed
{
456fed
	if [ $mb_cfgtest_cfgtype = 'host' ]; then
456fed
		mb_internal_makevar='CFLAGS_CONFIG'
456fed
	else
456fed
		mb_internal_makevar='NATIVE_CFLAGS'
456fed
	fi
456fed
456fed
	mb_cfgtest_makevar_saved=$mb_cfgtest_makevar
456fed
	mb_cfgtest_makevar=$mb_internal_makevar
456fed
456fed
	cfgtest_makevar_append "$@"
456fed
	mb_cfgtest_makevar=$mb_cfgtest_makevar_saved
456fed
}
456fed
456fed
456fed
cfgtest_ldflags_append()
456fed
{
456fed
	if [ $mb_cfgtest_cfgtype = 'host' ]; then
456fed
		mb_internal_makevar='LDFLAGS_CONFIG'
456fed
	else
456fed
		mb_internal_makevar='NATIVE_LDFLAGS'
456fed
	fi
456fed
456fed
	mb_cfgtest_makevar_saved=$mb_cfgtest_makevar
456fed
	mb_cfgtest_makevar=$mb_internal_makevar
456fed
456fed
	cfgtest_makevar_append "$@"
456fed
	mb_cfgtest_makevar=$mb_cfgtest_makevar_saved
456fed
}
456fed
456fed
456fed
cfgtest_common_init()
456fed
{
456fed
	# cfgtest variables
faf186
	cfgtest_type="${1:-}"
faf186
faf186
	if [ "$cfgtest_type" = 'asm' ]; then
456fed
		cfgtest_fmt='%s -c -xc - -o a.out'
faf186
	elif [ "$cfgtest_type" = 'lib' ]; then
456fed
		cfgtest_fmt='%s -xc - -o a.out'
456fed
	else
456fed
		cfgtest_fmt='%s -S -xc - -o -'
456fed
	fi
456fed
99b9ff
faf186
	if [ "$cfgtest_type" = 'lib' ]; then
456fed
		cfgtest_cmd=$(printf "$cfgtest_fmt %s %s %s" \
456fed
			"$mb_cfgtest_cc"                     \
456fed
			"$mb_cfgtest_cflags"                 \
456fed
			"$mb_cfgtest_ldflags"                \
456fed
			"$cfgtest_libs")
99b9ff
99b9ff
	elif [ "$cfgtest_type" = 'switch' ]; then
99b9ff
		cfgtest_cmd=$(printf "$cfgtest_fmt %s %s" \
99b9ff
			"$mb_cfgtest_cc"                  \
99b9ff
			"$mb_cfgtest_cflags"              \
99b9ff
			"$cfgtest_switches")
456fed
	else
456fed
		cfgtest_cmd=$(printf "$cfgtest_fmt %s" \
456fed
			"$mb_cfgtest_cc"               \
456fed
			"$mb_cfgtest_cflags")
456fed
	fi
456fed
99b9ff
faf186
	if [ -z "$mb_cfgtest_headers" ] || [ "$cfgtest_type" = 'lib' ]; then
456fed
		cfgtest_inc=
456fed
		cfgtest_src="$cfgtest_code_snippet"
99b9ff
99b9ff
	elif [ "$cfgtest_type" = 'switch' ]; then
99b9ff
		cfgtest_inc=
99b9ff
		cfgtest_src=
456fed
	else
456fed
		cfgtest_inc=$(printf '#include <%s>\n' $mb_cfgtest_headers)
456fed
		cfgtest_src=$(printf '%s\n_\n' "$cfgtest_inc" \
456fed
			| m4 -D_="$cfgtest_code_snippet")
456fed
	fi
456fed
99b9ff
456fed
	# config.log
456fed
	printf "$cfgtest_fmt" "$mb_cfgtest_cc" >&3
456fed
36a105
	for cfgtest_cflag in $(printf '%s' "$mb_cfgtest_cflags"); do
456fed
		printf ' \\\n\t%s' "$cfgtest_cflag" >&3
456fed
	done
456fed
faf186
	if [ "$cfgtest_type" = 'lib' ]; then
36a105
		for cfgtest_lib in $(printf '%s' "$cfgtest_libs"); do
456fed
			printf ' \\\n\t%s' "$cfgtest_lib" >&3
456fed
		done
99b9ff
99b9ff
	elif [ "$cfgtest_type" = 'switch' ]; then
36a105
		for cfgtest_switch in $(printf '%s' "$cfgtest_switches"); do
99b9ff
			printf ' \\\n\t%s' "$cfgtest_switch" >&3
99b9ff
		done
456fed
	fi
456fed
456fed
	printf ' \\\n'                           >&3
456fed
	printf '<< _SRCEOF\n%s\n' "$cfgtest_src" >&3
456fed
	printf '_SRCEOF \n\n\n'                  >&3
456fed
}
456fed
456fed
456fed
cfgtest_header_presence()
456fed
{
456fed
	#init
456fed
	cfgtest_prolog 'header' "${1}"
456fed
456fed
	cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}")
456fed
456fed
	cfgtest_common_init
456fed
456fed
	# execute
456fed
	printf '%s' "$cfgtest_src"                  \
456fed
		| eval $(printf '%s' "$cfgtest_cmd") \
456fed
		> /dev/null 2>&3                      \
456fed
	|| cfgtest_epilog 'header' '-----' "<${1}>"    \
456fed
	|| return
456fed
456fed
	# result
456fed
	mb_internal_str=$(printf '%s%s' '-DHAVE_' "${1}"  \
456fed
			| sed -e 's/\./_/g' -e 's@/@_@g'  \
456fed
			| tr "[:lower:]" "[:upper:]")
456fed
456fed
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
456fed
		cfgtest_cflags_append "$mb_internal_str"
456fed
	else
456fed
		cfgtest_makevar_append "$mb_internal_str"
456fed
	fi
456fed
456fed
	printf 'cfgtest: %s header <%s> was found and may be included.\n' \
456fed
		"$mb_cfgtest_cfgtype" "${1}" >&3
456fed
	printf '%s\n' '------------------------' >&3
456fed
456fed
	cfgtest_epilog 'header' "${1}"
456fed
}
456fed
456fed
456fed
cfgtest_header_absence()
456fed
{
456fed
	#init
456fed
	cfgtest_prolog 'header absence' "${1}"
456fed
456fed
	cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}")
456fed
456fed
	cfgtest_common_init
456fed
456fed
	# execute
456fed
	printf '%s' "$cfgtest_src"                  \
456fed
		| eval $(printf '%s' "$cfgtest_cmd") \
456fed
		> /dev/null 2>&3                      \
456fed
	&& printf 'cfgtest: %s header <%s>: no error.' \
456fed
		"$mb_cfgtest_cfgtype" "${1}" >&3        \
456fed
	&& cfgtest_epilog 'header' "${1}"                \
456fed
	&& return
456fed
456fed
	# result
456fed
	mb_internal_str=$(printf '%s%s' '-DHAVE_NO_' "$@" \
456fed
			| sed -e 's/\./_/g' -e 's@/@_@g'  \
456fed
			| tr "[:lower:]" "[:upper:]")
456fed
456fed
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
456fed
		cfgtest_cflags_append "$mb_internal_str"
456fed
	else
456fed
		cfgtest_makevar_append "$mb_internal_str"
456fed
	fi
456fed
456fed
	printf 'cfgtest: %s header <%s> may not be included.\n' \
456fed
		"$mb_cfgtest_cfgtype" "${1}" >&3
456fed
	printf '%s\n' '------------------------' >&3
456fed
6dbb14
	cfgtest_epilog 'header' '-----' "${1}"
456fed
}
456fed
456fed
456fed
cfgtest_interface_presence()
456fed
{
456fed
	# init
456fed
	cfgtest_prolog 'interface' "${1}"
456fed
456fed
	cfgtest_code_snippet=$(printf 'void * addr = &%;;\n' "${1}")
456fed
456fed
	cfgtest_common_init
456fed
456fed
	# execute
456fed
	printf '%s' "$cfgtest_src"                    \
456fed
		| eval $(printf '%s' "$cfgtest_cmd")   \
456fed
		> /dev/null 2>&3                        \
456fed
	|| cfgtest_epilog 'interface' '(error)' "${1}"   \
456fed
	|| return
456fed
456fed
	# result
456fed
	mb_internal_str=$(printf '%s%s' '-DHAVE_' "$@"  \
456fed
			| sed -e 's/\./_/g'             \
456fed
			| tr "[:lower:]" "[:upper:]")
456fed
456fed
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
456fed
		cfgtest_cflags_append "$mb_internal_str"
456fed
	else
456fed
		cfgtest_makevar_append "$mb_internal_str"
456fed
	fi
456fed
456fed
	printf 'cfgtest: %s interface `%s'"'"' is available.\n' \
456fed
		"$mb_cfgtest_cfgtype" "${1}" >&3
456fed
	printf '%s\n' '------------------------' >&3
456fed
456fed
	cfgtest_epilog 'interface' "${1}"
456fed
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_decl_presence()
456fed
{
456fed
	# init
456fed
	cfgtest_prolog 'decl' "${1}"
456fed
456fed
	cfgtest_code_snippet=$(printf 'void * any = (void *)(%s);' "${1}")
456fed
456fed
	cfgtest_common_init
456fed
456fed
	# execute
456fed
	printf '%s' "$cfgtest_src"                  \
456fed
		| eval $(printf '%s' "$cfgtest_cmd") \
456fed
		> /dev/null 2>&3                      \
456fed
	|| cfgtest_epilog 'decl' '(error)' "${1}"      \
456fed
	|| return
456fed
456fed
	# does the argument solely consist of the macro or enum member name?
456fed
	mb_internal_str=$(printf '%s' "$@" | tr -d '[a-z][A-Z][0-9][_]')
456fed
456fed
	if [ -n "$mb_internal_str" ]; then
456fed
		cfgtest_epilog 'decl' '(defined)'
456fed
		return 0
456fed
	fi
456fed
456fed
	# result
456fed
	mb_internal_str=$(printf '%s%s' '-DHAVE_DECL_' "$@"  \
456fed
			| sed -e 's/\./_/g'                  \
456fed
			| tr "[:lower:]" "[:upper:]")
456fed
456fed
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
456fed
		cfgtest_cflags_append "$mb_internal_str"
456fed
	else
456fed
		cfgtest_makevar_append "$mb_internal_str"
456fed
	fi
456fed
456fed
	printf 'cfgtest: `%s'"'"' is defined for the %s system.\n' \
456fed
		"${1}" "$mb_cfgtest_cfgtype" >&3
456fed
	printf '%s\n' '------------------------' >&3
456fed
456fed
	cfgtest_epilog 'decl' '(defined)'
456fed
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_type_size()
456fed
{
456fed
	cfgtest_entity_size_prolog "$@"
456fed
456fed
	mb_internal_size=''
456fed
	mb_internal_test='char x[(sizeof(%s) == %s) ? 1 : -1];'
456fed
456fed
	for mb_internal_guess in 8 4 2 1 16 32 64 128; do
456fed
		if [ -z $mb_internal_size ]; then
456fed
			printf '# guess %s ===>\n' "$mb_internal_guess" >&3
456fed
456fed
			mb_internal_type="$@"
456fed
456fed
			cfgtest_code_snippet=$(printf "$mb_internal_test" \
456fed
				"$mb_internal_type" "$mb_internal_guess")
456fed
456fed
			cfgtest_common_init
456fed
456fed
			printf '%s' "$cfgtest_src"                  \
456fed
				| eval $(printf '%s' "$cfgtest_cmd") \
456fed
				> /dev/null 2>&3                      \
456fed
			&& mb_internal_size=$mb_internal_guess
456fed
456fed
			printf '\n' >&3
456fed
		fi
456fed
	done
456fed
456fed
	# unrecognized type, or type size not within range
456fed
	if [ -z $mb_internal_size ]; then
456fed
		cfgtest_epilog 'size-of-type' '(error)' "@"
456fed
		return 1
456fed
	fi
456fed
456fed
	# -DSIZEOF_TYPE=SIZE
456fed
	mb_internal_str=$(printf '%s%s=%s' '-DSIZEOF_'        \
456fed
				"$mb_internal_type"           \
456fed
				"$mb_internal_size"           \
456fed
			| sed -e 's/\ /_/g' -e 's/*/P/g'      \
456fed
			| tr "[:lower:]" "[:upper:]")
456fed
456fed
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
456fed
		cfgtest_cflags_append "$mb_internal_str"
456fed
	else
456fed
		cfgtest_makevar_append "$mb_internal_str"
456fed
	fi
456fed
456fed
	printf 'cfgtest: size of type `%s'"'"' determined to be %s\n' \
456fed
		"${@}" "$mb_internal_size" >&3
456fed
	printf '%s\n' '------------------------' >&3
456fed
456fed
	cfgtest_epilog 'size-of-type' "$mb_internal_size"
456fed
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_code_snippet_asm()
456fed
{
456fed
	# init
456fed
	cfgtest_prolog 'support of code snippet' '<...>'
456fed
456fed
	cfgtest_code_snippet="$@"
456fed
456fed
	cfgtest_common_init 'asm'
456fed
456fed
	# execute
456fed
	cfgtest_ret=1
456fed
456fed
	printf '%s' "$cfgtest_src"                  \
456fed
		| eval $(printf '%s' "$cfgtest_cmd") \
456fed
		> /dev/null 2>&3                      \
456fed
	|| cfgtest_epilog 'snippet' '(error)'          \
456fed
	|| return
456fed
456fed
	# result
456fed
	cfgtest_ret=0
456fed
456fed
	printf 'cfgtest: %s compiler: above code snippet compiled successfully.\n\n' \
456fed
		"$mb_cfgtest_cfgtype" >&3
456fed
456fed
	cfgtest_epilog 'snippet' '(ok)'
456fed
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_library_presence()
456fed
{
456fed
	# init
456fed
	cfgtest_libs=
456fed
	cfgtest_spc=
456fed
456fed
	for cfgtest_lib in ${@}; do
456fed
		cfgtest_libs="$cfgtest_libs$cfgtest_spc$cfgtest_lib"
456fed
		cfgtest_spc=' '
456fed
	done
456fed
456fed
	if [ "${1}" = "$cfgtest_libs" ]; then
456fed
		cfgtest_prolog 'library' "${1#*-l}"
456fed
	else
456fed
		cfgtest_prolog 'lib module' '(see config.log)'
456fed
	fi
456fed
456fed
	cfgtest_code_snippet='int main(void){return 0;}'
456fed
456fed
	cfgtest_common_init 'lib'
456fed
456fed
	# execute
456fed
	printf '%s' "$cfgtest_src"                  \
456fed
		| eval $(printf '%s' "$cfgtest_cmd") \
456fed
		> /dev/null 2>&3                      \
456fed
	|| cfgtest_epilog 'library' '-----' "$@"       \
456fed
	|| return 1
456fed
456fed
	# result
456fed
	printf 'cfgtest: `%s'"'"' was accepted by the linker driver.\n' \
456fed
		"$cfgtest_libs" >&3
456fed
	printf '%s\n' '------------------------' >&3
456fed
456fed
	cfgtest_epilog 'library' '(present)'
456fed
456fed
	return 0
456fed
}
456fed
456fed
99b9ff
cfgtest_compiler_switch()
99b9ff
{
99b9ff
	# init
99b9ff
	cfgtest_switches=
99b9ff
	cfgtest_spc=
99b9ff
36a105
	for cfgtest_switch in $(printf '%s' "${@}"); do
99b9ff
		cfgtest_switches="$cfgtest_switches$cfgtest_spc$cfgtest_switch"
99b9ff
		cfgtest_spc=' '
99b9ff
	done
99b9ff
99b9ff
	if [ "${1}" = "$cfgtest_switches" ]; then
99b9ff
		cfgtest_prolog 'compiler switch' "$cfgtest_switches"
99b9ff
	else
99b9ff
		cfgtest_prolog 'compiler switch combination' "$cfgtest_switches"
99b9ff
	fi
99b9ff
99b9ff
	cfgtest_code_snippet=
99b9ff
99b9ff
	cfgtest_common_init 'switch'
99b9ff
99b9ff
	# execute
99b9ff
	printf '%s' "$cfgtest_src"                  \
99b9ff
		| eval $(printf '%s' "$cfgtest_cmd") \
99b9ff
		> /dev/null 2>&3                      \
99b9ff
	|| cfgtest_epilog 'switch' '(error)' "$@"      \
99b9ff
	|| return 1
99b9ff
99b9ff
	# result
99b9ff
	printf 'cfgtest: the switch `%s was accepted by the compier.\n' \
99b9ff
		"$cfgtest_switches'" >&3
99b9ff
	printf '%s\n' '------------------------' >&3
99b9ff
99b9ff
	cfgtest_epilog 'switch' '(accepted)'
99b9ff
99b9ff
	return 0
99b9ff
}
99b9ff
99b9ff
456fed
cfgtest_unit_header_presence()
456fed
{
456fed
	cfgtest_internal_unit_test='unit_test'
456fed
	cfgtest_header_presence "$@" || return 1
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_unit_header_absence()
456fed
{
456fed
	cfgtest_internal_unit_test='unit_test'
456fed
	cfgtest_header_absence "$@" || return 1
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_unit_interface_presence()
456fed
{
456fed
	cfgtest_internal_unit_test='unit_test'
456fed
	cfgtest_interface_presence "$@" || return 1
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_unit_decl_presence()
456fed
{
456fed
	cfgtest_internal_unit_test='unit_test'
456fed
	cfgtest_decl_presence "$@" || return 1
456fed
	return 0
456fed
}
456fed
456fed
456fed
cfgtest_unit_type_size()
456fed
{
456fed
	cfgtest_internal_unit_test='unit_test'
456fed
	cfgtest_type_size "$@" || return 1
456fed
	return 0
456fed
}