Module Name: src Committed By: rillig Date: Sat Feb 13 08:00:07 UTC 2021
Modified Files: src/tests/lib/libcurses: t_curses.sh src/tests/lib/libcurses/director: director.c testlang_conf.l Log Message: tests/libcurses: remove include path handling All include commands in the current test suite use relative paths. Instead of a fixed include path, interpret the included filename relative to the including file. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/t_curses.sh cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/director/testlang_conf.l 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/t_curses.sh diff -u src/tests/lib/libcurses/t_curses.sh:1.22 src/tests/lib/libcurses/t_curses.sh:1.23 --- src/tests/lib/libcurses/t_curses.sh:1.22 Sat Feb 13 06:29:45 2021 +++ src/tests/lib/libcurses/t_curses.sh Sat Feb 13 08:00:07 2021 @@ -25,7 +25,6 @@ r_run() $(atf_get_srcdir)/director $2 \ -T $(atf_get_srcdir) \ -t atf \ - -I $(atf_get_srcdir)/tests \ -C $(atf_get_srcdir)/check_files \ -s $(atf_get_srcdir)/slave $file || atf_fail "test ${file} failed" } Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.23 src/tests/lib/libcurses/director/director.c:1.24 --- src/tests/lib/libcurses/director/director.c:1.23 Sat Feb 13 07:32:19 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 08:00:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.23 2021/02/13 07:32:19 rillig Exp $ */ +/* $NetBSD: director.c,v 1.24 2021/02/13 08:00:07 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn <bl...@netbsd.org> @@ -51,7 +51,6 @@ void yyparse(void); #define DEF_SLAVE "./slave" const char *def_check_path = "./"; /* default check path */ -const char *def_include_path = "./"; /* default include path */ extern size_t nvars; /* In testlang_conf.y */ saved_data_t saved_output; /* In testlang_conf.y */ @@ -62,7 +61,6 @@ int verbose; /* control verbosity of t int check_file_flag; /* control check-file generation */ const char *check_path; /* path to prepend to check files for output validation */ -const char *include_path; /* path to prepend to include files */ char *cur_file; /* name of file currently being read */ void init_parse_variables(int); /* in testlang_parse.y */ @@ -142,11 +140,8 @@ main(int argc, char *argv[]) verbose = 0; check_file_flag = 0; - while ((ch = getopt(argc, argv, "vgfC:I:p:s:t:T:")) != -1) { + while ((ch = getopt(argc, argv, "vgfC:p:s:t:T:")) != -1) { switch (ch) { - case 'I': - include_path = optarg; - break; case 'C': check_path = optarg; break; @@ -199,14 +194,6 @@ main(int argc, char *argv[]) check_path = def_check_path; } - if (include_path == NULL) - include_path = getenv("INCLUDE_PATH"); - if ((include_path == NULL) || (include_path[0] == '\0')) { - warnx("$INCLUDE_PATH not set, defaulting to %s", - def_include_path); - include_path = def_include_path; - } - signal(SIGCHLD, slave_died); if (setenv("TERM", term, 1) != 0) Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.18 src/tests/lib/libcurses/director/testlang_conf.l:1.19 --- src/tests/lib/libcurses/director/testlang_conf.l:1.18 Mon Feb 8 23:54:03 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Sat Feb 13 08:00:07 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.18 2021/02/08 23:54:03 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.19 2021/02/13 08:00:07 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn <bl...@netbsd.org> @@ -45,7 +45,6 @@ int yylex(void); extern size_t line; -extern char *include_path; /* from director.c */ extern char *cur_file; /* from director.c */ static int include_stack[MAX_INCLUDES]; @@ -175,7 +174,7 @@ include BEGIN(incl); <incl>[ \t]* /* eat the whitespace */ <incl>[^ \t\n]+ { /* got the include file name */ - char inc_file[MAXPATHLEN]; + char *inc_file; if (include_ptr > MAX_INCLUDES) { fprintf(stderr, @@ -184,23 +183,27 @@ include BEGIN(incl); exit(2); } - if (yytext[0] != '/') { - if (strlcpy(inc_file, include_path, sizeof(inc_file)) - >= sizeof(inc_file)) - err(2, "CHECK_PATH too long"); - if ((include_path[strlen(include_path) - 1] != '/') && - ((strlcat(inc_file, "/", sizeof(inc_file)) - >= sizeof(inc_file)))) - err(2, "Could not append / to include file path"); + const char *dir_begin; + int dir_len; + if (yytext[0] == '/') { + dir_begin = ""; + dir_len = 0; } else { - inc_file[0] = '\0'; + dir_begin = cur_file; + const char *dir_end = strrchr(cur_file, '/'); + if (dir_end != NULL) { + dir_len = (int)(dir_end + 1 - dir_begin); + } else { + dir_begin = "."; + dir_len = 1; + } } - if (strlcat(inc_file, yytext, sizeof(inc_file)) - >= sizeof(inc_file)) - err(2, "Path to include file path overflowed"); + if (asprintf(&inc_file, "%.*s%s", + dir_len, dir_begin, yytext) == -1) + err(2, "Cannot construct include path"); - yyin = fopen(inc_file, "r" ); + yyin = fopen(inc_file, "r"); if (!yyin) err(1, "Error opening %s", inc_file); @@ -209,9 +212,7 @@ include BEGIN(incl); include_stack[include_ptr] = line; include_files[include_ptr++] = cur_file; - cur_file = strdup(inc_file); - if (cur_file == NULL) - err(2, "Cannot allocate new include file string"); + cur_file = inc_file; line = 1; BEGIN(INITIAL); } @@ -336,7 +337,7 @@ include BEGIN(incl); rv = yylval.retval->data_value; for (i = 0; i < len; i += 2) *rv++ = (str[i] << 8) | str[i+1]; - *rv = __NORMAL | '\0'; /* terminates chtype array */ + *rv = __NORMAL | '\0'; /* terminates chtype array */ yylval.retval->data_type = data_byte; yylval.retval->data_len = chlen; return BYTE;