From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 7E81B3858D20; Tue, 8 Aug 2023 13:16:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E81B3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691500563; bh=P1Yvr1xP4tblqv2N35uqcTdGTgJutvMcZyHAe7I6hno=; h=From:To:Subject:Date:From; b=R2cfXS0QAUq7TstBCT2mKJbHmDcCJqzr7MA6Vpi3Ny6qfBa1D0Wy/u/Cw5LOataML RzxCG4k5nidqtwjZvaNqBmVWOh+IZ50kcOlEah0rxsy1M1qrm40wwDmgPyaMxLEBDU cRAOQG/nbLBtdIE8zuShJPHEYAzTPv/bwDCTyw/o= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon Turney To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: testsuite: Add '-notimeout' option to cygrun X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/main X-Git-Oldrev: 2e7332d6bd0219da491e899e0c3cee335ec8c9ab X-Git-Newrev: c88ac48eab3e9df4c7bb353af1b5dfd3798fa9f0 Message-Id: <20230808131603.7E81B3858D20@sourceware.org> Date: Tue, 8 Aug 2023 13:16:03 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc88ac48eab3= e9df4c7bb353af1b5dfd3798fa9f0 commit c88ac48eab3e9df4c7bb353af1b5dfd3798fa9f0 Author: Jon Turney Date: Thu Jul 20 13:54:09 2023 +0100 Cygwin: testsuite: Add '-notimeout' option to cygrun =20 Add '-notimeout' option for cygrun. This is very useful when using it to run a test standalone and under a debugger. =20 Also: warn about excess arguments Diff: --- winsup/testsuite/cygrun.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/winsup/testsuite/cygrun.c b/winsup/testsuite/cygrun.c index d8de7d158..450201342 100644 --- a/winsup/testsuite/cygrun.c +++ b/winsup/testsuite/cygrun.c @@ -23,24 +23,42 @@ main (int argc, char **argv) DWORD res; DWORD ec =3D 1; char *p; + DWORD timeout =3D 60 * 1000; =20 if (argc < 2) { fprintf (stderr, "Usage: cygrun [program]\n"); - exit (0); + exit (1); + } + + int i; + for (i =3D 1; i < argc; ++i) + { + if (strcmp (argv[i], "-notimeout") =3D=3D 0) + timeout =3D INFINITE; + else + break; + } + + char *command =3D argv[i]; + + if (i < (argc-1)) + { + fprintf (stderr, "cygrun: excess arguments\n"); + exit (1); } =20 SetEnvironmentVariable ("CYGWIN_TESTING", "1"); =20 memset (&sa, 0, sizeof (sa)); memset (&pi, 0, sizeof (pi)); - if (!CreateProcess (0, argv[1], 0, 0, 1, 0, 0, 0, &sa, &pi)) + if (!CreateProcess (0, command, 0, 0, 1, 0, 0, 0, &sa, &pi)) { - fprintf (stderr, "CreateProcess %s failed\n", argv[1]); + fprintf (stderr, "CreateProcess %s failed\n", command); exit (1); } =20 - res =3D WaitForSingleObject (pi.hProcess, 60 * 1000); + res =3D WaitForSingleObject (pi.hProcess, timeout); =20 if (res =3D=3D WAIT_TIMEOUT) {