diff options
author | daniel <danieruru@gmail.com> | 2013-01-09 14:25:02 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-09 14:25:02 +0900 |
commit | 4d177908c1c68bedb01fb0c9146b06b249fd1b5e (patch) | |
tree | 8eb50b1e99b133bb4ad404d4f7cea11def3f7a34 /libvxi11client/client.c | |
parent | ee9413282d02d936185dc88a34bb817a1a273e6d (diff) |
More clean ups, add some more tests
Diffstat (limited to 'libvxi11client/client.c')
-rw-r--r-- | libvxi11client/client.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c index eb224f2..799df57 100644 --- a/libvxi11client/client.c +++ b/libvxi11client/client.c @@ -7,8 +7,14 @@ static char* geterrorstring(int errorcode) { switch (errorcode) { case 0: return "invalid state (not connected) or no response from server"; + case -4: + return "invalid link identifier"; case -8: return "operation not supported"; + case -11: + return "device locked by another link"; + case -12: + return "no lock held by this link"; default: return "unknown error code"; } @@ -27,6 +33,10 @@ int main(int argc, char *argv[]) { if ((err = vxi11_open(argv[1], NULL)) > 0) { + /** + * Basic tests + */ + // write some bytes int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY), false); if (byteswritten >= 0) @@ -78,6 +88,41 @@ int main(int argc, char *argv[]) { else printf("Error reading status byte\n"); + /** + * Locking tests + */ + + // try locking twice + printf("-- Locking twice --\n"); + if ((err = vxi11_lock()) > 0) { + printf("locked\n"); + if ((err = vxi11_lock()) > 0) { + printf("locked again!!\n"); + exit(1); + } + else { + printf("Second lock failed; %s\n", geterrorstring(err)); + } + } + if ((err = vxi11_unlock()) > 0) + printf("unlocked\n"); + else { + printf("error unlocking; %s\n", geterrorstring(err)); + exit(1); + } + + printf("\n"); + + // try unlocking unlocked device + printf("-- Unlocking when unlocked --\n"); + if ((err = vxi11_unlock()) > 0) { + printf("Unlocked!!\n"); + exit(1); + } + else + printf("error unlocking; %s\n", geterrorstring(err)); + printf("\n"); + // create interrupt channel err = vxi11_create_intr_chan(); |