kernel32/tests: Add test for FindFirstFileA()

Dmitry Timoshkov dmitry at baikal.ru
Thu Feb 6 04:55:29 CST 2014


Zhenbo Li <litimetal at gmail.com> wrote:

> >> +    strcpy(buffer2, nonexistent);
> >> +    handle = CreateFileA(buffer2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
> >
> > There is no need for a strcpy().
> Well, I'll add more tests later(like trailing \\).

strcpy() could be added later when new tests get added.

> >> +    ok(handle != INVALID_HANDLE_VALUE, "failed to create a file\n");
> >> +    handle = FindFirstFileA(buffer2, &data);
> >> +    ok(handle != FindFirstFileA, "failed to find an existent file\n");
> >
> > It would be useful to actually test what FindFirstFileA() returns.
> > Also not leaking the handle *twice* would be a bonus point.
> Thank you for mentioning that.
> Most of the previous testcases leak the handle.
> After this patch, is it necessary to fix them?

Every handle leak is bad on its own, and may lead to unwanted side
effects like inability to destroy an object or delete a file.

Another thing that could be improved in this test is printing last error
code in the failure message. Also you may find that making failure messages
shorter and simpler makes your life a bit easier. For axample:
"CreateFile(%s) error %d\n", name, GetLastError()
and
"FindFirstFile(%s) error %d\n", name, GetLastError()

-- 
Dmitry.



More information about the wine-devel mailing list