diff --git a/Makefile b/Makefile index 5549ce306..1fbebae4c 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ libs libflame \ check-env check-env-config check-env-fragments \ flat-headers \ - test \ + test check checklibflame\ checkcpp cleancpptest \ install-headers install-libs install-lib-symlinks \ clean cleanmk cleanh cleanlib cleanleaves distclean \ @@ -59,6 +59,7 @@ OBJ_DIR := obj LIB_DIR := lib INC_DIR := include LAPACKE_DIR := lapacke +TEST_DIR := test CPP_TEST_DIR := testcpp # Use the system type to name the config, object, and library directories. @@ -428,6 +429,8 @@ all: libs libs: libflame +check: checklibflame + install: libs install-libs install-lib-symlinks install-headers uninstall: uninstall-libs uninstall-lib-symlinks uninstall-headers @@ -656,9 +659,50 @@ endif # --- Test suite rules --- +# The test binary executable filename. +# +# $(TEST_WRAPPER) ./$(TEST_BIN) ... > $(TEST_OUT_FILE) +# +# "TEST_WRAPPER can be used to set additional environment variables +# such as LD_LIBRARY_PATH, numactl and others" +# +TEST_BIN := test_$(LIBFLAME).x +TEST_WRAPPER ?= +TEST_CHECK := check-flametest.sh + +# The location of the script that checks the BLIS testsuite output. +TEST_CHECK_PATH := $(DIST_PATH)/$(TEST_DIR)/$(TEST_CHECK) + +test-bin: check-env $(TEST_BIN) + +TEST_OUT_FILE := output.test + +# Check the results of the LIBLFLAME tests. +$(TEST_BIN): +ifeq ($(ENABLE_VERBOSE),yes) + $(MAKE) -C $(TEST_DIR) +else + @$(MAKE) -C $(TEST_DIR) +endif +test-run: test-bin +ifeq ($(ENABLE_VERBOSE),yes) + cd $(TEST_DIR) && $(TEST_WRAPPER) ./$(TEST_BIN) > $(TEST_OUT_FILE) +else + @echo "Running $(TEST_BIN) with output redirected to '$(TEST_OUT_FILE)'" + @chmod +x $(TEST_DIR)/$(TEST_CHECK) + @echo "Please wait for tests to complete..." + @cd $(TEST_DIR) && $(TEST_WRAPPER) ./$(TEST_BIN) > $(TEST_OUT_FILE) +endif +checklibflame:test-run +ifeq ($(ENABLE_VERBOSE),yes) + - $(TEST_CHECK_PATH) $(TEST_DIR)/$(TEST_OUT_FILE) +else + - $(TEST_CHECK_PATH) $(TEST_DIR)/$(TEST_OUT_FILE) +endif + # --- Install rules --- diff --git a/test/check-flametest.sh b/test/check-flametest.sh new file mode 100644 index 000000000..8a6123010 --- /dev/null +++ b/test/check-flametest.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# LIBFLAME +# An object-based framework for developing high-performance BLAS-like +# libraries. +# +# Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# - Neither the name(s) of the copyright holder(s) nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# + +script_name=${0##*/} + +ansi_red="\033[0;31m" #prints the message on console in red +ansi_green="\033[0;32m" #prints the message on console in green +ansi_normal="\033[0m" + +passmsg="All LIBFLAME tests passed!" +failmsg="Please see output.test for details." + +grep -q FAILURE $1 + +if [ $? -eq 0 ]; then + printf "${ansi_red}""${script_name}: ${failmsg}""${ansi_normal}\n" + exit 1 +else + printf "${ansi_green}""${script_name}: ${passmsg}""${ansi_normal}\n" + exit 0 +fi +