From patchwork Fri Dec 30 12:00:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mika Kahola X-Patchwork-Id: 9492059 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 33F4160417 for ; Fri, 30 Dec 2016 12:04:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20D351FF8F for ; Fri, 30 Dec 2016 12:04:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13C1522638; Fri, 30 Dec 2016 12:04:55 +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=-4.2 required=2.0 tests=BAYES_00, 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 19F2A1FF8F for ; Fri, 30 Dec 2016 12:04:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8177C6E259; Fri, 30 Dec 2016 12:04:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D0686E252 for ; Fri, 30 Dec 2016 12:04:25 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 30 Dec 2016 04:04:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="24384624" Received: from sorvi.fi.intel.com ([10.237.72.109]) by orsmga002.jf.intel.com with ESMTP; 30 Dec 2016 04:04:23 -0800 From: Mika Kahola To: intel-gfx@lists.freedesktop.org Date: Fri, 30 Dec 2016 14:00:41 +0200 Message-Id: <1483099241-15898-6-git-send-email-mika.kahola@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483099241-15898-1-git-send-email-mika.kahola@intel.com> References: <1483099241-15898-1-git-send-email-mika.kahola@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 5/5] tests/kms_test_only: Validate TEST_ONLY correctness against full atomic commit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This test case adds TEST_ONLY flag to the following test cases to test atomic commit correctness. - kms_plane_multiple - kms_atomic_transitions - kms_plane_scaling - kms_rotation_crc The test randomly selects one of the above test cases and tests atomic commit. If the test fails with TEST_ONLY flag the real deal atomic commit is executed and the outcome is verified. The test runs by default for 64 iterations. Signed-off-by: Mika Kahola --- tests/Makefile.sources | 1 + tests/kms_test_only.c | 455 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 456 insertions(+) create mode 100644 tests/kms_test_only.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 6316ea6..ff599c3 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -112,6 +112,7 @@ TESTS_progs_M = \ kms_plane \ kms_plane_multiple \ kms_plane_lowres \ + kms_test_only \ kms_properties \ kms_psr_sink_crc \ kms_render \ diff --git a/tests/kms_test_only.c b/tests/kms_test_only.c new file mode 100644 index 0000000..1ae835e --- /dev/null +++ b/tests/kms_test_only.c @@ -0,0 +1,455 @@ +/* + * Copyright © 2016 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include "igt.h" +#include "drmtest.h" +#include +#include +#include +#include +#include + +IGT_TEST_DESCRIPTION("Test atomic mode setting with a TEST_ONLY flag"); + +#define LOOP_FOREVER -1 + +#define FAIL -1 +#define SKIP 0 +#define SUCCESS 1 + +/* Command line parameters. */ +struct { + int iterations; +} opt = { + .iterations = 64, +}; + +static +int parse_output(char *testname) +{ + FILE *fid; + char output[1024]; + char result[32]; + + fid = popen(testname, "r"); + igt_assert(fid != NULL); + + while (fgets(output, sizeof(output)-1, fid) != NULL) { + if (strstr(output, "Subtest")) { + sscanf(output, "%*s %*s %s%*c", result); + + if (strncmp(result, "FAIL", 4) == 0) { + pclose(fid); + return FAIL; + } else if (strncmp(result, "SKIP", 4) == 0) { + pclose(fid); + return SKIP; + } else if (strncmp(result, "SUCCESS", 7) == 0) { + pclose(fid); + return SUCCESS; + } + } else if (strstr(output, "Test requirement not met in function")) { + pclose(fid); + return SKIP; + } + } + + pclose(fid); + + return -EINVAL; +} + +static +void test_kms_rotation_crc(void) +{ + int ret; + char testname[256]; + + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-180-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-180"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-180-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-180"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest cursor-rotation-180-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest cursor-rotation-180"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-90-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-90"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-270-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-270"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-90-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-90"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-270-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-270"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-90-pos-100-0-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest sprite-rotation-90-pos-100-0"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest bad-pixel-format-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest bad-pixel-format"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest bad-tiling-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest bad-tiling"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-90-flip-stress-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-90-flip-stress"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-90-Y-tiled-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest primary-rotation-90-Y-tiled"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_rotation_crc --run-subtest exhaust-fences-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_rotation_crc --run-subtest exhaust-fences"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } +} + +static +void test_kms_atomic_transition(void) +{ + int ret; + char testname[256]; + + strcpy(testname, "kms_atomic_transition --run-subtest plane-all-transition-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_atomic_transition --run-subtest plane-all-transition"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_atomic_transition --run-subtest plane-all-transition-nonblocking-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_atomic_transition --run-subtest plane-all-transition-nonblocking"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_atomic_transition --run-subtest plane-all-modeset-transition-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_atomic_transition --run-subtest plane-all-modeset-transition"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + strcpy(testname, "kms_atomic_transition --run-subtest plane-toggle-modeset-transition-test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_atomic_transition --run-subtest plane-toggle-modeset-transition"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + for (int i = 1; i <= I915_MAX_PIPES; i++) { + sprintf(testname, "kms_atomic_transition --run-subtest %ix-modeset-transitions-test-only", i); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + sprintf(testname, "kms_atomic_transition --run-subtest %ix-modeset-transitions", i); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + + sprintf(testname, "kms_atomic_transition --run-subtest %ix-modeset-transitions-nonblocking-test-only", i); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + sprintf(testname, "kms_atomic_transition --run-subtest %ix-modeset-transitions-nonblocking", i); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + } +} + +static +void test_kms_plane_scaling(void) +{ + int ret; + char testname[256]; + + strcpy(testname, "kms_plane_scaling --test-only"); + ret = parse_output(testname); + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + strcpy(testname, "kms_plane_scaling"); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } +} + +static +void test_kms_plane_multiple(void) +{ + char testname[256]; + const char *tiling_list[4] = {"none", "x", "y", "yf"}; + int ret; + + for (int pipe = 0; pipe < I915_MAX_PIPES; pipe++) { + for (int tiling = 0; tiling < 4; tiling++) { + for (int plane = IGT_PLANE_PRIMARY; plane < IGT_MAX_PLANES; plane++) { + sprintf(testname, "kms_plane_multiple --run-subtest atomic-pipe-%s-tiling-%s-planes-%d --iterations 1 --test-only", + kmstest_pipe_name(pipe), tiling_list[tiling], plane); + + ret = parse_output(testname); + + if (ret == SKIP) + return; + + if (ret == FAIL) { + igt_info("%s failed. Trying with real atomic commit\n", testname); + sprintf(testname, "kms_plane_multiple --run-subtest atomic-pipe-%s-tiling-%s-planes-%d --iterations 1", + kmstest_pipe_name(pipe), tiling_list[tiling], plane); + ret = parse_output(testname); + igt_assert_eq(ret, FAIL); + } + } + } + } +} + +static +int run_test(int index) +{ + switch (index) { + case 0: + igt_info("testing kms_plane_multiple\n"); + test_kms_plane_multiple(); + return 0; + case 1: + igt_info("testing kms_atomic_transition\n"); + test_kms_atomic_transition(); + return 1; + case 2: + igt_info("testing kms_plane_scaling\n"); + test_kms_plane_scaling(); + return 2; + case 3: + igt_info("testing kms_rotation_crc\n"); + test_kms_rotation_crc(); + return 3; + default: + igt_assert(false); + } +} + +static int opt_handler(int option, int option_index, void *input) +{ + switch (option) { + case 'i': + opt.iterations = strtol(optarg, NULL, 0); + + if (opt.iterations < LOOP_FOREVER || opt.iterations == 0) { + igt_info("incorrect number of iterations\n"); + igt_assert(false); + } + break; + default: + igt_assert(false); + } + + return 0; +} + +const char *help_str = + " --iterations Number of iterations for test coverage. -1 loop forever, default 64 iterations\n"; + +int main(int argc, char *argv[]) +{ + int i; + bool loop_forever; + + struct option long_options[] = { + { "iterations", required_argument, NULL, 'i'}, + { 0, 0, 0, 0 } + }; + + if (opt.iterations == LOOP_FOREVER) { + loop_forever = true; + opt.iterations = 1; + } else { + loop_forever = false; + } + + igt_subtest_init_parse_opts(&argc, argv, "", long_options, help_str, + opt_handler, NULL); + + igt_skip_on_simulation(); + + srand(time(NULL)); + + i = 0; + while (i < opt.iterations || loop_forever) { + run_test(rand() % 4); + i++; + } + + igt_success(); + + igt_exit(); +}