From: Daniel Vetter Subject: [RFC] More structure for igt_kms tests Date: Fri, 11 Jul 2014 10:19:23 +0200 Message-ID: <20140711081923.GX17271@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by gabe.freedesktop.org (Postfix) with ESMTP id AC4C26E80D for ; Fri, 11 Jul 2014 01:19:18 -0700 (PDT) Received: by mail-wi0-f172.google.com with SMTP id hi2so5860779wib.17 for ; Fri, 11 Jul 2014 01:19:14 -0700 (PDT) Received: from phenom.ffwll.local (84-73-67-144.dclient.hispeed.ch. [84.73.67.144]) by mx.google.com with ESMTPSA id dj2sm4705839wib.11.2014.07.11.01.19.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 11 Jul 2014 01:19:13 -0700 (PDT) Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Intel Graphics Development List-Id: intel-gfx@lists.freedesktop.org Hi all, So kms tests have rather ugly control flow compared to other tests. And the pattern is usually the same: - A subtest loops over a set of possible configurations to test and tries igt_commit. If that fails then it needs to manually reset the igt_display state and go to the next possible configuration. - A counter needs to keep track of the number of successfully applied configurations so that the test can decide to either skip (no config worked out) or succeed - failures will have bailed out earlier. The result is a lot of: - Fragile control flow code (since e.g. only few platforms have restrictions on the connector->pipe links like lvds on gen2/3 and dp on chv). - Fragile result computation logice - everyone has to duplicate the little bit of accounting to correctly skip/succeed. - Duplicated code (especially for the cleanup and try handling). I have a few ideas how we can improve: 1. We need an igt_display_reset to bring the configuration back to a known state. Imo that should be everything turned off and all properties (where known to the framework like e.g. rotation) reset to defaults. We probably need to make an igt_commit as part of this to avoid fun with strange state transitions. 2. New control flow block macros for display tests. I'm thinking of a special-cases igt_display_subtest (to make sure the special skip/succeed logic doesn't get lost) and a new igt_display_try block like this: igt_display_subtest("foo") { for_each_possible_config { /* set up the igt_display config with the igt_kms library */ /* Tries to commit the display config and skips the entire block * on failure. */ igt_display_try(display) { /* actual test code */ } /* Implicit state reset for the entire display * structure. The explicit call would be igt_display_reset(); * This is part of the igt_display_try block. */ } /* Implicit call to igt_display_result which skips/succeeds depending * whether at least one config worked. Explicit call would be igt_display_result(); * This is part of the igt_display_subtest block. */ } igt_display_try would also assert that it's called from within an igt_display_subtest block. And I guess we should disallow nesting. Comments? Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch