From patchwork Wed Dec 24 16:27:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 5539751 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E0EC0BEEA8 for ; Wed, 24 Dec 2014 16:33:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D52B201DD for ; Wed, 24 Dec 2014 16:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96FB7201C7 for ; Wed, 24 Dec 2014 16:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752601AbaLXQd2 (ORCPT ); Wed, 24 Dec 2014 11:33:28 -0500 Received: from resqmta-po-07v.sys.comcast.net ([96.114.154.166]:48197 "EHLO resqmta-po-07v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbaLXQdX (ORCPT ); Wed, 24 Dec 2014 11:33:23 -0500 Received: from resomta-po-20v.sys.comcast.net ([96.114.154.244]) by resqmta-po-07v.sys.comcast.net with comcast id XUTb1p0075Geu2801UUFHm; Wed, 24 Dec 2014 16:28:15 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-po-20v.sys.comcast.net with comcast id XUUD1p0030MU7Qa01UUEYZ; Wed, 24 Dec 2014 16:28:15 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 5E80A3FED4; Wed, 24 Dec 2014 09:28:14 -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 Cc: Shuah Khan , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 19/20] selftests: add install target to enable test install Date: Wed, 24 Dec 2014 09:27:55 -0700 Message-Id: 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=1419438495; bh=QmBFysPXxX+T1V5rdxM98pfLYJFrRw+zzecvUbM40PA=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=cSvNc2zKf4vpkG0XZt547AyoJt4iGFrVcT7OOuVfocofPwRTBG7h/u9J8w0wdUQUD uYG0PM8kL+KS8gVpws4jFP54NYQRwDCntYw9sx9ORY1sy5z7xZdEnM17n65NrOMmur nFFFZnLYQY3Skr/uJdkizdvAwMdfMH1PkmFBI8JKkH5ZyD86bZ+TINyh58N+a/b/1c LKQ71TliSyaYCRwycy5wuyky9Z2rhTKGrgIo6Q3NXyXQDRDtI35wRkxyWUKa6idg4P pZi3QmCUBg04z48wOVPwEJVnpv8qiAt7j9MytsOTKvxKQJEa54KrlnsOFLd/TuBq5v nFSAbsJAYWqlQ== 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..e70cdc9 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 \