14
14
#undef MONGOC_LOG_DOMAIN
15
15
#define MONGOC_LOG_DOMAIN "session-test"
16
16
17
- /*
18
- * Prevent failing on pedantic GCC/clang warning: "ISO C forbids conversion of
19
- * function pointer to object pointer type."
20
- */
21
- #ifdef __clang__
22
- #pragma clang diagnostic warning "-Wpedantic"
23
- #elif __GNUC__ > 6
24
- #pragma GCC diagnostic warning "-Wpedantic"
25
- #elif __GNUC__ <= 6
26
- #pragma GCC diagnostic warning "-pedantic"
27
- #endif
28
-
29
17
static void
30
18
test_session_opts_clone (void )
31
19
{
@@ -1627,34 +1615,36 @@ _run_session_test (session_test_fn_t test_fn, bool allow_read_concern)
1627
1615
static void
1628
1616
run_session_test (void * ctx )
1629
1617
{
1630
- _run_session_test ((session_test_fn_t ) ctx , true);
1618
+ _run_session_test ((session_test_fn_t ) (( TestFnCtx * ) ctx ) -> test_fn , true);
1631
1619
}
1632
1620
1633
1621
1634
1622
/* test a command that doesn't allow readConcern, and therefore isn't causal */
1635
1623
static void
1636
1624
run_session_test_no_rc (void * ctx )
1637
1625
{
1638
- _run_session_test ((session_test_fn_t ) ctx , false);
1626
+ _run_session_test ((session_test_fn_t ) (( TestFnCtx * ) ctx ) -> test_fn , false);
1639
1627
}
1640
1628
1641
1629
1642
1630
/* skip _test_session_from_wrong_client, which would abort with bulk op */
1643
1631
static void
1644
1632
run_session_test_bulk_operation (void * ctx )
1645
1633
{
1646
- _test_explicit_session_lsid ((session_test_fn_t ) ctx );
1647
- _test_implicit_session_lsid ((session_test_fn_t ) ctx );
1648
- _test_causal_consistency ((session_test_fn_t ) ctx , false /* read concern */ );
1634
+ session_test_fn_t test_fn = (session_test_fn_t ) ((TestFnCtx * ) ctx )-> test_fn ;
1635
+ _test_explicit_session_lsid (test_fn );
1636
+ _test_implicit_session_lsid (test_fn );
1637
+ _test_causal_consistency (test_fn , false /* read concern */ );
1649
1638
}
1650
1639
1651
1640
1652
1641
static void
1653
- run_count_test (session_test_fn_t test_fn )
1642
+ run_count_test (void * ctx )
1654
1643
{
1655
1644
/* CDRIVER-3612: mongoc_collection_estimated_document_count does not support
1656
1645
* explicit sessions */
1657
- _test_implicit_session_lsid (test_fn );
1646
+ _test_implicit_session_lsid (
1647
+ (session_test_fn_t ) ((TestFnCtx * ) ctx )-> test_fn );
1658
1648
}
1659
1649
1660
1650
@@ -2530,55 +2520,59 @@ _test_unacknowledged (session_test_fn_t test_fn,
2530
2520
static void
2531
2521
test_unacknowledged_explicit_cs_inherit_wc (void * ctx )
2532
2522
{
2533
- _test_unacknowledged ((session_test_fn_t ) ctx , true, true);
2523
+ _test_unacknowledged (
2524
+ (session_test_fn_t ) ((TestFnCtx * ) ctx )-> test_fn , true, true);
2534
2525
}
2535
2526
2536
2527
2537
2528
static void
2538
2529
test_unacknowledged_implicit_cs_explicit_wc (void * ctx )
2539
2530
{
2540
- _test_unacknowledged ((session_test_fn_t ) ctx , true, false);
2531
+ _test_unacknowledged (
2532
+ (session_test_fn_t ) ((TestFnCtx * ) ctx )-> test_fn , true, false);
2541
2533
}
2542
2534
2543
2535
2544
2536
static void
2545
2537
test_unacknowledged_implicit_cs_inherit_wc (void * ctx )
2546
2538
{
2547
- _test_unacknowledged ((session_test_fn_t ) ctx , false, true);
2539
+ _test_unacknowledged (
2540
+ (session_test_fn_t ) ((TestFnCtx * ) ctx )-> test_fn , false, true);
2548
2541
}
2549
2542
2550
2543
2551
2544
static void
2552
2545
test_unacknowledged_explicit_cs_explicit_wc (void * ctx )
2553
2546
{
2554
- _test_unacknowledged ((session_test_fn_t ) ctx , false, false);
2547
+ _test_unacknowledged (
2548
+ (session_test_fn_t ) ((TestFnCtx * ) ctx )-> test_fn , false, false);
2555
2549
}
2556
2550
2557
2551
2558
- #define add_session_test (_suite , _name , _test_fn , _allow_read_concern ) \
2559
- TestSuite_AddFull (_suite, \
2560
- _name, \
2561
- (_allow_read_concern) ? run_session_test \
2562
- : run_session_test_no_rc, \
2563
- NULL, \
2564
- (void *) (_test_fn), \
2565
- test_framework_skip_if_no_cluster_time, \
2566
- test_framework_skip_if_no_crypto)
2552
+ #define add_session_test (_suite , _name , _test_fn , _allow_read_concern ) \
2553
+ TestSuite_AddFullWithTestFn ( \
2554
+ _suite, \
2555
+ _name, \
2556
+ (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \
2557
+ NULL, \
2558
+ _test_fn, \
2559
+ test_framework_skip_if_no_cluster_time, \
2560
+ test_framework_skip_if_no_crypto)
2567
2561
2568
2562
#define add_session_test_wc (_suite , _name , _test_fn , _allow_read_concern , ...) \
2569
- TestSuite_AddFull (_suite, \
2570
- _name, \
2571
- (_allow_read_concern) ? run_session_test \
2572
- : run_session_test_no_rc, \
2573
- NULL, \
2574
- (void *) (_test_fn), \
2575
- test_framework_skip_if_no_cluster_time, \
2576
- test_framework_skip_if_no_crypto, \
2577
- __VA_ARGS__)
2563
+ TestSuite_AddFullWithTestFn ( \
2564
+ _suite, \
2565
+ _name, \
2566
+ (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \
2567
+ NULL, \
2568
+ _test_fn, \
2569
+ test_framework_skip_if_no_cluster_time, \
2570
+ test_framework_skip_if_no_crypto, \
2571
+ __VA_ARGS__)
2578
2572
2579
2573
#define add_unacknowledged_test ( \
2580
2574
_suite , _name , _test_fn , _explicit_cs , _inherit_wc ) \
2581
- TestSuite_AddFull ( \
2575
+ TestSuite_AddFullWithTestFn ( \
2582
2576
_suite, \
2583
2577
_name, \
2584
2578
(_explicit_cs) \
@@ -2587,7 +2581,7 @@ test_unacknowledged_explicit_cs_explicit_wc (void *ctx)
2587
2581
: (_inherit_wc ? test_unacknowledged_implicit_cs_inherit_wc \
2588
2582
: test_unacknowledged_explicit_cs_explicit_wc), \
2589
2583
NULL, \
2590
- (void *) ( _test_fn), \
2584
+ _test_fn, \
2591
2585
test_framework_skip_if_no_cluster_time, \
2592
2586
test_framework_skip_if_no_crypto)
2593
2587
@@ -2910,13 +2904,13 @@ test_session_install (TestSuite *suite)
2910
2904
add_session_test (
2911
2905
suite , "/Session/read_write_cmd" , test_read_write_cmd , true);
2912
2906
add_session_test (suite , "/Session/db_cmd" , test_db_cmd , false);
2913
- TestSuite_AddFull (suite ,
2914
- "/Session/count" ,
2915
- ( void * ) run_count_test ,
2916
- NULL ,
2917
- ( void * ) test_count ,
2918
- test_framework_skip_if_no_cluster_time ,
2919
- test_framework_skip_if_no_crypto );
2907
+ TestSuite_AddFullWithTestFn (suite ,
2908
+ "/Session/count" ,
2909
+ ( TestFuncWC ) run_count_test ,
2910
+ NULL ,
2911
+ test_count ,
2912
+ test_framework_skip_if_no_cluster_time ,
2913
+ test_framework_skip_if_no_crypto );
2920
2914
add_session_test (suite , "/Session/cursor" , test_cursor , true);
2921
2915
add_session_test (suite , "/Session/drop" , test_drop , false);
2922
2916
add_session_test (suite , "/Session/drop_index" , test_drop_index , false);
@@ -2951,20 +2945,20 @@ test_session_install (TestSuite *suite)
2951
2945
suite , "/Session/collection_names" , test_collection_names , true);
2952
2946
add_session_test (suite , "/Session/bulk" , test_bulk , false);
2953
2947
add_session_test (suite , "/Session/find_indexes" , test_find_indexes , true);
2954
- TestSuite_AddFull (suite ,
2955
- "/Session/bulk_set_session" ,
2956
- run_session_test_bulk_operation ,
2957
- NULL ,
2958
- test_bulk_set_session ,
2959
- test_framework_skip_if_no_cluster_time ,
2960
- test_framework_skip_if_no_crypto );
2961
- TestSuite_AddFull (suite ,
2962
- "/Session/bulk_set_client" ,
2963
- run_session_test_bulk_operation ,
2964
- NULL ,
2965
- test_bulk_set_client ,
2966
- test_framework_skip_if_no_cluster_time ,
2967
- test_framework_skip_if_no_crypto );
2948
+ TestSuite_AddFullWithTestFn (suite ,
2949
+ "/Session/bulk_set_session" ,
2950
+ run_session_test_bulk_operation ,
2951
+ NULL ,
2952
+ test_bulk_set_session ,
2953
+ test_framework_skip_if_no_cluster_time ,
2954
+ test_framework_skip_if_no_crypto );
2955
+ TestSuite_AddFullWithTestFn (suite ,
2956
+ "/Session/bulk_set_client" ,
2957
+ run_session_test_bulk_operation ,
2958
+ NULL ,
2959
+ test_bulk_set_client ,
2960
+ test_framework_skip_if_no_cluster_time ,
2961
+ test_framework_skip_if_no_crypto );
2968
2962
TestSuite_AddFull (suite ,
2969
2963
"/Session/cursor_implicit_session" ,
2970
2964
test_cursor_implicit_session ,
0 commit comments