Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libcurses/director - Add erase and kill to the ter...
details: https://anonhg.NetBSD.org/src/rev/91f351d11b9b
branches: trunk
changeset: 769585:91f351d11b9b
user: blymn <blymn%NetBSD.org@localhost>
date: Thu Sep 15 11:53:12 2011 +0000
description:
- Add erase and kill to the terminal attributes so we can test
fetching them
- Remove functions from the input_functions array that don't really do
input
- Re-enable the reporting of poll events after a function call
- Check that the return_type from the slave matches the expected one
- If verbose then print out the byte streams being compared in
validate_byte
- When reporting a length mismatch during a byte validation, report
the actual lengths.
diffstat:
tests/lib/libcurses/director/director.c | 4 +-
tests/lib/libcurses/director/testlang_parse.y | 44 ++++++++++++++++++++++----
2 files changed, 39 insertions(+), 9 deletions(-)
diffs (110 lines):
diff -r 99e783256860 -r 91f351d11b9b tests/lib/libcurses/director/director.c
--- a/tests/lib/libcurses/director/director.c Thu Sep 15 11:52:09 2011 +0000
+++ b/tests/lib/libcurses/director/director.c Thu Sep 15 11:53:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: director.c,v 1.7 2011/06/17 16:59:51 christos Exp $ */
+/* $NetBSD: director.c,v 1.8 2011/09/15 11:53:12 blymn Exp $ */
/*-
* Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -236,6 +236,8 @@
term_attr.c_cflag = TTYDEF_CFLAG;
term_attr.c_lflag = TTYDEF_LFLAG;
cfsetspeed(&term_attr, TTYDEF_SPEED);
+ term_attr.c_cc[VERASE] = '\b';
+ term_attr.c_cc[VKILL] = '\025'; /* ^U */
if ((slave_pid = forkpty(&master, NULL, &term_attr, NULL)) < 0)
err(1, "Fork of pty for slave failed\n");
diff -r 99e783256860 -r 91f351d11b9b tests/lib/libcurses/director/testlang_parse.y
--- a/tests/lib/libcurses/director/testlang_parse.y Thu Sep 15 11:52:09 2011 +0000
+++ b/tests/lib/libcurses/director/testlang_parse.y Thu Sep 15 11:53:12 2011 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: testlang_parse.y,v 1.10 2011/09/08 10:56:49 blymn Exp $ */
+/* $NetBSD: testlang_parse.y,v 1.11 2011/09/15 11:53:12 blymn Exp $ */
/*-
* Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -30,6 +30,7 @@
*
*/
#include <assert.h>
+#include <curses.h>
#include <errno.h>
#include <fcntl.h>
#include <err.h>
@@ -147,10 +148,8 @@
static void perform_delay(struct timespec *);
static const char *input_functions[] = {
- "inch", "getch", "getnstr", "getstr", "innstr", "instr", "mvgetnstr",
- "mvgetstr", "mvinchstr", "mvinchnstr", "mvgetnstr", "mvgetstr",
- "mvinchstr", "mvinchnstr", "winch", "wgetch", "wgetnstr", "wgetstr",
- "winchnstr", "winchstr", "winnstr", "winstr"
+ "getch", "getnstr", "getstr", "mvgetnstr", "mvgetstr", "mvgetnstr",
+ "mvgetstr", "wgetch", "wgetnstr", "wgetstr"
};
static const unsigned ninput_functions =
@@ -939,7 +938,7 @@
input_str = NULL;
}
- if (verbose && 0) {
+ if (verbose) {
fds[0].fd = slvpipe[READ_PIPE];
fds[0].events = POLLIN;
@@ -1114,8 +1113,18 @@
byte_response = data;
if ((command.returns[i].return_type != ret_byte) &&
(command.returns[i].return_type != ret_err) &&
- (command.returns[i].return_type != ret_ok))
+ (command.returns[i].return_type != ret_ok)) {
+ if ((byte_response->return_type == ret_byte) ||
+ (byte_response->return_type == ret_err) ||
+ (byte_response->return_type == ret_ok))
+ err(1, "validate: expecting type %s, received type %s"
+ " at line %d of file %s",
+ returns_enum_names[command.returns[i].return_type],
+ returns_enum_names[byte_response->return_type],
+ line, cur_file);
+
response = byte_response->return_value;
+ }
switch (command.returns[i].return_type) {
case ret_err:
@@ -1247,11 +1256,30 @@
static void
validate_byte(returns_t *expected, returns_t *value, int check)
{
+ char *ch;
+ size_t i;
+
+ if (verbose) {
+ ch = value->return_value;
+ fprintf(stderr, "checking returned byte stream: ");
+ for (i = 0; i < value->return_len; i++)
+ fprintf(stderr, "%s0x%x", (i != 0)? ", " : "", ch[i]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "%s byte stream: ",
+ (check == 0)? "matches" : "does not match");
+ ch = (char *) expected->return_value;
+ for (i = 0; i < expected->return_len; i++)
+ fprintf(stderr, "%s0x%x", (i != 0)? ", " : "", ch[i]);
+ fprintf(stderr, "\n");
+ }
+
/*
* No chance of a match if lengths differ...
*/
if ((check == 0) && (expected->return_len != value->return_len))
- errx(1, "Byte validation failed, length mismatch");
+ errx(1, "Byte validation failed, length mismatch, expected %zu,"
+ "received %zu", expected->return_len, value->return_len);
/*
* If check is 0 then we want to throw an error IFF the byte streams
Home |
Main Index |
Thread Index |
Old Index