kmscon/tests/test_vt.c
David Herrmann 1081c76274 test_vt: use new test_include.h code
test_vt now compiles again and uses the new infrastructure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-04-22 16:51:28 +02:00

87 lines
2.5 KiB
C

/*
* test_console - Test VT Layer
*
* Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
* Copyright (c) 2011 University of Tuebingen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Test VT Layer
* This opens a new VT and prints some text on it. You can then change the VT
* and change back. This is only to test the VT subsystem and event engine.
* This automatically switches to the new VT. Currently, the display gets
* frozen because we aren't painting to the framebuffer yet. Use
* ctrl+alt+FX (or some equivalent) to switch back to X/VT.
*/
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "eloop.h"
#include "log.h"
#include "vt.h"
#include "test_include.h"
int main(int argc, char **argv)
{
int ret;
struct ev_eloop *eloop;
struct kmscon_vt *vt;
ret = test_prepare(argc, argv, &eloop);
if (ret)
goto err_fail;
ret = kmscon_vt_new(&vt, NULL, NULL);
if (ret)
goto err_exit;
ret = kmscon_vt_open(vt, KMSCON_VT_NEW, eloop);
if (ret)
goto err_vt;
ret = kmscon_vt_enter(vt);
if (ret)
log_warn("Cannot switch to VT");
ev_eloop_run(eloop, -1);
log_debug("Terminating\n");
/* switch back to previous VT but wait for eloop to process SIGUSR0 */
ret = kmscon_vt_leave(vt);
if (ret == -EINPROGRESS)
ev_eloop_run(eloop, 50);
err_vt:
kmscon_vt_unref(vt);
err_exit:
test_exit(eloop);
err_fail:
test_fail(ret);
return abs(ret);
}