Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ee31a622
Commit
ee31a622
authored
Mar 03, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Mar 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add some tests for hard links.
Signed-off-by:
Zebediah Figura
<
zfigura@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d26a23d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
file.c
dlls/kernel32/tests/file.c
+82
-0
No files found.
dlls/kernel32/tests/file.c
View file @
ee31a622
...
@@ -117,6 +117,13 @@ static void InitFunctionPointers(void)
...
@@ -117,6 +117,13 @@ static void InitFunctionPointers(void)
pFindFirstStreamW
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"FindFirstStreamW"
);
pFindFirstStreamW
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"FindFirstStreamW"
);
}
}
static
void
create_file
(
const
char
*
path
)
{
FILE
*
f
=
fopen
(
path
,
"wb"
);
fputs
(
path
,
f
);
fclose
(
f
);
}
static
void
test__hread
(
void
)
static
void
test__hread
(
void
)
{
{
HFILE
filehandle
;
HFILE
filehandle
;
...
@@ -5510,6 +5517,80 @@ static void test_SetFileTime(void)
...
@@ -5510,6 +5517,80 @@ static void test_SetFileTime(void)
CloseHandle
(
hfile
);
CloseHandle
(
hfile
);
}
}
static
void
test_hard_link
(
void
)
{
char
cwd
[
MAX_PATH
],
temp_dir
[
MAX_PATH
],
name_buffer
[
200
],
buffer
[
20
];
FILE_NAME_INFORMATION
*
name_info
=
(
FILE_NAME_INFORMATION
*
)
name_buffer
;
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
HANDLE
file
;
DWORD
size
;
BOOL
ret
;
GetCurrentDirectoryA
(
sizeof
(
cwd
),
cwd
);
GetTempPathA
(
sizeof
(
temp_dir
),
temp_dir
);
SetCurrentDirectoryA
(
temp_dir
);
ret
=
CreateDirectoryA
(
"winetest_dir1"
,
NULL
);
ok
(
ret
,
"failed to create directory, error %u
\n
"
,
GetLastError
());
ret
=
CreateDirectoryA
(
"winetest_dir2"
,
NULL
);
ok
(
ret
,
"failed to create directory, error %u
\n
"
,
GetLastError
());
create_file
(
"winetest_file1"
);
create_file
(
"winetest_file2"
);
ret
=
CreateHardLinkA
(
"winetest_file3"
,
"winetest_file1"
,
NULL
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
file
=
CreateFileA
(
"winetest_file3"
,
FILE_READ_DATA
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"got error %u
\n
"
,
GetLastError
());
status
=
NtQueryInformationFile
(
file
,
&
io
,
name_buffer
,
sizeof
(
name_buffer
),
FileNameInformation
);
ok
(
!
status
,
"got status %#x
\n
"
,
status
);
ok
(
!
wcsncmp
(
name_info
->
FileName
+
(
name_info
->
FileNameLength
/
sizeof
(
WCHAR
))
-
wcslen
(
L"
\\
winetest_file3"
),
L"
\\
winetest_file3"
,
wcslen
(
L"
\\
winetest_file3"
)),
"got name %s
\n
"
,
debugstr_wn
(
name_info
->
FileName
,
name_info
->
FileNameLength
/
sizeof
(
WCHAR
)));
ret
=
ReadFile
(
file
,
buffer
,
sizeof
(
buffer
),
&
size
,
NULL
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
buffer
,
"winetest_file1"
,
size
),
"got file contents %s
\n
"
,
debugstr_an
(
buffer
,
size
));
CloseHandle
(
file
);
ret
=
DeleteFileA
(
"winetest_file3"
);
ok
(
ret
,
"failed to delete file, error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CreateHardLinkA
(
"winetest_file2"
,
"winetest_file1"
,
NULL
);
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ALREADY_EXISTS
,
"got error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CreateHardLinkA
(
"winetest_file3"
,
"winetest_dir1"
,
NULL
);
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"got error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CreateHardLinkA
(
"winetest_dir2"
,
"winetest_dir1"
,
NULL
);
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
||
GetLastError
()
==
ERROR_ALREADY_EXISTS
/* XP */
,
"got error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CreateHardLinkA
(
"winetest_dir1"
,
"winetest_file1"
,
NULL
);
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ALREADY_EXISTS
,
"got error %u
\n
"
,
GetLastError
());
ret
=
RemoveDirectoryA
(
"winetest_dir1"
);
ok
(
ret
,
"failed to remove directory, error %u
\n
"
,
GetLastError
());
ret
=
RemoveDirectoryA
(
"winetest_dir2"
);
ok
(
ret
,
"failed to remove directory, error %u
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
"winetest_file1"
);
ok
(
ret
,
"failed to delete file, error %u
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
"winetest_file2"
);
ok
(
ret
,
"failed to delete file, error %u
\n
"
,
GetLastError
());
SetCurrentDirectoryA
(
cwd
);
}
START_TEST
(
file
)
START_TEST
(
file
)
{
{
char
temp_path
[
MAX_PATH
];
char
temp_path
[
MAX_PATH
];
...
@@ -5584,4 +5665,5 @@ START_TEST(file)
...
@@ -5584,4 +5665,5 @@ START_TEST(file)
test_find_file_stream
();
test_find_file_stream
();
test_SetFileTime
();
test_SetFileTime
();
test_ReOpenFile
();
test_ReOpenFile
();
test_hard_link
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment