Browse Source

[test] Rewrite CMS tests using okx()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
7945542fb0
1 changed files with 40 additions and 14 deletions
  1. 40
    14
      src/tests/cms_test.c

+ 40
- 14
src/tests/cms_test.c View File

1342
  * Report signature parsing test result
1342
  * Report signature parsing test result
1343
  *
1343
  *
1344
  * @v sgn		Test signature
1344
  * @v sgn		Test signature
1345
+ * @v file		Test code file
1346
+ * @v line		Test code line
1345
  */
1347
  */
1346
-#define cms_signature_ok( sgn ) do {					\
1348
+static void cms_signature_okx ( struct cms_test_signature *sgn,
1347
-	ok ( cms_signature ( (sgn)->data, (sgn)->len,			\
1349
+				const char *file, unsigned int line ) {
1348
-			     &(sgn)->sig ) == 0 );			\
1350
+
1349
-	} while ( 0 )
1351
+	okx ( cms_signature ( sgn->data, sgn->len, &sgn->sig ) == 0,
1352
+	      file, line );
1353
+}
1354
+#define cms_signature_ok( sgn ) \
1355
+	cms_signature_okx ( sgn, __FILE__, __LINE__ )
1350
 
1356
 
1351
 /**
1357
 /**
1352
  * Report signature verification test result
1358
  * Report signature verification test result
1357
  * @v time		Test verification time
1363
  * @v time		Test verification time
1358
  * @v store		Test certificate store
1364
  * @v store		Test certificate store
1359
  * @v root		Test root certificate list
1365
  * @v root		Test root certificate list
1366
+ * @v file		Test code file
1367
+ * @v line		Test code line
1360
  */
1368
  */
1361
-#define cms_verify_ok( sgn, code, name, time, store, root ) do {	\
1369
+static void cms_verify_okx ( struct cms_test_signature *sgn,
1362
-	x509_invalidate_chain ( (sgn)->sig->certificates );		\
1370
+			     struct cms_test_code *code, const char *name,
1363
-	ok ( cms_verify ( (sgn)->sig, virt_to_user ( (code)->data ),	\
1371
+			     time_t time, struct x509_chain *store,
1364
-			  (code)->len, name, time, store, root ) == 0 );\
1372
+			     struct x509_root *root, const char *file,
1365
-	} while ( 0 )
1373
+			     unsigned int line ) {
1374
+
1375
+	x509_invalidate_chain ( sgn->sig->certificates );
1376
+	okx ( cms_verify ( sgn->sig, virt_to_user ( code->data ), code->len,
1377
+			   name, time, store, root ) == 0, file, line );
1378
+}
1379
+#define cms_verify_ok( sgn, code, name, time, store, root )		\
1380
+	cms_verify_okx ( sgn, code, name, time, store, root,		\
1381
+			 __FILE__, __LINE__ )
1366
 
1382
 
1367
 /**
1383
 /**
1368
  * Report signature verification failure test result
1384
  * Report signature verification failure test result
1373
  * @v time		Test verification time
1389
  * @v time		Test verification time
1374
  * @v store		Test certificate store
1390
  * @v store		Test certificate store
1375
  * @v root		Test root certificate list
1391
  * @v root		Test root certificate list
1392
+ * @v file		Test code file
1393
+ * @v line		Test code line
1376
  */
1394
  */
1377
-#define cms_verify_fail_ok( sgn, code, name, time, store, root ) do {	\
1395
+static void cms_verify_fail_okx ( struct cms_test_signature *sgn,
1378
-	x509_invalidate_chain ( (sgn)->sig->certificates );		\
1396
+				  struct cms_test_code *code, const char *name,
1379
-	ok ( cms_verify ( (sgn)->sig, virt_to_user ( (code)->data ),	\
1397
+				  time_t time, struct x509_chain *store,
1380
-			  (code)->len, name, time, store, root ) != 0 );\
1398
+				  struct x509_root *root, const char *file,
1381
-	} while ( 0 )
1399
+				  unsigned int line ) {
1400
+
1401
+	x509_invalidate_chain ( sgn->sig->certificates );
1402
+	okx ( cms_verify ( sgn->sig, virt_to_user ( code->data ), code->len,
1403
+			   name, time, store, root ) != 0, file, line );
1404
+}
1405
+#define cms_verify_fail_ok( sgn, code, name, time, store, root )	\
1406
+	cms_verify_fail_okx ( sgn, code, name, time, store, root,	\
1407
+			      __FILE__, __LINE__ )
1382
 
1408
 
1383
 /**
1409
 /**
1384
  * Perform CMS self-tests
1410
  * Perform CMS self-tests

Loading…
Cancel
Save