Download raw body.
got-build-regress.sh regress failure
On 2023/04/21 17:11:46 +0200, Omar Polo <op@omarpolo.com> wrote:
> ==== run-regress-fetch_test ====
> /home/chiaki/w/got/regress/fetch/obj/fetch_test -q
>
> ===> regress/tog
> ==== log ====
> ./log.sh -q -r "/home/chiaki/tmp/"
> tog: fopen: /home/chiaki/tmp/tog-test-log_hsplit_diff-eLI9p4Ou/view: No such file or directory
It fails because the file pointed in the TOG_SCR_DUMP environment
variable is not permitted by unveil(), but since the default
GOT_TEST_ROOT dir is /tmp which is unveiled this wasn't noticed
before.
Here's a possible way to fix it: open the screendump earlier and keep
it open. I've added a ftruncate call in screendump() just in case it
gets called multiple times.
With this all tests are passing again on amd64 when ran as
$ mkdir -p ~/tmp/got-tmp
$ make -C regress/tog GOT_TEST_ROOT=~/tmp/got-tmp
diff /home/op/w/gotacl
commit - 69b9e75f5436338a9b5cddd5b8462929def12e8c
path + /home/op/w/gotacl
blob - 69803386ef3f054281b09871e9eb299e4c663e2b
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -618,6 +618,7 @@ struct tog_io {
FILE *cin;
FILE *cout;
FILE *f;
+ FILE *sdump;
int wait_for_ui;
} tog_io;
static int using_mock_io;
@@ -1486,17 +1487,10 @@ screendump(struct tog_view *view)
screendump(struct tog_view *view)
{
const struct got_error *err;
- FILE *f = NULL;
- const char *path;
int i;
- path = getenv("TOG_SCR_DUMP");
- if (path == NULL || *path == '\0')
- return got_error_msg(GOT_ERR_BAD_PATH,
- "TOG_SCR_DUMP path not set to capture screen dump");
- f = fopen(path, "wex");
- if (f == NULL)
- return got_error_from_errno_fmt("fopen: %s", path);
+ if (ftruncate(fileno(tog_io.sdump), 0) == -1)
+ return got_error_from_errno("ftruncate");
if ((view->child && view->child->begin_x) ||
(view->parent && view->begin_x)) {
@@ -1504,7 +1498,7 @@ screendump(struct tog_view *view)
/* vertical splitscreen */
for (i = 0; i < view->nlines; ++i) {
- err = view_write_line(f, i, ncols - 1);
+ err = view_write_line(tog_io.sdump, i, ncols - 1);
if (err)
goto done;
}
@@ -1523,20 +1517,18 @@ screendump(struct tog_view *view)
/* ACS_HLINE writes out as 'q', overwrite it */
for (c = 0; c < view->cols; ++c)
- fputc('-', f);
- fputc('\n', f);
+ fputc('-', tog_io.sdump);
+ fputc('\n', tog_io.sdump);
continue;
}
- err = view_write_line(f, i, 0);
+ err = view_write_line(tog_io.sdump, i, 0);
if (err)
goto done;
}
}
done:
- if (f && fclose(f) == EOF && err == NULL)
- err = got_ferror(f, GOT_ERR_IO);
return err;
}
@@ -1950,6 +1942,8 @@ tog_io_close(void)
err = got_ferror(tog_io.cout, GOT_ERR_IO);
if (tog_io.f && fclose(tog_io.f) == EOF && err == NULL)
err = got_ferror(tog_io.f, GOT_ERR_IO);
+ if (tog_io.sdump && fclose(tog_io.sdump) == EOF && err == NULL)
+ err = got_ferror(tog_io.sdump, GOT_ERR_IO);
return err;
}
@@ -4186,6 +4180,7 @@ init_mock_term(const char *test_script_path)
init_mock_term(const char *test_script_path)
{
const struct got_error *err = NULL;
+ const char *screen_dump_path;
int in;
if (test_script_path == NULL || *test_script_path == '\0')
@@ -4217,6 +4212,15 @@ init_mock_term(const char *test_script_path)
goto done;
}
+ screen_dump_path = getenv("TOG_SCR_DUMP");
+ if (screen_dump_path == NULL || *screen_dump_path == '\0')
+ return got_error_msg(GOT_ERR_IO, "TOG_SCR_DUMP not defined");
+ tog_io.sdump = fopen(screen_dump_path, "wex");
+ if (tog_io.sdump == NULL) {
+ err = got_error_from_errno2("fopen", screen_dump_path);
+ goto done;
+ }
+
if (fseeko(tog_io.f, 0L, SEEK_SET) == -1) {
err = got_error_from_errno("fseeko");
goto done;
got-build-regress.sh regress failure