From patchwork Tue Jan 6 19:43:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 5576531 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0A5D7BF6C3 for ; Tue, 6 Jan 2015 19:50:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1529320221 for ; Tue, 6 Jan 2015 19:50:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99301200E9 for ; Tue, 6 Jan 2015 19:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932713AbbAFToJ (ORCPT ); Tue, 6 Jan 2015 14:44:09 -0500 Received: from resqmta-ch2-05v.sys.comcast.net ([69.252.207.37]:60456 "EHLO resqmta-ch2-05v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932735AbbAFToE (ORCPT ); Tue, 6 Jan 2015 14:44:04 -0500 Received: from resomta-ch2-07v.sys.comcast.net ([69.252.207.103]) by resqmta-ch2-05v.sys.comcast.net with comcast id cjk01p0062EPM3101jk0Tt; Tue, 06 Jan 2015 19:44:00 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-ch2-07v.sys.comcast.net with comcast id cjjz1p0010MU7Qa01jjzkV; Tue, 06 Jan 2015 19:44:00 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id A67A640A27; Tue, 6 Jan 2015 12:43:58 -0700 (MST) From: Shuah Khan To: mmarek@suse.cz, gregkh@linuxfoundation.org, akpm@linux-foundation.org, rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, keescook@chromium.org, tranmanphong@gmail.com, mpe@ellerman.id.au, cov@codeaurora.org, dh.herrmann@gmail.com, hughd@google.com, bobby.prani@gmail.com, serge.hallyn@ubuntu.com, ebiederm@xmission.com, tim.bird@sonymobile.com, josh@joshtriplett.org, koct9i@gmail.com, masami.hiramatsu.pt@hitachi.com Cc: Shuah Khan , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 19/20] selftests: add install target to enable test install Date: Tue, 6 Jan 2015 12:43:33 -0700 Message-Id: <5cca2e663023be7e3cc89aab34ffc62012e90045.1420571615.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1420573440; bh=xhdr7vRAWLtDCe7tyGa8q99WweqOqrf4YcOk6inQfAQ=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=T2M85oyoV93F2CTPGMJTLpqOvk8wwhKYiU6zQxvpCpPdP0/QpKswCVc3DulqYdAzi rxHTmtfz4nL+r84tNzKXkiZiemVRhCPcNM6fiCh/YLqRe4zMarD1v48+ENGcs5+fr5 8MTmRnrZlIMkoXjuRRuDnqwj50xEMkLT9nkj0b3tSIKsVcuumUZHVKr7uFCZv/igOh 1JDZ+ocWZu74ZxJNHw1vQl00mA2AwEeJaBfz3LvSCYgC4hVStG34aKArFaCh2LP2bo ojp0icDCx+cmwEQPjX3lcoqt4RwlBHwGm1wCY+YovJADR+vqsUVU7hkhaRHiPspyQy EWDDifzrKnYMQ== Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new make target to enable installing selftests. This new target will call install targets for the tests that are specified in INSTALL_TARGETS. During install, a script is generated to run tests that are installed. This script will be installed in the selftest install directory. Individual test Makefiles are changed to add to the script. This will allow new tests to add install and run test commands to the generated kselftest script. run_tests target runs the generated kselftest script to run tests when it is initiated from from "make kselftest" from top level source directory. Approach: Add a new kselftest_install target: -- exports kselftest INSTALL_KSFT_PATH default $(INSTALL_MOD_PATH)/lib/kselftest/$(KERNELRELEASE) -- exports INSTALL_KSFT_PATH -- runs selftests make kselftest_install target: selftests make install target -- Sets up environment for sub-makefiles -- creates kselftest.sh script in install install dir -- runs install targets for INSTALL_TARGETS -- install target can be run only from top level source dir. Individual test make install targets: -- install test programs and/or scripts in install dir -- append to the ksefltest.sh file to add commands to run test -- install target can be run only from top level source dir. Adds the following new ways to initiate selftests: -- Installing and running kselftest from install directory by running "make kselftest" -- Running kselftest script from install directory Maintains the following ways to run tests: -- make TARGETS=net kselftest -- make -C tools/testing/selftests run_tests -- make -C tools/testing/selftests TARGETS=target run_tests Ability specify targets: e.g TARGETS=net -- make run_tests from tools/testing/selftests -- make run_tests from individual test directories: e.g: make run_tests in tools/testing/selftests/net Signed-off-by: Shuah Khan --- tools/testing/selftests/Makefile | 54 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 4e51122..45661ce 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -22,15 +22,67 @@ TARGETS += vm TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG += memory-hotplug +# Used in only run_tests target when make kselftest is run in +# top level source directory +ifeq "$(origin TARGETS)" "command line" +no_install_run=1 +endif + +ifdef INSTALL_KSFT_PATH +KSELFTEST=$(INSTALL_KSFT_PATH)/kselftest.sh +export KSELFTEST +# TODO add install target for SKIP_INSTALL_TARGETS +SKIP_INSTALL_TARGETS = exec powerpc +INSTALL_TARGETS = $(filter-out $(SKIP_INSTALL_TARGETS),$(TARGETS)) ipc +else +no_install_run=1 +endif + +INSTALL_KSFT_ERR = "Run make kselftest_install in top level source directory" + all: for TARGET in $(TARGETS); do \ make -C $$TARGET; \ done; -run_tests: all +install: +ifdef INSTALL_KSFT_PATH + rm -rf $(INSTALL_KSFT_PATH) + mkdir -p $(INSTALL_KSFT_PATH) + + make all + @echo "#!/bin/sh\n# Kselftest Run Tests ...." >> $(KSELFTEST) + @echo "# This file is generated by kselftest_install" >> $(KSELFTEST) + @echo "# Please don't change it !!\n" >> $(KSELFTEST) + @echo "echo \"============================\"" >> $(KSELFTEST) + for TARGET in $(INSTALL_TARGETS); do \ + echo "Installing $$TARGET"; \ + echo "echo \"Start $$TARGET test ....\"" >> $(KSELFTEST); \ + make -C $$TARGET install; \ + echo "echo \"End $$TARGET test ....\"" >> $(KSELFTEST); \ + echo "echo \"============================\"" >> $(KSELFTEST); \ + done; + chmod +x $(KSELFTEST) +else + @echo $(INSTALL_KSFT_ERR) +endif + +run_tests: +ifndef no_install_run +# ifdef INSTALL_KSFT_PATH + make install + @cd $(INSTALL_KSFT_PATH); ./kselftest.sh; cd - +# invoke run_tests for SKIP_INSTALL_TARGETS + for TARGET in $(SKIP_INSTALL_TARGETS); do \ + make -C $$TARGET run_tests; \ + done; +# endif +else + make all for TARGET in $(TARGETS); do \ make -C $$TARGET run_tests; \ done; +endif hotplug: for TARGET in $(TARGETS_HOTPLUG); do \