From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t 35/36] testdisplay: Nuke custom main function
Date: Thu, 23 May 2019 15:27:26 +0300 [thread overview]
Message-ID: <20190523122727.6932-35-petri.latvala@intel.com> (raw)
In-Reply-To: <20190523122727.6932-1-petri.latvala@intel.com>
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
tests/testdisplay.c | 230 ++++++++++++++++++++------------------------
1 file changed, 103 insertions(+), 127 deletions(-)
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 67d1b68a..b4f0d45f 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -69,10 +69,8 @@
#include <stdlib.h>
#include <signal.h>
-#define SUBTEST_OPTS 1
-#define HELP_DESCRIPTION 2
-#define Yb_OPT 3
-#define Yf_OPT 4
+#define Yb_OPT 5
+#define Yf_OPT 6
static int tio_fd;
struct termios saved_tio;
@@ -87,6 +85,7 @@ int do_dpms = 0; /* This aliases to DPMS_ON */
uint32_t depth = 24, stride, bpp;
int qr_code = 0;
int specified_mode_num = -1, specified_disp_id = -1;
+bool opt_dump_info = false;
drmModeModeInfo force_timing;
@@ -519,29 +518,6 @@ int update_display(bool probe)
return 1;
}
-static char optstr[] = "3hiaf:s:d:p:mrto:j:y";
-
-static void __attribute__((noreturn)) usage(char *name, char opt)
-{
- igt_info("usage: %s [-hiasdpmtf]\n", name);
- igt_info("\t-i\tdump info\n");
- igt_info("\t-a\ttest all modes\n");
- igt_info("\t-s\t<duration>\tsleep between each mode test (default: 0)\n");
- igt_info("\t-d\t<depth>\tbit depth of scanout buffer\n");
- igt_info("\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n");
- igt_info("\t-m\ttest the preferred mode\n");
- igt_info("\t-3\ttest all 3D modes\n");
- igt_info("\t-t\tuse a tiled framebuffer\n");
- igt_info("\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n");
- igt_info("\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n");
- igt_info("\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n");
- igt_info("\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n");
- igt_info("\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n");
- igt_info("\t\ttest force mode\n");
- igt_info("\tDefault is to test all modes.\n");
- exit((opt != 'h') ? -1 : 0);
-}
-
#define dump_resource(res) if (res) dump_##res()
static void __attribute__((noreturn)) cleanup_and_exit(int ret)
@@ -564,17 +540,12 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,
return TRUE;
}
-static void enter_exec_path(const char **argv)
+static void enter_exec_path(void)
{
- char *argv0, *exec_path;
- int ret;
+ char path[PATH_MAX];
- argv0 = strdup(argv[0]);
- igt_assert(argv0);
- exec_path = dirname(argv0);
- ret = chdir(exec_path);
- igt_assert_eq(ret, 0);
- free(argv0);
+ if (readlink("/proc/self/exe", path, sizeof(path)) > 0)
+ chdir(dirname(path));
}
static void restore_termio_mode(int sig)
@@ -600,101 +571,108 @@ static void set_termio_mode(void)
tcsetattr(tio_fd, TCSANOW, &tio);
}
-int main(int argc, char **argv)
+static char optstr[] = "3iaf:s:d:p:mrto:j:y";
+static struct option long_opts[] = {
+ {"yb", 0, 0, Yb_OPT},
+ {"yf", 0, 0, Yf_OPT},
+ { 0, 0, 0, 0 }
+};
+
+static const char *help_str =
+ " -i\tdump info\n"
+ " -a\ttest all modes\n"
+ " -s\t<duration>\tsleep between each mode test (default: 0)\n"
+ " -d\t<depth>\tbit depth of scanout buffer\n"
+ " -p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n"
+ " -m\ttest the preferred mode\n"
+ " -3\ttest all 3D modes\n"
+ " -t\tuse an X-tiled framebuffer\n"
+ " -y, --yb\n"
+ " \tuse a Y-tiled framebuffer\n"
+ " --yf\tuse a Yf-tiled framebuffer\n"
+ " -j\tdo dpms off, optional arg to select dpms level (1-3)\n"
+ " -r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n"
+ " -o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n"
+ " -f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n"
+ " \t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n"
+ " \ttest force mode\n"
+ " \tDefault is to test all modes.\n"
+ ;
+
+static int opt_handler(int opt, int opt_index, void *data)
+{
+ float force_clock;
+
+ switch (opt) {
+ case '3':
+ test_stereo_modes = 1;
+ break;
+ case 'i':
+ opt_dump_info = true;
+ break;
+ case 'a':
+ test_all_modes = 1;
+ break;
+ case 'f':
+ force_mode = 1;
+ if (sscanf(optarg,"%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu",
+ &force_clock,&force_timing.hdisplay, &force_timing.hsync_start,&force_timing.hsync_end,&force_timing.htotal,
+ &force_timing.vdisplay, &force_timing.vsync_start, &force_timing.vsync_end, &force_timing.vtotal)!= 9)
+ return IGT_OPT_HANDLER_ERROR;
+ force_timing.clock = force_clock*1000;
+
+ break;
+ case 's':
+ sleep_between_modes = atoi(optarg);
+ break;
+ case 'j':
+ do_dpms = atoi(optarg);
+ if (do_dpms == 0)
+ do_dpms = DRM_MODE_DPMS_OFF;
+ break;
+ case 'd':
+ depth = atoi(optarg);
+ igt_info("using depth %d\n", depth);
+ break;
+ case 'p':
+ if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width,
+ &plane_height, &crtc_x, &crtc_y,
+ &crtc_w, &crtc_h) != 6)
+ return IGT_OPT_HANDLER_ERROR;
+ test_plane = 1;
+ break;
+ case 'm':
+ test_preferred_mode = 1;
+ break;
+ case 't':
+ tiling = LOCAL_I915_FORMAT_MOD_X_TILED;
+ break;
+ case 'y':
+ case Yb_OPT:
+ tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
+ break;
+ case Yf_OPT:
+ tiling = LOCAL_I915_FORMAT_MOD_Yf_TILED;
+ break;
+ case 'r':
+ qr_code = 1;
+ break;
+ case 'o':
+ sscanf(optarg, "%d,%d", &specified_disp_id, &specified_mode_num);
+ break;
+ }
+
+ return IGT_OPT_HANDLER_SUCCESS;
+}
+
+igt_simple_main_args(optstr, long_opts, help_str, opt_handler, NULL)
{
- int c;
int ret = 0;
GIOChannel *stdinchannel;
GMainLoop *mainloop;
- float force_clock;
- bool opt_dump_info = false;
- struct option long_opts[] = {
- {"list-subtests", 0, 0, SUBTEST_OPTS},
- {"run-subtest", 1, 0, SUBTEST_OPTS},
- {"help-description", 0, 0, HELP_DESCRIPTION},
- {"help", 0, 0, 'h'},
- {"yb", 0, 0, Yb_OPT},
- {"yf", 0, 0, Yf_OPT},
- { 0, 0, 0, 0 }
- };
-
igt_skip_on_simulation();
- enter_exec_path((const char **) argv);
-
- while ((c = getopt_long(argc, argv, optstr, long_opts, NULL)) != -1) {
- switch (c) {
- case '3':
- test_stereo_modes = 1;
- break;
- case 'i':
- opt_dump_info = true;
- break;
- case 'a':
- test_all_modes = 1;
- break;
- case 'f':
- force_mode = 1;
- if(sscanf(optarg,"%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu",
- &force_clock,&force_timing.hdisplay, &force_timing.hsync_start,&force_timing.hsync_end,&force_timing.htotal,
- &force_timing.vdisplay, &force_timing.vsync_start, &force_timing.vsync_end, &force_timing.vtotal)!= 9)
- usage(argv[0], c);
- force_timing.clock = force_clock*1000;
-
- break;
- case 's':
- sleep_between_modes = atoi(optarg);
- break;
- case 'j':
- do_dpms = atoi(optarg);
- if (do_dpms == 0)
- do_dpms = DRM_MODE_DPMS_OFF;
- break;
- case 'd':
- depth = atoi(optarg);
- igt_info("using depth %d\n", depth);
- break;
- case 'p':
- if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width,
- &plane_height, &crtc_x, &crtc_y,
- &crtc_w, &crtc_h) != 6)
- usage(argv[0], c);
- test_plane = 1;
- break;
- case 'm':
- test_preferred_mode = 1;
- break;
- case 't':
- tiling = LOCAL_I915_FORMAT_MOD_X_TILED;
- break;
- case 'y':
- case Yb_OPT:
- tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
- break;
- case Yf_OPT:
- tiling = LOCAL_I915_FORMAT_MOD_Yf_TILED;
- break;
- case 'r':
- qr_code = 1;
- break;
- case 'o':
- sscanf(optarg, "%d,%d", &specified_disp_id, &specified_mode_num);
- break;
- case SUBTEST_OPTS:
- /* invalid subtest options */
- exit(IGT_EXIT_INVALID);
- break;
- case HELP_DESCRIPTION:
- igt_info("Tests display functionality.");
- exit(0);
- break;
- default:
- /* fall through */
- case 'h':
- usage(argv[0], c);
- break;
- }
- }
+ enter_exec_path();
set_termio_mode();
@@ -771,6 +749,4 @@ out_close:
close(drm_fd);
igt_assert_eq(ret, 0);
-
- igt_exit();
}
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-05-23 12:27 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 12:26 [igt-dev] [PATCH i-g-t 01/36] lib: Introduce main function macros with custom args Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 02/36] lib: Document igt_opt_handler_t semantics Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 03/36] i915/gem_exec_blt: Nuke custom main function Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 04/36] i915/gem_gtt_speed: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 05/36] i915/gem_hang: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 06/36] i915/gem_linear_blits: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 07/36] i915/gem_ppgtt: " Petri Latvala
2019-05-23 12:26 ` [igt-dev] [PATCH i-g-t 08/36] i915/gem_pread: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 09/36] i915/gem_pwrite: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 10/36] i915/gem_pwrite_pread: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 11/36] i915/gem_render_copy: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 12/36] i915/gem_render_copy_redux: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 13/36] i915/gem_request_retire: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 14/36] i915/gem_stress: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 15/36] i915/gem_tiled_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 16/36] i915/gem_userptr_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 17/36] i915/gen3_mixed_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 18/36] i915/gen3_render_linear_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 19/36] i915/gen3_render_mixed_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 20/36] i915/gen3_render_tiledx_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 21/36] i915/gen3_render_tiledy_blits: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 22/36] i915/i915_pm_rpm: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 23/36] kms_concurrent: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 24/36] kms_cursor_edge_walk: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 25/36] kms_flip: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 26/36] kms_force_connector_basic: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 27/36] kms_frontbuffer_tracking: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 28/36] kms_mmap_write_crc: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 29/36] kms_plane_multiple: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 30/36] kms_psr2_su: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 31/36] kms_psr: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 32/36] kms_setmode: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 33/36] kms_tv_load_detect: " Petri Latvala
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 34/36] prime_mmap_coherency: " Petri Latvala
2019-05-23 12:27 ` Petri Latvala [this message]
2019-05-23 12:27 ` [igt-dev] [PATCH i-g-t 36/36] tests: Remove redundant igt_exit() calls Petri Latvala
2019-05-23 14:29 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/36] lib: Introduce main function macros with custom args Patchwork
2019-05-24 13:50 ` [igt-dev] [PATCH i-g-t 01/36] " Arkadiusz Hiler
2019-05-24 18:14 ` Daniel Vetter
2019-05-24 18:26 ` Hiatt, Don
2019-05-24 19:38 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,01/36] " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523122727.6932-35-petri.latvala@intel.com \
--to=petri.latvala@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox