The public internet can (and does) go pear-shaped
in the middle of test runs, which means any test
that tries to access the public internet is de facto
flaky, even if it tries to protect itself by skipping
if the internet is down.
So let's provide a way for automated testers to
force all hostname resolution requests to
return the same result (say, 'localhost' or 'mytestserver').
Only include this in debugging builds.
Later we should provide a script to set up
a local test server that can handle all of
our conformance tests' requests, but for
now, just letting patchwatcher or winetest
redirect everything to localhost will let tests
fail reliably instead of randomly.
See http://bugs.winehq.org/show_bug.cgi?id=15716
diff --git a/dlls/wininet/utility.c b/dlls/wininet/utility.c
index ff914f4..021aea0 100644
--- a/dlls/wininet/utility.c
+++ b/dlls/wininet/utility.c
@@ -153,6 +153,24 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
struct hostent *phe;
#endif
+#ifndef NDEBUG
+ /* Provide a way to redirect all internet access to
+ * a private server, usually localhost.
+ * Don't enable this in any builds that go out to users,
+ * this is just for automated conformance testing, where
+ * we can't afford letting the flaky internet make
+ * tests fail randomly.
+ */
+ static char *dns_override = 0;
+ static int first_run = 1;
+ if (first_run) {
+ dns_override = getenv("WINETEST_DNSOVERRIDE");
+ first_run = 0;
+ }
+ if (dns_override)
+ lpszServerName = dns_override;
+#endif
+
TRACE("%s\n", debugstr_w(lpszServerName));
/* Validate server name first