diff options
author | Stef Walter <stef@thewalter.net> | 2013-07-23 14:53:53 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2013-07-23 23:06:27 +0200 |
commit | b7cc29a78c3c705374ff25223fe14749ddb076b9 (patch) | |
tree | 4d9ec4586d19ed2230f4bdbb2a2e1887f7b254a4 /trust | |
parent | 4d04cfdf2ac078cc4a95ff9a145f0045e074470b (diff) |
Use simple serial automake test harness
* Add a testing sanity check to see if we're catching errors
* Fix a few other testing issues
Diffstat (limited to 'trust')
-rw-r--r-- | trust/builder.c | 2 | ||||
-rw-r--r-- | trust/tests/test-builder.c | 12 | ||||
-rw-r--r-- | trust/token.c | 3 |
3 files changed, 11 insertions, 6 deletions
diff --git a/trust/builder.c b/trust/builder.c index 038fc88..2daadb3 100644 --- a/trust/builder.c +++ b/trust/builder.c @@ -240,7 +240,7 @@ type_date (p11_builder *builder, date = attr->pValue; memset (&tm, 0, sizeof (tm)); - tm.tm_year = atoin ((char *)date->year, 4); + tm.tm_year = atoin ((char *)date->year, 4) - 1900; tm.tm_mon = atoin ((char *)date->month, 2); tm.tm_mday = atoin ((char *)date->day, 2); diff --git a/trust/tests/test-builder.c b/trust/tests/test-builder.c index 6f9fdcc..1d37924 100644 --- a/trust/tests/test-builder.c +++ b/trust/tests/test-builder.c @@ -760,7 +760,9 @@ test_valid_dates (void) { CKA_INVALID }, }; - memcpy (&date, "20001010", sizeof (date)); + memcpy (date.year, "2000", sizeof (date.year)); + memcpy (date.month, "10", sizeof (date.month)); + memcpy (date.day, "10", sizeof (date.day)); rv = p11_builder_build (test.builder, test.index, attrs, input, &extra); assert_num_eq (CKR_OK, rv); @@ -791,11 +793,15 @@ test_invalid_dates (void) p11_message_quiet (); - memcpy (&date, "AAAABBCC", sizeof (date)); + memcpy (date.year, "AAAA", sizeof (date.year)); + memcpy (date.month, "BB", sizeof (date.month)); + memcpy (date.day, "CC", sizeof (date.day)); rv = p11_builder_build (test.builder, test.index, attrs, input, &extra); assert_num_eq (CKR_ATTRIBUTE_VALUE_INVALID, rv); - memcpy (&date, "20001580", sizeof (date)); + memcpy (date.year, "2000", sizeof (date.year)); + memcpy (date.month, "15", sizeof (date.month)); + memcpy (date.day, "80", sizeof (date.day)); rv = p11_builder_build (test.builder, test.index, attrs, input, &extra); assert_num_eq (CKR_ATTRIBUTE_VALUE_INVALID, rv); diff --git a/trust/token.c b/trust/token.c index d2a12d0..97b1fc0 100644 --- a/trust/token.c +++ b/trust/token.c @@ -225,9 +225,8 @@ loader_load_if_file (p11_token *token, struct stat sb; if (stat (path, &sb) < 0) { - if (errno == ENOENT) { + if (errno != ENOENT) p11_message_err (errno, "couldn't stat path: %s", path); - } } else if (!S_ISDIR (sb.st_mode)) { return loader_load_file (token, path, &sb); |