summaryrefslogtreecommitdiff
path: root/trust/tests
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-03-20 10:55:06 +0100
committerStef Walter <stefw@gnome.org>2013-03-20 10:55:06 +0100
commitfc562261c6bbb35dfed585a78fdec9a408b981c7 (patch)
treec6afefe98a5251ce10eab6289a655485e0b5bec8 /trust/tests
parentf45942a4fc3e1c5219e9b5201b82203337ee7280 (diff)
attrs: Print out the CKA_VALUE for certificates when debugging
While it's true that we shouldn't be pritning out CKA_VALUE in certain cases, like for keys, we obviously can do so for certificates. We don't have keys anyway, but in the interest of being general purpose use the class to determine whether CKA_VALUE can be printed
Diffstat (limited to 'trust/tests')
-rw-r--r--trust/tests/test-data.c15
-rw-r--r--trust/tests/test-data.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/trust/tests/test-data.c b/trust/tests/test-data.c
index b235f33..6c55fd0 100644
--- a/trust/tests/test-data.c
+++ b/trust/tests/test-data.c
@@ -104,7 +104,7 @@ test_check_id_msg (CuTest *cu,
one = p11_attrs_find (expected, CKA_ID);
two = p11_attrs_find (attr, CKA_ID);
- test_check_attr_msg (cu, file, line, one, two);
+ test_check_attr_msg (cu, file, line, CKA_INVALID, one, two);
}
void
@@ -114,11 +114,15 @@ test_check_attrs_msg (CuTest *cu,
CK_ATTRIBUTE *expected,
CK_ATTRIBUTE *attrs)
{
+ CK_OBJECT_CLASS klass;
CK_ATTRIBUTE *attr;
+ if (!p11_attrs_find_ulong (expected, CKA_CLASS, &klass))
+ klass = CKA_INVALID;
+
while (!p11_attrs_terminator (expected)) {
attr = p11_attrs_find (attrs, expected->type);
- test_check_attr_msg (cu, file, line, expected, attr);
+ test_check_attr_msg (cu, file, line, klass, expected, attr);
expected++;
}
}
@@ -127,6 +131,7 @@ void
test_check_attr_msg (CuTest *cu,
const char *file,
int line,
+ CK_OBJECT_CLASS klass,
CK_ATTRIBUTE *expected,
CK_ATTRIBUTE *attr)
{
@@ -135,14 +140,14 @@ test_check_attr_msg (CuTest *cu,
if (attr == NULL) {
asprintf (&message, "expected %s but found NULL",
- p11_attr_to_string (expected));
+ p11_attr_to_string (expected, klass));
CuFail_Line (cu, file, line, "attribute does not match", message);
}
if (!p11_attr_equal (attr, expected)) {
asprintf (&message, "expected %s but found %s",
- p11_attr_to_string (expected),
- p11_attr_to_string (attr));
+ p11_attr_to_string (expected, klass),
+ p11_attr_to_string (attr, klass));
CuFail_Line (cu, file, line, "attribute does not match", message);
}
}
diff --git a/trust/tests/test-data.h b/trust/tests/test-data.h
index 9daff87..275dd70 100644
--- a/trust/tests/test-data.h
+++ b/trust/tests/test-data.h
@@ -68,11 +68,12 @@ void test_check_attrs_msg (CuTest *cu,
CK_ATTRIBUTE *attrs);
#define test_check_attr(cu, expected, attr) \
- test_check_attr_msg (cu, __FILE__, __LINE__, expected, attr)
+ test_check_attr_msg (cu, __FILE__, __LINE__, CKA_INVALID, expected, attr)
void test_check_attr_msg (CuTest *cu,
const char *file,
int line,
+ CK_OBJECT_CLASS klass,
CK_ATTRIBUTE *expected,
CK_ATTRIBUTE *attr);