Steve Hay wrote:
> Jan Dubois wrote:
>> On Mon, 17 Sep 2007, Jerry D. Hedden wrote:
>>> Jan Dubois wrote:
>>>> That is weird, why does the test fail then.
Doesn't
>>>> Win32: omainNam
e() on that machine return "MSHOME"? When I run
it
>>>> on an XP (SP2) machine that is not part of
the domain, I get the
>>>> workgroup name:
>>>>
>>>> C:>perl -MWin32 -e "print
Win32: omainNam
e"
>>>> WORKGROUP
>>>
>>> It prints out nothing on my PC. So it appears
to be returning an
>>> empty string.
>>
>> It looks like we cannot determine the workgroup
name if the
>> "Workstation" service isn't running. I
therefore removed the
>> Win32: omainNam
e() test from t/Names.t (patch below is against by
>> local depot for the CPAN version, but should
otherwise be identical
>> to the bleadperl one).
>
> Couldn't we call Win32: omainNam
e() and then check the value of $^E
> afterwards? If it is 2138 (The Workstation service has
not been
> started) then skip the tests, otherwise test the
returned $domain?
Well, it seems that Win32: omainNam
e() doesn't set $^E to anything
useful on failure, probably because the NetWkstaGetInfo()
API call that
it uses seems to *return* an error code rather than just
returning
true/false and then setting the "last error code"
(which is what $^E
exposes).
The attached patch picks up NetWkstaGetInfo()'s return value
and makes
it the last error code in the event of failure (many Win32
API calls
don't bother setting the last error code when they succeed,
so I haven't
bothered with the "success" case eitehr). The
Names.t script is now able
to test $^E, and correctly skips the DomainName() test for
me if I run
it with the Workstation service stopped.
Does this work for you?
|