public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH 1/4] Cygwin: testsuite: Add '-notimeout' option to cygrun
Date: Fri,  4 Aug 2023 13:47:20 +0100	[thread overview]
Message-ID: <20230804124723.9236-2-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20230804124723.9236-1-jon.turney@dronecode.org.uk>

Add '-notimeout' option for cygrun.  This is very useful when using it
to run a test standalone and under a debugger.

Also: warn about excess arguments
---
 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 = 1;
   char *p;
+  DWORD timeout = 60 * 1000;
 
   if (argc < 2)
     {
       fprintf (stderr, "Usage: cygrun [program]\n");
-      exit (0);
+      exit (1);
+    }
+
+  int i;
+  for (i = 1; i < argc; ++i)
+    {
+      if (strcmp (argv[i], "-notimeout") == 0)
+	timeout = INFINITE;
+      else
+	break;
+    }
+
+  char *command = argv[i];
+
+  if (i < (argc-1))
+    {
+      fprintf (stderr, "cygrun: excess arguments\n");
+      exit (1);
     }
 
   SetEnvironmentVariable ("CYGWIN_TESTING", "1");
 
   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);
     }
 
-  res = WaitForSingleObject (pi.hProcess, 60 * 1000);
+  res = WaitForSingleObject (pi.hProcess, timeout);
 
   if (res == WAIT_TIMEOUT)
     {
-- 
2.39.0


  reply	other threads:[~2023-08-04 12:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04 12:47 [PATCH 0/4] Testsuite update Jon Turney
2023-08-04 12:47 ` Jon Turney [this message]
2023-08-04 12:47 ` [PATCH 2/4] Cygwin: testsuite: Update README Jon Turney
2023-08-04 12:47 ` [PATCH 3/4] Cygwin: testsuite: Fix cygload test Jon Turney
2023-08-04 12:47 ` [PATCH 4/4] Cygwin: CI: XFAIL umask03 Jon Turney
2023-08-07  8:55 ` [PATCH 0/4] Testsuite update Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230804124723.9236-2-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).