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();
47 #include "uterm_input.h"
49 #include "test_include.h"
51 static void print_help()
54 * Usage/Help information
55 * This should be scaled to a maximum of 80 characters per line:
58 * | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
59 * "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
60 * 80 char line starting with tab:
61 * |10| 20 | 30 | 40 | 50 | 60 | 70 | 80 |
62 * "\t901234567890123456789012345678901234567890123456789012345678901234567890\n"
67 "\t%1$s -h [options]\n"
69 "You can prefix boolean options with \"no-\" to negate it. If an argument is\n"
70 "given multiple times, only the last argument matters if not otherwise stated.\n"
76 "\t --vt <vt> [-] Path to VT to use\n"
77 "\t-s, --switchvt [off] Switch automatically to the new VT\n",
81 * | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
82 * "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
83 * 80 char line starting with tab:
84 * |10| 20 | 30 | 40 | 50 | 60 | 70 | 80 |
85 * "\t901234567890123456789012345678901234567890123456789012345678901234567890\n"
89 static const char *vtpath = NULL;
90 static bool switchvt = false;
92 struct conf_option options[] = {
94 CONF_OPTION_STRING(0, "vt", &vtpath, NULL),
95 CONF_OPTION_BOOL('s', "switchvt", &switchvt, false),
98 int main(int argc, char **argv)
101 struct ev_eloop *eloop;
102 struct uterm_vt_master *vtm;
103 struct uterm_input *input;
107 onum = sizeof(options) / sizeof(*options);
108 ret = test_prepare(options, onum, argc, argv, &eloop);
112 ret = uterm_vt_master_new(&vtm, eloop);
116 ret = uterm_input_new(&input, eloop, "", "", "", "", 0, 0);
120 ret = uterm_vt_allocate(vtm, &vt, UTERM_VT_FAKE | UTERM_VT_REAL,
121 "seat0", input, vtpath, NULL, NULL);
126 ret = uterm_vt_activate(vt);
127 if (ret == -EINPROGRESS)
128 log_debug("VT switch in progress");
130 log_warn("cannot switch to VT: %d", ret);
133 ev_eloop_run(eloop, -1);
135 log_debug("Terminating");
137 /* switch back to previous VT but wait for eloop to process SIGUSR0 */
139 ret = uterm_vt_deactivate(vt);
140 if (ret == -EINPROGRESS)
141 ev_eloop_run(eloop, 50);
146 uterm_input_unref(input);
148 uterm_vt_master_unref(vtm);
150 test_exit(options, onum, eloop);
152 if (ret != -ECANCELED)