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
7a9fce25
Commit
7a9fce25
authored
Mar 08, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Mar 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add some CreateFile disposition and access tests.
parent
75209ffd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
file.c
dlls/kernel32/tests/file.c
+87
-0
No files found.
dlls/kernel32/tests/file.c
View file @
7a9fce25
...
...
@@ -3151,6 +3151,92 @@ static void test_ReplaceFileW(void)
}
}
static
void
test_CreatFile
(
void
)
{
static
const
struct
test_data
{
DWORD
disposition
,
access
,
error
,
clean_up
;
}
td
[]
=
{
/* 0 */
{
0
,
0
,
ERROR_INVALID_PARAMETER
,
0
},
/* 1 */
{
0
,
GENERIC_READ
,
ERROR_INVALID_PARAMETER
,
0
},
/* 2 */
{
0
,
GENERIC_READ
|
GENERIC_WRITE
,
ERROR_INVALID_PARAMETER
,
0
},
/* 3 */
{
CREATE_NEW
,
0
,
ERROR_FILE_EXISTS
,
1
},
/* 4 */
{
CREATE_NEW
,
0
,
0
,
1
},
/* 5 */
{
CREATE_NEW
,
GENERIC_READ
,
0
,
1
},
/* 6 */
{
CREATE_NEW
,
GENERIC_WRITE
,
0
,
1
},
/* 7 */
{
CREATE_NEW
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
0
},
/* 8 */
{
CREATE_ALWAYS
,
0
,
0
,
0
},
/* 9 */
{
CREATE_ALWAYS
,
GENERIC_READ
,
0
,
0
},
/* 10*/
{
CREATE_ALWAYS
,
GENERIC_WRITE
,
0
,
0
},
/* 11*/
{
CREATE_ALWAYS
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
1
},
/* 12*/
{
OPEN_EXISTING
,
0
,
ERROR_FILE_NOT_FOUND
,
0
},
/* 13*/
{
CREATE_ALWAYS
,
0
,
0
,
0
},
/* 14*/
{
OPEN_EXISTING
,
0
,
0
,
0
},
/* 15*/
{
OPEN_EXISTING
,
GENERIC_READ
,
0
,
0
},
/* 16*/
{
OPEN_EXISTING
,
GENERIC_WRITE
,
0
,
0
},
/* 17*/
{
OPEN_EXISTING
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
1
},
/* 18*/
{
OPEN_ALWAYS
,
0
,
0
,
0
},
/* 19*/
{
OPEN_ALWAYS
,
GENERIC_READ
,
0
,
0
},
/* 20*/
{
OPEN_ALWAYS
,
GENERIC_WRITE
,
0
,
0
},
/* 21*/
{
OPEN_ALWAYS
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
0
},
/* 22*/
{
TRUNCATE_EXISTING
,
0
,
ERROR_INVALID_PARAMETER
,
0
},
/* 23*/
{
TRUNCATE_EXISTING
,
GENERIC_READ
,
ERROR_INVALID_PARAMETER
,
0
},
/* 24*/
{
TRUNCATE_EXISTING
,
GENERIC_WRITE
,
0
,
0
},
/* 25*/
{
TRUNCATE_EXISTING
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
0
}
};
char
temp_path
[
MAX_PATH
];
char
file_name
[
MAX_PATH
];
DWORD
i
,
ret
,
written
;
HANDLE
hfile
;
GetTempPath
(
MAX_PATH
,
temp_path
);
GetTempFileName
(
temp_path
,
"tmp"
,
0
,
file_name
);
for
(
i
=
0
;
i
<
sizeof
(
td
)
/
sizeof
(
td
[
0
]);
i
++
)
{
SetLastError
(
0xdeadbeef
);
hfile
=
CreateFile
(
file_name
,
td
[
i
].
access
,
0
,
NULL
,
td
[
i
].
disposition
,
0
,
0
);
if
(
!
td
[
i
].
error
)
{
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"%d: CreateFile error %d
\n
"
,
i
,
GetLastError
());
written
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
ret
=
WriteFile
(
hfile
,
&
td
[
i
].
error
,
sizeof
(
td
[
i
].
error
),
&
written
,
NULL
);
if
(
td
[
i
].
access
&
GENERIC_WRITE
)
ok
(
ret
,
"%d: WriteFile error %d
\n
"
,
i
,
GetLastError
());
else
{
ok
(
!
ret
,
"%d: WriteFile should fail
\n
"
,
i
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"%d: expected ERROR_ACCESS_DENIED, got %d
\n
"
,
i
,
GetLastError
());
}
CloseHandle
(
hfile
);
}
else
{
/* FIXME: remove the condition below once Wine is fixed */
if
(
td
[
i
].
disposition
==
TRUNCATE_EXISTING
&&
!
(
td
[
i
].
access
&
GENERIC_WRITE
))
{
todo_wine
{
ok
(
hfile
==
INVALID_HANDLE_VALUE
,
"%d: CreateFile should fail
\n
"
,
i
);
ok
(
GetLastError
()
==
td
[
i
].
error
,
"%d: expected %d, got %d
\n
"
,
i
,
td
[
i
].
error
,
GetLastError
());
}
CloseHandle
(
hfile
);
}
else
{
ok
(
hfile
==
INVALID_HANDLE_VALUE
,
"%d: CreateFile should fail
\n
"
,
i
);
ok
(
GetLastError
()
==
td
[
i
].
error
,
"%d: expected %d, got %d
\n
"
,
i
,
td
[
i
].
error
,
GetLastError
());
}
}
if
(
td
[
i
].
clean_up
)
DeleteFile
(
file_name
);
}
DeleteFile
(
file_name
);
}
START_TEST
(
file
)
{
InitFunctionPointers
();
...
...
@@ -3166,6 +3252,7 @@ START_TEST(file)
test_GetTempFileNameA
();
test_CopyFileA
();
test_CopyFileW
();
test_CreatFile
();
test_CreateFileA
();
test_CreateFileW
();
test_DeleteFileA
();
...
...
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