2 * test_console - Test VT Layer
4 * Copyright (c) 2011 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 * freezed then because we aren't painting to the framebuffer yet. Use
33 * ctrl+alt+FX (or some equivalent) to switch back to X/VT.
47 static bool terminate;
49 static void sig_term(struct ev_signal *sig, int signum, void *data)
54 int main(int argc, char **argv)
57 struct ev_eloop *loop;
59 struct ev_signal *sig;
61 ret = ev_eloop_new(&loop);
63 log_err("Cannot create eloop\n");
67 ret = ev_eloop_new_signal(loop, &sig, SIGINT, sig_term, NULL);
69 log_err("Cannot add signal\n");
73 ret = kmscon_vt_new(&vt, NULL, NULL);
75 log_err("Cannot create vt\n");
79 ret = kmscon_vt_open(vt, KMSCON_VT_NEW, loop);
81 log_err("Cannot open VT\n");
85 ret = kmscon_vt_enter(vt);
87 log_warn("Cannot switch to VT\n");
90 ret = ev_eloop_dispatch(loop, -1);
92 log_err("Dispatcher failed\n");
97 log_debug("Terminating\n");
99 /* switch back to previous VT but wait for eloop to process SIGUSR0 */
100 ret = kmscon_vt_leave(vt);
101 if (ret == -EINPROGRESS)
102 ev_eloop_dispatch(loop, 1000);
107 ev_eloop_rm_signal(sig);
109 ev_eloop_unref(loop);