From patchwork Wed Jul 23 10:57:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4609911 Return-Path: X-Original-To: patchwork-intel-gfx@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 BD7C2C0514 for ; Wed, 23 Jul 2014 10:58:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 807E8201DD for ; Wed, 23 Jul 2014 10:58:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0921A201C0 for ; Wed, 23 Jul 2014 10:58:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F7186E621; Wed, 23 Jul 2014 03:58:08 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 1484D6E624 for ; Wed, 23 Jul 2014 03:58:06 -0700 (PDT) Received: by mail-we0-f176.google.com with SMTP id q58so994898wes.21 for ; Wed, 23 Jul 2014 03:58:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g6KB1ehdbCLunLR5wxh86IWNeNEB97/TllRHMplJtqE=; b=YU7CqD4UNaDTsbpIWIPzxmiqxct9DMfR6JxrHJu+OK59tcquzDxYEPTbbQ4zcxi8pB gmAU4bOiJSJIFJiieL/v5sl1JbzT4hF1xOyE5rR/3BJfZQTYbkgxKFTp3cnsEpIfEd+z DWHpsGRgFr9yVCvIkHn3LatUSfAjDTQiU86hS8q52LuLomgO84A271sD5cP2vh3OjYWb R1KFc725mM0kBJRZuHt2lT3SIcpoWUZ18ptKZ8Fm8Ws+iqyUA/MAMdpe36B/OE3mxtHT OHkxNkWptBrBxFdYBRScKHkMq5HdXGSToXpUbezrUDFSjnpq4rzn3Gd89Hxxwtu6Q/5g geqw== X-Gm-Message-State: ALoCoQk1UPKOzj0skw+AYTV4RhPaKp3DdtLO/dJNVAoBW4GhIKNGBtjAmwtB8YuCrl8n9CrFD5VP X-Received: by 10.180.78.100 with SMTP id a4mr23765691wix.36.1406113086288; Wed, 23 Jul 2014 03:58:06 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id de5sm7787760wib.18.2014.07.23.03.58.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jul 2014 03:58:05 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Wed, 23 Jul 2014 11:57:53 +0100 Message-Id: <1406113075-30860-7-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406113075-30860-1-git-send-email-thomas.wood@intel.com> References: <1406113075-30860-1-git-send-email-thomas.wood@intel.com> Cc: daniel.vetter@ffwll.ch Subject: [Intel-gfx] [PATCH i-g-t 6/8] tests: convert simple tests to use igt_simple_init_parse_opts X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Convert simple tests to use igt_simple_init_parse_opts if they require extra options. Signed-off-by: Thomas Wood --- lib/igt_core.h | 1 + tests/gem_ctx_basic.c | 20 +++------ tests/gem_render_copy.c | 25 +++++------- tests/gem_seqno_wrap.c | 82 +++++++++++++++---------------------- tests/gem_stress.c | 105 ++++++++++++++++++++++-------------------------- 5 files changed, 98 insertions(+), 135 deletions(-) diff --git a/lib/igt_core.h b/lib/igt_core.h index 408cf3a..b19a897 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -36,6 +36,7 @@ #include #include #include +#include /** * IGT_EXIT_TIMEOUT: diff --git a/tests/gem_ctx_basic.c b/tests/gem_ctx_basic.c index a2464fd..a0bec60 100644 --- a/tests/gem_ctx_basic.c +++ b/tests/gem_ctx_basic.c @@ -39,7 +39,6 @@ #include #include #include -#include #include "drm.h" #include "ioctl_wrappers.h" #include "drmtest.h" @@ -119,11 +118,9 @@ static void *work(void *arg) pthread_exit(NULL); } -static void parse(int argc, char *argv[]) +static int opt_handler(int opt, int opt_index) { - int opt; - while ((opt = getopt(argc, argv, "i:c:n:muh?")) != -1) { - switch (opt) { + switch (opt) { case 'i': iter = atoi(optarg); break; @@ -136,20 +133,17 @@ static void parse(int argc, char *argv[]) case 'u': uncontexted = 1; break; - case 'h': - case '?': - default: - igt_success(); - break; - } } + + return 0; } int main(int argc, char *argv[]) { int i; - igt_simple_init(argc, argv); + igt_simple_init_parse_opts(argc, argv, "i:c:n:mu", NULL, NULL, + opt_handler); fd = drm_open_any_render(); devid = intel_get_drm_devid(fd); @@ -159,8 +153,6 @@ int main(int argc, char *argv[]) iter = 4; } - parse(argc, argv); - threads = calloc(num_contexts, sizeof(*threads)); for (i = 0; i < num_contexts; i++) diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c index 76ba40e..6ff0c77 100644 --- a/tests/gem_render_copy.c +++ b/tests/gem_render_copy.c @@ -41,7 +41,6 @@ #include #include #include -#include #include @@ -67,6 +66,7 @@ typedef struct { drm_intel_bufmgr *bufmgr; uint32_t linear[WIDTH * HEIGHT]; } data_t; +static int opt_dump_png = false; static void scratch_buf_write_to_png(struct igt_buf *buf, const char *filename) { @@ -117,27 +117,24 @@ scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y, color, val, x, y); } +static int opt_handler(int opt, int opt_index) +{ + if (opt == 'd') { + opt_dump_png = true; + } + + return 0; +} + int main(int argc, char **argv) { data_t data = {0, }; struct intel_batchbuffer *batch = NULL; struct igt_buf src, dst; igt_render_copyfunc_t render_copy = NULL; - int opt; - int opt_dump_png = false; int opt_dump_aub = igt_aub_dump_enabled(); - igt_simple_init(argc, argv); - - while ((opt = getopt(argc, argv, "d")) != -1) { - switch (opt) { - case 'd': - opt_dump_png = true; - break; - default: - break; - } - } + igt_simple_init_parse_opts(argc, argv, "d", NULL, NULL, opt_handler); igt_fixture { data.drm_fd = drm_open_any_render(); diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c index 0fa722d..3a40860 100644 --- a/tests/gem_seqno_wrap.c +++ b/tests/gem_seqno_wrap.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -452,45 +451,9 @@ static void background_run_once(void) sleep(3); } -static void print_usage(const char *s) +static int parse_options(int opt, int opt_index) { - igt_info("%s: [OPTION]...\n", s); - igt_info(" where options are:\n"); - igt_info(" -b --background run in background inducing wraps\n"); - igt_info(" -n --rounds=num run num times across wrap boundary, 0 == forever\n"); - igt_info(" -t --timeout=sec set timeout to wait for testrun to sec seconds\n"); - igt_info(" -d --dontwrap don't wrap just run the test\n"); - igt_info(" -p --prewrap=n set seqno to WRAP - n for each testrun\n"); - igt_info(" -r --norandom dont randomize prewrap space\n"); - igt_info(" -i --buffers number of buffers to copy\n"); - igt_fail(-1); -} - -static void parse_options(int argc, char **argv) -{ - int c; - int option_index = 0; - static struct option long_options[] = { - {"rounds", required_argument, 0, 'n'}, - {"background", no_argument, 0, 'b'}, - {"timeout", required_argument, 0, 't'}, - {"dontwrap", no_argument, 0, 'd'}, - {"prewrap", required_argument, 0, 'p'}, - {"norandom", no_argument, 0, 'r'}, - {"buffers", required_argument, 0, 'i'}, - }; - - options.rounds = SLOW_QUICK(50, 2); - options.background = 0; - options.dontwrap = 0; - options.timeout = 20; - options.random = 1; - options.prewrap_space = 21; - options.buffers = 10; - - while((c = getopt_long(argc, argv, "n:bvt:dp:ri:", - long_options, &option_index)) != -1) { - switch(c) { + switch(opt) { case 'b': options.background = 1; igt_info("running in background inducing wraps\n"); @@ -520,17 +483,9 @@ static void parse_options(int argc, char **argv) options.prewrap_space = atoi(optarg); igt_info("prewrap set to %d (0x%x)\n", options.prewrap_space, UINT32_MAX - options.prewrap_space); break; - default: - igt_info("unkown command options\n"); - print_usage(argv[0]); - break; - } } - if (optind < argc) { - igt_info("unkown command options\n"); - print_usage(argv[0]); - } + return 0; } int main(int argc, char **argv) @@ -538,9 +493,36 @@ int main(int argc, char **argv) int wcount = 0; int r = -1; - igt_simple_init(argc, argv); + static struct option long_options[] = { + {"rounds", required_argument, 0, 'n'}, + {"background", no_argument, 0, 'b'}, + {"timeout", required_argument, 0, 't'}, + {"dontwrap", no_argument, 0, 'd'}, + {"prewrap", required_argument, 0, 'p'}, + {"norandom", no_argument, 0, 'r'}, + {"buffers", required_argument, 0, 'i'}, + { 0, 0, 0, 0 } + }; + + const char *help = + " -b --background run in background inducing wraps\n" + " -n --rounds=num run num times across wrap boundary, 0 == forever\n" + " -t --timeout=sec set timeout to wait for testrun to sec seconds\n" + " -d --dontwrap don't wrap just run the test\n" + " -p --prewrap=n set seqno to WRAP - n for each testrun\n" + " -r --norandom dont randomize prewrap space\n" + " -i --buffers number of buffers to copy\n"; + + options.rounds = SLOW_QUICK(50, 2); + options.background = 0; + options.dontwrap = 0; + options.timeout = 20; + options.random = 1; + options.prewrap_space = 21; + options.buffers = 10; - parse_options(argc, argv); + igt_simple_init_parse_opts(argc, argv, "n:bvt:dp:ri:", long_options, + help, parse_options); card_index = drm_get_card(); diff --git a/tests/gem_stress.c b/tests/gem_stress.c index c8d7393..3bbe487 100644 --- a/tests/gem_stress.c +++ b/tests/gem_stress.c @@ -58,7 +58,6 @@ #include #include #include -#include #include @@ -72,6 +71,10 @@ #define CMD_POLY_STIPPLE_OFFSET 0x7906 +#define DUCTAPE 0xdead0001 +#define TILESZ 0xdead0002 +#define CHCK_RENDER 0xdead0003 + /** TODO: * - beat on relaxed fencing (i.e. mappable/fenceable tracking in the kernel) * - render copy (to check fence tracking and cache coherency management by the @@ -624,54 +627,11 @@ static void sanitize_tiles_per_buf(void) options.tiles_per_buf = options.scratch_buf_size / TILE_BYTES(options.tile_size); } -static void parse_options(int argc, char **argv) +static int parse_options(int opt, int opt_index) { - int c, tmp; - int option_index = 0; - static struct option long_options[] = { - {"no-hw", 0, 0, 'd'}, - {"buf-size", 1, 0, 's'}, - {"gpu-busy-load", 1, 0, 'g'}, - {"no-signals", 0, 0, 'S'}, - {"buffer-count", 1, 0, 'c'}, - {"trace-tile", 1, 0, 't'}, - {"disable-blt", 0, 0, 'b'}, - {"disable-render", 0, 0, 'r'}, - {"untiled", 0, 0, 'u'}, - {"x-tiled", 0, 0, 'x'}, - {"use-cpu-maps", 0, 0, 'm'}, - {"rounds", 1, 0, 'o'}, - {"no-fail", 0, 0, 'f'}, - {"tiles-per-buf", 0, 0, 'p'}, -#define DUCTAPE 0xdead0001 - {"remove-duct-tape", 0, 0, DUCTAPE}, -#define TILESZ 0xdead0002 - {"tile-size", 1, 0, TILESZ}, -#define CHCK_RENDER 0xdead0003 - {"check-render-cpyfn", 0, 0, CHCK_RENDER}, - {NULL, 0, 0, 0}, - }; - - options.scratch_buf_size = 256*4096; - options.no_hw = 0; - options.use_signal_helper = 1; - options.gpu_busy_load = 0; - options.num_buffers = 0; - options.trace_tile = -1; - options.use_render = 1; - options.use_blt = 1; - options.forced_tiling = -1; - options.use_cpu_maps = 0; - options.total_rounds = 512; - options.fail = 1; - options.ducttape = 1; - options.tile_size = 16; - options.tiles_per_buf = options.scratch_buf_size / TILE_BYTES(options.tile_size); - options.check_render_cpyfn = 0; + int tmp; - while((c = getopt_long(argc, argv, "ds:g:c:t:rbuxmo:fp:", - long_options, &option_index)) != -1) { - switch(c) { + switch(opt) { case 'd': options.no_hw = 1; igt_info("no-hw debug mode\n"); @@ -759,15 +719,8 @@ static void parse_options(int argc, char **argv) options.check_render_cpyfn = 1; igt_info("checking render copy function\n"); break; - default: - igt_info("unkown command options\n"); - break; - } } - if (optind < argc) - igt_info("unkown command options\n"); - /* actually 32767, according to docs, but that kills our nice pot calculations. */ options.max_dimension = 16*1024; if (options.use_render) { @@ -777,6 +730,8 @@ static void parse_options(int argc, char **argv) options.max_dimension = 8192; } igt_info("Limiting buffer to %dx%d\n", options.max_dimension, options.max_dimension); + + return 0; } static void init(void) @@ -864,14 +819,50 @@ int main(int argc, char **argv) { int i, j; unsigned *current_permutation, *tmp_permutation; + static struct option long_options[] = { + {"no-hw", 0, 0, 'd'}, + {"buf-size", 1, 0, 's'}, + {"gpu-busy-load", 1, 0, 'g'}, + {"no-signals", 0, 0, 'S'}, + {"buffer-count", 1, 0, 'c'}, + {"trace-tile", 1, 0, 't'}, + {"disable-blt", 0, 0, 'b'}, + {"disable-render", 0, 0, 'r'}, + {"untiled", 0, 0, 'u'}, + {"x-tiled", 0, 0, 'x'}, + {"use-cpu-maps", 0, 0, 'm'}, + {"rounds", 1, 0, 'o'}, + {"no-fail", 0, 0, 'f'}, + {"tiles-per-buf", 0, 0, 'p'}, + {"remove-duct-tape", 0, 0, DUCTAPE}, + {"tile-size", 1, 0, TILESZ}, + {"check-render-cpyfn", 0, 0, CHCK_RENDER}, + {NULL, 0, 0, 0}, + }; + + options.scratch_buf_size = 256*4096; + options.no_hw = 0; + options.use_signal_helper = 1; + options.gpu_busy_load = 0; + options.num_buffers = 0; + options.trace_tile = -1; + options.use_render = 1; + options.use_blt = 1; + options.forced_tiling = -1; + options.use_cpu_maps = 0; + options.total_rounds = 512; + options.fail = 1; + options.ducttape = 1; + options.tile_size = 16; + options.tiles_per_buf = options.scratch_buf_size / TILE_BYTES(options.tile_size); + options.check_render_cpyfn = 0; - igt_simple_init(argc, argv); + igt_simple_init_parse_opts(argc, argv,"ds:g:c:t:rbuxmo:fp:", + long_options, NULL, parse_options); drm_fd = drm_open_any(); devid = intel_get_drm_devid(drm_fd); - parse_options(argc, argv); - /* start our little helper early before too may allocations occur */ if (options.use_signal_helper) igt_fork_signal_helper();