# ============================================================== # Copyright (c) 1996 - 1998 Tim Barbour # Copyright (c) 1998-1999 ACT Financial Systems Pty Ltd. # All Rights Reserved. # This make library may be used and distributed under the terms # of the GNU LGPL, as published by the Free Software Foundation. # See the file COPYING for details. # ============================================================== # $Id: test.mk,v 1.17 2001/11/30 22:56:36 trb Exp $ #------------------------------------------------------------------------------------------------------- # text requires: unit_test test_result_dir pass_suffix inst_bin_dir #------------------------------------------------------------------------------------------------------- # rules require: mkemissiondir inst_dir TEST_ENVIRONMENT_SCRIPTS fail_suffix pass_suffix # tmp_suffix MV subdirs target_os_kind target_os_kinds #------------------------------------------------------------------------------------------------------- # refers to: #------------------------------------------------------------------------------------------------------- # provides rules for: making successful test results #------------------------------------------------------------------------------------------------------- # provides variables: #------------------------------------------------------------------------------------------------------- # provides commands: #------------------------------------------------------------------------------------------------------- # contributes to: #------------------------------------------------------------------------------------------------------- ifeq ($(strip $(unit_test)),yes) ifeq ($(target_type),test) maybe_test_result = $(test_result_dir)/$(target_name).$(pass_suffix) endif endif # ulimit is only valid under SunOS ifeq (target_os,SunOS) ulimit_cmd = ulimit -c 0; endif define run_test @$(mkemissiondir) $(test_result_dir) @. $(MKINC)/functions.sh; \ fail_result=$(test_result_dir)/$*.$(fail_suffix); \ pass_result=$(test_result_dir)/$*.$(pass_suffix); \ MoveAnyOldLog $$fail_result; \ MoveAnyOldLog $$pass_result; \ install_dir=$(inst_dir); \ env_scripts=$(strip $(TEST_ENVIRONMENT_SCRIPTS)); \ if [ -n $$env_scripts ]; then \ for script in $$env_scripts; do \ . $$script; \ done \ fi; \ tmp_result=$(test_result_dir)/$*.$(tmp_suffix); \ run_it="$< > $$tmp_result 2>&1"; \ echo "$$run_it"; \ $(ulimit_cmd) \ if ( eval "$$run_it" ); then \ final_result=$$pass_result; \ else \ final_result=$$fail_result; \ fi; \ move_result="$(MV) $$tmp_result $$final_result"; \ echo "$$move_result"; \ eval "$$move_result"; \ if [ "$$final_result" != "$$pass_result" ]; then \ cat $$final_result 1>&2; \ exit 1; \ fi endef #+ this is not valid for the (hypothetical) case of "running" a kernel module $(test_result_dir)/%.$(pass_suffix) : $(bin_dir)/%$(program_ext) $(run_test) .PHONY : test_norec test ifneq ($(strip $(maybe_test_result)),) # we can only run tests for the host platform (at present) ifeq ($(strip $(target_platform)),$(strip $(host_platform))) # this target does not make sense in a kernel way (gluon currently cannot run tests in kernel-space) ifeq ($(strip $(filter $(kernel_module), $(sorted_way_components))),) test_norec : $(maybe_test_result) else test_norec : @echo "=== not running test in kernel way" 1>&2 endif else test_norec : @echo "=== not running test for non-host target_platform $(target_platform)" 1>&2 endif endif test :: test_norec