Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
77fdfdb8
Commit
77fdfdb8
authored
Feb 16, 2023
by
Hans Leidekker
Committed by
Alexandre Julliard
Feb 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winscard/tests: Initial tests.
parent
190a31d1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
244 additions
and
0 deletions
+244
-0
configure
configure
+1
-0
configure.ac
configure.ac
+1
-0
Makefile.in
dlls/winscard/tests/Makefile.in
+5
-0
winscard.c
dlls/winscard/tests/winscard.c
+237
-0
No files found.
configure
View file @
77fdfdb8
...
@@ -21863,6 +21863,7 @@ wine_fn_config_makefile dlls/winnls.dll16 enable_win16
...
@@ -21863,6 +21863,7 @@ wine_fn_config_makefile dlls/winnls.dll16 enable_win16
wine_fn_config_makefile dlls/winnls32 enable_winnls32
wine_fn_config_makefile dlls/winnls32 enable_winnls32
wine_fn_config_makefile dlls/winprint enable_winprint
wine_fn_config_makefile dlls/winprint enable_winprint
wine_fn_config_makefile dlls/winscard enable_winscard
wine_fn_config_makefile dlls/winscard enable_winscard
wine_fn_config_makefile dlls/winscard/tests enable_tests
wine_fn_config_makefile dlls/winsock.dll16 enable_win16
wine_fn_config_makefile dlls/winsock.dll16 enable_win16
wine_fn_config_makefile dlls/winspool.drv enable_winspool_drv
wine_fn_config_makefile dlls/winspool.drv enable_winspool_drv
wine_fn_config_makefile dlls/winspool.drv/tests enable_tests
wine_fn_config_makefile dlls/winspool.drv/tests enable_tests
...
...
configure.ac
View file @
77fdfdb8
...
@@ -3176,6 +3176,7 @@ WINE_CONFIG_MAKEFILE(dlls/winnls.dll16,enable_win16)
...
@@ -3176,6 +3176,7 @@ WINE_CONFIG_MAKEFILE(dlls/winnls.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/winnls32)
WINE_CONFIG_MAKEFILE(dlls/winnls32)
WINE_CONFIG_MAKEFILE(dlls/winprint)
WINE_CONFIG_MAKEFILE(dlls/winprint)
WINE_CONFIG_MAKEFILE(dlls/winscard)
WINE_CONFIG_MAKEFILE(dlls/winscard)
WINE_CONFIG_MAKEFILE(dlls/winscard/tests)
WINE_CONFIG_MAKEFILE(dlls/winsock.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/winsock.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/winspool.drv)
WINE_CONFIG_MAKEFILE(dlls/winspool.drv)
WINE_CONFIG_MAKEFILE(dlls/winspool.drv/tests)
WINE_CONFIG_MAKEFILE(dlls/winspool.drv/tests)
...
...
dlls/winscard/tests/Makefile.in
0 → 100644
View file @
77fdfdb8
TESTDLL
=
winscard.dll
IMPORTS
=
winscard
C_SRCS
=
\
winscard.c
dlls/winscard/tests/winscard.c
0 → 100644
View file @
77fdfdb8
/*
* Unit test for winscard functions
*
* Copyright 2022 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <windows.h>
#include <winscard.h>
#include "wine/test.h"
static
void
test_SCardEstablishContext
(
void
)
{
const
BYTE
cmd
[]
=
{
0x00
,
0xca
,
0x01
,
0x86
,
0x00
};
SCARDCONTEXT
context
;
SCARDHANDLE
connect
;
SCARD_READERSTATEA
states
[
2
];
SCARD_IO_REQUEST
send_pci
=
{
SCARD_PROTOCOL_T1
,
8
},
recv_pci
=
{
SCARD_PROTOCOL_T1
,
8
};
char
*
readers
,
*
groups
,
*
ptr
;
WCHAR
*
names
,
*
ptrW
;
BYTE
buf
[
32
],
recv_buf
[
264
],
*
atr
,
*
attr
;
DWORD
len
,
atrlen
,
state
,
protocol
;
LONG
ret
;
ret
=
SCardEstablishContext
(
0
,
NULL
,
NULL
,
NULL
);
ok
(
ret
==
SCARD_E_INVALID_PARAMETER
,
"got %lx
\n
"
,
ret
);
ret
=
SCardEstablishContext
(
0
,
NULL
,
NULL
,
&
context
);
if
(
ret
==
SCARD_E_NO_SERVICE
)
{
skip
(
"can't establish context, make sure pcscd is running
\n
"
);
return
;
}
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardIsValidContext
(
context
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
len
=
0
;
ret
=
SCardListReadersA
(
context
,
NULL
,
NULL
,
&
len
);
if
(
ret
==
SCARD_E_NO_READERS_AVAILABLE
)
{
skip
(
"connect a smart card device to run more tests
\n
"
);
return
;
}
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
len
,
"got zero length
\n
"
);
readers
=
calloc
(
1
,
len
);
ret
=
SCardListReadersA
(
context
,
NULL
,
readers
,
NULL
);
ok
(
ret
==
SCARD_E_INVALID_PARAMETER
,
"got %lx
\n
"
,
ret
);
ret
=
SCardListReadersA
(
context
,
NULL
,
readers
,
&
len
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ptr
=
readers
;
while
(
*
ptr
)
{
trace
(
"found reader: %s
\n
"
,
wine_dbgstr_a
(
ptr
)
);
ptr
+=
strlen
(
ptr
)
+
1
;
}
len
=
0
;
ret
=
SCardListReaderGroupsA
(
context
,
NULL
,
&
len
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
len
,
"got zero length
\n
"
);
groups
=
calloc
(
1
,
len
);
ret
=
SCardListReaderGroupsA
(
context
,
groups
,
&
len
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ptr
=
groups
;
while
(
*
ptr
)
{
trace
(
"found group: %s
\n
"
,
wine_dbgstr_a
(
ptr
)
);
ptr
+=
strlen
(
ptr
)
+
1
;
}
free
(
groups
);
ret
=
SCardGetStatusChangeW
(
context
,
1000
,
NULL
,
0
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
memset
(
states
,
0
,
sizeof
(
states
)
);
states
[
0
].
szReader
=
"
\\\\
?PnP?
\\
Notification"
;
states
[
1
].
szReader
=
readers
;
ret
=
SCardGetStatusChangeA
(
context
,
1000
,
states
,
2
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
states
[
1
].
dwCurrentState
=
states
[
1
].
dwEventState
&
~
SCARD_STATE_CHANGED
;
ret
=
SCardGetStatusChangeA
(
context
,
1000
,
states
,
2
);
todo_wine
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardConnectA
(
context
,
readers
,
SCARD_SHARE_SHARED
,
SCARD_PROTOCOL_Tx
,
&
connect
,
NULL
);
if
(
ret
==
SCARD_E_READER_UNAVAILABLE
)
{
skip
(
"can't connect to reader %s (in use by other application?)
\n
"
,
wine_dbgstr_a
(
readers
)
);
free
(
readers
);
return
;
}
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
connect
=
0xdeadbeef
;
protocol
=
0xdeadbeef
;
ret
=
SCardConnectA
(
context
,
readers
,
SCARD_SHARE_SHARED
,
SCARD_PROTOCOL_Tx
,
&
connect
,
&
protocol
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
connect
!=
0xdeadbeef
,
"connect not set
\n
"
);
ok
(
protocol
==
SCARD_PROTOCOL_T1
,
"got %lx
\n
"
,
protocol
);
free
(
readers
);
len
=
atrlen
=
0
;
state
=
0xdeadbeef
;
protocol
=
0xdeadbeef
;
ret
=
SCardStatusW
(
connect
,
NULL
,
&
len
,
&
state
,
&
protocol
,
NULL
,
&
atrlen
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
len
,
"got zero length
\n
"
);
ok
(
state
!=
0xdeadbeef
,
"state not set
\n
"
);
ok
(
protocol
==
SCARD_PROTOCOL_T1
,
"got %lx
\n
"
,
protocol
);
ok
(
atrlen
,
"got zero length
\n
"
);
names
=
calloc
(
1
,
len
*
sizeof
(
WCHAR
)
);
atr
=
calloc
(
1
,
atrlen
);
state
=
protocol
=
0xdeadbeef
;
ret
=
SCardStatusW
(
connect
,
names
,
&
len
,
&
state
,
&
protocol
,
atr
,
&
atrlen
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
state
!=
0xdeadbeef
,
"state not set
\n
"
);
ok
(
protocol
==
SCARD_PROTOCOL_T1
,
"got %lx
\n
"
,
protocol
);
ptrW
=
names
;
while
(
*
ptrW
)
{
trace
(
"found name: %s
\n
"
,
wine_dbgstr_w
(
ptrW
)
);
ptrW
+=
wcslen
(
ptrW
)
+
1
;
}
ret
=
SCardStatusW
(
connect
,
names
,
&
len
,
&
state
,
&
protocol
,
NULL
,
NULL
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardStatusW
(
connect
,
NULL
,
NULL
,
&
state
,
&
protocol
,
NULL
,
NULL
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardStatusW
(
connect
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
free
(
names
);
free
(
atr
);
ret
=
SCardBeginTransaction
(
connect
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardEndTransaction
(
connect
,
0
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardReconnect
(
connect
,
SCARD_SHARE_SHARED
,
SCARD_PROTOCOL_Tx
,
SCARD_LEAVE_CARD
,
NULL
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
protocol
=
0xdeadbeef
;
ret
=
SCardReconnect
(
connect
,
SCARD_SHARE_SHARED
,
SCARD_PROTOCOL_Tx
,
SCARD_LEAVE_CARD
,
&
protocol
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
protocol
==
SCARD_PROTOCOL_T1
,
"got %lx
\n
"
,
protocol
);
len
=
0
;
ret
=
SCardGetAttrib
(
connect
,
SCARD_ATTR_VENDOR_NAME
,
NULL
,
&
len
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
len
,
"got zero length
\n
"
);
attr
=
calloc
(
1
,
len
);
ret
=
SCardGetAttrib
(
connect
,
SCARD_ATTR_VENDOR_NAME
,
attr
,
&
len
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardGetAttrib
(
connect
,
SCARD_ATTR_VENDOR_NAME
,
attr
,
NULL
);
ok
(
ret
==
SCARD_E_INVALID_PARAMETER
,
"got %lx
\n
"
,
ret
);
free
(
attr
);
ret
=
SCardBeginTransaction
(
connect
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
send_pci
.
dwProtocol
=
recv_pci
.
dwProtocol
=
protocol
;
memset
(
recv_buf
,
0
,
sizeof
(
recv_buf
)
);
ret
=
SCardTransmit
(
connect
,
&
send_pci
,
cmd
,
sizeof
(
cmd
),
&
recv_pci
,
recv_buf
,
NULL
);
ok
(
ret
==
SCARD_E_INVALID_PARAMETER
,
"got %lx (%lu)
\n
"
,
ret
,
ret
);
len
=
sizeof
(
recv_buf
);
ret
=
SCardTransmit
(
connect
,
&
send_pci
,
cmd
,
sizeof
(
cmd
),
&
recv_pci
,
recv_buf
,
&
len
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx (%lu)
\n
"
,
ret
,
ret
);
ret
=
SCardEndTransaction
(
connect
,
0
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
buf
[
0
]
=
0x02
;
ret
=
SCardControl
(
connect
,
SCARD_CTL_CODE
(
1
),
buf
,
1
,
buf
,
sizeof
(
buf
),
NULL
);
ok
(
ret
==
SCARD_E_INVALID_PARAMETER
,
"got %lx
\n
"
,
ret
);
len
=
sizeof
(
buf
);
ret
=
SCardControl
(
connect
,
SCARD_CTL_CODE
(
1
),
buf
,
1
,
buf
,
sizeof
(
buf
),
&
len
);
todo_wine
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
todo_wine
ok
(
!
len
,
"got %lu
\n
"
,
len
);
ret
=
SCardDisconnect
(
connect
,
0
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardDisconnect
(
0
,
0
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"got %lx
\n
"
,
ret
);
ret
=
SCardCancel
(
context
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardCancel
(
0
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"got %lx
\n
"
,
ret
);
ret
=
SCardIsValidContext
(
context
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardReleaseContext
(
0
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"got %lx
\n
"
,
ret
);
ret
=
SCardReleaseContext
(
context
);
ok
(
ret
==
SCARD_S_SUCCESS
,
"got %lx
\n
"
,
ret
);
ret
=
SCardIsValidContext
(
context
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"got %lx
\n
"
,
ret
);
ret
=
SCardIsValidContext
(
0
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"got %lx
\n
"
,
ret
);
}
START_TEST
(
winscard
)
{
test_SCardEstablishContext
();
}
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