summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2014-04-05 02:01:33 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-04-05 02:01:33 +0200
commit6931967cb2196061cdcacdb1fb04fca3dc56e1c8 (patch)
tree80850ab05255e5b1fb55dd1c1b1380cb1553b639 /tests
parentbd5a6936fbefd222f63d7442f1e6809403eebe75 (diff)
downloadgnutls-6931967cb2196061cdcacdb1fb04fca3dc56e1c8.tar.gz
updated test to run in more systems.
Diffstat (limited to 'tests')
-rw-r--r--tests/suite/pkcs11-chainverify.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/suite/pkcs11-chainverify.c b/tests/suite/pkcs11-chainverify.c
index b250b1269c..845cfefc56 100644
--- a/tests/suite/pkcs11-chainverify.c
+++ b/tests/suite/pkcs11-chainverify.c
@@ -67,12 +67,16 @@ int pin_func(void* userdata, int attempt, const char* url, const char *label,
return -1;
}
+#define LIB1 "/usr/lib64/softhsm/libsofthsm.so"
+#define LIB2 "/usr/lib/softhsm/libsofthsm.so"
+
void doit(void)
{
int exit_val = 0;
size_t i;
int ret;
FILE *fp;
+ const char *lib;
/* The overloading of time() seems to work in linux (ELF?)
* systems only. Disable it on windows.
@@ -81,11 +85,21 @@ void doit(void)
exit(77);
#endif
- if (access("/usr/bin/softhsm", X_OK) < 0 ||
- access("/usr/lib64/softhsm/libsofthsm.so", X_OK) < 0) {
+ if (access("/usr/bin/softhsm", X_OK) < 0) {
+ fprintf(stderr, "cannot find softhsm binary\n");
+ exit(77);
+ }
+
+ if (access(LIB1, R_OK) == 0) {
+ lib = LIB1;
+ } else if (access(LIB2, R_OK) == 0) {
+ lib = LIB2;
+ } else {
+ fprintf(stderr, "cannot find softhsm module\n");
exit(77);
}
+
ret = global_init();
if (ret != 0) {
fail("%d: %s\n", ret, gnutls_strerror(ret));
@@ -108,10 +122,10 @@ void doit(void)
fclose(fp);
setenv("SOFTHSM_CONF", "softhsm.config", 0);
-
+
system("softhsm --init-token --slot 0 --label test --so-pin 1234 --pin 1234");
- ret = gnutls_pkcs11_add_provider("/usr/lib64/softhsm/libsofthsm.so", "trusted");
+ ret = gnutls_pkcs11_add_provider(lib, "trusted");
if (ret < 0) {
fprintf(stderr, "gnutls_x509_crt_init: %s\n",
gnutls_strerror(ret));