From patchwork Wed May 30 00:45:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10437441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 87812601E9 for ; Wed, 30 May 2018 00:45:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75CD8286F7 for ; Wed, 30 May 2018 00:45:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6964B28703; Wed, 30 May 2018 00:45:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BBC38286F7 for ; Wed, 30 May 2018 00:45:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB1596F51B; Wed, 30 May 2018 00:45:26 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-x22f.google.com (mail-qk0-x22f.google.com [IPv6:2607:f8b0:400d:c09::22f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5CD856F51A; Wed, 30 May 2018 00:45:25 +0000 (UTC) Received: by mail-qk0-x22f.google.com with SMTP id h19-v6so13055848qkj.10; Tue, 29 May 2018 17:45:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=65G5e6+3R/vWoxnLazbnP7PrctcYpsNJgFilu+TRYxg=; b=dY6TwiT6jDYYOrzqi8seYlbn4uOrTwiAtcOlorRzWO26rfDA7Cn5VXbjjp8cB3ISwu giAjsZTqJW1527pprfVwAIsiunqLJfGeuVEjlINNqhX1k7lYgl/aszy3ZJXrd6qGjyeS /PThPMFF244EvN337uzbaFc0I3Rj/M11ER9zw8J881p20Qg8s5ms3poPHE2qFUJXunnX u5kGJSfk2pFjn86h2h5ri4m/6wI1VavYzwWqXn7B86Rq6LD4ul57YR//lTF0DoIuBRNk h8u6hlgTXjo+a/vm1k9U5CuMDakjdJotD2SON2qPrl57ooN9cMnCI3zCOPhZVsno7jtK UB2A== X-Gm-Message-State: APt69E27kPWVWsnKs62jv7Usnw/avec8+R9OlWvbzT/6LGjH8QVmSUWk NG6eZMzRvtf/Sol0lndaeJk= X-Google-Smtp-Source: ADUXVKIQTZW7HLWUMirUtaAYKf78ublaJEbeUDEnme5/xJn0HZ4PANgEx6caNPS2EcZu+j5p3OdAow== X-Received: by 2002:a37:c84d:: with SMTP id c74-v6mr552288qkj.245.1527641124141; Tue, 29 May 2018 17:45:24 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id q8-v6sm22922529qtp.2.2018.05.29.17.45.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 17:45:23 -0700 (PDT) Date: Tue, 29 May 2018 21:45:20 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: <20180530004520.qnqnainaevyrcoae@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180512 Subject: [Intel-gfx] [PATCH i-g-t] [RFC] Add support to force specific module load X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a new option to force the use of a module specified from the command line. The force command expects a module name which will be used on the target test (changing the standard behavior). This feature can be useful for developers that have to create a new module since it is possible to use some of the tests already provided by IGT (e.g., kms_color, core, etc.) as a start point. Additionally, it can also be useful for someone that wants to implement a new set of tests for a specific driver because the developer can first check the behavior of any test in the target module. It is important to highlight, that a force option can produce unexpected results and developers should be aware of that. Signed-off-by: Rodrigo Siqueira --- lib/drmtest.c | 19 +++++++++++++------ lib/igt_core.c | 20 ++++++++++++++++++++ lib/igt_core.h | 4 ++++ scripts/run-tests.sh | 4 +++- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index fae6f86f..1d2ba178 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -258,6 +258,7 @@ static int __open_device(const char *base, int offset, unsigned int chipset) static int __open_driver(const char *base, int offset, unsigned int chipset) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + const char* target; static const struct module { unsigned int bit; const char *module; @@ -276,13 +277,19 @@ static int __open_driver(const char *base, int offset, unsigned int chipset) if (fd != -1) return fd; + target = get_target_module(); + pthread_mutex_lock(&mutex); - for (const struct module *m = modules; m->module; m++) { - if (chipset & m->bit) { - if (m->modprobe) - m->modprobe(m->module); - else - modprobe(m->module); + if (target) { + modprobe(target); + } else { + for (const struct module *m = modules; m->module; m++) { + if (chipset & m->bit) { + if (m->modprobe) + m->modprobe(m->module); + else + modprobe(m->module); + } } } pthread_mutex_unlock(&mutex); diff --git a/lib/igt_core.c b/lib/igt_core.c index 5092a3f0..ed66eae1 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -286,6 +286,7 @@ enum { OPT_DESCRIPTION, OPT_DEBUG, OPT_INTERACTIVE_DEBUG, + OPT_FORCE_MODULE, OPT_HELP = 'h' }; @@ -303,6 +304,20 @@ static pthread_mutex_t log_buffer_mutex = PTHREAD_MUTEX_INITIALIZER; GKeyFile *igt_key_file; #endif +char *target_module; + +void set_target_module(char *target) +{ + if (!target) + igt_warn("No module specified, keep default behaviour"); + target_module = target; +} + +const char *get_target_module(void) +{ + return target_module; +} + char *igt_frame_dump_path; const char *igt_test_name(void) @@ -555,6 +570,7 @@ static void print_usage(const char *help_str, bool output_on_stderr) " --debug[=log-domain]\n" " --interactive-debug[=domain]\n" " --help-description\n" + " --force-module \n" " --help\n"); if (help_str) fprintf(f, "%s\n", help_str); @@ -666,6 +682,7 @@ static int common_init(int *argc, char **argv, {"debug", optional_argument, 0, OPT_DEBUG}, {"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG}, {"help", 0, 0, OPT_HELP}, + {"force-module", required_argument, 0, OPT_FORCE_MODULE}, {0, 0, 0, 0} }; char *short_opts; @@ -763,6 +780,9 @@ static int common_init(int *argc, char **argv, print_test_description(); ret = -1; goto out; + case OPT_FORCE_MODULE: + set_target_module(strdup(optarg)); + break; case OPT_HELP: print_usage(help_str, false); ret = -1; diff --git a/lib/igt_core.h b/lib/igt_core.h index bf8cd66c..6d635ebd 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -50,6 +50,10 @@ extern const char* __igt_test_description __attribute__((weak)); extern bool __igt_plain_output; extern char *igt_frame_dump_path; +extern char *target_module; +void set_target_module(char *target); +const char *get_target_module(void); + /** * IGT_TEST_DESCRIPTION: * @str: description string diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 4209dd8c..c810a8dd 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -80,6 +80,7 @@ function print_help { echo " (can be used more than once)" echo " -T run tests listed in testlist" echo " (overrides -t and -x)" + echo " -m force load a specific module" echo " -v enable verbose mode" echo " -x exclude tests that match the regular expression" echo " (can be used more than once)" @@ -91,7 +92,7 @@ function print_help { echo "Useful patterns for test filtering are described in the API documentation." } -while getopts ":dhlr:st:T:vx:Rn" opt; do +while getopts ":dhlr:st:T:m:vx:Rn" opt; do case $opt in d) download_piglit; exit ;; h) print_help; exit ;; @@ -100,6 +101,7 @@ while getopts ":dhlr:st:T:vx:Rn" opt; do s) SUMMARY="html" ;; t) FILTER="$FILTER -t $OPTARG" ;; T) FILTER="$FILTER --test-list $OPTARG" ;; + m) FILTER="$FILTER -m $OPTARG" ;; v) VERBOSE="-v" ;; x) EXCLUDE="$EXCLUDE -x $OPTARG" ;; R) RESUME="true" ;;