teken_stress.c revision 186681
1186681Sed/*- 2186681Sed * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org> 3186681Sed * All rights reserved. 4186681Sed * 5186681Sed * Redistribution and use in source and binary forms, with or without 6186681Sed * modification, are permitted provided that the following conditions 7186681Sed * are met: 8186681Sed * 1. Redistributions of source code must retain the above copyright 9186681Sed * notice, this list of conditions and the following disclaimer. 10186681Sed * 2. Redistributions in binary form must reproduce the above copyright 11186681Sed * notice, this list of conditions and the following disclaimer in the 12186681Sed * documentation and/or other materials provided with the distribution. 13186681Sed * 14186681Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15186681Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16186681Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17186681Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18186681Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19186681Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20186681Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21186681Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22186681Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23186681Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24186681Sed * SUCH DAMAGE. 25186681Sed * 26186681Sed * $FreeBSD: head/sys/dev/syscons/teken/teken_stress.c 186681 2009-01-01 13:26:53Z ed $ 27186681Sed */ 28186681Sed 29186681Sed#include <sys/cdefs.h> 30186681Sed 31186681Sed#include <fcntl.h> 32186681Sed#include <inttypes.h> 33186681Sed#include <stdio.h> 34186681Sed#include <stdlib.h> 35186681Sed#include <unistd.h> 36186681Sed 37186681Sed#include "teken.h" 38186681Sed 39186681Sedstatic tf_bell_t stress_bell; 40186681Sedstatic tf_cursor_t stress_cursor; 41186681Sedstatic tf_putchar_t stress_putchar; 42186681Sedstatic tf_fill_t stress_fill; 43186681Sedstatic tf_copy_t stress_copy; 44186681Sedstatic tf_param_t stress_param; 45186681Sedstatic tf_respond_t stress_respond; 46186681Sed 47186681Sedstatic teken_funcs_t tf = { 48186681Sed .tf_bell = stress_bell, 49186681Sed .tf_cursor = stress_cursor, 50186681Sed .tf_putchar = stress_putchar, 51186681Sed .tf_fill = stress_fill, 52186681Sed .tf_copy = stress_copy, 53186681Sed .tf_param = stress_param, 54186681Sed .tf_respond = stress_respond, 55186681Sed}; 56186681Sed 57186681Sedstatic void 58186681Sedstress_bell(void *s __unused) 59186681Sed{ 60186681Sed} 61186681Sed 62186681Sedstatic void 63186681Sedstress_cursor(void *s __unused, const teken_pos_t *p __unused) 64186681Sed{ 65186681Sed} 66186681Sed 67186681Sedstatic void 68186681Sedstress_putchar(void *s __unused, const teken_pos_t *p __unused, 69186681Sed teken_char_t c __unused, const teken_attr_t *a __unused) 70186681Sed{ 71186681Sed} 72186681Sed 73186681Sedstatic void 74186681Sedstress_fill(void *s __unused, const teken_rect_t *r __unused, 75186681Sed teken_char_t c __unused, const teken_attr_t *a __unused) 76186681Sed{ 77186681Sed} 78186681Sed 79186681Sedstatic void 80186681Sedstress_copy(void *s __unused, const teken_rect_t *r __unused, 81186681Sed const teken_pos_t *p __unused) 82186681Sed{ 83186681Sed} 84186681Sed 85186681Sedstatic void 86186681Sedstress_param(void *s __unused, int cmd __unused, int value __unused) 87186681Sed{ 88186681Sed} 89186681Sed 90186681Sedstatic void 91186681Sedstress_respond(void *s __unused, const void *buf __unused, size_t len __unused) 92186681Sed{ 93186681Sed} 94186681Sed 95186681Sedint 96186681Sedmain(int argc __unused, char *argv[] __unused) 97186681Sed{ 98186681Sed teken_t t; 99186681Sed int rnd; 100186681Sed unsigned int iteration = 0; 101186681Sed char buf[2048]; 102186681Sed 103186681Sed rnd = open("/dev/urandom", O_RDONLY); 104186681Sed if (rnd < 0) { 105186681Sed perror("/dev/urandom"); 106186681Sed exit(1); 107186681Sed } 108186681Sed 109186681Sed teken_init(&t, &tf, NULL); 110186681Sed 111186681Sed for (;;) { 112186681Sed if (read(rnd, buf, sizeof buf) != sizeof buf) { 113186681Sed perror("read"); 114186681Sed exit(1); 115186681Sed } 116186681Sed 117186681Sed teken_input(&t, buf, sizeof buf); 118186681Sed 119186681Sed iteration++; 120186681Sed if ((iteration % 10000) == 0) 121186681Sed printf("Processed %u frames\n", iteration); 122186681Sed } 123186681Sed} 124