summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-04-05 16:03:07 +0200
committerDaiki Ueno <ueno@gnu.org>2018-04-06 18:27:24 +0200
commitaf6ab322b1ad9a4f4a0117a79bd566550ec0a0a8 (patch)
tree0f858b191f11898673d92bc31390a101116581c4
parent843fca9b67b7407a47bcae698f434c975a4a4e91 (diff)
test: Add test for p11_attrs_purge()
-rw-r--r--common/test-attrs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/test-attrs.c b/common/test-attrs.c
index 79895e2..bc588c8 100644
--- a/common/test-attrs.c
+++ b/common/test-attrs.c
@@ -564,6 +564,34 @@ test_remove (void)
}
static void
+test_purge (void)
+{
+ CK_BBOOL vtrue = CK_TRUE;
+ CK_ATTRIBUTE *attr;
+ CK_ATTRIBUTE *attrs;
+
+ CK_ATTRIBUTE initial[] = {
+ { CKA_LABEL, "label", 5 },
+ { CKA_TOKEN, &vtrue, sizeof (vtrue) },
+ };
+
+ attrs = p11_attrs_buildn (NULL, initial, 2);
+ assert_ptr_not_null (attrs);
+
+ attr = p11_attrs_find (attrs, CKA_LABEL);
+ assert_ptr_eq (attrs + 0, attr);
+
+ attr[0].ulValueLen = (CK_ULONG) -1;
+
+ p11_attrs_purge (attrs);
+
+ attr = p11_attrs_find (attrs, CKA_LABEL);
+ assert_ptr_eq (NULL, attr);
+
+ p11_attrs_free (attrs);
+}
+
+static void
test_match (void)
{
CK_BBOOL vtrue = CK_TRUE;
@@ -753,5 +781,6 @@ main (int argc,
p11_test (test_find_value, "/attrs/find-value");
p11_test (test_find_valid, "/attrs/find-valid");
p11_test (test_remove, "/attrs/remove");
+ p11_test (test_purge, "/attrs/purge");
return p11_test_run (argc, argv);
}