summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorMichael Brown2014-03-31 14:06:07 +0200
committerMichael Brown2014-03-31 14:07:43 +0200
commit7945542fb0925c6a01c8a1edb368574f39240ac2 (patch)
tree46c3d3ae478d66cb7bbf7bf04007271836e6f44f /src/tests
parent[test] Rewrite X.509 tests using okx() (diff)
downloadipxe-7945542fb0925c6a01c8a1edb368574f39240ac2.tar.gz
ipxe-7945542fb0925c6a01c8a1edb368574f39240ac2.tar.xz
ipxe-7945542fb0925c6a01c8a1edb368574f39240ac2.zip
[test] Rewrite CMS tests using okx()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cms_test.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/src/tests/cms_test.c b/src/tests/cms_test.c
index b96decfc..8767504c 100644
--- a/src/tests/cms_test.c
+++ b/src/tests/cms_test.c
@@ -1342,11 +1342,17 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug 3 23:38:31 2013 */
* Report signature parsing test result
*
* @v sgn Test signature
+ * @v file Test code file
+ * @v line Test code line
*/
-#define cms_signature_ok( sgn ) do { \
- ok ( cms_signature ( (sgn)->data, (sgn)->len, \
- &(sgn)->sig ) == 0 ); \
- } while ( 0 )
+static void cms_signature_okx ( struct cms_test_signature *sgn,
+ const char *file, unsigned int line ) {
+
+ okx ( cms_signature ( sgn->data, sgn->len, &sgn->sig ) == 0,
+ file, line );
+}
+#define cms_signature_ok( sgn ) \
+ cms_signature_okx ( sgn, __FILE__, __LINE__ )
/**
* Report signature verification test result
@@ -1357,12 +1363,22 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug 3 23:38:31 2013 */
* @v time Test verification time
* @v store Test certificate store
* @v root Test root certificate list
+ * @v file Test code file
+ * @v line Test code line
*/
-#define cms_verify_ok( sgn, code, name, time, store, root ) do { \
- x509_invalidate_chain ( (sgn)->sig->certificates ); \
- ok ( cms_verify ( (sgn)->sig, virt_to_user ( (code)->data ), \
- (code)->len, name, time, store, root ) == 0 );\
- } while ( 0 )
+static void cms_verify_okx ( struct cms_test_signature *sgn,
+ struct cms_test_code *code, const char *name,
+ time_t time, struct x509_chain *store,
+ struct x509_root *root, const char *file,
+ unsigned int line ) {
+
+ x509_invalidate_chain ( sgn->sig->certificates );
+ okx ( cms_verify ( sgn->sig, virt_to_user ( code->data ), code->len,
+ name, time, store, root ) == 0, file, line );
+}
+#define cms_verify_ok( sgn, code, name, time, store, root ) \
+ cms_verify_okx ( sgn, code, name, time, store, root, \
+ __FILE__, __LINE__ )
/**
* Report signature verification failure test result
@@ -1373,12 +1389,22 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug 3 23:38:31 2013 */
* @v time Test verification time
* @v store Test certificate store
* @v root Test root certificate list
+ * @v file Test code file
+ * @v line Test code line
*/
-#define cms_verify_fail_ok( sgn, code, name, time, store, root ) do { \
- x509_invalidate_chain ( (sgn)->sig->certificates ); \
- ok ( cms_verify ( (sgn)->sig, virt_to_user ( (code)->data ), \
- (code)->len, name, time, store, root ) != 0 );\
- } while ( 0 )
+static void cms_verify_fail_okx ( struct cms_test_signature *sgn,
+ struct cms_test_code *code, const char *name,
+ time_t time, struct x509_chain *store,
+ struct x509_root *root, const char *file,
+ unsigned int line ) {
+
+ x509_invalidate_chain ( sgn->sig->certificates );
+ okx ( cms_verify ( sgn->sig, virt_to_user ( code->data ), code->len,
+ name, time, store, root ) != 0, file, line );
+}
+#define cms_verify_fail_ok( sgn, code, name, time, store, root ) \
+ cms_verify_fail_okx ( sgn, code, name, time, store, root, \
+ __FILE__, __LINE__ )
/**
* Perform CMS self-tests