fsutils/tests: Fsutils requires elevated privileges on Windows <= 7.

So skip the tests if the first fsutils run fails and we don't have
elevated privileges.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2020-12-02 06:34:04 +01:00 committed by Alexandre Julliard
parent 24508594ba
commit fe719e16a4
2 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,5 @@
TESTDLL = fsutil.exe
IMPORTS = user32
IMPORTS = advapi32 user32
C_SRCS = \
fsutil.c

View File

@ -21,6 +21,22 @@
#include "wine/test.h"
static BOOL is_process_elevated(void)
{
HANDLE token;
if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token ))
{
TOKEN_ELEVATION_TYPE type;
DWORD size;
BOOL ret;
ret = GetTokenInformation( token, TokenElevationType, &type, sizeof(type), &size );
CloseHandle( token );
return (ret && type == TokenElevationTypeFull);
}
return FALSE;
}
static DWORD runcmd(const char* cmd)
{
STARTUPINFOA si = { sizeof(STARTUPINFOA) };
@ -64,6 +80,11 @@ static void test_hardlink(void)
CloseHandle(hfile);
rc = runcmd("fsutil");
if (rc == 1 && !is_process_elevated())
{
win_skip("Cannot run fsutil without elevated privileges on Windows <= 7\n");
return;
}
ok(rc == 0, "failed to run fsutil\n");
rc = runcmd("fsutil hardlink");