[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Run test_operator_cleanup on our unit tests



commit ded6d9fcb47fededa8cb2dd835772eb3036ef36d
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Sep 11 18:47:19 2019 -0400

    Run test_operator_cleanup on our unit tests
    
    Coccinelle doesn't understand it when we use "==" and "!=" and so on as
    arguments to macros.  To solve this, we prefer OP_EQ, OP_NE, and so
    on.
    
    This commit is automatically generated by running
    ./scripts/coccinelle/test_operator_cleanup over all of the source
    code in src.
---
 src/test/hs_test_helpers.c | 28 ++++++++++++-------------
 src/test/test_router.c     | 10 ++++-----
 src/test/test_scheduler.c  | 52 +++++++++++++++++++++++-----------------------
 3 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/src/test/hs_test_helpers.c b/src/test/hs_test_helpers.c
index 0a21fe576..22be4aea2 100644
--- a/src/test/hs_test_helpers.c
+++ b/src/test/hs_test_helpers.c
@@ -53,7 +53,7 @@ hs_helper_build_intro_point(const ed25519_keypair_t *signing_kp, time_t now,
   }
 
   ret = ed25519_keypair_generate(&auth_kp, 0);
-  tt_int_op(ret, ==, 0);
+  tt_int_op(ret, OP_EQ, 0);
   ip->auth_key_cert = tor_cert_create(signing_kp, CERT_TYPE_AUTH_HS_IP_KEY,
                                       &auth_kp.pubkey, now,
                                       HS_DESC_CERT_LIFETIME,
@@ -64,7 +64,7 @@ hs_helper_build_intro_point(const ed25519_keypair_t *signing_kp, time_t now,
     ip->legacy.key = crypto_pk_new();
     tt_assert(ip->legacy.key);
     ret = crypto_pk_generate_key(ip->legacy.key);
-    tt_int_op(ret, ==, 0);
+    tt_int_op(ret, OP_EQ, 0);
     ssize_t cert_len = tor_make_rsa_ed25519_crosscert(
                                     &signing_kp->pubkey, ip->legacy.key,
                                     now + HS_DESC_CERT_LIFETIME,
@@ -82,7 +82,7 @@ hs_helper_build_intro_point(const ed25519_keypair_t *signing_kp, time_t now,
     tor_cert_t *cross_cert;
 
     ret = curve25519_keypair_generate(&curve25519_kp, 0);
-    tt_int_op(ret, ==, 0);
+    tt_int_op(ret, OP_EQ, 0);
     ed25519_keypair_from_curve25519_keypair(&ed25519_kp, &signbit,
                                             &curve25519_kp);
     cross_cert = tor_cert_create(signing_kp, CERT_TYPE_CROSS_HS_IP_KEYS,
@@ -140,7 +140,7 @@ hs_helper_build_hs_desc_impl(unsigned int no_ip,
 
   /* Setup superencrypted data section. */
   ret = curve25519_keypair_generate(&auth_ephemeral_kp, 0);
-  tt_int_op(ret, ==, 0);
+  tt_int_op(ret, OP_EQ, 0);
   memcpy(&desc->superencrypted_data.auth_ephemeral_pubkey,
          &auth_ephemeral_kp.pubkey,
          sizeof(curve25519_public_key_t));
@@ -224,7 +224,7 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
   tt_mem_op(desc1->plaintext_data.blinded_pubkey.pubkey, OP_EQ,
             desc2->plaintext_data.blinded_pubkey.pubkey,
             ED25519_PUBKEY_LEN);
-  tt_u64_op(desc1->plaintext_data.revision_counter, ==,
+  tt_u64_op(desc1->plaintext_data.revision_counter, OP_EQ,
             desc2->plaintext_data.revision_counter);
 
   /* NOTE: We can't compare the encrypted blob because when encoding the
@@ -241,7 +241,7 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
   {
     tt_assert(desc1->superencrypted_data.clients);
     tt_assert(desc2->superencrypted_data.clients);
-    tt_int_op(smartlist_len(desc1->superencrypted_data.clients), ==,
+    tt_int_op(smartlist_len(desc1->superencrypted_data.clients), OP_EQ,
               smartlist_len(desc2->superencrypted_data.clients));
     for (int i=0;
          i < smartlist_len(desc1->superencrypted_data.clients);
@@ -259,15 +259,15 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
   }
 
   /* Encrypted data section. */
-  tt_uint_op(desc1->encrypted_data.create2_ntor, ==,
+  tt_uint_op(desc1->encrypted_data.create2_ntor, OP_EQ,
              desc2->encrypted_data.create2_ntor);
 
   /* Authentication type. */
-  tt_int_op(!!desc1->encrypted_data.intro_auth_types, ==,
+  tt_int_op(!!desc1->encrypted_data.intro_auth_types, OP_EQ,
             !!desc2->encrypted_data.intro_auth_types);
   if (desc1->encrypted_data.intro_auth_types &&
       desc2->encrypted_data.intro_auth_types) {
-    tt_int_op(smartlist_len(desc1->encrypted_data.intro_auth_types), ==,
+    tt_int_op(smartlist_len(desc1->encrypted_data.intro_auth_types), OP_EQ,
               smartlist_len(desc2->encrypted_data.intro_auth_types));
     for (int i = 0;
          i < smartlist_len(desc1->encrypted_data.intro_auth_types);
@@ -281,7 +281,7 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
   {
     tt_assert(desc1->encrypted_data.intro_points);
     tt_assert(desc2->encrypted_data.intro_points);
-    tt_int_op(smartlist_len(desc1->encrypted_data.intro_points), ==,
+    tt_int_op(smartlist_len(desc1->encrypted_data.intro_points), OP_EQ,
               smartlist_len(desc2->encrypted_data.intro_points));
     for (int i=0; i < smartlist_len(desc1->encrypted_data.intro_points); i++) {
       hs_desc_intro_point_t *ip1 = smartlist_get(desc1->encrypted_data
@@ -296,12 +296,12 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
         tt_mem_op(&ip1->enc_key, OP_EQ, &ip2->enc_key, CURVE25519_PUBKEY_LEN);
       }
 
-      tt_int_op(smartlist_len(ip1->link_specifiers), ==,
+      tt_int_op(smartlist_len(ip1->link_specifiers), OP_EQ,
                 smartlist_len(ip2->link_specifiers));
       for (int j = 0; j < smartlist_len(ip1->link_specifiers); j++) {
         link_specifier_t *ls1 = smartlist_get(ip1->link_specifiers, j),
                          *ls2 = smartlist_get(ip2->link_specifiers, j);
-        tt_int_op(link_specifier_get_ls_type(ls1), ==,
+        tt_int_op(link_specifier_get_ls_type(ls1), OP_EQ,
                   link_specifier_get_ls_type(ls2));
         switch (link_specifier_get_ls_type(ls1)) {
           case LS_IPV4:
@@ -311,7 +311,7 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
               tt_int_op(addr1, OP_EQ, addr2);
               uint16_t port1 = link_specifier_get_un_ipv4_port(ls1);
               uint16_t port2 = link_specifier_get_un_ipv4_port(ls2);
-              tt_int_op(port1, ==, port2);
+              tt_int_op(port1, OP_EQ, port2);
             }
             break;
           case LS_IPV6:
@@ -326,7 +326,7 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
                         link_specifier_getlen_un_ipv6_addr(ls1));
               uint16_t port1 = link_specifier_get_un_ipv6_port(ls1);
               uint16_t port2 = link_specifier_get_un_ipv6_port(ls2);
-              tt_int_op(port1, ==, port2);
+              tt_int_op(port1, OP_EQ, port2);
             }
             break;
           case LS_LEGACY_ID:
diff --git a/src/test/test_router.c b/src/test/test_router.c
index 5477ab51e..24c7d32bc 100644
--- a/src/test/test_router.c
+++ b/src/test/test_router.c
@@ -92,13 +92,13 @@ test_router_dump_router_to_string_no_bridge_distribution_method(void *arg)
   options->BridgeRelay = 1;
 
   /* Generate keys which router_dump_router_to_string() expects to exist. */
-  tt_int_op(0, ==, curve25519_keypair_generate(&ntor_keypair, 0));
-  tt_int_op(0, ==, ed25519_keypair_generate(&signing_keypair, 0));
+  tt_int_op(0, OP_EQ, curve25519_keypair_generate(&ntor_keypair, 0));
+  tt_int_op(0, OP_EQ, ed25519_keypair_generate(&signing_keypair, 0));
 
   /* Set up part of our routerinfo_t so that we don't trigger any other
    * assertions in router_dump_router_to_string(). */
   router = (routerinfo_t*)router_get_my_routerinfo();
-  tt_ptr_op(router, !=, NULL);
+  tt_ptr_op(router, OP_NE, NULL);
 
   /* The real router_get_my_routerinfo() looks up onion_curve25519_pkey using
    * get_current_curve25519_keypair(), but we don't initialise static data in
@@ -115,9 +115,9 @@ test_router_dump_router_to_string_no_bridge_distribution_method(void *arg)
                                       &ntor_keypair,
                                       &signing_keypair);
   crypto_pk_free(onion_pkey);
-  tt_ptr_op(desc, !=, NULL);
+  tt_ptr_op(desc, OP_NE, NULL);
   found = strstr(desc, needle);
-  tt_ptr_op(found, !=, NULL);
+  tt_ptr_op(found, OP_NE, NULL);
 
  done:
   NS_UNMOCK(router_get_my_routerinfo);
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c
index bf9c6a49c..39c4963fc 100644
--- a/src/test/test_scheduler.c
+++ b/src/test/test_scheduler.c
@@ -848,8 +848,8 @@ test_scheduler_initfree(void *arg)
 {
   (void)arg;
 
-  tt_ptr_op(channels_pending, ==, NULL);
-  tt_ptr_op(run_sched_ev, ==, NULL);
+  tt_ptr_op(channels_pending, OP_EQ, NULL);
+  tt_ptr_op(run_sched_ev, OP_EQ, NULL);
 
   MOCK(get_options, mock_get_options);
   set_scheduler_options(SCHEDULER_KIST);
@@ -858,17 +858,17 @@ test_scheduler_initfree(void *arg)
 
   scheduler_init();
 
-  tt_ptr_op(channels_pending, !=, NULL);
-  tt_ptr_op(run_sched_ev, !=, NULL);
+  tt_ptr_op(channels_pending, OP_NE, NULL);
+  tt_ptr_op(run_sched_ev, OP_NE, NULL);
   /* We have specified nothing in the torrc and there's no consensus so the
    * KIST scheduler is what should be in use */
-  tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
-  tt_int_op(sched_run_interval, ==, 10);
+  tt_ptr_op(the_scheduler, OP_EQ, get_kist_scheduler());
+  tt_int_op(sched_run_interval, OP_EQ, 10);
 
   scheduler_free_all();
 
-  tt_ptr_op(channels_pending, ==, NULL);
-  tt_ptr_op(run_sched_ev, ==, NULL);
+  tt_ptr_op(channels_pending, OP_EQ, NULL);
+  tt_ptr_op(run_sched_ev, OP_EQ, NULL);
 
  done:
   UNMOCK(get_options);
@@ -890,11 +890,11 @@ test_scheduler_can_use_kist(void *arg)
   res_should = scheduler_can_use_kist();
   res_freq = kist_scheduler_run_interval();
 #ifdef HAVE_KIST_SUPPORT
-  tt_int_op(res_should, ==, 1);
+  tt_int_op(res_should, OP_EQ, 1);
 #else /* HAVE_KIST_SUPPORT */
-  tt_int_op(res_should, ==, 0);
+  tt_int_op(res_should, OP_EQ, 0);
 #endif /* HAVE_KIST_SUPPORT */
-  tt_int_op(res_freq, ==, 1234);
+  tt_int_op(res_freq, OP_EQ, 1234);
 
   /* Test defer to consensus, but no consensus available */
   clear_options();
@@ -902,11 +902,11 @@ test_scheduler_can_use_kist(void *arg)
   res_should = scheduler_can_use_kist();
   res_freq = kist_scheduler_run_interval();
 #ifdef HAVE_KIST_SUPPORT
-  tt_int_op(res_should, ==, 1);
+  tt_int_op(res_should, OP_EQ, 1);
 #else /* HAVE_KIST_SUPPORT */
-  tt_int_op(res_should, ==, 0);
+  tt_int_op(res_should, OP_EQ, 0);
 #endif /* HAVE_KIST_SUPPORT */
-  tt_int_op(res_freq, ==, 10);
+  tt_int_op(res_freq, OP_EQ, 10);
 
   /* Test defer to consensus, and kist consensus available */
   MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
@@ -915,11 +915,11 @@ test_scheduler_can_use_kist(void *arg)
   res_should = scheduler_can_use_kist();
   res_freq = kist_scheduler_run_interval();
 #ifdef HAVE_KIST_SUPPORT
-  tt_int_op(res_should, ==, 1);
+  tt_int_op(res_should, OP_EQ, 1);
 #else /* HAVE_KIST_SUPPORT */
-  tt_int_op(res_should, ==, 0);
+  tt_int_op(res_should, OP_EQ, 0);
 #endif /* HAVE_KIST_SUPPORT */
-  tt_int_op(res_freq, ==, 12);
+  tt_int_op(res_freq, OP_EQ, 12);
   UNMOCK(networkstatus_get_param);
 
   /* Test defer to consensus, and vanilla consensus available */
@@ -928,8 +928,8 @@ test_scheduler_can_use_kist(void *arg)
   mocked_options.KISTSchedRunInterval = 0;
   res_should = scheduler_can_use_kist();
   res_freq = kist_scheduler_run_interval();
-  tt_int_op(res_should, ==, 0);
-  tt_int_op(res_freq, ==, 0);
+  tt_int_op(res_should, OP_EQ, 0);
+  tt_int_op(res_freq, OP_EQ, 0);
   UNMOCK(networkstatus_get_param);
 
  done:
@@ -956,7 +956,7 @@ test_scheduler_ns_changed(void *arg)
   set_scheduler_options(SCHEDULER_KIST);
   set_scheduler_options(SCHEDULER_VANILLA);
 
-  tt_ptr_op(the_scheduler, ==, NULL);
+  tt_ptr_op(the_scheduler, OP_EQ, NULL);
 
   /* Change from vanilla to kist via consensus */
   the_scheduler = get_vanilla_scheduler();
@@ -964,9 +964,9 @@ test_scheduler_ns_changed(void *arg)
   scheduler_notify_networkstatus_changed();
   UNMOCK(networkstatus_get_param);
 #ifdef HAVE_KIST_SUPPORT
-  tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
+  tt_ptr_op(the_scheduler, OP_EQ, get_kist_scheduler());
 #else
-  tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
+  tt_ptr_op(the_scheduler, OP_EQ, get_vanilla_scheduler());
 #endif
 
   /* Change from kist to vanilla via consensus */
@@ -974,7 +974,7 @@ test_scheduler_ns_changed(void *arg)
   MOCK(networkstatus_get_param, mock_vanilla_networkstatus_get_param);
   scheduler_notify_networkstatus_changed();
   UNMOCK(networkstatus_get_param);
-  tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
+  tt_ptr_op(the_scheduler, OP_EQ, get_vanilla_scheduler());
 
   /* Doesn't change when using KIST */
   the_scheduler = get_kist_scheduler();
@@ -982,9 +982,9 @@ test_scheduler_ns_changed(void *arg)
   scheduler_notify_networkstatus_changed();
   UNMOCK(networkstatus_get_param);
 #ifdef HAVE_KIST_SUPPORT
-  tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
+  tt_ptr_op(the_scheduler, OP_EQ, get_kist_scheduler());
 #else
-  tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
+  tt_ptr_op(the_scheduler, OP_EQ, get_vanilla_scheduler());
 #endif
 
   /* Doesn't change when using vanilla */
@@ -992,7 +992,7 @@ test_scheduler_ns_changed(void *arg)
   MOCK(networkstatus_get_param, mock_vanilla_networkstatus_get_param);
   scheduler_notify_networkstatus_changed();
   UNMOCK(networkstatus_get_param);
-  tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
+  tt_ptr_op(the_scheduler, OP_EQ, get_vanilla_scheduler());
 
  done:
   UNMOCK(get_options);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits