@@ -415,7 +415,6 @@ test_server_selection_logic_cb (bson_t *test)
415
415
sd -> round_trip_time_msec = bson_iter_int32 (& sd_iter );
416
416
} else if (sd -> type != MONGOC_SERVER_UNKNOWN ) {
417
417
test_error ("%s has no avg_rtt_ms" , sd -> host .host_and_port );
418
- abort ();
419
418
}
420
419
421
420
if (bson_iter_init_find (& sd_iter , & server , "maxWireVersion" )) {
@@ -529,7 +528,6 @@ test_server_selection_logic_cb (bson_t *test)
529
528
if (!found ) {
530
529
test_error ("Should have been selected but wasn't: %s" ,
531
530
bson_iter_utf8 (& host , NULL ));
532
- abort ();
533
531
}
534
532
535
533
matched_servers [i ] = true;
@@ -543,7 +541,6 @@ test_server_selection_logic_cb (bson_t *test)
543
541
544
542
test_error ("Shouldn't have been selected but was: %s" ,
545
543
sd -> host .host_and_port );
546
- abort ();
547
544
}
548
545
}
549
546
@@ -652,9 +649,9 @@ collect_tests_from_dir (char (*paths)[MAX_TEST_NAME_LENGTH] /* OUT */,
652
649
653
650
dir = opendir (dir_path );
654
651
if (!dir ) {
655
- MONGOC_ERROR ("Cannot open \"%s\"" , dir_path );
656
- MONGOC_ERROR ( "Run test-libmongoc in repository root directory.\n" );
657
- abort ( );
652
+ test_error ("Cannot open \"%s\"\n"
653
+ "Run test-libmongoc in repository root directory." ,
654
+ dir_path );
658
655
}
659
656
660
657
while ((entry = readdir (dir ))) {
@@ -720,7 +717,7 @@ get_bson_from_json_file (char *filename)
720
717
/* read entire file into buffer */
721
718
buffer = (const char * ) bson_malloc0 (length );
722
719
if (fread ((void * ) buffer , 1 , length , file ) != length ) {
723
- abort ( );
720
+ test_error ( "Failed to read JSON file into buffer" );
724
721
}
725
722
726
723
fclose (file );
@@ -731,8 +728,7 @@ get_bson_from_json_file (char *filename)
731
728
/* convert to bson */
732
729
data = bson_new_from_json ((const uint8_t * ) buffer , length , & error );
733
730
if (!data ) {
734
- fprintf (stderr , "Cannot parse %s: %s\n" , filename , error .message );
735
- abort ();
731
+ test_error ("Cannot parse %s: %s" , filename , error .message );
736
732
}
737
733
738
734
bson_free ((void * ) buffer );
@@ -1430,10 +1426,9 @@ set_uri_opts_from_bson (mongoc_uri_t *uri, const bson_t *opts)
1430
1426
} else if (mongoc_uri_option_is_utf8 (key )) {
1431
1427
mongoc_uri_set_option_as_utf8 (uri , key , bson_iter_utf8 (& iter , NULL ));
1432
1428
} else {
1433
- MONGOC_ERROR ("Unsupported clientOptions field \"%s\" in %s" ,
1434
- key ,
1435
- bson_as_json (opts , NULL ));
1436
- abort ();
1429
+ test_error ("Unsupported clientOptions field \"%s\" in %s" ,
1430
+ key ,
1431
+ bson_as_json (opts , NULL ));
1437
1432
}
1438
1433
}
1439
1434
}
@@ -1479,11 +1474,10 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
1479
1474
test_framework_getenv ("MONGOC_TEST_AWS_ACCESS_KEY_ID" );
1480
1475
1481
1476
if (!secret_access_key || !access_key_id ) {
1482
- fprintf (stderr ,
1483
- "Set MONGOC_TEST_AWS_SECRET_ACCESS_KEY and "
1484
- "MONGOC_TEST_AWS_ACCESS_KEY_ID environment variables to "
1485
- "run Client Side Encryption tests.\n" );
1486
- abort ();
1477
+ test_error (
1478
+ "Set MONGOC_TEST_AWS_SECRET_ACCESS_KEY and "
1479
+ "MONGOC_TEST_AWS_ACCESS_KEY_ID environment variables to "
1480
+ "run Client Side Encryption tests." );
1487
1481
}
1488
1482
1489
1483
{
@@ -1517,19 +1511,16 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
1517
1511
test_framework_getenv ("MONGOC_TEST_AWS_TEMP_SESSION_TOKEN" );
1518
1512
1519
1513
if (!secret_access_key || !access_key_id ) {
1520
- fprintf (stderr ,
1521
- "Set MONGOC_TEST_AWS_TEMP_SECRET_ACCESS_KEY and "
1522
- "MONGOC_TEST_AWS_TEMP_ACCESS_KEY_ID environment variables "
1523
- "to run Client Side Encryption tests.\n" );
1524
- abort ();
1514
+ test_error (
1515
+ "Set MONGOC_TEST_AWS_TEMP_SECRET_ACCESS_KEY and "
1516
+ "MONGOC_TEST_AWS_TEMP_ACCESS_KEY_ID environment variables "
1517
+ "to run Client Side Encryption tests." );
1525
1518
}
1526
1519
1527
1520
// Only require session token when requested.
1528
1521
if (!session_token && need_aws_with_session_token ) {
1529
- fprintf (stderr ,
1530
- "Set MONGOC_TEST_AWS_TEMP_SESSION_TOKEN environment "
1531
- "variable to run Client Side Encryption tests.\n" );
1532
- abort ();
1522
+ test_error ("Set MONGOC_TEST_AWS_TEMP_SESSION_TOKEN environment "
1523
+ "variable to run Client Side Encryption tests." );
1533
1524
}
1534
1525
1535
1526
{
@@ -1567,12 +1558,10 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
1567
1558
test_framework_getenv ("MONGOC_TEST_AZURE_CLIENT_SECRET" );
1568
1559
1569
1560
if (!azure_tenant_id || !azure_client_id || !azure_client_secret ) {
1570
- fprintf (stderr ,
1571
- "Set MONGOC_TEST_AZURE_TENANT_ID, "
1572
- "MONGOC_TEST_AZURE_CLIENT_ID, and "
1573
- "MONGOC_TEST_AZURE_CLIENT_SECRET to enable CSFLE "
1574
- "tests." );
1575
- abort ();
1561
+ test_error ("Set MONGOC_TEST_AZURE_TENANT_ID, "
1562
+ "MONGOC_TEST_AZURE_CLIENT_ID, and "
1563
+ "MONGOC_TEST_AZURE_CLIENT_SECRET to enable CSFLE "
1564
+ "tests." );
1576
1565
}
1577
1566
1578
1567
bson_concat (& kms_providers ,
@@ -1595,11 +1584,9 @@ set_auto_encryption_opts (mongoc_client_t *client, bson_t *test)
1595
1584
gcp_privatekey = test_framework_getenv ("MONGOC_TEST_GCP_PRIVATEKEY" );
1596
1585
1597
1586
if (!gcp_email || !gcp_privatekey ) {
1598
- fprintf (stderr ,
1599
- "Set MONGOC_TEST_GCP_EMAIL and "
1600
- "MONGOC_TEST_GCP_PRIVATEKEY to enable CSFLE "
1601
- "tests." );
1602
- abort ();
1587
+ test_error ("Set MONGOC_TEST_GCP_EMAIL and "
1588
+ "MONGOC_TEST_GCP_PRIVATEKEY to enable CSFLE "
1589
+ "tests." );
1603
1590
}
1604
1591
1605
1592
bson_concat (
0 commit comments