"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: got-build-regress.sh regress failure
To:
Omar Polo <op@omarpolo.com>
Cc:
stsp@stsp.name, gameoftrees@openbsd.org
Date:
Fri, 21 Apr 2023 18:42:06 +1000

Download raw body.

Thread
On 23-04-21 10:17AM, Omar Polo wrote:
> On 2023/04/21 10:03:25 +0200, Omar Polo <op@omarpolo.com> wrote:
> > On 2023/04/21 08:10:18 +0200, stsp@stsp.name wrote:
> > > ===> regress/tog
> > > ==== log ====
> > > ./log.sh -q -r "/tmp"
> > > tog: fopen: /dev/tty: Device not configured
> > > diff: /tmp/tog-test-log_hsplit_diff-oHQDaq7m/view: No such file or directory
> > > test failed; leaving test data in /tmp/tog-test-log_hsplit_diff-oHQDaq7m
> > > tog: fopen: /dev/tty: Device not configured
> > > [...]
> > 
> > i've hit the same in my i386 regress.  init_mock_term() tries to open
> > /dev/tty, but that device may not be available in all circumstances.
> > 
> > This seems to fix it for me, but I haven't looked closer at how the
> > tog regress suite works (yet!) and don't know if this breaks some
> > assumption not catched by regress.
> > 
> > (tog_io_close() will close stdin now, but I guess it's not a problem.)
> 
> Upon a second look I think it's probably better to just dup the fd for
> /dev/null and use it for tog.cin too.  Maybe it was intended since
> cout is open with w+.
> 
> Regress still passes from me (I'm using `nq make -C regress/tog' to
> replicate the case without a tty, which is equivalent to running the
> regress under cron.)

Yes, I like this better. Thanks! ok

> diff /home/op/w/gotacl
> commit - 9cbac887301ab85a09a6e123f9963b76f60514e1
> path + /home/op/w/gotacl
> blob - a411c9ed187b845c6ae5b24e656b8f43e9515a72
> file + tog/tog.c
> --- tog/tog.c
> +++ tog/tog.c
> @@ -4186,6 +4186,7 @@ init_mock_term(const char *test_script_path)
>  init_mock_term(const char *test_script_path)
>  {
>  	const struct got_error	*err = NULL;
> +	int in;
>  
>  	if (test_script_path == NULL || *test_script_path == '\0')
>  		return got_error_msg(GOT_ERR_IO, "TOG_TEST_SCRIPT not defined");
> @@ -4200,13 +4201,19 @@ init_mock_term(const char *test_script_path)
>  	/* test mode, we don't want any output */
>  	tog_io.cout = fopen("/dev/null", "w+");
>  	if (tog_io.cout == NULL) {
> -		err = got_error_from_errno("fopen: /dev/null");
> +		err = got_error_from_errno2("fopen", "/dev/null");
>  		goto done;
>  	}
>  
> -	tog_io.cin = fopen("/dev/tty", "r+");
> +	in = dup(fileno(tog_io.cout));
> +	if (in == -1) {
> +		err = got_error_from_errno("dup");
> +		goto done;
> +	}
> +	tog_io.cin = fdopen(in, "r");
>  	if (tog_io.cin == NULL) {
> -		err = got_error_from_errno("fopen: /dev/tty");
> +		err = got_error_from_errno("fdopen");
> +		close(in);
>  		goto done;
>  	}
>  
> 

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68