From: Daniel Vetter Subject: [PATCH 3/3] [RFC] lib: add igt_main macro Date: Thu, 31 Oct 2013 16:25:55 +0100 Message-ID: <1383233155-18610-3-git-send-email-daniel.vetter@ffwll.ch> References: <1383231150-13133-1-git-send-email-daniel.vetter@ffwll.ch> <1383233155-18610-1-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F98DEE2EA for ; Thu, 31 Oct 2013 08:26:05 -0700 (PDT) Received: by mail-ee0-f44.google.com with SMTP id c4so1442323eek.17 for ; Thu, 31 Oct 2013 08:26:05 -0700 (PDT) In-Reply-To: <1383233155-18610-1-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Intel Graphics Development Cc: Daniel Vetter List-Id: intel-gfx@lists.freedesktop.org In the past new testcases with subtest often forgot to add the call to igt_exit at the end of their main() function. That is now caught with a bit more obnoxious asserts, but it's still a nuissance. This little igt_main macro takes care of that (and also of calling the subtest machinery initialization code correctly). If no one objects I'll roll this out for all the simple cases (i.e. those tests that don't have additional argv parsing on top of the subtest machinery). Signed-off-by: Daniel Vetter --- lib/drmtest.h | 10 ++++++++++ tests/kms_cursor_crc.c | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/drmtest.h b/lib/drmtest.h index f5e2708..9807bc7 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -138,6 +138,16 @@ bool __igt_run_subtest(const char *subtest_name); (setjmp(igt_subtest_jmpbuf) == 0); \ igt_success()) const char *igt_subtest_name(void); +#define igt_main \ + static void igt_tokencat(__real_main, __LINE__)(void); \ + int main(int argc, char **argv) { \ + igt_subtest_init(argc, argv); \ + igt_tokencat(__real_main, __LINE__)(); \ + igt_exit(); \ + } \ + static void igt_tokencat(__real_main, __LINE__)(void) \ + + /** * igt_skip - subtest aware test skipping * diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c index c82d3e7..d29b0a6 100644 --- a/tests/kms_cursor_crc.c +++ b/tests/kms_cursor_crc.c @@ -321,11 +321,10 @@ static void create_cursor_fb(data_t *data, igt_assert(cairo_status(cr) == 0); } -int main(int argc, char **argv) +igt_main { data_t data = {}; - igt_subtest_init(argc, argv); igt_skip_on_simulation(); igt_fixture { @@ -375,6 +374,4 @@ int main(int argc, char **argv) display_fini(&data); fclose(data.ctl); } - - igt_exit(); } -- 1.8.4.rc3