winscard/tests: Add test base functions of winscard.dll

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Fri May 6 06:34:33 CDT 2011


Sergey,

>+ * Unit test suite for AVI Functions
>+ * Copyright 2008 Detlef Riekenberg
+#include "wingdi.h"
>+#include "vfw.h"
Please try and hide better the copy&paste origin of the code :-)

>rezult
result

+    ok(winscard_rezult != SCARD_F_INTERNAL_ERROR
I recommend tests to be stricter, e.g.
ok(result == SCARD_S_SUCCESS || result == SCARD_E_XYZ || broken(result == SCARD_E_...)

Here's work done last year by Yauheni Baltouski and Aliaksei Hud.
They are not working on winscard any more.

I'd be pleased to eventually see winscard tests in Wine.
Maybe you could merge this work?

I *hope* I attached the latest version of the patch.  If yes, it was verified
last year to pass on:
- native machines with and without card readers;
- testbot, incl. w9x machines;
- 64 bit? can't remember;
- stock Linux (Ubuntu Lucid);
- Linux with Mounir Idrassi's winscard dll (in which case the todo_wine succeed)
  and a card reader.
It contains a good mixture of win_skip(), broken() and todo_wine to that effect.

I had not submitted these tests in the past because IIRC there's
still a resource leak (FreeLibrary following LoadLibrary;
 SCardFreeMemory following SCardListReaders AUTOALLOCATE)
and some style issues (casts inside ok("%ld") formats)
as well as IMHO too many redundant trace("testing X\n"), see $WINETEST_REPORT_SUCCESS.

In their patch,
LoadLibrary was necessary instead of a statically linked .exe because
not all native systems provide winscard.dll
Nowadays, successful tests on w9x are not considered important anymore,
so this might be superfluous (but I don't know whether one can expect
winscard on all machines since NT).

+#ifndef SCARD_AUTOALLOCATE
+#define SCARD_AUTOALLOCATE (DWORD)(-1)
+#ifndef SCARD_SCOPE_USER
+#define SCARD_SCOPE_USER 0x0000
was necessary because Wine's winscard.h does not yet provide enough definitions.
-- Completing winscard.h would be a useful patch on its own.

This test was considered the first of a series: small enough yet still doing
something useful (ListReaders), but not yet depending on the presence of a chip card.


Final comments on your initial patch:
+	    mszReaders = malloc(cchReaders);
HeapAlloc() is recommended in Wine, i.e. programming against the MS API.

+START_TEST(winscard_api)
Just name it winscard.  Keep the name short because you use it on the command line.

You don't initialize SCARD_READERSTATE as MSDN requires it for SCardGetStatusChange:
"Important  Each member of each structure in this array must be initialized to zero"
and you don't check whether SCardListReaders returned at least one string in mszReaders
for you to feed into SCardGetStatusChange.

Regards,
 Jörg Höhle



More information about the wine-devel mailing list