diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | regress/gg.1 | 7 | ||||
-rw-r--r-- | regress/gg.c | 21 | ||||
-rwxr-xr-x | regress/runtime | 6 |
4 files changed, 29 insertions, 7 deletions
@@ -1,5 +1,7 @@ 2021-07-06 Omar Polo <op@omarpolo.com> + * regress/gg.c (main): add -T timeout + * configure (guessing_cflags): try to preserve CFLAGS/LDFLAGS 2021-07-02 Omar Polo <op@omarpolo.com> diff --git a/regress/gg.1 b/regress/gg.1 index ad47822..acda5da 100644 --- a/regress/gg.1 +++ b/regress/gg.1 @@ -23,6 +23,7 @@ .Op Fl 23bchNVv .Op Fl C Pa cert.pem Fl K Pa key.pem .Op Fl H Ar hostname +.Op Fl T Ar timeout .Ar IRI .Ek .Sh DESCRIPTION @@ -54,6 +55,12 @@ Load the client certificate key, must be in PEM format. .It Fl N Don't check whether the peer certificate name matches the requested hostname. +.It Fl T Ar timeout +Kill +.Nm +after +.Ar timeout +seconds. .It Fl V Only validate the IRI, don't do the Gemini transaction. .It Fl v diff --git a/regress/gg.c b/regress/gg.c index 7eb698f..5537c68 100644 --- a/regress/gg.c +++ b/regress/gg.c @@ -21,6 +21,13 @@ int flag2, flag3, bflag, cflag, hflag, Nflag, Vflag, vflag; const char *cert, *key; +static void +timeout(int signo) +{ + dprintf(2, "%s: timer expired\n", getprogname()); + exit(1); +} + int main(int argc, char **argv) { @@ -28,15 +35,14 @@ main(int argc, char **argv) struct tls_config *conf; struct tls *ctx; char iribuf[GEMINI_URL_LEN], buf[GEMINI_URL_LEN]; - const char *parse_err = "unknown error", *port = "1965"; + const char *parse_err = "unknown error", *port = "1965", *errstr; const char *hostname; char *t; - int ch; - int handshake; + int ch, handshake, timer; ssize_t len; hostname = NULL; - while ((ch = getopt(argc, argv, "23C:cbH:hK:NVv")) != -1) { + while ((ch = getopt(argc, argv, "23C:cbH:hK:NT:Vv")) != -1) { switch (ch) { case '2': flag2 = 1; @@ -65,6 +71,13 @@ main(int argc, char **argv) case 'N': Nflag = 1; break; + case 'T': + timer = strtonum(optarg, 1, 1000, &errstr); + if (errstr != NULL) + errx(1, "timeout is %s: %s", errstr, optarg); + signal(SIGALRM, timeout); + alarm(timer); + break; case 'V': Vflag = 1; break; diff --git a/regress/runtime b/regress/runtime index 267331e..6b8fdbb 100755 --- a/regress/runtime +++ b/regress/runtime @@ -31,19 +31,19 @@ checkconf() { # usage: get <path> # return the body of the request on stdout get() { - ./gg -b $ggflags "gemini://localhost:10965/$1" + ./gg -T30 -b $ggflags "gemini://localhost:10965/$1" } # usage: head <path> # return the meta response line on stdout head() { - ./gg -h $ggflags "gemini://localhost:10965/$1" + ./gg -T30 -h $ggflags "gemini://localhost:10965/$1" } # usage: raw <path> # return both header and body raw() { - ./gg $ggflags "gemini://localhost:10965/$1" + ./gg -T30 $ggflags "gemini://localhost:10965/$1" } run() { |