renamed readable_pages to readonly_pages
[cryptodev-linux.git] / tests / testhelper.h
blobea0b100cc2ac687f3b8a7d0b3a96aaf822944b7f
1 /*
2 * Some helper stuff shared between the sample programs.
3 */
4 #ifndef _TESTHELPER_H
5 #define _TESTHELPER_H
7 /* poll until POLLOUT, then call CIOCASYNCCRYPT */
8 inline int do_async_crypt(int cfd, struct crypt_op *cryp)
10 struct pollfd pfd;
12 pfd.fd = cfd;
13 pfd.events = POLLOUT;
15 if (poll(&pfd, 1, -1) < 1) {
16 perror("poll()");
17 return 1;
20 if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) {
21 perror("ioctl(CIOCCRYPT)");
22 return 1;
24 return 0;
27 /* poll until POLLIN, then call CIOCASYNCFETCH */
28 inline int do_async_fetch(int cfd, struct crypt_op *cryp)
30 struct pollfd pfd;
32 pfd.fd = cfd;
33 pfd.events = POLLIN;
35 if (poll(&pfd, 1, -1) < 1) {
36 perror("poll()");
37 return 1;
40 if (ioctl(cfd, CIOCASYNCFETCH, cryp)) {
41 perror("ioctl(CIOCCRYPT)");
42 return 1;
44 return 0;
47 /* Check return value of stmt for identity with goodval. If they
48 * don't match, call return with the value of stmt. */
49 #define DO_OR_DIE(stmt, goodval) { \
50 int __rc_val; \
51 if ((__rc_val = stmt) != goodval) { \
52 perror("DO_OR_DIE(" #stmt "," #goodval ")"); \
53 return __rc_val; \
54 } \
57 #endif /* _TESTHELPER_H */