Module Name: src
Committed By: blymn
Date: Thu Sep 15 11:53:12 UTC 2011
Modified Files:
src/tests/lib/libcurses/director: director.c testlang_parse.y
Log Message:
- 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.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/director/director.c
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libcurses/director/testlang_parse.y
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libcurses/director/director.c
diff -u src/tests/lib/libcurses/director/director.c:1.7 src/tests/lib/libcurses/director/director.c:1.8
--- src/tests/lib/libcurses/director/director.c:1.7 Fri Jun 17 16:59:51 2011
+++ src/tests/lib/libcurses/director/director.c Thu Sep 15 11:53:12 2011
@@ -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 <[email protected]>
@@ -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");
Index: src/tests/lib/libcurses/director/testlang_parse.y
diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.10 src/tests/lib/libcurses/director/testlang_parse.y:1.11
--- src/tests/lib/libcurses/director/testlang_parse.y:1.10 Thu Sep 8 10:56:49 2011
+++ src/tests/lib/libcurses/director/testlang_parse.y Thu Sep 15 11:53:12 2011
@@ -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 <[email protected]>
@@ -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