2000-02-17 20:38:31 +01:00
|
|
|
/* cygrun.c: testsuite support program
|
|
|
|
|
2002-08-26 06:30:11 +02:00
|
|
|
Copyright 1999, 2000, 2001, 2002 Red Hat, Inc.
|
2000-02-17 20:38:31 +01:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
/* This program is intended to be used only by the testsuite. It runs
|
|
|
|
programs without using the cygwin api, so that the just-built dll
|
|
|
|
can be tested without interference from the currently installed
|
|
|
|
dll. */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <windows.h>
|
2001-04-03 04:53:25 +02:00
|
|
|
#include <stdlib.h>
|
2000-02-17 20:38:31 +01:00
|
|
|
|
|
|
|
int
|
2002-08-26 06:30:11 +02:00
|
|
|
main (int argc, char **argv)
|
2000-02-17 20:38:31 +01:00
|
|
|
{
|
|
|
|
STARTUPINFO sa;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
DWORD ec = 1;
|
2002-08-26 06:30:11 +02:00
|
|
|
char *p;
|
2000-02-17 20:38:31 +01:00
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
{
|
2002-08-26 06:30:11 +02:00
|
|
|
fprintf (stderr, "Usage: cygrun [program]\n");
|
2000-02-17 20:38:31 +01:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2002-08-26 06:30:11 +02:00
|
|
|
SetEnvironmentVariable ("CYGWIN_TESTING", "1");
|
|
|
|
if ((p = getenv ("CYGWIN")) == NULL || (strstr (p, "ntsec") == NULL))
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
if (!p)
|
2002-09-25 15:53:46 +02:00
|
|
|
{
|
|
|
|
p = buf;
|
|
|
|
p[0] = '\0';
|
|
|
|
}
|
2002-08-26 06:30:11 +02:00
|
|
|
else
|
|
|
|
{
|
2002-09-25 15:53:46 +02:00
|
|
|
strcpy (buf, p);
|
2002-08-26 06:30:11 +02:00
|
|
|
strcat (buf, " ");
|
|
|
|
}
|
|
|
|
strcat(buf, "ntsec");
|
|
|
|
SetEnvironmentVariable ("CYGWIN", buf);
|
|
|
|
}
|
2000-02-17 20:38:31 +01:00
|
|
|
|
2002-08-26 06:30:11 +02:00
|
|
|
memset (&sa, 0, sizeof (sa));
|
|
|
|
memset (&pi, 0, sizeof (pi));
|
|
|
|
if (!CreateProcess (0, argv[1], 0, 0, 1, 0, 0, 0, &sa, &pi))
|
2000-02-17 20:38:31 +01:00
|
|
|
{
|
2002-08-26 06:30:11 +02:00
|
|
|
fprintf (stderr, "CreateProcess %s failed\n", argv[1]);
|
|
|
|
exit (1);
|
2000-02-17 20:38:31 +01:00
|
|
|
}
|
|
|
|
|
2002-08-26 06:30:11 +02:00
|
|
|
WaitForSingleObject (pi.hProcess, INFINITE);
|
2000-02-17 20:38:31 +01:00
|
|
|
|
2002-08-26 06:30:11 +02:00
|
|
|
GetExitCodeProcess (pi.hProcess, &ec);
|
2000-02-17 20:38:31 +01:00
|
|
|
|
2002-08-26 06:30:11 +02:00
|
|
|
CloseHandle (pi.hProcess);
|
|
|
|
CloseHandle (pi.hThread);
|
2000-02-17 20:38:31 +01:00
|
|
|
return ec;
|
|
|
|
}
|