[master] 895af0a Add a feature test "term" for having a adm3a term{info|cap} entry

Poul-Henning Kamp phk at FreeBSD.org
Thu Jan 11 11:08:07 UTC 2018


commit 895af0a667e694ce49efb85c6d498e179cbefe0f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 11 10:41:16 2018 +0000

    Add a feature test "term" for having a adm3a term{info|cap} entry

diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index 02e8da3..11c1ca5 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -712,12 +712,32 @@ cmd_delay(CMD_ARGS)
  * ignore_unknown_macro
  *        Do not fail the test if a string of the form ${...} is not
  *        recognized as a macro.
+ * term
+ *	  Support for ADM3A terminal
  *
  * Be careful with the last feature, because it may cause a test with a
  * misspelled macro to fail silently. You should only need it if you must
  * run a test with strings of the form "${...}".
  */
 
+static int
+test_term(struct vtclog *vl)
+{
+	FILE *p;
+	int a, b, c;
+
+	p = popen("tput -T adm3a clear 2>&1", "r");
+	if (p == NULL)
+		return (0);
+	a = fgetc(p);
+	b = fgetc(p);
+	c = pclose(p);
+	if (a == 0x1a && b == EOF && c == 0)
+		return (1);
+	vtc_log(vl, 3, "No adm3a terminfo entry. (insteall ncurses-term ?)");
+	return (0);
+}
+
 static void
 cmd_feature(CMD_ARGS)
 {
@@ -766,6 +786,7 @@ cmd_feature(CMD_ARGS)
 		FEATURE("user_varnish", getpwnam("varnish") != NULL);
 		FEATURE("user_vcache", getpwnam("vcache") != NULL);
 		FEATURE("group_varnish", getgrnam("varnish") != NULL);
+		FEATURE("term", test_term(vl));
 
 		if (!strcmp(*av, "disable_aslr")) {
 			good = 1;
diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c
index d6db686..81d18bc 100644
--- a/bin/varnishtest/vtc_process.c
+++ b/bin/varnishtest/vtc_process.c
@@ -320,8 +320,7 @@ process_init_term(int fd)
 	tt.c_iflag = BRKINT | ICRNL | IMAXBEL | IXON | IXANY;
 	tt.c_lflag = ICANON | ISIG | IEXTEN;
 	tt.c_oflag = OPOST | ONLCR;
-	cfsetispeed(&tt, B9600);
-	cfsetospeed(&tt, B9600);
+	AZ(cfsetspeed(&tt, B9600));
 	tt.c_cc[VEOF] = '\x04';			// CTRL-D
 	tt.c_cc[VERASE] = '\x08';		// CTRL-H (Backspace)
 	tt.c_cc[VKILL] = '\x15';		// CTRL-U
@@ -365,7 +364,7 @@ process_start(struct process *p)
 	p->pid = fork();
 	assert(p->pid >= 0);
 	if (p->pid == 0) {
-		setenv("TERM", "adm3a", 1);
+		AZ(setenv("TERM", "adm3a", 1));
 		assert(dup2(slave, STDIN_FILENO) == STDIN_FILENO);
 		assert(dup2(slave, STDOUT_FILENO) == STDOUT_FILENO);
 		assert(dup2(fd2[1], STDERR_FILENO) == STDERR_FILENO);


More information about the varnish-commit mailing list