Sfoglia il codice sorgente

[test] Rewrite CMS tests using okx()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 anni fa
parent
commit
7945542fb0
1 ha cambiato i file con 40 aggiunte e 14 eliminazioni
  1. 40
    14
      src/tests/cms_test.c

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

@@ -1342,11 +1342,17 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug  3 23:38:31 2013 */
1342 1342
  * Report signature parsing test result
1343 1343
  *
1344 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 {					\
1347
-	ok ( cms_signature ( (sgn)->data, (sgn)->len,			\
1348
-			     &(sgn)->sig ) == 0 );			\
1349
-	} while ( 0 )
1348
+static void cms_signature_okx ( struct cms_test_signature *sgn,
1349
+				const char *file, unsigned int line ) {
1350
+
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 1358
  * Report signature verification test result
@@ -1357,12 +1363,22 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug  3 23:38:31 2013 */
1357 1363
  * @v time		Test verification time
1358 1364
  * @v store		Test certificate store
1359 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 {	\
1362
-	x509_invalidate_chain ( (sgn)->sig->certificates );		\
1363
-	ok ( cms_verify ( (sgn)->sig, virt_to_user ( (code)->data ),	\
1364
-			  (code)->len, name, time, store, root ) == 0 );\
1365
-	} while ( 0 )
1369
+static void cms_verify_okx ( struct cms_test_signature *sgn,
1370
+			     struct cms_test_code *code, const char *name,
1371
+			     time_t time, struct x509_chain *store,
1372
+			     struct x509_root *root, const char *file,
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 1384
  * Report signature verification failure test result
@@ -1373,12 +1389,22 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug  3 23:38:31 2013 */
1373 1389
  * @v time		Test verification time
1374 1390
  * @v store		Test certificate store
1375 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 {	\
1378
-	x509_invalidate_chain ( (sgn)->sig->certificates );		\
1379
-	ok ( cms_verify ( (sgn)->sig, virt_to_user ( (code)->data ),	\
1380
-			  (code)->len, name, time, store, root ) != 0 );\
1381
-	} while ( 0 )
1395
+static void cms_verify_fail_okx ( struct cms_test_signature *sgn,
1396
+				  struct cms_test_code *code, const char *name,
1397
+				  time_t time, struct x509_chain *store,
1398
+				  struct x509_root *root, const char *file,
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 1410
  * Perform CMS self-tests

Loading…
Annulla
Salva