Blame sofort/cfgtest/cfgtest.sh

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