2 * test_console - Test VT Layer
4 * Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
5 * Copyright (c) 2011 University of Tuebingen
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files
9 * (the "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This opens a new VT and prints some text on it. You can then change the VT
30 * and change back. This is only to test the VT subsystem and event engine.
31 * This automatically switches to the new VT. Currently, the display gets
32 * frozen because we aren't painting to the framebuffer yet. Use
33 * ctrl+alt+FX (or some equivalent) to switch back to X/VT.
36 static void print_help();
48 #include "test_include.h"
50 static void print_help()
53 * Usage/Help information
54 * This should be scaled to a maximum of 80 characters per line:
57 * | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
58 * "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
59 * 80 char line starting with tab:
60 * |10| 20 | 30 | 40 | 50 | 60 | 70 | 80 |
61 * "\t901234567890123456789012345678901234567890123456789012345678901234567890\n"
66 "\t%1$s -h [options]\n"
68 "You can prefix boolean options with \"no-\" to negate it. If an argument is\n"
69 "given multiple times, only the last argument matters if not otherwise stated.\n"
75 "\t --vt <vt> [-] Path to VT to use\n"
76 "\t-s, --switchvt [off] Switch automatically to the new VT\n",
80 * | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
81 * "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
82 * 80 char line starting with tab:
83 * |10| 20 | 30 | 40 | 50 | 60 | 70 | 80 |
84 * "\t901234567890123456789012345678901234567890123456789012345678901234567890\n"
88 static const char *vtpath = NULL;
89 static bool switchvt = false;
91 struct conf_option options[] = {
93 CONF_OPTION_STRING(0, "vt", &vtpath, NULL),
94 CONF_OPTION_BOOL('s', "switchvt", &switchvt, false),
97 int main(int argc, char **argv)
100 struct ev_eloop *eloop;
101 struct uterm_vt_master *vtm;
102 struct uterm_input *input;
106 onum = sizeof(options) / sizeof(*options);
107 ret = test_prepare(options, onum, argc, argv, &eloop);
111 ret = uterm_vt_master_new(&vtm, eloop);
115 ret = uterm_input_new(&input, eloop, "", "", "", "", 0, 0);
119 ret = uterm_vt_allocate(vtm, &vt, UTERM_VT_FAKE | UTERM_VT_REAL,
120 "seat0", input, vtpath, NULL, NULL);
125 ret = uterm_vt_activate(vt);
126 if (ret == -EINPROGRESS)
127 log_debug("VT switch in progress");
129 log_warn("cannot switch to VT: %d", ret);
132 ev_eloop_run(eloop, -1);
134 log_debug("Terminating");
136 /* switch back to previous VT but wait for eloop to process SIGUSR0 */
138 ret = uterm_vt_deactivate(vt);
139 if (ret == -EINPROGRESS)
140 ev_eloop_run(eloop, 50);
145 uterm_input_unref(input);
147 uterm_vt_master_unref(vtm);
149 test_exit(options, onum, eloop);
151 if (ret != -ECANCELED)