mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Fix operator usage in src/test/*.c
This patch fixes the operator usage in src/test/*.c to use the symbolic
operators instead of the normal C comparison operators.
This patch was generated using:
./scripts/coccinelle/test-operator-cleanup src/test/*.[ch]
This commit is contained in:
committed by
Nick Mathewson
parent
9e1fa95920
commit
c4744a01cc
+20
-20
@@ -55,7 +55,7 @@ test_directory(void *arg)
|
||||
init_test();
|
||||
/* Generate a valid descriptor with normal values. */
|
||||
ret = ed25519_keypair_generate(&signing_kp1, 0);
|
||||
tt_int_op(ret, ==, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
desc1 = hs_helper_build_hs_desc_with_ip(&signing_kp1);
|
||||
tt_assert(desc1);
|
||||
ret = hs_desc_encode_descriptor(desc1, &signing_kp1, &desc1_str);
|
||||
@@ -79,7 +79,7 @@ test_directory(void *arg)
|
||||
/* Tell our OOM to run and to at least remove a byte which will result in
|
||||
* removing the descriptor from our cache. */
|
||||
oom_size = hs_cache_handle_oom(time(NULL), 1);
|
||||
tt_int_op(oom_size, >=, 1);
|
||||
tt_int_op(oom_size, OP_GE, 1);
|
||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ test_directory(void *arg)
|
||||
{
|
||||
ed25519_keypair_t signing_kp_zero;
|
||||
ret = ed25519_keypair_generate(&signing_kp_zero, 0);
|
||||
tt_int_op(ret, ==, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
hs_descriptor_t *desc_zero_lifetime;
|
||||
desc_zero_lifetime = hs_helper_build_hs_desc_with_ip(&signing_kp_zero);
|
||||
tt_assert(desc_zero_lifetime);
|
||||
@@ -116,7 +116,7 @@ test_directory(void *arg)
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
/* Cleanup our entire cache. */
|
||||
oom_size = hs_cache_handle_oom(time(NULL), 1);
|
||||
tt_int_op(oom_size, >=, 1);
|
||||
tt_int_op(oom_size, OP_GE, 1);
|
||||
hs_descriptor_free(desc_zero_lifetime);
|
||||
tor_free(desc_zero_lifetime_str);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ test_clean_as_dir(void *arg)
|
||||
|
||||
/* Generate a valid descriptor with values. */
|
||||
ret = ed25519_keypair_generate(&signing_kp1, 0);
|
||||
tt_int_op(ret, ==, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
desc1 = hs_helper_build_hs_desc_with_ip(&signing_kp1);
|
||||
tt_assert(desc1);
|
||||
ret = hs_desc_encode_descriptor(desc1, &signing_kp1, &desc1_str);
|
||||
@@ -188,21 +188,21 @@ test_clean_as_dir(void *arg)
|
||||
|
||||
/* With the lifetime being 3 hours, a cleanup shouldn't remove it. */
|
||||
ret = cache_clean_v3_as_dir(now, 0);
|
||||
tt_int_op(ret, ==, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
/* Should be present after clean up. */
|
||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||
tt_int_op(ret, OP_EQ, 1);
|
||||
/* Set a cutoff 100 seconds in the past. It should not remove the entry
|
||||
* since the entry is still recent enough. */
|
||||
ret = cache_clean_v3_as_dir(now, now - 100);
|
||||
tt_int_op(ret, ==, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
/* Should be present after clean up. */
|
||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||
tt_int_op(ret, OP_EQ, 1);
|
||||
/* Set a cutoff of 100 seconds in the future. It should remove the entry
|
||||
* that we've just added since it's not too old for the cutoff. */
|
||||
ret = cache_clean_v3_as_dir(now, now + 100);
|
||||
tt_int_op(ret, >, 0);
|
||||
tt_int_op(ret, OP_GT, 0);
|
||||
/* Shouldn't be present after clean up. */
|
||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
@@ -232,7 +232,7 @@ helper_fetch_desc_from_hsdir(const ed25519_public_key_t *blinded_key)
|
||||
|
||||
retval = ed25519_public_to_base64(hsdir_cache_key,
|
||||
blinded_key);
|
||||
tt_int_op(retval, ==, 0);
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
tor_asprintf(&hsdir_query_str, GET("/tor/hs/3/%s"), hsdir_cache_key);
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ test_upload_and_download_hs_desc(void *arg)
|
||||
{
|
||||
ed25519_keypair_t signing_kp;
|
||||
retval = ed25519_keypair_generate(&signing_kp, 0);
|
||||
tt_int_op(retval, ==, 0);
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||
tt_assert(published_desc);
|
||||
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
||||
@@ -302,7 +302,7 @@ test_upload_and_download_hs_desc(void *arg)
|
||||
/* Publish descriptor to the HSDir */
|
||||
{
|
||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
||||
tt_int_op(retval, ==, 200);
|
||||
tt_int_op(retval, OP_EQ, 200);
|
||||
}
|
||||
|
||||
/* Simulate a fetch of the previously published descriptor */
|
||||
@@ -355,7 +355,7 @@ test_hsdir_revision_counter_check(void *arg)
|
||||
/* Generate a valid descriptor with normal values. */
|
||||
{
|
||||
retval = ed25519_keypair_generate(&signing_kp, 0);
|
||||
tt_int_op(retval, ==, 0);
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||
tt_assert(published_desc);
|
||||
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
||||
@@ -366,13 +366,13 @@ test_hsdir_revision_counter_check(void *arg)
|
||||
/* Publish descriptor to the HSDir */
|
||||
{
|
||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
||||
tt_int_op(retval, ==, 200);
|
||||
tt_int_op(retval, OP_EQ, 200);
|
||||
}
|
||||
|
||||
/* Try publishing again with the same revision counter: Should fail. */
|
||||
{
|
||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
||||
tt_int_op(retval, ==, 400);
|
||||
tt_int_op(retval, OP_EQ, 400);
|
||||
}
|
||||
|
||||
/* Fetch the published descriptor and validate the revision counter. */
|
||||
@@ -385,11 +385,11 @@ test_hsdir_revision_counter_check(void *arg)
|
||||
|
||||
retval = hs_desc_decode_descriptor(received_desc_str,
|
||||
subcredential, &received_desc);
|
||||
tt_int_op(retval, ==, 0);
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
tt_assert(received_desc);
|
||||
|
||||
/* Check that the revision counter is correct */
|
||||
tt_u64_op(received_desc->plaintext_data.revision_counter, ==, 42);
|
||||
tt_u64_op(received_desc->plaintext_data.revision_counter, OP_EQ, 42);
|
||||
|
||||
hs_descriptor_free(received_desc);
|
||||
received_desc = NULL;
|
||||
@@ -405,7 +405,7 @@ test_hsdir_revision_counter_check(void *arg)
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
|
||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
||||
tt_int_op(retval, ==, 200);
|
||||
tt_int_op(retval, OP_EQ, 200);
|
||||
}
|
||||
|
||||
/* Again, fetch the published descriptor and perform the revision counter
|
||||
@@ -418,11 +418,11 @@ test_hsdir_revision_counter_check(void *arg)
|
||||
|
||||
retval = hs_desc_decode_descriptor(received_desc_str,
|
||||
subcredential, &received_desc);
|
||||
tt_int_op(retval, ==, 0);
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
tt_assert(received_desc);
|
||||
|
||||
/* Check that the revision counter is the latest */
|
||||
tt_u64_op(received_desc->plaintext_data.revision_counter, ==, 1313);
|
||||
tt_u64_op(received_desc->plaintext_data.revision_counter, OP_EQ, 1313);
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -452,7 +452,7 @@ test_client_cache(void *arg)
|
||||
/* Generate a valid descriptor with normal values. */
|
||||
{
|
||||
retval = ed25519_keypair_generate(&signing_kp, 0);
|
||||
tt_int_op(retval, ==, 0);
|
||||
tt_int_op(retval, OP_EQ, 0);
|
||||
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||
tt_assert(published_desc);
|
||||
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
||||
|
||||
Reference in New Issue
Block a user