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
e8449e60
Commit
e8449e60
authored
May 09, 2002
by
Jakob Eriksson
Committed by
Alexandre Julliard
May 09, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some more tests.
parent
b06116e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
14 deletions
+136
-14
file.c
dlls/kernel/tests/file.c
+136
-14
No files found.
dlls/kernel/tests/file.c
View file @
e8449e60
/*
* Unit tests for file functions
* Unit tests for file functions
in Wine
*
* Copyright 2002 Jakob Eriksson
* Copyright
(c)
2002 Jakob Eriksson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -16,12 +16,14 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "winbase.h"
#include "winerror.h"
#include "wine/test.h"
#include <stdlib.h>
#include <time.h>
...
...
@@ -39,12 +41,13 @@ LPCSTR sillytext =
"1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
"sdlkfjasdlkfj a dslkj adsklf
\n
\n
asdklf askldfa sdlkf
\n
sadklf asdklf asdf "
;
static
void
test__hread
(
void
)
{
HFILE
filehandle
;
char
buffer
[
10000
];
long
bytes_read
;
UINT
bytes_wanted
;
long
bytes_wanted
;
UINT
i
;
filehandle
=
_lcreat
(
filename
,
0
);
...
...
@@ -77,6 +80,7 @@ static void test__hread( void )
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFile complains."
);
}
static
void
test__hwrite
(
void
)
{
HFILE
filehandle
;
...
...
@@ -155,6 +159,7 @@ static void test__hwrite( void )
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFile complains."
);
}
static
void
test__lclose
(
void
)
{
HFILE
filehandle
;
...
...
@@ -198,9 +203,7 @@ static void test__lcreat( void )
filehandle
=
_lcreat
(
filename
,
1
);
ok
(
HFILE_ERROR
!=
filehandle
,
"couldn't create file!?"
);
#if 0 /* FIXME: this fails on NT too */
ok( HFILE_ERROR == _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't succeed writing." );
#endif
ok
(
HFILE_ERROR
!=
_hwrite
(
filehandle
,
sillytext
,
strlen
(
sillytext
)
),
"_hwrite shouldn't be able to write never the less."
);
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
...
...
@@ -227,7 +230,6 @@ static void test__lcreat( void )
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFileA complains."
);
filehandle
=
_lcreat
(
filename
,
4
);
ok
(
HFILE_ERROR
!=
filehandle
,
"couldn't create file. Wrong permissions on directory?"
);
...
...
@@ -273,16 +275,14 @@ void test__llseek( void )
bytes_read
=
_hread
(
filehandle
,
buffer
,
1
);
ok
(
1
==
bytes_read
,
"file read size error."
);
ok
(
buffer
[
0
]
==
sillytext
[
0
],
"_llseek error. It got lost seeking..."
);
#if 0 /* FIXME: this fails on NT too */
ok( HFILE_ERROR == _llseek( filehandle, 1000000, FILE_END ), "should get HFILE_ERROR for trying to seek past end of file" );
#endif
ok
(
HFILE_ERROR
!=
_llseek
(
filehandle
,
1000000
,
FILE_END
),
"should be able to seek past file. Poor, poor Windows programmers."
);
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFileA complains."
);
}
void
test__llopen
(
void
)
static
void
test__llopen
(
void
)
{
HFILE
filehandle
;
UINT
bytes_read
;
...
...
@@ -311,9 +311,129 @@ void test__llopen( void )
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFileA complains."
);
/* TODO - add tests for the SHARE modes - use two processes to pull this off */
/* TODO - add tests for the SHARE modes - use two processes to pull this one off */
}
static
void
test__lread
(
void
)
{
HFILE
filehandle
;
char
buffer
[
10000
];
long
bytes_read
;
UINT
bytes_wanted
;
UINT
i
;
filehandle
=
_lcreat
(
filename
,
0
);
ok
(
HFILE_ERROR
!=
filehandle
,
"couldn't create file. Wrong permissions on directory?"
);
ok
(
HFILE_ERROR
!=
_hwrite
(
filehandle
,
sillytext
,
strlen
(
sillytext
)
),
"_hwrite complains."
);
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
filehandle
=
_lopen
(
filename
,
OF_READ
);
ok
(
HFILE_ERROR
!=
filehandle
,
"couldn't open file again?"
);
bytes_read
=
_lread
(
filehandle
,
buffer
,
2
*
strlen
(
sillytext
)
);
ok
(
strlen
(
sillytext
)
==
bytes_read
,
"file read size error."
);
for
(
bytes_wanted
=
0
;
bytes_wanted
<
strlen
(
sillytext
);
bytes_wanted
++
)
{
ok
(
0
==
_llseek
(
filehandle
,
0
,
FILE_BEGIN
),
"_llseek complains."
);
ok
(
_lread
(
filehandle
,
buffer
,
bytes_wanted
)
==
bytes_wanted
,
"erratic _hread return value."
);
for
(
i
=
0
;
i
<
bytes_wanted
;
i
++
)
{
ok
(
buffer
[
i
]
==
sillytext
[
i
],
"that's not what's written."
);
}
}
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFile complains."
);
}
static
void
test__lwrite
(
void
)
{
HFILE
filehandle
;
char
buffer
[
10000
];
long
bytes_read
;
UINT
bytes_written
;
UINT
blocks
;
UINT
i
;
char
*
contents
;
HLOCAL
memory_object
;
char
checksum
[
1
];
filehandle
=
_lcreat
(
filename
,
0
);
ok
(
HFILE_ERROR
!=
filehandle
,
"couldn't create file. Wrong permissions on directory?"
);
ok
(
HFILE_ERROR
!=
_lwrite
(
filehandle
,
""
,
0
),
"_hwrite complains."
);
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
filehandle
=
_lopen
(
filename
,
OF_READ
);
bytes_read
=
_hread
(
filehandle
,
buffer
,
1
);
ok
(
0
==
bytes_read
,
"file read size error."
);
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
filehandle
=
_lopen
(
filename
,
OF_READWRITE
);
bytes_written
=
0
;
checksum
[
0
]
=
'\0'
;
srand
(
(
unsigned
)
time
(
NULL
)
);
for
(
blocks
=
0
;
blocks
<
100
;
blocks
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
buffer
);
i
++
)
{
buffer
[
i
]
=
rand
(
);
checksum
[
0
]
=
checksum
[
0
]
+
buffer
[
i
];
}
ok
(
HFILE_ERROR
!=
_lwrite
(
filehandle
,
buffer
,
sizeof
(
buffer
)
),
"_hwrite complains."
);
bytes_written
=
bytes_written
+
sizeof
(
buffer
);
}
ok
(
HFILE_ERROR
!=
_lwrite
(
filehandle
,
checksum
,
1
),
"_hwrite complains."
);
bytes_written
++
;
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
memory_object
=
LocalAlloc
(
LPTR
,
bytes_written
);
ok
(
0
!=
memory_object
,
"LocalAlloc fails. (Could be out of memory.)"
);
contents
=
LocalLock
(
memory_object
);
filehandle
=
_lopen
(
filename
,
OF_READ
);
contents
=
LocalLock
(
memory_object
);
ok
(
NULL
!=
contents
,
"LocalLock whines."
);
ok
(
bytes_written
==
_hread
(
filehandle
,
contents
,
bytes_written
),
"read length differ from write length."
);
checksum
[
0
]
=
'\0'
;
i
=
0
;
do
{
checksum
[
0
]
=
checksum
[
0
]
+
contents
[
i
];
i
++
;
}
while
(
i
<
bytes_written
-
1
);
ok
(
checksum
[
0
]
==
contents
[
i
],
"stored checksum differ from computed checksum."
);
return
;
ok
(
HFILE_ERROR
!=
_lclose
(
filehandle
),
"_lclose complains."
);
ok
(
DeleteFileA
(
filename
)
!=
0
,
"DeleteFile complains."
);
}
START_TEST
(
file
)
{
test__hread
(
);
...
...
@@ -322,4 +442,6 @@ START_TEST(file)
test__lcreat
(
);
test__llseek
(
);
test__llopen
(
);
test__lread
(
);
test__lwrite
(
);
}
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