+ struct pollfd pfd;
+
+ pfd.fd = 0;
+ pfd.events = POLLIN;
+ return poll(&pfd, 1, timeout) == 1;
+}
+
+void expect(char *s, int len)
+{
+ int i;
+ char c;
+ for (i=0; i < len; i++)
+ {
+ if (waitchar(100) == 0)
+ {
+ fprintf(stderr, "Timeout reached in expect (expected %c)\n", s[i]);
+ return;
+ }
+ while (read(0, &c, 1) == 0)
+ fprintf(stderr, "Short read...\n");
+ if (c != s[i])
+ fprintf(stderr, "Expect failed: expected %d, got %d (pos %d)\n", s[i], c, i);
+ }
+}
+
+void expect_no_chars()
+{
+ int cs = 0;
+
+ while (waitchar(10) == 1)
+ {
+ char c;
+ if (read(0, &c, 1) == 0)
+ fprintf(stderr, "enc Short read...\n");
+ cs++;
+ fprintf(stderr, "Warning: expected no chars, got %d\n", c);
+ }
+ if (cs)
+ fprintf(stderr, "Expect no chars failed: got %d chars\n", cs);
+
+
+}
+
+void main(int argc, char **argv)
+{
+ unsigned char buf[259];