diff options
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 2190 |
1 files changed, 1095 insertions, 1095 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 04dfe64f5a..5211701cf1 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -53,20 +53,20 @@ test_util_read_until_eof_impl(const char *fname, size_t file_len, crypto_rand(test_str, file_len); r = write_bytes_to_file(fifo_name, test_str, file_len, 1); - tt_int_op(r, ==, 0); + tt_int_op(r, OP_EQ, 0); fd = open(fifo_name, O_RDONLY|O_BINARY); - tt_int_op(fd, >=, 0); + tt_int_op(fd, OP_GE, 0); str = read_file_to_str_until_eof(fd, read_limit, &sz); tt_assert(str != NULL); if (read_limit < file_len) - tt_int_op(sz, ==, read_limit); + tt_int_op(sz, OP_EQ, read_limit); else - tt_int_op(sz, ==, file_len); + tt_int_op(sz, OP_EQ, file_len); - tt_mem_op(test_str, ==, str, sz); - tt_int_op(str[sz], ==, '\0'); + tt_mem_op(test_str, OP_EQ, str, sz); + tt_int_op(str[sz], OP_EQ, '\0'); done: unlink(fifo_name); @@ -168,17 +168,17 @@ test_util_write_chunks_to_file(void *arg) // write a known string to a file where the tempfile will be r = write_bytes_to_file(tempname, temp_str, temp_str_len, 1); - tt_int_op(r, ==, 0); + tt_int_op(r, OP_EQ, 0); // call write_chunks_to_file r = write_chunks_to_file(fname, chunks, 1, 0); - tt_int_op(r, ==, 0); + tt_int_op(r, OP_EQ, 0); // assert the file has been written (expected size) str = read_file_to_str(fname, RFTS_BIN, &st); tt_assert(str != NULL); - tt_u64_op((uint64_t)st.st_size, ==, data_str_len); - tt_mem_op(data_str, ==, str, data_str_len); + tt_u64_op((uint64_t)st.st_size, OP_EQ, data_str_len); + tt_mem_op(data_str, OP_EQ, str, data_str_len); tor_free(str); // assert that the tempfile is removed (should not leave artifacts) @@ -187,7 +187,7 @@ test_util_write_chunks_to_file(void *arg) // Remove old testfile for second test r = unlink(fname); - tt_int_op(r, ==, 0); + tt_int_op(r, OP_EQ, 0); tor_free(fname); tor_free(tempname); @@ -199,24 +199,24 @@ test_util_write_chunks_to_file(void *arg) // write a known string to a file where the tempfile will be r = write_bytes_to_file(tempname, temp_str, temp_str_len, 1); - tt_int_op(r, ==, 0); + tt_int_op(r, OP_EQ, 0); // call write_chunks_to_file with no_tempfile = true r = write_chunks_to_file(fname, chunks, 1, 1); - tt_int_op(r, ==, 0); + tt_int_op(r, OP_EQ, 0); // assert the file has been written (expected size) str = read_file_to_str(fname, RFTS_BIN, &st); tt_assert(str != NULL); - tt_u64_op((uint64_t)st.st_size, ==, data_str_len); - tt_mem_op(data_str, ==, str, data_str_len); + tt_u64_op((uint64_t)st.st_size, OP_EQ, data_str_len); + tt_mem_op(data_str, OP_EQ, str, data_str_len); tor_free(str); // assert the tempfile still contains the known string str = read_file_to_str(tempname, RFTS_BIN, &st); tt_assert(str != NULL); - tt_u64_op((uint64_t)st.st_size, ==, temp_str_len); - tt_mem_op(temp_str, ==, str, temp_str_len); + tt_u64_op((uint64_t)st.st_size, OP_EQ, temp_str_len); + tt_mem_op(temp_str, OP_EQ, str, temp_str_len); done: unlink(fname); @@ -229,7 +229,7 @@ test_util_write_chunks_to_file(void *arg) tor_free(temp_str); } -#define _TFE(a, b, f) tt_int_op((a).f, ==, (b).f) +#define _TFE(a, b, f) tt_int_op((a).f, OP_EQ, (b).f) /** test the minimum set of struct tm fields needed for a unique epoch value * this is also the set we use to test tor_timegm */ #define TM_EQUAL(a, b) \ @@ -261,23 +261,23 @@ test_util_time(void *arg) end.tv_sec = 5; end.tv_usec = 5000; - tt_int_op(0L,==, tv_udiff(&start, &end)); + tt_int_op(0L,OP_EQ, tv_udiff(&start, &end)); end.tv_usec = 7000; - tt_int_op(2000L,==, tv_udiff(&start, &end)); + tt_int_op(2000L,OP_EQ, tv_udiff(&start, &end)); end.tv_sec = 6; - tt_int_op(1002000L,==, tv_udiff(&start, &end)); + tt_int_op(1002000L,OP_EQ, tv_udiff(&start, &end)); end.tv_usec = 0; - tt_int_op(995000L,==, tv_udiff(&start, &end)); + tt_int_op(995000L,OP_EQ, tv_udiff(&start, &end)); end.tv_sec = 4; - tt_int_op(-1005000L,==, tv_udiff(&start, &end)); + tt_int_op(-1005000L,OP_EQ, tv_udiff(&start, &end)); /* Test tor_timegm & tor_gmtime_r */ @@ -299,26 +299,26 @@ test_util_time(void *arg) a_time.tm_min = 14; a_time.tm_sec = 55; t_res = 1062224095UL; - tt_int_op(t_res, ==, tor_timegm(&a_time)); + tt_int_op(t_res, OP_EQ, tor_timegm(&a_time)); tor_gmtime_r(&t_res, &b_time); TM_EQUAL(a_time, b_time); a_time.tm_year = 2004-1900; /* Try a leap year, after feb. */ t_res = 1093846495UL; - tt_int_op(t_res, ==, tor_timegm(&a_time)); + tt_int_op(t_res, OP_EQ, tor_timegm(&a_time)); tor_gmtime_r(&t_res, &b_time); TM_EQUAL(a_time, b_time); a_time.tm_mon = 1; /* Try a leap year, in feb. */ a_time.tm_mday = 10; t_res = 1076393695UL; - tt_int_op(t_res, ==, tor_timegm(&a_time)); + tt_int_op(t_res, OP_EQ, tor_timegm(&a_time)); tor_gmtime_r(&t_res, &b_time); TM_EQUAL(a_time, b_time); a_time.tm_mon = 0; t_res = 1073715295UL; - tt_int_op(t_res, ==, tor_timegm(&a_time)); + tt_int_op(t_res, OP_EQ, tor_timegm(&a_time)); tor_gmtime_r(&t_res, &b_time); TM_EQUAL(a_time, b_time); @@ -328,27 +328,27 @@ test_util_time(void *arg) /* Wrong year < 1970 */ a_time.tm_year = 1969-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = -1-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); #if SIZEOF_INT == 4 || SIZEOF_INT == 8 a_time.tm_year = -1*(1 << 16); - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* one of the smallest tm_year values my 64 bit system supports: * t_res = -9223372036854775LL without clamping */ a_time.tm_year = -292275055-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = INT32_MIN; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); #endif #if SIZEOF_INT == 8 a_time.tm_year = -1*(1 << 48); - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* while unlikely, the system's gmtime(_r) could return * a "correct" retrospective gregorian negative year value, @@ -356,25 +356,25 @@ test_util_time(void *arg) * -1*(2^63)/60/60/24*2000/730485 + 1970 = -292277022657 * 730485 is the number of days in two millenia, including leap days */ a_time.tm_year = -292277022657-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = INT64_MIN; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); #endif /* Wrong year >= INT32_MAX - 1900 */ #if SIZEOF_INT == 4 || SIZEOF_INT == 8 a_time.tm_year = INT32_MAX-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = INT32_MAX; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); #endif #if SIZEOF_INT == 8 /* one of the largest tm_year values my 64 bit system supports */ a_time.tm_year = 292278994-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* while unlikely, the system's gmtime(_r) could return * a "correct" proleptic gregorian year value, @@ -382,72 +382,72 @@ test_util_time(void *arg) * (2^63-1)/60/60/24*2000/730485 + 1970 = 292277026596 * 730485 is the number of days in two millenia, including leap days */ a_time.tm_year = 292277026596-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = INT64_MAX-1900; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = INT64_MAX; - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); #endif /* month */ a_time.tm_year = 2007-1900; /* restore valid year */ a_time.tm_mon = 12; /* Wrong month, it's 0-based */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_mon = -1; /* Wrong month */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* day */ a_time.tm_mon = 6; /* Try July */ a_time.tm_mday = 32; /* Wrong day */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_mon = 5; /* Try June */ a_time.tm_mday = 31; /* Wrong day */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = 2008-1900; /* Try a leap year */ a_time.tm_mon = 1; /* in feb. */ a_time.tm_mday = 30; /* Wrong day */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_year = 2011-1900; /* Try a non-leap year */ a_time.tm_mon = 1; /* in feb. */ a_time.tm_mday = 29; /* Wrong day */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_mday = 0; /* Wrong day, it's 1-based (to be different) */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* hour */ a_time.tm_mday = 3; /* restore valid month day */ a_time.tm_hour = 24; /* Wrong hour, it's 0-based */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_hour = -1; /* Wrong hour */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* minute */ a_time.tm_hour = 22; /* restore valid hour */ a_time.tm_min = 60; /* Wrong minute, it's 0-based */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_min = -1; /* Wrong minute */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* second */ a_time.tm_min = 37; /* restore valid minute */ a_time.tm_sec = 61; /* Wrong second: 0-based with leap seconds */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); a_time.tm_sec = -1; /* Wrong second */ - tt_int_op((time_t) -1,==, tor_timegm(&a_time)); + tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time)); /* Test tor_gmtime_r out of range */ @@ -534,69 +534,69 @@ test_util_time(void *arg) /* Test {format,parse}_rfc1123_time */ format_rfc1123_time(timestr, 0); - tt_str_op("Thu, 01 Jan 1970 00:00:00 GMT",==, timestr); + tt_str_op("Thu, 01 Jan 1970 00:00:00 GMT",OP_EQ, timestr); format_rfc1123_time(timestr, (time_t)1091580502UL); - tt_str_op("Wed, 04 Aug 2004 00:48:22 GMT",==, timestr); + tt_str_op("Wed, 04 Aug 2004 00:48:22 GMT",OP_EQ, timestr); t_res = 0; i = parse_rfc1123_time(timestr, &t_res); - tt_int_op(0,==, i); - tt_int_op(t_res,==, (time_t)1091580502UL); + tt_int_op(0,OP_EQ, i); + tt_int_op(t_res,OP_EQ, (time_t)1091580502UL); /* The timezone doesn't matter */ t_res = 0; - tt_int_op(0,==, parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res)); - tt_int_op(t_res,==, (time_t)1091580502UL); - tt_int_op(-1,==, + tt_int_op(0,OP_EQ, parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res)); + tt_int_op(t_res,OP_EQ, (time_t)1091580502UL); + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, zz Aug 2004 99-99x99 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 32 Mar 2011 00:00:00 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Mar 2011 24:00:00 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Mar 2011 23:60:00 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Mar 2011 23:59:62 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Mar 1969 23:59:59 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Ene 2011 23:59:59 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Mar 2011 23:59:59 GM", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 29 Feb 2011 16:00:00 GMT", &t_res)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_rfc1123_time("Wed, 30 Mar 2011 23:59:61 GMT", &t_res)); /* Test parse_iso_time */ t_res = 0; i = parse_iso_time("", &t_res); - tt_int_op(-1,==, i); + tt_int_op(-1,OP_EQ, i); t_res = 0; i = parse_iso_time("2004-08-32 00:48:22", &t_res); - tt_int_op(-1,==, i); + tt_int_op(-1,OP_EQ, i); t_res = 0; i = parse_iso_time("1969-08-03 00:48:22", &t_res); - tt_int_op(-1,==, i); + tt_int_op(-1,OP_EQ, i); t_res = 0; i = parse_iso_time("2004-08-04 00:48:22", &t_res); - tt_int_op(0,==, i); - tt_int_op(t_res,==, (time_t)1091580502UL); + tt_int_op(0,OP_EQ, i); + tt_int_op(t_res,OP_EQ, (time_t)1091580502UL); t_res = 0; i = parse_iso_time("2004-8-4 0:48:22", &t_res); - tt_int_op(0,==, i); - tt_int_op(t_res,==, (time_t)1091580502UL); - tt_int_op(-1,==, parse_iso_time("2004-08-zz 99-99x99 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("2011-03-32 00:00:00 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("2011-03-30 24:00:00 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("2011-03-30 23:60:00 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("2011-03-30 23:59:62 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("1969-03-30 23:59:59 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("2011-00-30 23:59:59 GMT", &t_res)); - tt_int_op(-1,==, parse_iso_time("2147483647-08-29 14:00:00", &t_res)); - tt_int_op(-1,==, parse_iso_time("2011-03-30 23:59", &t_res)); + tt_int_op(0,OP_EQ, i); + tt_int_op(t_res,OP_EQ, (time_t)1091580502UL); + tt_int_op(-1,OP_EQ, parse_iso_time("2004-08-zz 99-99x99 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-32 00:00:00 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 24:00:00 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 23:60:00 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 23:59:62 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("1969-03-30 23:59:59 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2011-00-30 23:59:59 GMT", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2147483647-08-29 14:00:00", &t_res)); + tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 23:59", &t_res)); /* Test tor_gettimeofday */ @@ -609,14 +609,14 @@ test_util_time(void *arg) /* now make sure time works. */ tor_gettimeofday(&end); /* We might've timewarped a little. */ - tt_int_op(tv_udiff(&start, &end), >=, -5000); + tt_int_op(tv_udiff(&start, &end), OP_GE, -5000); /* Test format_iso_time */ tv.tv_sec = (time_t)1326296338; tv.tv_usec = 3060; format_iso_time(timestr, (time_t)tv.tv_sec); - tt_str_op("2012-01-11 15:38:58",==, timestr); + tt_str_op("2012-01-11 15:38:58",OP_EQ, timestr); /* The output of format_local_iso_time will vary by timezone, and setting our timezone for testing purposes would be a nontrivial flaky pain. Skip this test for now. @@ -624,11 +624,11 @@ test_util_time(void *arg) test_streq("2012-01-11 10:38:58", timestr); */ format_iso_time_nospace(timestr, (time_t)tv.tv_sec); - tt_str_op("2012-01-11T15:38:58",==, timestr); - tt_int_op(strlen(timestr),==, ISO_TIME_LEN); + tt_str_op("2012-01-11T15:38:58",OP_EQ, timestr); + tt_int_op(strlen(timestr),OP_EQ, ISO_TIME_LEN); format_iso_time_nospace_usec(timestr, &tv); - tt_str_op("2012-01-11T15:38:58.003060",==, timestr); - tt_int_op(strlen(timestr),==, ISO_TIME_USEC_LEN); + tt_str_op("2012-01-11T15:38:58.003060",OP_EQ, timestr); + tt_int_op(strlen(timestr),OP_EQ, ISO_TIME_USEC_LEN); done: ; @@ -643,72 +643,72 @@ test_util_parse_http_time(void *arg) #define T(s) do { \ format_iso_time(b, tor_timegm(&a_time)); \ - tt_str_op(b, ==, (s)); \ + tt_str_op(b, OP_EQ, (s)); \ b[0]='\0'; \ } while (0) /* Test parse_http_time */ - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("", &a_time)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("Sunday, 32 Aug 2004 00:48:22 GMT", &a_time)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("Sunday, 3 Aug 1869 00:48:22 GMT", &a_time)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("Sunday, 32-Aug-94 00:48:22 GMT", &a_time)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("Sunday, 3-Ago-04 00:48:22", &a_time)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("Sunday, August the third", &a_time)); - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, parse_http_time("Wednesday,,04 Aug 1994 00:48:22 GMT", &a_time)); - tt_int_op(0,==, + tt_int_op(0,OP_EQ, parse_http_time("Wednesday, 04 Aug 1994 00:48:22 GMT", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, + tt_int_op(0,OP_EQ, parse_http_time("Wednesday, 4 Aug 1994 0:48:22 GMT", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, + tt_int_op(0,OP_EQ, parse_http_time("Miercoles, 4 Aug 1994 0:48:22 GMT", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, + tt_int_op(0,OP_EQ, parse_http_time("Wednesday, 04-Aug-94 00:48:22 GMT", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, parse_http_time("Wed Aug 04 00:48:22 1994", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Wed Aug 04 00:48:22 1994", &a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, parse_http_time("Wed Aug 4 0:48:22 1994", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Wed Aug 4 0:48:22 1994", &a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, parse_http_time("Mie Aug 4 0:48:22 1994", &a_time)); - tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Mie Aug 4 0:48:22 1994", &a_time)); + tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time)); T("1994-08-04 00:48:22"); - tt_int_op(0,==, parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time)); - tt_int_op((time_t)1325376000UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time)); + tt_int_op((time_t)1325376000UL,OP_EQ, tor_timegm(&a_time)); T("2012-01-01 00:00:00"); - tt_int_op(0,==, parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time)); - tt_int_op((time_t)1356912000UL,==, tor_timegm(&a_time)); + tt_int_op(0,OP_EQ, parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time)); + tt_int_op((time_t)1356912000UL,OP_EQ, tor_timegm(&a_time)); T("2012-12-31 00:00:00"); - tt_int_op(-1,==, parse_http_time("2004-08-zz 99-99x99 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("2011-03-32 00:00:00 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("2011-03-30 24:00:00 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("2011-03-30 23:60:00 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("2011-03-30 23:59:62 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("1969-03-30 23:59:59 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("2011-00-30 23:59:59 GMT", &a_time)); - tt_int_op(-1,==, parse_http_time("2011-03-30 23:59", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2004-08-zz 99-99x99 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2011-03-32 00:00:00 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2011-03-30 24:00:00 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2011-03-30 23:60:00 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2011-03-30 23:59:62 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("1969-03-30 23:59:59 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2011-00-30 23:59:59 GMT", &a_time)); + tt_int_op(-1,OP_EQ, parse_http_time("2011-03-30 23:59", &a_time)); #undef T done: @@ -743,110 +743,110 @@ test_util_config_line(void *arg) str = buf; str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k"); - tt_str_op(v,==, "v"); + tt_str_op(k,OP_EQ, "k"); + tt_str_op(v,OP_EQ, "v"); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "key value with")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "key"); - tt_str_op(v,==, "value with spaces"); + tt_str_op(k,OP_EQ, "key"); + tt_str_op(v,OP_EQ, "value with spaces"); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "keykey")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "keykey"); - tt_str_op(v,==, "val"); + tt_str_op(k,OP_EQ, "keykey"); + tt_str_op(v,OP_EQ, "val"); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "k2\n")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k2"); - tt_str_op(v,==, ""); + tt_str_op(k,OP_EQ, "k2"); + tt_str_op(v,OP_EQ, ""); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "k3 \n")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k3"); - tt_str_op(v,==, ""); + tt_str_op(k,OP_EQ, "k3"); + tt_str_op(v,OP_EQ, ""); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "#comment")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k4"); - tt_str_op(v,==, ""); + tt_str_op(k,OP_EQ, "k4"); + tt_str_op(v,OP_EQ, ""); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "k5#abc")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k5"); - tt_str_op(v,==, ""); + tt_str_op(k,OP_EQ, "k5"); + tt_str_op(v,OP_EQ, ""); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "k6")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k6"); - tt_str_op(v,==, "val"); + tt_str_op(k,OP_EQ, "k6"); + tt_str_op(v,OP_EQ, "val"); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "kseven")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "kseven"); - tt_str_op(v,==, "a quoted \'string"); + tt_str_op(k,OP_EQ, "kseven"); + tt_str_op(v,OP_EQ, "a quoted \'string"); tor_free(k); tor_free(v); tt_assert(!strcmpstart(str, "k8 ")); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k8"); - tt_str_op(v,==, "a quoted\n\"str\\ing\t\x01\x01\x01\""); + tt_str_op(k,OP_EQ, "k8"); + tt_str_op(v,OP_EQ, "a quoted\n\"str\\ing\t\x01\x01\x01\""); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k9"); - tt_str_op(v,==, "a line that spans two lines."); + tt_str_op(k,OP_EQ, "k9"); + tt_str_op(v,OP_EQ, "a line that spans two lines."); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k10"); - tt_str_op(v,==, "more than one continuation"); + tt_str_op(k,OP_EQ, "k10"); + tt_str_op(v,OP_EQ, "more than one continuation"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k11"); - tt_str_op(v,==, "continuation at the start"); + tt_str_op(k,OP_EQ, "k11"); + tt_str_op(v,OP_EQ, "continuation at the start"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k12"); - tt_str_op(v,==, "line with a embedded"); + tt_str_op(k,OP_EQ, "k12"); + tt_str_op(v,OP_EQ, "line with a embedded"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k13"); - tt_str_op(v,==, "continuation at the very start"); + tt_str_op(k,OP_EQ, "k13"); + tt_str_op(v,OP_EQ, "continuation at the very start"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k14"); - tt_str_op(v,==, "a line that has a comment and" ); + tt_str_op(k,OP_EQ, "k14"); + tt_str_op(v,OP_EQ, "a line that has a comment and" ); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k15"); - tt_str_op(v,==, "this should be the next new line"); + tt_str_op(k,OP_EQ, "k15"); + tt_str_op(v,OP_EQ, "this should be the next new line"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k16"); - tt_str_op(v,==, "a line that has a comment and" ); + tt_str_op(k,OP_EQ, "k16"); + tt_str_op(v,OP_EQ, "a line that has a comment and" ); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k17"); - tt_str_op(v,==, "this should be the next new line"); + tt_str_op(k,OP_EQ, "k17"); + tt_str_op(v,OP_EQ, "this should be the next new line"); tor_free(k); tor_free(v); - tt_str_op(str,==, ""); + tt_str_op(str,OP_EQ, ""); done: tor_free(k); @@ -877,30 +877,30 @@ test_util_config_line_quotes(void *arg) str = buf1; str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "kTrailingSpace"); - tt_str_op(v,==, "quoted value"); + tt_str_op(k,OP_EQ, "kTrailingSpace"); + tt_str_op(v,OP_EQ, "quoted value"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); str = buf2; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); str = buf3; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); str = buf4; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); done: @@ -924,16 +924,16 @@ test_util_config_line_comment_character(void *arg) str = buf; str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k1"); - tt_str_op(v,==, "# in quotes"); + tt_str_op(k,OP_EQ, "k1"); + tt_str_op(v,OP_EQ, "# in quotes"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "k2"); - tt_str_op(v,==, "some value"); + tt_str_op(k,OP_EQ, "k2"); + tt_str_op(v,OP_EQ, "some value"); tor_free(k); tor_free(v); - tt_str_op(str,==, "k3 /home/user/myTorNetwork#2\n"); + tt_str_op(str,OP_EQ, "k3 /home/user/myTorNetwork#2\n"); #if 0 str = parse_config_line_from_str(str, &k, &v); @@ -994,91 +994,91 @@ test_util_config_line_escaped_content(void *arg) str = buf1; str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "HexadecimalLower"); - tt_str_op(v,==, "*"); + tt_str_op(k,OP_EQ, "HexadecimalLower"); + tt_str_op(v,OP_EQ, "*"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "HexadecimalUpper"); - tt_str_op(v,==, "*"); + tt_str_op(k,OP_EQ, "HexadecimalUpper"); + tt_str_op(v,OP_EQ, "*"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "HexadecimalUpperX"); - tt_str_op(v,==, "*"); + tt_str_op(k,OP_EQ, "HexadecimalUpperX"); + tt_str_op(v,OP_EQ, "*"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "Octal"); - tt_str_op(v,==, "*"); + tt_str_op(k,OP_EQ, "Octal"); + tt_str_op(v,OP_EQ, "*"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "Newline"); - tt_str_op(v,==, "\n"); + tt_str_op(k,OP_EQ, "Newline"); + tt_str_op(v,OP_EQ, "\n"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "Tab"); - tt_str_op(v,==, "\t"); + tt_str_op(k,OP_EQ, "Tab"); + tt_str_op(v,OP_EQ, "\t"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "CarriageReturn"); - tt_str_op(v,==, "\r"); + tt_str_op(k,OP_EQ, "CarriageReturn"); + tt_str_op(v,OP_EQ, "\r"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "DoubleQuote"); - tt_str_op(v,==, "\""); + tt_str_op(k,OP_EQ, "DoubleQuote"); + tt_str_op(v,OP_EQ, "\""); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "SimpleQuote"); - tt_str_op(v,==, "'"); + tt_str_op(k,OP_EQ, "SimpleQuote"); + tt_str_op(v,OP_EQ, "'"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "Backslash"); - tt_str_op(v,==, "\\"); + tt_str_op(k,OP_EQ, "Backslash"); + tt_str_op(v,OP_EQ, "\\"); tor_free(k); tor_free(v); str = parse_config_line_from_str(str, &k, &v); - tt_str_op(k,==, "Mix"); - tt_str_op(v,==, "This is a \"star\":\t'*'\nAnd second line"); + tt_str_op(k,OP_EQ, "Mix"); + tt_str_op(v,OP_EQ, "This is a \"star\":\t'*'\nAnd second line"); tor_free(k); tor_free(v); - tt_str_op(str,==, ""); + tt_str_op(str,OP_EQ, ""); str = buf2; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); str = buf3; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); str = buf4; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); #if 0 str = buf5; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str, ==, NULL); + tt_ptr_op(str, OP_EQ, NULL); tor_free(k); tor_free(v); #endif str = buf6; str = parse_config_line_from_str(str, &k, &v); - tt_ptr_op(str,==, NULL); + tt_ptr_op(str,OP_EQ, NULL); tor_free(k); tor_free(v); done: @@ -1096,39 +1096,39 @@ test_util_expand_filename(void *arg) setenv("HOME", "/home/itv", 1); /* For "internal test value" */ str = expand_filename(""); - tt_str_op("",==, str); + tt_str_op("",OP_EQ, str); tor_free(str); str = expand_filename("/normal/path"); - tt_str_op("/normal/path",==, str); + tt_str_op("/normal/path",OP_EQ, str); tor_free(str); str = expand_filename("/normal/trailing/path/"); - tt_str_op("/normal/trailing/path/",==, str); + tt_str_op("/normal/trailing/path/",OP_EQ, str); tor_free(str); str = expand_filename("~"); - tt_str_op("/home/itv/",==, str); + tt_str_op("/home/itv/",OP_EQ, str); tor_free(str); str = expand_filename("$HOME/nodice"); - tt_str_op("$HOME/nodice",==, str); + tt_str_op("$HOME/nodice",OP_EQ, str); tor_free(str); str = expand_filename("~/"); - tt_str_op("/home/itv/",==, str); + tt_str_op("/home/itv/",OP_EQ, str); tor_free(str); str = expand_filename("~/foobarqux"); - tt_str_op("/home/itv/foobarqux",==, str); + tt_str_op("/home/itv/foobarqux",OP_EQ, str); tor_free(str); str = expand_filename("~/../../etc/passwd"); - tt_str_op("/home/itv/../../etc/passwd",==, str); + tt_str_op("/home/itv/../../etc/passwd",OP_EQ, str); tor_free(str); str = expand_filename("~/trailing/"); - tt_str_op("/home/itv/trailing/",==, str); + tt_str_op("/home/itv/trailing/",OP_EQ, str); tor_free(str); /* Ideally we'd test ~anotheruser, but that's shady to test (we'd have to somehow inject/fake the get_user_homedir call) */ @@ -1137,15 +1137,15 @@ test_util_expand_filename(void *arg) setenv("HOME", "/home/itv/", 1); str = expand_filename("~"); - tt_str_op("/home/itv/",==, str); + tt_str_op("/home/itv/",OP_EQ, str); tor_free(str); str = expand_filename("~/"); - tt_str_op("/home/itv/",==, str); + tt_str_op("/home/itv/",OP_EQ, str); tor_free(str); str = expand_filename("~/foo"); - tt_str_op("/home/itv/foo",==, str); + tt_str_op("/home/itv/foo",OP_EQ, str); tor_free(str); /* Try with empty $HOME */ @@ -1153,15 +1153,15 @@ test_util_expand_filename(void *arg) setenv("HOME", "", 1); str = expand_filename("~"); - tt_str_op("/",==, str); + tt_str_op("/",OP_EQ, str); tor_free(str); str = expand_filename("~/"); - tt_str_op("/",==, str); + tt_str_op("/",OP_EQ, str); tor_free(str); str = expand_filename("~/foobar"); - tt_str_op("/foobar",==, str); + tt_str_op("/foobar",OP_EQ, str); tor_free(str); /* Try with $HOME unset */ @@ -1169,15 +1169,15 @@ test_util_expand_filename(void *arg) unsetenv("HOME"); str = expand_filename("~"); - tt_str_op("/",==, str); + tt_str_op("/",OP_EQ, str); tor_free(str); str = expand_filename("~/"); - tt_str_op("/",==, str); + tt_str_op("/",OP_EQ, str); tor_free(str); str = expand_filename("~/foobar"); - tt_str_op("/foobar",==, str); + tt_str_op("/foobar",OP_EQ, str); tor_free(str); done: @@ -1195,30 +1195,30 @@ test_util_escape_string_socks(void *arg) (void)arg; escaped_string = tor_escape_str_for_pt_args("This is a backslash: \\",";\\"); tt_assert(escaped_string); - tt_str_op(escaped_string,==, "This is a backslash: \\\\"); + tt_str_op(escaped_string,OP_EQ, "This is a backslash: \\\\"); tor_free(escaped_string); /** Simple semicolon escape. */ escaped_string = tor_escape_str_for_pt_args("First rule:Do not use ;",";\\"); tt_assert(escaped_string); - tt_str_op(escaped_string,==, "First rule:Do not use \\;"); + tt_str_op(escaped_string,OP_EQ, "First rule:Do not use \\;"); tor_free(escaped_string); /** Empty string. */ escaped_string = tor_escape_str_for_pt_args("", ";\\"); tt_assert(escaped_string); - tt_str_op(escaped_string,==, ""); + tt_str_op(escaped_string,OP_EQ, ""); tor_free(escaped_string); /** Escape all characters. */ escaped_string = tor_escape_str_for_pt_args(";\\;\\", ";\\"); tt_assert(escaped_string); - tt_str_op(escaped_string,==, "\\;\\\\\\;\\\\"); + tt_str_op(escaped_string,OP_EQ, "\\;\\\\\\;\\\\"); tor_free(escaped_string); escaped_string = tor_escape_str_for_pt_args(";", ";\\"); tt_assert(escaped_string); - tt_str_op(escaped_string,==, "\\;"); + tt_str_op(escaped_string,OP_EQ, "\\;"); tor_free(escaped_string); done: @@ -1254,152 +1254,152 @@ test_util_strmisc(void *arg) /* Test strl operations */ (void)arg; - tt_int_op(5,==, strlcpy(buf, "Hello", 0)); - tt_int_op(5,==, strlcpy(buf, "Hello", 10)); - tt_str_op(buf,==, "Hello"); - tt_int_op(5,==, strlcpy(buf, "Hello", 6)); - tt_str_op(buf,==, "Hello"); - tt_int_op(5,==, strlcpy(buf, "Hello", 5)); - tt_str_op(buf,==, "Hell"); + tt_int_op(5,OP_EQ, strlcpy(buf, "Hello", 0)); + tt_int_op(5,OP_EQ, strlcpy(buf, "Hello", 10)); + tt_str_op(buf,OP_EQ, "Hello"); + tt_int_op(5,OP_EQ, strlcpy(buf, "Hello", 6)); + tt_str_op(buf,OP_EQ, "Hello"); + tt_int_op(5,OP_EQ, strlcpy(buf, "Hello", 5)); + tt_str_op(buf,OP_EQ, "Hell"); strlcpy(buf, "Hello", sizeof(buf)); - tt_int_op(10,==, strlcat(buf, "Hello", 5)); + tt_int_op(10,OP_EQ, strlcat(buf, "Hello", 5)); /* Test strstrip() */ strlcpy(buf, "Testing 1 2 3", sizeof(buf)); tor_strstrip(buf, ",!"); - tt_str_op(buf,==, "Testing 1 2 3"); + tt_str_op(buf,OP_EQ, "Testing 1 2 3"); strlcpy(buf, "!Testing 1 2 3?", sizeof(buf)); tor_strstrip(buf, "!? "); - tt_str_op(buf,==, "Testing123"); + tt_str_op(buf,OP_EQ, "Testing123"); strlcpy(buf, "!!!Testing 1 2 3??", sizeof(buf)); tor_strstrip(buf, "!? "); - tt_str_op(buf,==, "Testing123"); + tt_str_op(buf,OP_EQ, "Testing123"); /* Test parse_long */ /* Empty/zero input */ - tt_int_op(0L,==, tor_parse_long("",10,0,100,&i,NULL)); - tt_int_op(0,==, i); - tt_int_op(0L,==, tor_parse_long("0",10,0,100,&i,NULL)); - tt_int_op(1,==, i); + tt_int_op(0L,OP_EQ, tor_parse_long("",10,0,100,&i,NULL)); + tt_int_op(0,OP_EQ, i); + tt_int_op(0L,OP_EQ, tor_parse_long("0",10,0,100,&i,NULL)); + tt_int_op(1,OP_EQ, i); /* Normal cases */ - tt_int_op(10L,==, tor_parse_long("10",10,0,100,&i,NULL)); - tt_int_op(1,==, i); - tt_int_op(10L,==, tor_parse_long("10",10,0,10,&i,NULL)); - tt_int_op(1,==, i); - tt_int_op(10L,==, tor_parse_long("10",10,10,100,&i,NULL)); - tt_int_op(1,==, i); - tt_int_op(-50L,==, tor_parse_long("-50",10,-100,100,&i,NULL)); - tt_int_op(1,==, i); - tt_int_op(-50L,==, tor_parse_long("-50",10,-100,0,&i,NULL)); - tt_int_op(1,==, i); - tt_int_op(-50L,==, tor_parse_long("-50",10,-50,0,&i,NULL)); - tt_int_op(1,==, i); + tt_int_op(10L,OP_EQ, tor_parse_long("10",10,0,100,&i,NULL)); + tt_int_op(1,OP_EQ, i); + tt_int_op(10L,OP_EQ, tor_parse_long("10",10,0,10,&i,NULL)); + tt_int_op(1,OP_EQ, i); + tt_int_op(10L,OP_EQ, tor_parse_long("10",10,10,100,&i,NULL)); + tt_int_op(1,OP_EQ, i); + tt_int_op(-50L,OP_EQ, tor_parse_long("-50",10,-100,100,&i,NULL)); + tt_int_op(1,OP_EQ, i); + tt_int_op(-50L,OP_EQ, tor_parse_long("-50",10,-100,0,&i,NULL)); + tt_int_op(1,OP_EQ, i); + tt_int_op(-50L,OP_EQ, tor_parse_long("-50",10,-50,0,&i,NULL)); + tt_int_op(1,OP_EQ, i); /* Extra garbage */ - tt_int_op(0L,==, tor_parse_long("10m",10,0,100,&i,NULL)); - tt_int_op(0,==, i); - tt_int_op(0L,==, tor_parse_long("-50 plus garbage",10,-100,100,&i,NULL)); - tt_int_op(0,==, i); - tt_int_op(10L,==, tor_parse_long("10m",10,0,100,&i,&cp)); - tt_int_op(1,==, i); - tt_str_op(cp,==, "m"); - tt_int_op(-50L,==, tor_parse_long("-50 plus garbage",10,-100,100,&i,&cp)); - tt_int_op(1,==, i); - tt_str_op(cp,==, " plus garbage"); + tt_int_op(0L,OP_EQ, tor_parse_long("10m",10,0,100,&i,NULL)); + tt_int_op(0,OP_EQ, i); + tt_int_op(0L,OP_EQ, tor_parse_long("-50 plus garbage",10,-100,100,&i,NULL)); + tt_int_op(0,OP_EQ, i); + tt_int_op(10L,OP_EQ, tor_parse_long("10m",10,0,100,&i,&cp)); + tt_int_op(1,OP_EQ, i); + tt_str_op(cp,OP_EQ, "m"); + tt_int_op(-50L,OP_EQ, tor_parse_long("-50 plus garbage",10,-100,100,&i,&cp)); + tt_int_op(1,OP_EQ, i); + tt_str_op(cp,OP_EQ, " plus garbage"); /* Out of bounds */ - tt_int_op(0L,==, tor_parse_long("10",10,50,100,&i,NULL)); - tt_int_op(0,==, i); - tt_int_op(0L,==, tor_parse_long("-50",10,0,100,&i,NULL)); - tt_int_op(0,==, i); + tt_int_op(0L,OP_EQ, tor_parse_long("10",10,50,100,&i,NULL)); + tt_int_op(0,OP_EQ, i); + tt_int_op(0L,OP_EQ, tor_parse_long("-50",10,0,100,&i,NULL)); + tt_int_op(0,OP_EQ, i); /* Base different than 10 */ - tt_int_op(2L,==, tor_parse_long("10",2,0,100,NULL,NULL)); - tt_int_op(0L,==, tor_parse_long("2",2,0,100,NULL,NULL)); - tt_int_op(0L,==, tor_parse_long("10",-2,0,100,NULL,NULL)); - tt_int_op(68284L,==, tor_parse_long("10abc",16,0,70000,NULL,NULL)); - tt_int_op(68284L,==, tor_parse_long("10ABC",16,0,70000,NULL,NULL)); - tt_int_op(0,==, tor_parse_long("10ABC",-1,0,70000,&i,NULL)); - tt_int_op(i,==, 0); + tt_int_op(2L,OP_EQ, tor_parse_long("10",2,0,100,NULL,NULL)); + tt_int_op(0L,OP_EQ, tor_parse_long("2",2,0,100,NULL,NULL)); + tt_int_op(0L,OP_EQ, tor_parse_long("10",-2,0,100,NULL,NULL)); + tt_int_op(68284L,OP_EQ, tor_parse_long("10abc",16,0,70000,NULL,NULL)); + tt_int_op(68284L,OP_EQ, tor_parse_long("10ABC",16,0,70000,NULL,NULL)); + tt_int_op(0,OP_EQ, tor_parse_long("10ABC",-1,0,70000,&i,NULL)); + tt_int_op(i,OP_EQ, 0); /* Test parse_ulong */ - tt_int_op(0UL,==, tor_parse_ulong("",10,0,100,NULL,NULL)); - tt_int_op(0UL,==, tor_parse_ulong("0",10,0,100,NULL,NULL)); - tt_int_op(10UL,==, tor_parse_ulong("10",10,0,100,NULL,NULL)); - tt_int_op(0UL,==, tor_parse_ulong("10",10,50,100,NULL,NULL)); - tt_int_op(10UL,==, tor_parse_ulong("10",10,0,10,NULL,NULL)); - tt_int_op(10UL,==, tor_parse_ulong("10",10,10,100,NULL,NULL)); - tt_int_op(0UL,==, tor_parse_ulong("8",8,0,100,NULL,NULL)); - tt_int_op(50UL,==, tor_parse_ulong("50",10,50,100,NULL,NULL)); - tt_int_op(0UL,==, tor_parse_ulong("-50",10,-100,100,NULL,NULL)); - tt_int_op(0UL,==, tor_parse_ulong("50",-1,50,100,&i,NULL)); - tt_int_op(0,==, i); + tt_int_op(0UL,OP_EQ, tor_parse_ulong("",10,0,100,NULL,NULL)); + tt_int_op(0UL,OP_EQ, tor_parse_ulong("0",10,0,100,NULL,NULL)); + tt_int_op(10UL,OP_EQ, tor_parse_ulong("10",10,0,100,NULL,NULL)); + tt_int_op(0UL,OP_EQ, tor_parse_ulong("10",10,50,100,NULL,NULL)); + tt_int_op(10UL,OP_EQ, tor_parse_ulong("10",10,0,10,NULL,NULL)); + tt_int_op(10UL,OP_EQ, tor_parse_ulong("10",10,10,100,NULL,NULL)); + tt_int_op(0UL,OP_EQ, tor_parse_ulong("8",8,0,100,NULL,NULL)); + tt_int_op(50UL,OP_EQ, tor_parse_ulong("50",10,50,100,NULL,NULL)); + tt_int_op(0UL,OP_EQ, tor_parse_ulong("-50",10,-100,100,NULL,NULL)); + tt_int_op(0UL,OP_EQ, tor_parse_ulong("50",-1,50,100,&i,NULL)); + tt_int_op(0,OP_EQ, i); /* Test parse_uint64 */ tt_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp)); - tt_int_op(1,==, i); - tt_str_op(cp,==, " x"); + tt_int_op(1,OP_EQ, i); + tt_str_op(cp,OP_EQ, " x"); tt_assert(U64_LITERAL(12345678901) == tor_parse_uint64("12345678901",10,0,UINT64_MAX, &i, &cp)); - tt_int_op(1,==, i); - tt_str_op(cp,==, ""); + tt_int_op(1,OP_EQ, i); + tt_str_op(cp,OP_EQ, ""); tt_assert(U64_LITERAL(0) == tor_parse_uint64("12345678901",10,500,INT32_MAX, &i, &cp)); - tt_int_op(0,==, i); + tt_int_op(0,OP_EQ, i); tt_assert(U64_LITERAL(0) == tor_parse_uint64("123",-1,0,INT32_MAX, &i, &cp)); - tt_int_op(0,==, i); + tt_int_op(0,OP_EQ, i); { /* Test parse_double */ double d = tor_parse_double("10", 0, UINT64_MAX,&i,NULL); - tt_int_op(1,==, i); + tt_int_op(1,OP_EQ, i); tt_assert(DBL_TO_U64(d) == 10); d = tor_parse_double("0", 0, UINT64_MAX,&i,NULL); - tt_int_op(1,==, i); + tt_int_op(1,OP_EQ, i); tt_assert(DBL_TO_U64(d) == 0); d = tor_parse_double(" ", 0, UINT64_MAX,&i,NULL); - tt_int_op(0,==, i); + tt_int_op(0,OP_EQ, i); d = tor_parse_double(".0a", 0, UINT64_MAX,&i,NULL); - tt_int_op(0,==, i); + tt_int_op(0,OP_EQ, i); d = tor_parse_double(".0a", 0, UINT64_MAX,&i,&cp); - tt_int_op(1,==, i); + tt_int_op(1,OP_EQ, i); d = tor_parse_double("-.0", 0, UINT64_MAX,&i,NULL); - tt_int_op(1,==, i); + tt_int_op(1,OP_EQ, i); tt_assert(DBL_TO_U64(d) == 0); d = tor_parse_double("-10", -100.0, 100.0,&i,NULL); - tt_int_op(1,==, i); - tt_int_op(-10.0,==, d); + tt_int_op(1,OP_EQ, i); + tt_int_op(-10.0,OP_EQ, d); } { /* Test tor_parse_* where we overflow/underflow the underlying type. */ /* This string should overflow 64-bit ints. */ #define TOOBIG "100000000000000000000000000" - tt_int_op(0L,==, tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL)); - tt_int_op(i,==, 0); - tt_int_op(0L,==, + tt_int_op(0L,OP_EQ, tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL)); + tt_int_op(i,OP_EQ, 0); + tt_int_op(0L,OP_EQ, tor_parse_long("-"TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL)); - tt_int_op(i,==, 0); - tt_int_op(0UL,==, tor_parse_ulong(TOOBIG, 10, 0, ULONG_MAX, &i, NULL)); - tt_int_op(i,==, 0); - tt_u64_op(U64_LITERAL(0), ==, tor_parse_uint64(TOOBIG, 10, + tt_int_op(i,OP_EQ, 0); + tt_int_op(0UL,OP_EQ, tor_parse_ulong(TOOBIG, 10, 0, ULONG_MAX, &i, NULL)); + tt_int_op(i,OP_EQ, 0); + tt_u64_op(U64_LITERAL(0), OP_EQ, tor_parse_uint64(TOOBIG, 10, 0, UINT64_MAX, &i, NULL)); - tt_int_op(i,==, 0); + tt_int_op(i,OP_EQ, 0); } /* Test snprintf */ /* Returning -1 when there's not enough room in the output buffer */ - tt_int_op(-1,==, tor_snprintf(buf, 0, "Foo")); - tt_int_op(-1,==, tor_snprintf(buf, 2, "Foo")); - tt_int_op(-1,==, tor_snprintf(buf, 3, "Foo")); - tt_int_op(-1,!=, tor_snprintf(buf, 4, "Foo")); + tt_int_op(-1,OP_EQ, tor_snprintf(buf, 0, "Foo")); + tt_int_op(-1,OP_EQ, tor_snprintf(buf, 2, "Foo")); + tt_int_op(-1,OP_EQ, tor_snprintf(buf, 3, "Foo")); + tt_int_op(-1,OP_NE, tor_snprintf(buf, 4, "Foo")); /* Always NUL-terminate the output */ tor_snprintf(buf, 5, "abcdef"); - tt_int_op(0,==, buf[4]); + tt_int_op(0,OP_EQ, buf[4]); tor_snprintf(buf, 10, "abcdef"); - tt_int_op(0,==, buf[6]); + tt_int_op(0,OP_EQ, buf[6]); /* uint64 */ tor_snprintf(buf, sizeof(buf), "x!"U64_FORMAT"!x", U64_PRINTF_ARG(U64_LITERAL(12345678901))); - tt_str_op("x!12345678901!x",==, buf); + tt_str_op("x!12345678901!x",OP_EQ, buf); /* Test str{,case}cmpstart */ tt_assert(strcmpstart("abcdef", "abcdef")==0); @@ -1450,31 +1450,31 @@ test_util_strmisc(void *arg) /* Test 'escaped' */ tt_assert(NULL == escaped(NULL)); - tt_str_op("\"\"",==, escaped("")); - tt_str_op("\"abcd\"",==, escaped("abcd")); - tt_str_op("\"\\\\ \\n\\r\\t\\\"\\'\"",==, escaped("\\ \n\r\t\"'")); - tt_str_op("\"unnecessary \\'backslashes\\'\"",==, + tt_str_op("\"\"",OP_EQ, escaped("")); + tt_str_op("\"abcd\"",OP_EQ, escaped("abcd")); + tt_str_op("\"\\\\ \\n\\r\\t\\\"\\'\"",OP_EQ, escaped("\\ \n\r\t\"'")); + tt_str_op("\"unnecessary \\'backslashes\\'\"",OP_EQ, escaped("unnecessary \'backslashes\'")); /* Non-printable characters appear as octal */ - tt_str_op("\"z\\001abc\\277d\"",==, escaped("z\001abc\277d")); - tt_str_op("\"z\\336\\255 ;foo\"",==, escaped("z\xde\xad\x20;foo")); + tt_str_op("\"z\\001abc\\277d\"",OP_EQ, escaped("z\001abc\277d")); + tt_str_op("\"z\\336\\255 ;foo\"",OP_EQ, escaped("z\xde\xad\x20;foo")); /* Test strndup and memdup */ { const char *s = "abcdefghijklmnopqrstuvwxyz"; cp_tmp = tor_strndup(s, 30); - tt_str_op(cp_tmp,==, s); /* same string, */ - tt_ptr_op(cp_tmp,!=,s); /* but different pointers. */ + tt_str_op(cp_tmp,OP_EQ, s); /* same string, */ + tt_ptr_op(cp_tmp,OP_NE,s); /* but different pointers. */ tor_free(cp_tmp); cp_tmp = tor_strndup(s, 5); - tt_str_op(cp_tmp,==, "abcde"); + tt_str_op(cp_tmp,OP_EQ, "abcde"); tor_free(cp_tmp); s = "a\0b\0c\0d\0e\0"; cp_tmp = tor_memdup(s,10); - tt_mem_op(cp_tmp,==, s, 10); /* same ram, */ - tt_ptr_op(cp_tmp,!=,s); /* but different pointers. */ + tt_mem_op(cp_tmp,OP_EQ, s, 10); /* same ram, */ + tt_ptr_op(cp_tmp,OP_NE,s); /* but different pointers. */ tor_free(cp_tmp); } @@ -1484,9 +1484,9 @@ test_util_strmisc(void *arg) cp_tmp[3] = 'D'; tt_assert(!tor_strisnonupper(cp_tmp)); tor_strupper(cp_tmp); - tt_str_op(cp_tmp,==, "ABCDEF"); + tt_str_op(cp_tmp,OP_EQ, "ABCDEF"); tor_strlower(cp_tmp); - tt_str_op(cp_tmp,==, "abcdef"); + tt_str_op(cp_tmp,OP_EQ, "abcdef"); tt_assert(tor_strisnonupper(cp_tmp)); tt_assert(tor_strisprint(cp_tmp)); cp_tmp[3] = 3; @@ -1497,18 +1497,18 @@ test_util_strmisc(void *arg) { const char *haystack = "abcde"; tt_assert(!tor_memmem(haystack, 5, "ef", 2)); - tt_ptr_op(tor_memmem(haystack, 5, "cd", 2),==, haystack + 2); - tt_ptr_op(tor_memmem(haystack, 5, "cde", 3),==, haystack + 2); + tt_ptr_op(tor_memmem(haystack, 5, "cd", 2),OP_EQ, haystack + 2); + tt_ptr_op(tor_memmem(haystack, 5, "cde", 3),OP_EQ, haystack + 2); tt_assert(!tor_memmem(haystack, 4, "cde", 3)); haystack = "ababcad"; - tt_ptr_op(tor_memmem(haystack, 7, "abc", 3),==, haystack + 2); - tt_ptr_op(tor_memmem(haystack, 7, "ad", 2),==, haystack + 5); - tt_ptr_op(tor_memmem(haystack, 7, "cad", 3),==, haystack + 4); + tt_ptr_op(tor_memmem(haystack, 7, "abc", 3),OP_EQ, haystack + 2); + tt_ptr_op(tor_memmem(haystack, 7, "ad", 2),OP_EQ, haystack + 5); + tt_ptr_op(tor_memmem(haystack, 7, "cad", 3),OP_EQ, haystack + 4); tt_assert(!tor_memmem(haystack, 7, "dadad", 5)); tt_assert(!tor_memmem(haystack, 7, "abcdefghij", 10)); /* memstr */ - tt_ptr_op(tor_memstr(haystack, 7, "abc"),==, haystack + 2); - tt_ptr_op(tor_memstr(haystack, 7, "cad"),==, haystack + 4); + tt_ptr_op(tor_memstr(haystack, 7, "abc"),OP_EQ, haystack + 2); + tt_ptr_op(tor_memstr(haystack, 7, "cad"),OP_EQ, haystack + 4); tt_assert(!tor_memstr(haystack, 6, "cad")); tt_assert(!tor_memstr(haystack, 7, "cadd")); tt_assert(!tor_memstr(haystack, 7, "fe")); @@ -1521,42 +1521,42 @@ test_util_strmisc(void *arg) size_t i; for (i = 0; i < sizeof(binary_data); ++i) binary_data[i] = i; - tt_str_op(hex_str(binary_data, 0),==, ""); - tt_str_op(hex_str(binary_data, 1),==, "00"); - tt_str_op(hex_str(binary_data, 17),==, + tt_str_op(hex_str(binary_data, 0),OP_EQ, ""); + tt_str_op(hex_str(binary_data, 1),OP_EQ, "00"); + tt_str_op(hex_str(binary_data, 17),OP_EQ, "000102030405060708090A0B0C0D0E0F10"); - tt_str_op(hex_str(binary_data, 32),==, + tt_str_op(hex_str(binary_data, 32),OP_EQ, "000102030405060708090A0B0C0D0E0F" "101112131415161718191A1B1C1D1E1F"); - tt_str_op(hex_str(binary_data, 34),==, + tt_str_op(hex_str(binary_data, 34),OP_EQ, "000102030405060708090A0B0C0D0E0F" "101112131415161718191A1B1C1D1E1F"); /* Repeat these tests for shorter strings after longer strings have been tried, to make sure we're correctly terminating strings */ - tt_str_op(hex_str(binary_data, 1),==, "00"); - tt_str_op(hex_str(binary_data, 0),==, ""); + tt_str_op(hex_str(binary_data, 1),OP_EQ, "00"); + tt_str_op(hex_str(binary_data, 0),OP_EQ, ""); } /* Test strcmp_opt */ - tt_int_op(strcmp_opt("", "foo"), <, 0); - tt_int_op(strcmp_opt("", ""), ==, 0); - tt_int_op(strcmp_opt("foo", ""), >, 0); + tt_int_op(strcmp_opt("", "foo"), OP_LT, 0); + tt_int_op(strcmp_opt("", ""), OP_EQ, 0); + tt_int_op(strcmp_opt("foo", ""), OP_GT, 0); - tt_int_op(strcmp_opt(NULL, ""), <, 0); - tt_int_op(strcmp_opt(NULL, NULL), ==, 0); - tt_int_op(strcmp_opt("", NULL), >, 0); + tt_int_op(strcmp_opt(NULL, ""), OP_LT, 0); + tt_int_op(strcmp_opt(NULL, NULL), OP_EQ, 0); + tt_int_op(strcmp_opt("", NULL), OP_GT, 0); - tt_int_op(strcmp_opt(NULL, "foo"), <, 0); - tt_int_op(strcmp_opt("foo", NULL), >, 0); + tt_int_op(strcmp_opt(NULL, "foo"), OP_LT, 0); + tt_int_op(strcmp_opt("foo", NULL), OP_GT, 0); /* Test strcmp_len */ - tt_int_op(strcmp_len("foo", "bar", 3), >, 0); - tt_int_op(strcmp_len("foo", "bar", 2), <, 0); /* First len, then lexical */ - tt_int_op(strcmp_len("foo2", "foo1", 4), >, 0); - tt_int_op(strcmp_len("foo2", "foo1", 3), <, 0); /* Really stop at len */ - tt_int_op(strcmp_len("foo2", "foo", 3), ==, 0); /* Really stop at len */ - tt_int_op(strcmp_len("blah", "", 4), >, 0); - tt_int_op(strcmp_len("blah", "", 0), ==, 0); + tt_int_op(strcmp_len("foo", "bar", 3), OP_GT, 0); + tt_int_op(strcmp_len("foo", "bar", 2), OP_LT, 0); /* First len, then lexical */ + tt_int_op(strcmp_len("foo2", "foo1", 4), OP_GT, 0); + tt_int_op(strcmp_len("foo2", "foo1", 3), OP_LT, 0); /* Really stop at len */ + tt_int_op(strcmp_len("foo2", "foo", 3), OP_EQ, 0); /* Really stop at len */ + tt_int_op(strcmp_len("blah", "", 4), OP_GT, 0); + tt_int_op(strcmp_len("blah", "", 0), OP_EQ, 0); done: tor_free(cp_tmp); @@ -1567,34 +1567,34 @@ test_util_pow2(void *arg) { /* Test tor_log2(). */ (void)arg; - tt_int_op(tor_log2(64),==, 6); - tt_int_op(tor_log2(65),==, 6); - tt_int_op(tor_log2(63),==, 5); - tt_int_op(tor_log2(0),==, 0);/* incorrect mathematically, but as specified */ - tt_int_op(tor_log2(1),==, 0); - tt_int_op(tor_log2(2),==, 1); - tt_int_op(tor_log2(3),==, 1); - tt_int_op(tor_log2(4),==, 2); - tt_int_op(tor_log2(5),==, 2); - tt_int_op(tor_log2(U64_LITERAL(40000000000000000)),==, 55); - tt_int_op(tor_log2(UINT64_MAX),==, 63); + tt_int_op(tor_log2(64),OP_EQ, 6); + tt_int_op(tor_log2(65),OP_EQ, 6); + tt_int_op(tor_log2(63),OP_EQ, 5); + tt_int_op(tor_log2(0),OP_EQ, 0);/* incorrect mathematically, but as specified */ + tt_int_op(tor_log2(1),OP_EQ, 0); + tt_int_op(tor_log2(2),OP_EQ, 1); + tt_int_op(tor_log2(3),OP_EQ, 1); + tt_int_op(tor_log2(4),OP_EQ, 2); + tt_int_op(tor_log2(5),OP_EQ, 2); + tt_int_op(tor_log2(U64_LITERAL(40000000000000000)),OP_EQ, 55); + tt_int_op(tor_log2(UINT64_MAX),OP_EQ, 63); /* Test round_to_power_of_2 */ - tt_u64_op(round_to_power_of_2(120), ==, 128); - tt_u64_op(round_to_power_of_2(128), ==, 128); - tt_u64_op(round_to_power_of_2(130), ==, 128); - tt_u64_op(round_to_power_of_2(U64_LITERAL(40000000000000000)), ==, + tt_u64_op(round_to_power_of_2(120), OP_EQ, 128); + tt_u64_op(round_to_power_of_2(128), OP_EQ, 128); + tt_u64_op(round_to_power_of_2(130), OP_EQ, 128); + tt_u64_op(round_to_power_of_2(U64_LITERAL(40000000000000000)), OP_EQ, U64_LITERAL(1)<<55); - tt_u64_op(round_to_power_of_2(U64_LITERAL(0xffffffffffffffff)), ==, + tt_u64_op(round_to_power_of_2(U64_LITERAL(0xffffffffffffffff)), OP_EQ, U64_LITERAL(1)<<63); - tt_u64_op(round_to_power_of_2(0), ==, 1); - tt_u64_op(round_to_power_of_2(1), ==, 1); - tt_u64_op(round_to_power_of_2(2), ==, 2); - tt_u64_op(round_to_power_of_2(3), ==, 2); - tt_u64_op(round_to_power_of_2(4), ==, 4); - tt_u64_op(round_to_power_of_2(5), ==, 4); - tt_u64_op(round_to_power_of_2(6), ==, 4); - tt_u64_op(round_to_power_of_2(7), ==, 8); + tt_u64_op(round_to_power_of_2(0), OP_EQ, 1); + tt_u64_op(round_to_power_of_2(1), OP_EQ, 1); + tt_u64_op(round_to_power_of_2(2), OP_EQ, 2); + tt_u64_op(round_to_power_of_2(3), OP_EQ, 2); + tt_u64_op(round_to_power_of_2(4), OP_EQ, 4); + tt_u64_op(round_to_power_of_2(5), OP_EQ, 4); + tt_u64_op(round_to_power_of_2(6), OP_EQ, 4); + tt_u64_op(round_to_power_of_2(7), OP_EQ, 8); done: ; @@ -1758,8 +1758,8 @@ test_util_gzip(void *arg) tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1, GZIP_METHOD, 1, LOG_INFO)); tt_assert(buf3); - tt_int_op(strlen(buf1) + 1,==, len2); - tt_str_op(buf1,==, buf3); + tt_int_op(strlen(buf1) + 1,OP_EQ, len2); + tt_str_op(buf1,OP_EQ, buf3); tor_free(buf2); tor_free(buf3); @@ -1773,8 +1773,8 @@ test_util_gzip(void *arg) tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1, ZLIB_METHOD, 1, LOG_INFO)); tt_assert(buf3); - tt_int_op(strlen(buf1) + 1,==, len2); - tt_str_op(buf1,==, buf3); + tt_int_op(strlen(buf1) + 1,OP_EQ, len2); + tt_str_op(buf1,OP_EQ, buf3); /* Check whether we can uncompress concatenated, compressed strings. */ tor_free(buf3); @@ -1782,8 +1782,8 @@ test_util_gzip(void *arg) memcpy(buf2+len1, buf2, len1); tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1*2, ZLIB_METHOD, 1, LOG_INFO)); - tt_int_op((strlen(buf1)+1)*2,==, len2); - tt_mem_op(buf3,==, + tt_int_op((strlen(buf1)+1)*2,OP_EQ, len2); + tt_mem_op(buf3,OP_EQ, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0" "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0", (strlen(buf1)+1)*2); @@ -1823,20 +1823,20 @@ test_util_gzip(void *arg) len2 = 21; tt_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 0) == TOR_ZLIB_OK); - tt_int_op(0,==, len2); /* Make sure we compressed it all. */ + tt_int_op(0,OP_EQ, len2); /* Make sure we compressed it all. */ tt_assert(cp1 > buf1); len2 = 0; cp2 = cp1; tt_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 1) == TOR_ZLIB_DONE); - tt_int_op(0,==, len2); + tt_int_op(0,OP_EQ, len2); tt_assert(cp1 > cp2); /* Make sure we really added something. */ tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf1, 1024-len1, ZLIB_METHOD, 1, LOG_WARN)); - tt_str_op(buf3,==,"ABCDEFGHIJABCDEFGHIJ"); /*Make sure it compressed right.*/ - tt_int_op(21,==, len2); + tt_str_op(buf3,OP_EQ,"ABCDEFGHIJABCDEFGHIJ"); /*Make sure it compressed right.*/ + tt_int_op(21,OP_EQ, len2); done: if (state) @@ -1867,25 +1867,25 @@ test_util_mmap(void *arg) mapping = tor_mmap_file(fname1); tt_assert(mapping); - tt_int_op(mapping->size,==, strlen("Short file.")); - tt_str_op(mapping->data,==, "Short file."); + tt_int_op(mapping->size,OP_EQ, strlen("Short file.")); + tt_str_op(mapping->data,OP_EQ, "Short file."); #ifdef _WIN32 - tt_int_op(0, ==, tor_munmap_file(mapping)); + tt_int_op(0, OP_EQ, tor_munmap_file(mapping)); mapping = NULL; tt_assert(unlink(fname1) == 0); #else /* make sure we can unlink. */ tt_assert(unlink(fname1) == 0); - tt_str_op(mapping->data,==, "Short file."); - tt_int_op(0, ==, tor_munmap_file(mapping)); + tt_str_op(mapping->data,OP_EQ, "Short file."); + tt_int_op(0, OP_EQ, tor_munmap_file(mapping)); mapping = NULL; #endif /* Now a zero-length file. */ write_str_to_file(fname1, "", 1); mapping = tor_mmap_file(fname1); - tt_ptr_op(mapping,==, NULL); - tt_int_op(ERANGE,==, errno); + tt_ptr_op(mapping,OP_EQ, NULL); + tt_int_op(ERANGE,OP_EQ, errno); unlink(fname1); /* Make sure that we fail to map a no-longer-existent file. */ @@ -1896,18 +1896,18 @@ test_util_mmap(void *arg) write_bytes_to_file(fname2, buf, buflen, 1); mapping = tor_mmap_file(fname2); tt_assert(mapping); - tt_int_op(mapping->size,==, buflen); - tt_mem_op(mapping->data,==, buf, buflen); - tt_int_op(0, ==, tor_munmap_file(mapping)); + tt_int_op(mapping->size,OP_EQ, buflen); + tt_mem_op(mapping->data,OP_EQ, buf, buflen); + tt_int_op(0, OP_EQ, tor_munmap_file(mapping)); mapping = NULL; /* Now try a big aligned file. */ write_bytes_to_file(fname3, buf, 16384, 1); mapping = tor_mmap_file(fname3); tt_assert(mapping); - tt_int_op(mapping->size,==, 16384); - tt_mem_op(mapping->data,==, buf, 16384); - tt_int_op(0, ==, tor_munmap_file(mapping)); + tt_int_op(mapping->size,OP_EQ, 16384); + tt_mem_op(mapping->data,OP_EQ, buf, 16384); + tt_int_op(0, OP_EQ, tor_munmap_file(mapping)); mapping = NULL; done: @@ -1934,9 +1934,9 @@ test_util_control_formats(void *arg) (void)arg; sz = read_escaped_data(inp, strlen(inp), &out); - tt_str_op(out,==, + tt_str_op(out,OP_EQ, ".This is a test\nof the emergency \n.system.\n\rZ.\n"); - tt_int_op(sz,==, strlen(out)); + tt_int_op(sz,OP_EQ, strlen(out)); done: tor_free(out); @@ -1968,334 +1968,334 @@ test_util_sscanf(void *arg) /* Simple tests (malformed patterns, literal matching, ...) */ (void)arg; - tt_int_op(-1,==, tor_sscanf("123", "%i", &r)); /* %i is not supported */ - tt_int_op(-1,==, + tt_int_op(-1,OP_EQ, tor_sscanf("123", "%i", &r)); /* %i is not supported */ + tt_int_op(-1,OP_EQ, tor_sscanf("wrong", "%5c", s1)); /* %c cannot have a number. */ - tt_int_op(-1,==, tor_sscanf("hello", "%s", s1)); /* %s needs a number. */ - tt_int_op(-1,==, tor_sscanf("prettylongstring", "%999999s", s1)); + tt_int_op(-1,OP_EQ, tor_sscanf("hello", "%s", s1)); /* %s needs a number. */ + tt_int_op(-1,OP_EQ, tor_sscanf("prettylongstring", "%999999s", s1)); #if 0 /* GCC thinks these two are illegal. */ test_eq(-1, tor_sscanf("prettylongstring", "%0s", s1)); test_eq(0, tor_sscanf("prettylongstring", "%10s", NULL)); #endif /* No '%'-strings: always "success" */ - tt_int_op(0,==, tor_sscanf("hello world", "hello world")); - tt_int_op(0,==, tor_sscanf("hello world", "good bye")); + tt_int_op(0,OP_EQ, tor_sscanf("hello world", "hello world")); + tt_int_op(0,OP_EQ, tor_sscanf("hello world", "good bye")); /* Excess data */ - tt_int_op(0,==, + tt_int_op(0,OP_EQ, tor_sscanf("hello 3", "%u", &u1)); /* have to match the start */ - tt_int_op(0,==, tor_sscanf(" 3 hello", "%u", &u1)); - tt_int_op(0,==, + tt_int_op(0,OP_EQ, tor_sscanf(" 3 hello", "%u", &u1)); + tt_int_op(0,OP_EQ, tor_sscanf(" 3 hello", "%2u", &u1)); /* not even in this case */ - tt_int_op(1,==, + tt_int_op(1,OP_EQ, tor_sscanf("3 hello", "%u", &u1)); /* but trailing is alright */ /* Numbers (ie. %u) */ - tt_int_op(0,==, + tt_int_op(0,OP_EQ, tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */ - tt_int_op(1,==, tor_sscanf("12345", "%u", &u1)); - tt_int_op(12345u,==, u1); - tt_int_op(1,==, tor_sscanf("12346 ", "%u", &u1)); - tt_int_op(12346u,==, u1); - tt_int_op(0,==, tor_sscanf(" 12347", "%u", &u1)); - tt_int_op(1,==, tor_sscanf(" 12348", " %u", &u1)); - tt_int_op(12348u,==, u1); - tt_int_op(1,==, tor_sscanf("0", "%u", &u1)); - tt_int_op(0u,==, u1); - tt_int_op(1,==, tor_sscanf("0000", "%u", &u2)); - tt_int_op(0u,==, u2); - tt_int_op(0,==, tor_sscanf("", "%u", &u1)); /* absent number */ - tt_int_op(0,==, tor_sscanf("A", "%u", &u1)); /* bogus number */ - tt_int_op(0,==, tor_sscanf("-1", "%u", &u1)); /* negative number */ + tt_int_op(1,OP_EQ, tor_sscanf("12345", "%u", &u1)); + tt_int_op(12345u,OP_EQ, u1); + tt_int_op(1,OP_EQ, tor_sscanf("12346 ", "%u", &u1)); + tt_int_op(12346u,OP_EQ, u1); + tt_int_op(0,OP_EQ, tor_sscanf(" 12347", "%u", &u1)); + tt_int_op(1,OP_EQ, tor_sscanf(" 12348", " %u", &u1)); + tt_int_op(12348u,OP_EQ, u1); + tt_int_op(1,OP_EQ, tor_sscanf("0", "%u", &u1)); + tt_int_op(0u,OP_EQ, u1); + tt_int_op(1,OP_EQ, tor_sscanf("0000", "%u", &u2)); + tt_int_op(0u,OP_EQ, u2); + tt_int_op(0,OP_EQ, tor_sscanf("", "%u", &u1)); /* absent number */ + tt_int_op(0,OP_EQ, tor_sscanf("A", "%u", &u1)); /* bogus number */ + tt_int_op(0,OP_EQ, tor_sscanf("-1", "%u", &u1)); /* negative number */ /* Numbers with size (eg. %2u) */ - tt_int_op(0,==, tor_sscanf("-1", "%2u", &u1)); - tt_int_op(2,==, tor_sscanf("123456", "%2u%u", &u1, &u2)); - tt_int_op(12u,==, u1); - tt_int_op(3456u,==, u2); - tt_int_op(1,==, tor_sscanf("123456", "%8u", &u1)); - tt_int_op(123456u,==, u1); - tt_int_op(1,==, tor_sscanf("123457 ", "%8u", &u1)); - tt_int_op(123457u,==, u1); - tt_int_op(0,==, tor_sscanf(" 123456", "%8u", &u1)); - tt_int_op(3,==, tor_sscanf("!12:3:456", "!%2u:%2u:%3u", &u1, &u2, &u3)); - tt_int_op(12u,==, u1); - tt_int_op(3u,==, u2); - tt_int_op(456u,==, u3); - tt_int_op(3,==, + tt_int_op(0,OP_EQ, tor_sscanf("-1", "%2u", &u1)); + tt_int_op(2,OP_EQ, tor_sscanf("123456", "%2u%u", &u1, &u2)); + tt_int_op(12u,OP_EQ, u1); + tt_int_op(3456u,OP_EQ, u2); + tt_int_op(1,OP_EQ, tor_sscanf("123456", "%8u", &u1)); + tt_int_op(123456u,OP_EQ, u1); + tt_int_op(1,OP_EQ, tor_sscanf("123457 ", "%8u", &u1)); + tt_int_op(123457u,OP_EQ, u1); + tt_int_op(0,OP_EQ, tor_sscanf(" 123456", "%8u", &u1)); + tt_int_op(3,OP_EQ, tor_sscanf("!12:3:456", "!%2u:%2u:%3u", &u1, &u2, &u3)); + tt_int_op(12u,OP_EQ, u1); + tt_int_op(3u,OP_EQ, u2); + tt_int_op(456u,OP_EQ, u3); + tt_int_op(3,OP_EQ, tor_sscanf("67:8:099", "%2u:%2u:%3u", &u1, &u2, &u3)); /* 0s */ - tt_int_op(67u,==, u1); - tt_int_op(8u,==, u2); - tt_int_op(99u,==, u3); + tt_int_op(67u,OP_EQ, u1); + tt_int_op(8u,OP_EQ, u2); + tt_int_op(99u,OP_EQ, u3); /* %u does not match space.*/ - tt_int_op(2,==, tor_sscanf("12:3: 45", "%2u:%2u:%3u", &u1, &u2, &u3)); - tt_int_op(12u,==, u1); - tt_int_op(3u,==, u2); + tt_int_op(2,OP_EQ, tor_sscanf("12:3: 45", "%2u:%2u:%3u", &u1, &u2, &u3)); + tt_int_op(12u,OP_EQ, u1); + tt_int_op(3u,OP_EQ, u2); /* %u does not match negative numbers. */ - tt_int_op(2,==, tor_sscanf("67:8:-9", "%2u:%2u:%3u", &u1, &u2, &u3)); - tt_int_op(67u,==, u1); - tt_int_op(8u,==, u2); + tt_int_op(2,OP_EQ, tor_sscanf("67:8:-9", "%2u:%2u:%3u", &u1, &u2, &u3)); + tt_int_op(67u,OP_EQ, u1); + tt_int_op(8u,OP_EQ, u2); /* Arbitrary amounts of 0-padding are okay */ - tt_int_op(3,==, tor_sscanf("12:03:000000000000000099", "%2u:%2u:%u", + tt_int_op(3,OP_EQ, tor_sscanf("12:03:000000000000000099", "%2u:%2u:%u", &u1, &u2, &u3)); - tt_int_op(12u,==, u1); - tt_int_op(3u,==, u2); - tt_int_op(99u,==, u3); + tt_int_op(12u,OP_EQ, u1); + tt_int_op(3u,OP_EQ, u2); + tt_int_op(99u,OP_EQ, u3); /* Hex (ie. %x) */ - tt_int_op(3,==, tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3)); - tt_int_op(0x1234,==, u1); - tt_int_op(0x2ABCDEF,==, u2); - tt_int_op(0xFF,==, u3); + tt_int_op(3,OP_EQ, tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3)); + tt_int_op(0x1234,OP_EQ, u1); + tt_int_op(0x2ABCDEF,OP_EQ, u2); + tt_int_op(0xFF,OP_EQ, u3); /* Width works on %x */ - tt_int_op(3,==, tor_sscanf("f00dcafe444", "%4x%4x%u", &u1, &u2, &u3)); - tt_int_op(0xf00d,==, u1); - tt_int_op(0xcafe,==, u2); - tt_int_op(444,==, u3); + tt_int_op(3,OP_EQ, tor_sscanf("f00dcafe444", "%4x%4x%u", &u1, &u2, &u3)); + tt_int_op(0xf00d,OP_EQ, u1); + tt_int_op(0xcafe,OP_EQ, u2); + tt_int_op(444,OP_EQ, u3); /* Literal '%' (ie. '%%') */ - tt_int_op(1,==, tor_sscanf("99% fresh", "%3u%% fresh", &u1)); - tt_int_op(99,==, u1); - tt_int_op(0,==, tor_sscanf("99 fresh", "%% %3u %s", &u1, s1)); - tt_int_op(1,==, tor_sscanf("99 fresh", "%3u%% %s", &u1, s1)); - tt_int_op(2,==, tor_sscanf("99 fresh", "%3u %5s %%", &u1, s1)); - tt_int_op(99,==, u1); - tt_str_op(s1,==, "fresh"); - tt_int_op(1,==, tor_sscanf("% boo", "%% %3s", s1)); - tt_str_op("boo",==, s1); + tt_int_op(1,OP_EQ, tor_sscanf("99% fresh", "%3u%% fresh", &u1)); + tt_int_op(99,OP_EQ, u1); + tt_int_op(0,OP_EQ, tor_sscanf("99 fresh", "%% %3u %s", &u1, s1)); + tt_int_op(1,OP_EQ, tor_sscanf("99 fresh", "%3u%% %s", &u1, s1)); + tt_int_op(2,OP_EQ, tor_sscanf("99 fresh", "%3u %5s %%", &u1, s1)); + tt_int_op(99,OP_EQ, u1); + tt_str_op(s1,OP_EQ, "fresh"); + tt_int_op(1,OP_EQ, tor_sscanf("% boo", "%% %3s", s1)); + tt_str_op("boo",OP_EQ, s1); /* Strings (ie. %s) */ - tt_int_op(2,==, tor_sscanf("hello", "%3s%7s", s1, s2)); - tt_str_op(s1,==, "hel"); - tt_str_op(s2,==, "lo"); - tt_int_op(2,==, tor_sscanf("WD40", "%2s%u", s3, &u1)); /* %s%u */ - tt_str_op(s3,==, "WD"); - tt_int_op(40,==, u1); - tt_int_op(2,==, tor_sscanf("WD40", "%3s%u", s3, &u1)); /* %s%u */ - tt_str_op(s3,==, "WD4"); - tt_int_op(0,==, u1); - tt_int_op(2,==, tor_sscanf("76trombones", "%6u%9s", &u1, s1)); /* %u%s */ - tt_int_op(76,==, u1); - tt_str_op(s1,==, "trombones"); - tt_int_op(1,==, tor_sscanf("prettylongstring", "%999s", s1)); - tt_str_op(s1,==, "prettylongstring"); + tt_int_op(2,OP_EQ, tor_sscanf("hello", "%3s%7s", s1, s2)); + tt_str_op(s1,OP_EQ, "hel"); + tt_str_op(s2,OP_EQ, "lo"); + tt_int_op(2,OP_EQ, tor_sscanf("WD40", "%2s%u", s3, &u1)); /* %s%u */ + tt_str_op(s3,OP_EQ, "WD"); + tt_int_op(40,OP_EQ, u1); + tt_int_op(2,OP_EQ, tor_sscanf("WD40", "%3s%u", s3, &u1)); /* %s%u */ + tt_str_op(s3,OP_EQ, "WD4"); + tt_int_op(0,OP_EQ, u1); + tt_int_op(2,OP_EQ, tor_sscanf("76trombones", "%6u%9s", &u1, s1)); /* %u%s */ + tt_int_op(76,OP_EQ, u1); + tt_str_op(s1,OP_EQ, "trombones"); + tt_int_op(1,OP_EQ, tor_sscanf("prettylongstring", "%999s", s1)); + tt_str_op(s1,OP_EQ, "prettylongstring"); /* %s doesn't eat spaces */ - tt_int_op(2,==, tor_sscanf("hello world", "%9s %9s", s1, s2)); - tt_str_op(s1,==, "hello"); - tt_str_op(s2,==, "world"); - tt_int_op(2,==, tor_sscanf("bye world?", "%9s %9s", s1, s2)); - tt_str_op(s1,==, "bye"); - tt_str_op(s2,==, ""); - tt_int_op(3,==, + tt_int_op(2,OP_EQ, tor_sscanf("hello world", "%9s %9s", s1, s2)); + tt_str_op(s1,OP_EQ, "hello"); + tt_str_op(s2,OP_EQ, "world"); + tt_int_op(2,OP_EQ, tor_sscanf("bye world?", "%9s %9s", s1, s2)); + tt_str_op(s1,OP_EQ, "bye"); + tt_str_op(s2,OP_EQ, ""); + tt_int_op(3,OP_EQ, tor_sscanf("hi", "%9s%9s%3s", s1, s2, s3)); /* %s can be empty. */ - tt_str_op(s1,==, "hi"); - tt_str_op(s2,==, ""); - tt_str_op(s3,==, ""); + tt_str_op(s1,OP_EQ, "hi"); + tt_str_op(s2,OP_EQ, ""); + tt_str_op(s3,OP_EQ, ""); - tt_int_op(3,==, tor_sscanf("1.2.3", "%u.%u.%u%c", &u1, &u2, &u3, &ch)); - tt_int_op(4,==, + tt_int_op(3,OP_EQ, tor_sscanf("1.2.3", "%u.%u.%u%c", &u1, &u2, &u3, &ch)); + tt_int_op(4,OP_EQ, tor_sscanf("1.2.3 foobar", "%u.%u.%u%c", &u1, &u2, &u3, &ch)); - tt_int_op(' ',==, ch); + tt_int_op(' ',OP_EQ, ch); r = tor_sscanf("12345 -67890 -1", "%d %ld %d", &int1, &lng1, &int2); - tt_int_op(r,==, 3); - tt_int_op(int1,==, 12345); - tt_int_op(lng1,==, -67890); - tt_int_op(int2,==, -1); + tt_int_op(r,OP_EQ, 3); + tt_int_op(int1,OP_EQ, 12345); + tt_int_op(lng1,OP_EQ, -67890); + tt_int_op(int2,OP_EQ, -1); #if SIZEOF_INT == 4 /* %u */ /* UINT32_MAX should work */ - tt_int_op(1,==, tor_sscanf("4294967295", "%u", &u1)); - tt_int_op(4294967295U,==, u1); + tt_int_op(1,OP_EQ, tor_sscanf("4294967295", "%u", &u1)); + tt_int_op(4294967295U,OP_EQ, u1); /* But UINT32_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("4294967296", "%u", &u1)); + tt_int_op(0,OP_EQ, tor_sscanf("4294967296", "%u", &u1)); /* but parsing only 9... */ - tt_int_op(1,==, tor_sscanf("4294967296", "%9u", &u1)); - tt_int_op(429496729U,==, u1); + tt_int_op(1,OP_EQ, tor_sscanf("4294967296", "%9u", &u1)); + tt_int_op(429496729U,OP_EQ, u1); /* %x */ /* UINT32_MAX should work */ - tt_int_op(1,==, tor_sscanf("FFFFFFFF", "%x", &u1)); - tt_int_op(0xFFFFFFFF,==, u1); + tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFF", "%x", &u1)); + tt_int_op(0xFFFFFFFF,OP_EQ, u1); /* But UINT32_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("100000000", "%x", &u1)); + tt_int_op(0,OP_EQ, tor_sscanf("100000000", "%x", &u1)); /* %d */ /* INT32_MIN and INT32_MAX should work */ r = tor_sscanf("-2147483648. 2147483647.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 2); - tt_int_op(int1,==, -2147483647 - 1); - tt_int_op(int2,==, 2147483647); + tt_int_op(r,OP_EQ, 2); + tt_int_op(int1,OP_EQ, -2147483647 - 1); + tt_int_op(int2,OP_EQ, 2147483647); /* But INT32_MIN - 1 and INT32_MAX + 1 shouldn't work */ r = tor_sscanf("-2147483649.", "%d.", &int1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("2147483648.", "%d.", &int1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); /* and the first failure stops further processing */ r = tor_sscanf("-2147483648. 2147483648.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 1); + tt_int_op(r,OP_EQ, 1); r = tor_sscanf("-2147483649. 2147483647.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("2147483648. -2147483649.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); #elif SIZEOF_INT == 8 /* %u */ /* UINT64_MAX should work */ - tt_int_op(1,==, tor_sscanf("18446744073709551615", "%u", &u1)); - tt_int_op(18446744073709551615U,==, u1); + tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551615", "%u", &u1)); + tt_int_op(18446744073709551615U,OP_EQ, u1); /* But UINT64_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("18446744073709551616", "%u", &u1)); + tt_int_op(0,OP_EQ, tor_sscanf("18446744073709551616", "%u", &u1)); /* but parsing only 19... */ - tt_int_op(1,==, tor_sscanf("18446744073709551616", "%19u", &u1)); - tt_int_op(1844674407370955161U,==, u1); + tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551616", "%19u", &u1)); + tt_int_op(1844674407370955161U,OP_EQ, u1); /* %x */ /* UINT64_MAX should work */ - tt_int_op(1,==, tor_sscanf("FFFFFFFFFFFFFFFF", "%x", &u1)); - tt_int_op(0xFFFFFFFFFFFFFFFF,==, u1); + tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFFFFFFFFFF", "%x", &u1)); + tt_int_op(0xFFFFFFFFFFFFFFFF,OP_EQ, u1); /* But UINT64_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("10000000000000000", "%x", &u1)); + tt_int_op(0,OP_EQ, tor_sscanf("10000000000000000", "%x", &u1)); /* %d */ /* INT64_MIN and INT64_MAX should work */ r = tor_sscanf("-9223372036854775808. 9223372036854775807.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 2); - tt_int_op(int1,==, -9223372036854775807 - 1); - tt_int_op(int2,==, 9223372036854775807); + tt_int_op(r,OP_EQ, 2); + tt_int_op(int1,OP_EQ, -9223372036854775807 - 1); + tt_int_op(int2,OP_EQ, 9223372036854775807); /* But INT64_MIN - 1 and INT64_MAX + 1 shouldn't work */ r = tor_sscanf("-9223372036854775809.", "%d.", &int1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("9223372036854775808.", "%d.", &int1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); /* and the first failure stops further processing */ r = tor_sscanf("-9223372036854775808. 9223372036854775808.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 1); + tt_int_op(r,OP_EQ, 1); r = tor_sscanf("-9223372036854775809. 9223372036854775807.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("9223372036854775808. -9223372036854775809.", "%d. %d.", &int1, &int2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); #endif #if SIZEOF_LONG == 4 /* %lu */ /* UINT32_MAX should work */ - tt_int_op(1,==, tor_sscanf("4294967295", "%lu", &ulng)); - tt_int_op(4294967295UL,==, ulng); + tt_int_op(1,OP_EQ, tor_sscanf("4294967295", "%lu", &ulng)); + tt_int_op(4294967295UL,OP_EQ, ulng); /* But UINT32_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("4294967296", "%lu", &ulng)); + tt_int_op(0,OP_EQ, tor_sscanf("4294967296", "%lu", &ulng)); /* but parsing only 9... */ - tt_int_op(1,==, tor_sscanf("4294967296", "%9lu", &ulng)); - tt_int_op(429496729UL,==, ulng); + tt_int_op(1,OP_EQ, tor_sscanf("4294967296", "%9lu", &ulng)); + tt_int_op(429496729UL,OP_EQ, ulng); /* %lx */ /* UINT32_MAX should work */ - tt_int_op(1,==, tor_sscanf("FFFFFFFF", "%lx", &ulng)); - tt_int_op(0xFFFFFFFFUL,==, ulng); + tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFF", "%lx", &ulng)); + tt_int_op(0xFFFFFFFFUL,OP_EQ, ulng); /* But UINT32_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("100000000", "%lx", &ulng)); + tt_int_op(0,OP_EQ, tor_sscanf("100000000", "%lx", &ulng)); /* %ld */ /* INT32_MIN and INT32_MAX should work */ r = tor_sscanf("-2147483648. 2147483647.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 2); - tt_int_op(lng1,==, -2147483647L - 1L); - tt_int_op(lng2,==, 2147483647L); + tt_int_op(r,OP_EQ, 2); + tt_int_op(lng1,OP_EQ, -2147483647L - 1L); + tt_int_op(lng2,OP_EQ, 2147483647L); /* But INT32_MIN - 1 and INT32_MAX + 1 shouldn't work */ r = tor_sscanf("-2147483649.", "%ld.", &lng1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("2147483648.", "%ld.", &lng1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); /* and the first failure stops further processing */ r = tor_sscanf("-2147483648. 2147483648.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 1); + tt_int_op(r,OP_EQ, 1); r = tor_sscanf("-2147483649. 2147483647.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("2147483648. -2147483649.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); #elif SIZEOF_LONG == 8 /* %lu */ /* UINT64_MAX should work */ - tt_int_op(1,==, tor_sscanf("18446744073709551615", "%lu", &ulng)); - tt_int_op(18446744073709551615UL,==, ulng); + tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551615", "%lu", &ulng)); + tt_int_op(18446744073709551615UL,OP_EQ, ulng); /* But UINT64_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("18446744073709551616", "%lu", &ulng)); + tt_int_op(0,OP_EQ, tor_sscanf("18446744073709551616", "%lu", &ulng)); /* but parsing only 19... */ - tt_int_op(1,==, tor_sscanf("18446744073709551616", "%19lu", &ulng)); - tt_int_op(1844674407370955161UL,==, ulng); + tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551616", "%19lu", &ulng)); + tt_int_op(1844674407370955161UL,OP_EQ, ulng); /* %lx */ /* UINT64_MAX should work */ - tt_int_op(1,==, tor_sscanf("FFFFFFFFFFFFFFFF", "%lx", &ulng)); - tt_int_op(0xFFFFFFFFFFFFFFFFUL,==, ulng); + tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFFFFFFFFFF", "%lx", &ulng)); + tt_int_op(0xFFFFFFFFFFFFFFFFUL,OP_EQ, ulng); /* But UINT64_MAX + 1 shouldn't work */ - tt_int_op(0,==, tor_sscanf("10000000000000000", "%lx", &ulng)); + tt_int_op(0,OP_EQ, tor_sscanf("10000000000000000", "%lx", &ulng)); /* %ld */ /* INT64_MIN and INT64_MAX should work */ r = tor_sscanf("-9223372036854775808. 9223372036854775807.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 2); - tt_int_op(lng1,==, -9223372036854775807L - 1L); - tt_int_op(lng2,==, 9223372036854775807L); + tt_int_op(r,OP_EQ, 2); + tt_int_op(lng1,OP_EQ, -9223372036854775807L - 1L); + tt_int_op(lng2,OP_EQ, 9223372036854775807L); /* But INT64_MIN - 1 and INT64_MAX + 1 shouldn't work */ r = tor_sscanf("-9223372036854775809.", "%ld.", &lng1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("9223372036854775808.", "%ld.", &lng1); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); /* and the first failure stops further processing */ r = tor_sscanf("-9223372036854775808. 9223372036854775808.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 1); + tt_int_op(r,OP_EQ, 1); r = tor_sscanf("-9223372036854775809. 9223372036854775807.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); r = tor_sscanf("9223372036854775808. -9223372036854775809.", "%ld. %ld.", &lng1, &lng2); - tt_int_op(r,==, 0); + tt_int_op(r,OP_EQ, 0); #endif r = tor_sscanf("123.456 .000007 -900123123.2000787 00003.2", "%lf %lf %lf %lf", &d1,&d2,&d3,&d4); - tt_int_op(r,==, 4); + tt_int_op(r,OP_EQ, 4); test_feq(d1, 123.456); test_feq(d2, .000007); test_feq(d3, -900123123.2000787); @@ -2350,234 +2350,234 @@ test_util_format_time_interval(void *arg) /* ignore exact spelling of "second(s)"*/ format_time_interval(dbuf, sizeof(dbuf), 0); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &sec, label_s); - tt_int_op(r,==, 2); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(sec,==, 0); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(sec,OP_EQ, 0); format_time_interval(dbuf, sizeof(dbuf), 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &sec, label_s); - tt_int_op(r,==, 2); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(sec,==, 1); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(sec,OP_EQ, 1); format_time_interval(dbuf, sizeof(dbuf), 10); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &sec, label_s); - tt_int_op(r,==, 2); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(sec,==, 10); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(sec,OP_EQ, 10); format_time_interval(dbuf, sizeof(dbuf), 59); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &sec, label_s); - tt_int_op(r,==, 2); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(sec,==, 59); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(sec,OP_EQ, 59); /* negative seconds are reported as their absolute value */ format_time_interval(dbuf, sizeof(dbuf), -4); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &sec, label_s); - tt_int_op(r,==, 2); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(sec,==, 4); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(sec,OP_EQ, 4); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); format_time_interval(dbuf, sizeof(dbuf), -32); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &sec, label_s); - tt_int_op(r,==, 2); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(sec,==, 32); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(sec,OP_EQ, 32); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); /* minutes: 1:00, 1:01, 1:59, 2:00, 2:01, 59:59 */ /* ignore trailing "0 second(s)", if present */ format_time_interval(dbuf, sizeof(dbuf), 60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &min, label_m); - tt_int_op(r,==, 2); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(min,==, 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(r,OP_EQ, 2); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(min,OP_EQ, 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); /* ignore exact spelling of "minute(s)," and "second(s)" */ format_time_interval(dbuf, sizeof(dbuf), 60 + 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &min, label_m, &sec, label_s); - tt_int_op(r,==, 4); - tt_int_op(min,==, 1); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(sec,==, 1); - tt_ci_char_op(label_s[0],==, 's'); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(r,OP_EQ, 4); + tt_int_op(min,OP_EQ, 1); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(sec,OP_EQ, 1); + tt_ci_char_op(label_s[0],OP_EQ, 's'); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); format_time_interval(dbuf, sizeof(dbuf), 60*2 - 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &min, label_m, &sec, label_s); - tt_int_op(r,==, 4); - tt_int_op(min,==, 1); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(sec,==, 59); - tt_ci_char_op(label_s[0],==, 's'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(min,OP_EQ, 1); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(sec,OP_EQ, 59); + tt_ci_char_op(label_s[0],OP_EQ, 's'); /* ignore trailing "0 second(s)", if present */ format_time_interval(dbuf, sizeof(dbuf), 60*2); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &min, label_m); - tt_int_op(r,==, 2); - tt_int_op(min,==, 2); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(min,OP_EQ, 2); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* ignore exact spelling of "minute(s)," and "second(s)" */ format_time_interval(dbuf, sizeof(dbuf), 60*2 + 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &min, label_m, &sec, label_s); - tt_int_op(r,==, 4); - tt_int_op(min,==, 2); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(sec,==, 1); - tt_ci_char_op(label_s[0],==, 's'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(min,OP_EQ, 2); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(sec,OP_EQ, 1); + tt_ci_char_op(label_s[0],OP_EQ, 's'); format_time_interval(dbuf, sizeof(dbuf), 60*60 - 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &min, label_m, &sec, label_s); - tt_int_op(r,==, 4); - tt_int_op(min,==, 59); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(sec,==, 59); - tt_ci_char_op(label_s[0],==, 's'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(min,OP_EQ, 59); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(sec,OP_EQ, 59); + tt_ci_char_op(label_s[0],OP_EQ, 's'); /* negative minutes are reported as their absolute value */ /* ignore trailing "0 second(s)", if present */ format_time_interval(dbuf, sizeof(dbuf), -3*60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &min, label_m); - tt_int_op(r,==, 2); - tt_int_op(min,==, 3); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(min,OP_EQ, 3); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* ignore exact spelling of "minute(s)," and "second(s)" */ format_time_interval(dbuf, sizeof(dbuf), -96); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &min, label_m, &sec, label_s); - tt_int_op(r,==, 4); - tt_int_op(min,==, 1); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(sec,==, 36); - tt_ci_char_op(label_s[0],==, 's'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(min,OP_EQ, 1); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(sec,OP_EQ, 36); + tt_ci_char_op(label_s[0],OP_EQ, 's'); format_time_interval(dbuf, sizeof(dbuf), -2815); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &min, label_m, &sec, label_s); - tt_int_op(r,==, 4); - tt_int_op(min,==, 46); - tt_ci_char_op(label_m[0],==, 'm'); - tt_int_op(sec,==, 55); - tt_ci_char_op(label_s[0],==, 's'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(min,OP_EQ, 46); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); + tt_int_op(sec,OP_EQ, 55); + tt_ci_char_op(label_s[0],OP_EQ, 's'); /* hours: 1:00, 1:00:01, 1:01, 23:59, 23:59:59 */ /* always ignore trailing seconds, if present */ /* ignore trailing "0 minute(s)" etc., if present */ format_time_interval(dbuf, sizeof(dbuf), 60*60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &hour, label_h); - tt_int_op(r,==, 2); - tt_int_op(hour,==, 1); - tt_ci_char_op(label_h[0],==, 'h'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(hour,OP_EQ, 1); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); format_time_interval(dbuf, sizeof(dbuf), 60*60 + 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &hour, label_h); - tt_int_op(r,==, 2); - tt_int_op(hour,==, 1); - tt_ci_char_op(label_h[0],==, 'h'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(hour,OP_EQ, 1); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); /* ignore exact spelling of "hour(s)," etc. */ format_time_interval(dbuf, sizeof(dbuf), 60*60 + 60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &hour, label_h, &min, label_m); - tt_int_op(r,==, 4); - tt_int_op(hour,==, 1); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 1); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(hour,OP_EQ, 1); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 1); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &hour, label_h, &min, label_m); - tt_int_op(r,==, 4); - tt_int_op(hour,==, 23); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 59); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(hour,OP_EQ, 23); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 59); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &hour, label_h, &min, label_m); - tt_int_op(r,==, 4); - tt_int_op(hour,==, 23); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 59); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(hour,OP_EQ, 23); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 59); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* negative hours are reported as their absolute value */ /* ignore exact spelling of "hour(s)," etc., if present */ format_time_interval(dbuf, sizeof(dbuf), -2*60*60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &hour, label_h); - tt_int_op(r,==, 2); - tt_int_op(hour,==, 2); - tt_ci_char_op(label_h[0],==, 'h'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(hour,OP_EQ, 2); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); format_time_interval(dbuf, sizeof(dbuf), -75804); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &hour, label_h, &min, label_m); - tt_int_op(r,==, 4); - tt_int_op(hour,==, 21); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 3); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(hour,OP_EQ, 21); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 3); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* days: 1:00, 1:00:00:01, 1:00:01, 1:01 */ /* always ignore trailing seconds, if present */ /* ignore trailing "0 hours(s)" etc., if present */ format_time_interval(dbuf, sizeof(dbuf), 24*60*60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &day, label_d); - tt_int_op(r,==, 2); - tt_int_op(day,==, 1); - tt_ci_char_op(label_d[0],==, 'd'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(day,OP_EQ, 1); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 1); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_, &day, label_d); - tt_int_op(r,==, 2); - tt_int_op(day,==, 1); - tt_ci_char_op(label_d[0],==, 'd'); + tt_int_op(r,OP_EQ, 2); + tt_int_op(day,OP_EQ, 1); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); /* ignore exact spelling of "days(s)," etc. */ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); if (r == -1) { @@ -2586,68 +2586,68 @@ test_util_format_time_interval(void *arg) &day, label_d, &min, label_m); } tt_assert(r == 4 || r == 6); - tt_int_op(day,==, 1); - tt_ci_char_op(label_d[0],==, 'd'); + tt_int_op(day,OP_EQ, 1); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); if (r == 6) { - tt_int_op(hour,==, 0); - tt_ci_char_op(label_h[0],==, 'h'); + tt_int_op(hour,OP_EQ, 0); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); } - tt_int_op(min,==, 1); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(min,OP_EQ, 1); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* ignore trailing "0 minutes(s)" etc., if present */ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60*60); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_, &day, label_d, &hour, label_h); - tt_int_op(r,==, 4); - tt_int_op(day,==, 1); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 1); - tt_ci_char_op(label_h[0],==, 'h'); + tt_int_op(r,OP_EQ, 4); + tt_int_op(day,OP_EQ, 1); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 1); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); /* negative days are reported as their absolute value */ format_time_interval(dbuf, sizeof(dbuf), -21936184); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 253); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 21); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 23); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 253); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 21); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 23); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* periods > 1 year are reported in days (warn?) */ /* ignore exact spelling of "days(s)," etc., if present */ format_time_interval(dbuf, sizeof(dbuf), 758635154); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 8780); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 11); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 59); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 8780); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 11); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 59); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* negative periods > 1 year are reported in days (warn?) */ format_time_interval(dbuf, sizeof(dbuf), -1427014922); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 16516); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 9); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 2); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 16516); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 9); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 2); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); #if SIZEOF_LONG == 4 || SIZEOF_LONG == 8 @@ -2656,32 +2656,32 @@ test_util_format_time_interval(void *arg) /* INT32_MAX */ format_time_interval(dbuf, sizeof(dbuf), 2147483647); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 24855); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 3); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 14); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 24855); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 3); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 14); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* and 7 seconds - ignored */ /* INT32_MIN: check that we get the absolute value of interval, * which doesn't actually fit in int32_t. * We expect INT32_MAX or INT32_MAX + 1 with 64 bit longs */ format_time_interval(dbuf, sizeof(dbuf), -2147483647L - 1L); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 24855); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 3); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 14); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 24855); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 3); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 14); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* and 7 or 8 seconds - ignored */ #endif @@ -2693,16 +2693,16 @@ test_util_format_time_interval(void *arg) /* INT64_MAX */ format_time_interval(dbuf, sizeof(dbuf), 9223372036854775807L); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 106751991167300L); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 15); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 30); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 106751991167300L); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 15); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 30); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* and 7 seconds - ignored */ /* INT64_MIN: check that we get the absolute value of interval, @@ -2710,16 +2710,16 @@ test_util_format_time_interval(void *arg) * We expect INT64_MAX */ format_time_interval(dbuf, sizeof(dbuf), -9223372036854775807L - 1L); - tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); + tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1); r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, &day, label_d, &hour, label_h, &min, label_m); - tt_int_op(r,==, 6); - tt_int_op(day,==, 106751991167300L); - tt_ci_char_op(label_d[0],==, 'd'); - tt_int_op(hour,==, 15); - tt_ci_char_op(label_h[0],==, 'h'); - tt_int_op(min,==, 30); - tt_ci_char_op(label_m[0],==, 'm'); + tt_int_op(r,OP_EQ, 6); + tt_int_op(day,OP_EQ, 106751991167300L); + tt_ci_char_op(label_d[0],OP_EQ, 'd'); + tt_int_op(hour,OP_EQ, 15); + tt_ci_char_op(label_h[0],OP_EQ, 'h'); + tt_int_op(min,OP_EQ, 30); + tt_ci_char_op(label_m[0],OP_EQ, 'm'); /* and 7 or 8 seconds - ignored */ #endif @@ -2741,30 +2741,30 @@ test_util_path_is_relative(void *arg) { /* OS-independent tests */ (void)arg; - tt_int_op(1,==, path_is_relative("")); - tt_int_op(1,==, path_is_relative("dir")); - tt_int_op(1,==, path_is_relative("dir/")); - tt_int_op(1,==, path_is_relative("./dir")); - tt_int_op(1,==, path_is_relative("../dir")); + tt_int_op(1,OP_EQ, path_is_relative("")); + tt_int_op(1,OP_EQ, path_is_relative("dir")); + tt_int_op(1,OP_EQ, path_is_relative("dir/")); + tt_int_op(1,OP_EQ, path_is_relative("./dir")); + tt_int_op(1,OP_EQ, path_is_relative("../dir")); - tt_int_op(0,==, path_is_relative("/")); - tt_int_op(0,==, path_is_relative("/dir")); - tt_int_op(0,==, path_is_relative("/dir/")); + tt_int_op(0,OP_EQ, path_is_relative("/")); + tt_int_op(0,OP_EQ, path_is_relative("/dir")); + tt_int_op(0,OP_EQ, path_is_relative("/dir/")); /* Windows */ #ifdef _WIN32 /* I don't have Windows so I can't test this, hence the "#ifdef 0". These are tests that look useful, so please try to get them running and uncomment if it all works as it should */ - tt_int_op(1,==, path_is_relative("dir")); - tt_int_op(1,==, path_is_relative("dir\\")); - tt_int_op(1,==, path_is_relative("dir\\a:")); - tt_int_op(1,==, path_is_relative("dir\\a:\\")); - tt_int_op(1,==, path_is_relative("http:\\dir")); - - tt_int_op(0,==, path_is_relative("\\dir")); - tt_int_op(0,==, path_is_relative("a:\\dir")); - tt_int_op(0,==, path_is_relative("z:\\dir")); + tt_int_op(1,OP_EQ, path_is_relative("dir")); + tt_int_op(1,OP_EQ, path_is_relative("dir\\")); + tt_int_op(1,OP_EQ, path_is_relative("dir\\a:")); + tt_int_op(1,OP_EQ, path_is_relative("dir\\a:\\")); + tt_int_op(1,OP_EQ, path_is_relative("http:\\dir")); + + tt_int_op(0,OP_EQ, path_is_relative("\\dir")); + tt_int_op(0,OP_EQ, path_is_relative("a:\\dir")); + tt_int_op(0,OP_EQ, path_is_relative("z:\\dir")); #endif done: @@ -2793,7 +2793,7 @@ test_util_mempool(void *arg) tt_assert(pool); tt_assert(pool->new_chunk_capacity >= 10); tt_assert(pool->item_alloc_size >= sizeof(void*)+241); - tt_int_op(pool->item_alloc_size & 0x03,==, 0); + tt_int_op(pool->item_alloc_size & 0x03,OP_EQ, 0); tt_assert(pool->new_chunk_capacity < 60); allocated = smartlist_new(); @@ -2857,16 +2857,16 @@ test_util_memarea(void *arg) tt_assert(p1+64 <= p2); tt_assert(p2+52 <= p3); /* Make sure we aligned. */ - tt_int_op(((uintptr_t)p1) % sizeof(void*),==, 0); - tt_int_op(((uintptr_t)p2) % sizeof(void*),==, 0); - tt_int_op(((uintptr_t)p3) % sizeof(void*),==, 0); + tt_int_op(((uintptr_t)p1) % sizeof(void*),OP_EQ, 0); + tt_int_op(((uintptr_t)p2) % sizeof(void*),OP_EQ, 0); + tt_int_op(((uintptr_t)p3) % sizeof(void*),OP_EQ, 0); tt_assert(!memarea_owns_ptr(area, p3+8192)); tt_assert(!memarea_owns_ptr(area, p3+30)); tt_assert(tor_mem_is_zero(p2, 52)); /* Make sure we don't overalign. */ p1 = memarea_alloc(area, 1); p2 = memarea_alloc(area, 1); - tt_ptr_op(p1+sizeof(void*),==, p2); + tt_ptr_op(p1+sizeof(void*),OP_EQ, p2); { malloced_ptr = tor_malloc(64); tt_assert(!memarea_owns_ptr(area, malloced_ptr)); @@ -2879,7 +2879,7 @@ test_util_memarea(void *arg) crypto_rand((char*)malloced_ptr, 64); p1 = memarea_memdup(area, malloced_ptr, 64); tt_assert(p1 != malloced_ptr); - tt_mem_op(p1,==, malloced_ptr, 64); + tt_mem_op(p1,OP_EQ, malloced_ptr, 64); tor_free(malloced_ptr); } @@ -2888,8 +2888,8 @@ test_util_memarea(void *arg) p2 = memarea_strdup(area, "abcd"); tt_assert(p1); tt_assert(p2); - tt_str_op(p1,==, ""); - tt_str_op(p2,==, "abcd"); + tt_str_op(p1,OP_EQ, ""); + tt_str_op(p2,OP_EQ, "abcd"); /* memarea_strndup. */ { @@ -2898,20 +2898,20 @@ test_util_memarea(void *arg) size_t len = strlen(s); p1 = memarea_strndup(area, s, 1000); p2 = memarea_strndup(area, s, 10); - tt_str_op(p1,==, s); + tt_str_op(p1,OP_EQ, s); tt_assert(p2 >= p1 + len + 1); - tt_mem_op(s,==, p2, 10); - tt_int_op(p2[10],==, '\0'); + tt_mem_op(s,OP_EQ, p2, 10); + tt_int_op(p2[10],OP_EQ, '\0'); p3 = memarea_strndup(area, s, len); - tt_str_op(p3,==, s); + tt_str_op(p3,OP_EQ, s); p3 = memarea_strndup(area, s, len-1); - tt_mem_op(s,==, p3, len-1); - tt_int_op(p3[len-1],==, '\0'); + tt_mem_op(s,OP_EQ, p3, len-1); + tt_int_op(p3[len-1],OP_EQ, '\0'); } memarea_clear(area); p1 = memarea_alloc(area, 1); - tt_ptr_op(p1,==, p1_orig); + tt_ptr_op(p1,OP_EQ, p1_orig); memarea_clear(area); /* Check for running over an area's size. */ @@ -2944,22 +2944,22 @@ test_util_datadir(void *arg) temp_dir = get_datadir_fname(NULL); f = get_datadir_fname("state"); tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"state", temp_dir); - tt_str_op(f,==, buf); + tt_str_op(f,OP_EQ, buf); tor_free(f); f = get_datadir_fname2("cache", "thingy"); tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"cache"PATH_SEPARATOR"thingy", temp_dir); - tt_str_op(f,==, buf); + tt_str_op(f,OP_EQ, buf); tor_free(f); f = get_datadir_fname2_suffix("cache", "thingy", ".foo"); tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"cache"PATH_SEPARATOR"thingy.foo", temp_dir); - tt_str_op(f,==, buf); + tt_str_op(f,OP_EQ, buf); tor_free(f); f = get_datadir_fname_suffix("cache", ".foo"); tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"cache.foo", temp_dir); - tt_str_op(f,==, buf); + tt_str_op(f,OP_EQ, buf); done: tor_free(f); @@ -3000,43 +3000,43 @@ test_util_strtok(void *arg) "%sthey.seemed;;their!.own;most.perfect;monument%s",pad2,pad2); /* -- "Year's End", Richard Wilbur */ - tt_str_op("Graved",==, tor_strtok_r_impl(buf, " ", &cp1)); - tt_str_op("they",==, tor_strtok_r_impl(buf2, ".!..;!", &cp2)); + tt_str_op("Graved",OP_EQ, tor_strtok_r_impl(buf, " ", &cp1)); + tt_str_op("they",OP_EQ, tor_strtok_r_impl(buf2, ".!..;!", &cp2)); #define S1() tor_strtok_r_impl(NULL, " ", &cp1) #define S2() tor_strtok_r_impl(NULL, ".!..;!", &cp2) - tt_str_op("on",==, S1()); - tt_str_op("the",==, S1()); - tt_str_op("dark",==, S1()); - tt_str_op("seemed",==, S2()); - tt_str_op("their",==, S2()); - tt_str_op("own",==, S2()); - tt_str_op("in",==, S1()); - tt_str_op("gestures",==, S1()); - tt_str_op("of",==, S1()); - tt_str_op("most",==, S2()); - tt_str_op("perfect",==, S2()); - tt_str_op("descent",==, S1()); - tt_str_op("monument",==, S2()); - tt_ptr_op(NULL,==, S1()); - tt_ptr_op(NULL,==, S2()); + tt_str_op("on",OP_EQ, S1()); + tt_str_op("the",OP_EQ, S1()); + tt_str_op("dark",OP_EQ, S1()); + tt_str_op("seemed",OP_EQ, S2()); + tt_str_op("their",OP_EQ, S2()); + tt_str_op("own",OP_EQ, S2()); + tt_str_op("in",OP_EQ, S1()); + tt_str_op("gestures",OP_EQ, S1()); + tt_str_op("of",OP_EQ, S1()); + tt_str_op("most",OP_EQ, S2()); + tt_str_op("perfect",OP_EQ, S2()); + tt_str_op("descent",OP_EQ, S1()); + tt_str_op("monument",OP_EQ, S2()); + tt_ptr_op(NULL,OP_EQ, S1()); + tt_ptr_op(NULL,OP_EQ, S2()); } buf[0] = 0; - tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, " ", &cp1)); - tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, "!", &cp1)); + tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, " ", &cp1)); + tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, "!", &cp1)); strlcpy(buf, "Howdy!", sizeof(buf)); - tt_str_op("Howdy",==, tor_strtok_r_impl(buf, "!", &cp1)); - tt_ptr_op(NULL,==, tor_strtok_r_impl(NULL, "!", &cp1)); + tt_str_op("Howdy",OP_EQ, tor_strtok_r_impl(buf, "!", &cp1)); + tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(NULL, "!", &cp1)); strlcpy(buf, " ", sizeof(buf)); - tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, " ", &cp1)); + tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, " ", &cp1)); strlcpy(buf, " ", sizeof(buf)); - tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, " ", &cp1)); + tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, " ", &cp1)); strlcpy(buf, "something ", sizeof(buf)); - tt_str_op("something",==, tor_strtok_r_impl(buf, " ", &cp1)); - tt_ptr_op(NULL,==, tor_strtok_r_impl(NULL, ";", &cp1)); + tt_str_op("something",OP_EQ, tor_strtok_r_impl(buf, " ", &cp1)); + tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(NULL, ";", &cp1)); done: ; } @@ -3056,24 +3056,24 @@ test_util_find_str_at_start_of_line(void *ptr) (void)ptr; - tt_ptr_op(long_string,==, find_str_at_start_of_line(long_string, "")); - tt_ptr_op(NULL,==, find_str_at_start_of_line(short_string, "nonsense")); - tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "nonsense")); - tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "\n")); - tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "how ")); - tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "kitty")); - tt_ptr_op(long_string,==, find_str_at_start_of_line(long_string, "h")); - tt_ptr_op(long_string,==, find_str_at_start_of_line(long_string, "how")); - tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "he")); - tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "hell")); - tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "hello k")); - tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "hello kitty\n")); - tt_ptr_op(line2,==, + tt_ptr_op(long_string,OP_EQ, find_str_at_start_of_line(long_string, "")); + tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(short_string, "nonsense")); + tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(long_string, "nonsense")); + tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(long_string, "\n")); + tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(long_string, "how ")); + tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(long_string, "kitty")); + tt_ptr_op(long_string,OP_EQ, find_str_at_start_of_line(long_string, "h")); + tt_ptr_op(long_string,OP_EQ, find_str_at_start_of_line(long_string, "how")); + tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "he")); + tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hell")); + tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hello k")); + tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hello kitty\n")); + tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hello kitty\nt")); - tt_ptr_op(line3,==, find_str_at_start_of_line(long_string, "third")); - tt_ptr_op(line3,==, find_str_at_start_of_line(long_string, "third line")); - tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "third line\n")); - tt_ptr_op(short_line2,==, find_str_at_start_of_line(short_string, + tt_ptr_op(line3,OP_EQ, find_str_at_start_of_line(long_string, "third")); + tt_ptr_op(line3,OP_EQ, find_str_at_start_of_line(long_string, "third line")); + tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(long_string, "third line\n")); + tt_ptr_op(short_line2,OP_EQ, find_str_at_start_of_line(short_string, "second line\n")); done: ; @@ -3084,25 +3084,25 @@ test_util_string_is_C_identifier(void *ptr) { (void)ptr; - tt_int_op(1,==, string_is_C_identifier("string_is_C_identifier")); - tt_int_op(1,==, string_is_C_identifier("_string_is_C_identifier")); - tt_int_op(1,==, string_is_C_identifier("_")); - tt_int_op(1,==, string_is_C_identifier("i")); - tt_int_op(1,==, string_is_C_identifier("_____")); - tt_int_op(1,==, string_is_C_identifier("__00__")); - tt_int_op(1,==, string_is_C_identifier("__init__")); - tt_int_op(1,==, string_is_C_identifier("_0")); - tt_int_op(1,==, string_is_C_identifier("_0string_is_C_identifier")); - tt_int_op(1,==, string_is_C_identifier("_0")); - - tt_int_op(0,==, string_is_C_identifier("0_string_is_C_identifier")); - tt_int_op(0,==, string_is_C_identifier("0")); - tt_int_op(0,==, string_is_C_identifier("")); - tt_int_op(0,==, string_is_C_identifier(";")); - tt_int_op(0,==, string_is_C_identifier("i;")); - tt_int_op(0,==, string_is_C_identifier("_;")); - tt_int_op(0,==, string_is_C_identifier("í")); - tt_int_op(0,==, string_is_C_identifier("ñ")); + tt_int_op(1,OP_EQ, string_is_C_identifier("string_is_C_identifier")); + tt_int_op(1,OP_EQ, string_is_C_identifier("_string_is_C_identifier")); + tt_int_op(1,OP_EQ, string_is_C_identifier("_")); + tt_int_op(1,OP_EQ, string_is_C_identifier("i")); + tt_int_op(1,OP_EQ, string_is_C_identifier("_____")); + tt_int_op(1,OP_EQ, string_is_C_identifier("__00__")); + tt_int_op(1,OP_EQ, string_is_C_identifier("__init__")); + tt_int_op(1,OP_EQ, string_is_C_identifier("_0")); + tt_int_op(1,OP_EQ, string_is_C_identifier("_0string_is_C_identifier")); + tt_int_op(1,OP_EQ, string_is_C_identifier("_0")); + + tt_int_op(0,OP_EQ, string_is_C_identifier("0_string_is_C_identifier")); + tt_int_op(0,OP_EQ, string_is_C_identifier("0")); + tt_int_op(0,OP_EQ, string_is_C_identifier("")); + tt_int_op(0,OP_EQ, string_is_C_identifier(";")); + tt_int_op(0,OP_EQ, string_is_C_identifier("i;")); + tt_int_op(0,OP_EQ, string_is_C_identifier("_;")); + tt_int_op(0,OP_EQ, string_is_C_identifier("í")); + tt_int_op(0,OP_EQ, string_is_C_identifier("ñ")); done: ; @@ -3120,29 +3120,29 @@ test_util_asprintf(void *ptr) /* simple string */ r = tor_asprintf(&cp, "simple string 100%% safe"); tt_assert(cp); - tt_str_op("simple string 100% safe",==, cp); - tt_int_op(strlen(cp),==, r); + tt_str_op("simple string 100% safe",OP_EQ, cp); + tt_int_op(strlen(cp),OP_EQ, r); tor_free(cp); /* empty string */ r = tor_asprintf(&cp, "%s", ""); tt_assert(cp); - tt_str_op("",==, cp); - tt_int_op(strlen(cp),==, r); + tt_str_op("",OP_EQ, cp); + tt_int_op(strlen(cp),OP_EQ, r); tor_free(cp); /* numbers (%i) */ r = tor_asprintf(&cp, "I like numbers-%2i, %i, etc.", -1, 2); tt_assert(cp); - tt_str_op("I like numbers--1, 2, etc.",==, cp); - tt_int_op(strlen(cp),==, r); + tt_str_op("I like numbers--1, 2, etc.",OP_EQ, cp); + tt_int_op(strlen(cp),OP_EQ, r); /* don't free cp; next test uses it. */ /* numbers (%d) */ r = tor_asprintf(&cp2, "First=%d, Second=%d", 101, 202); tt_assert(cp2); - tt_int_op(strlen(cp2),==, r); - tt_str_op("First=101, Second=202",==, cp2); + tt_int_op(strlen(cp2),OP_EQ, r); + tt_str_op("First=101, Second=202",OP_EQ, cp2); tt_assert(cp != cp2); tor_free(cp); tor_free(cp2); @@ -3150,17 +3150,17 @@ test_util_asprintf(void *ptr) /* Glass-box test: a string exactly 128 characters long. */ r = tor_asprintf(&cp, "Lorem1: %sLorem2: %s", LOREMIPSUM, LOREMIPSUM); tt_assert(cp); - tt_int_op(128,==, r); - tt_int_op(cp[128], ==, '\0'); - tt_str_op("Lorem1: "LOREMIPSUM"Lorem2: "LOREMIPSUM,==, cp); + tt_int_op(128,OP_EQ, r); + tt_int_op(cp[128], OP_EQ, '\0'); + tt_str_op("Lorem1: "LOREMIPSUM"Lorem2: "LOREMIPSUM,OP_EQ, cp); tor_free(cp); /* String longer than 128 characters */ r = tor_asprintf(&cp, "1: %s 2: %s 3: %s", LOREMIPSUM, LOREMIPSUM, LOREMIPSUM); tt_assert(cp); - tt_int_op(strlen(cp),==, r); - tt_str_op("1: "LOREMIPSUM" 2: "LOREMIPSUM" 3: "LOREMIPSUM,==, cp); + tt_int_op(strlen(cp),OP_EQ, r); + tt_str_op("1: "LOREMIPSUM" 2: "LOREMIPSUM" 3: "LOREMIPSUM,OP_EQ, cp); done: tor_free(cp); @@ -3181,9 +3181,9 @@ test_util_listdir(void *ptr) dir1 = tor_strdup(get_fname("some-directory")); dirname = tor_strdup(get_fname(NULL)); - tt_int_op(0,==, write_str_to_file(fname1, "X\n", 0)); - tt_int_op(0,==, write_str_to_file(fname2, "Y\n", 0)); - tt_int_op(0,==, write_str_to_file(fname3, "Z\n", 0)); + tt_int_op(0,OP_EQ, write_str_to_file(fname1, "X\n", 0)); + tt_int_op(0,OP_EQ, write_str_to_file(fname2, "Y\n", 0)); + tt_int_op(0,OP_EQ, write_str_to_file(fname3, "Z\n", 0)); #ifdef _WIN32 r = mkdir(dir1); #else @@ -3229,9 +3229,9 @@ test_util_parent_dir(void *ptr) int ok; \ cp = tor_strdup(input); \ ok = get_parent_directory(cp); \ - tt_int_op(expect_ok, ==, ok); \ + tt_int_op(expect_ok, OP_EQ, ok); \ if (ok==0) \ - tt_str_op(output, ==, cp); \ + tt_str_op(output, OP_EQ, cp); \ tor_free(cp); \ } while (0); @@ -3280,32 +3280,32 @@ test_util_ftruncate(void *ptr) fname = get_fname("ftruncate"); fd = tor_open_cloexec(fname, O_WRONLY|O_CREAT, 0600); - tt_int_op(fd, >=, 0); + tt_int_op(fd, OP_GE, 0); /* Make the file be there. */ - tt_int_op(strlen(message), ==, write_all(fd, message, strlen(message), 0)); - tt_int_op((int)tor_fd_getpos(fd), ==, strlen(message)); - tt_int_op(0, ==, fstat(fd, &st)); - tt_int_op((int)st.st_size, ==, strlen(message)); + tt_int_op(strlen(message), OP_EQ, write_all(fd, message, strlen(message), 0)); + tt_int_op((int)tor_fd_getpos(fd), OP_EQ, strlen(message)); + tt_int_op(0, OP_EQ, fstat(fd, &st)); + tt_int_op((int)st.st_size, OP_EQ, strlen(message)); /* Truncate and see if it got truncated */ - tt_int_op(0, ==, tor_ftruncate(fd)); - tt_int_op((int)tor_fd_getpos(fd), ==, 0); - tt_int_op(0, ==, fstat(fd, &st)); - tt_int_op((int)st.st_size, ==, 0); + tt_int_op(0, OP_EQ, tor_ftruncate(fd)); + tt_int_op((int)tor_fd_getpos(fd), OP_EQ, 0); + tt_int_op(0, OP_EQ, fstat(fd, &st)); + tt_int_op((int)st.st_size, OP_EQ, 0); /* Replace, and see if it got replaced */ - tt_int_op(strlen(message2), ==, + tt_int_op(strlen(message2), OP_EQ, write_all(fd, message2, strlen(message2), 0)); - tt_int_op((int)tor_fd_getpos(fd), ==, strlen(message2)); - tt_int_op(0, ==, fstat(fd, &st)); - tt_int_op((int)st.st_size, ==, strlen(message2)); + tt_int_op((int)tor_fd_getpos(fd), OP_EQ, strlen(message2)); + tt_int_op(0, OP_EQ, fstat(fd, &st)); + tt_int_op((int)st.st_size, OP_EQ, strlen(message2)); close(fd); fd = -1; buf = read_file_to_str(fname, 0, NULL); - tt_str_op(message2, ==, buf); + tt_str_op(message2, OP_EQ, buf); done: if (fd >= 0) @@ -3344,53 +3344,53 @@ test_util_exit_status(void *ptr) (void)ptr; clear_hex_errno(hex_errno); - tt_str_op("",==, hex_errno); + tt_str_op("",OP_EQ, hex_errno); clear_hex_errno(hex_errno); n = format_helper_exit_status(0, 0, hex_errno); - tt_str_op("0/0\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); + tt_str_op("0/0\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); #if SIZEOF_INT == 4 clear_hex_errno(hex_errno); n = format_helper_exit_status(0, 0x7FFFFFFF, hex_errno); - tt_str_op("0/7FFFFFFF\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); + tt_str_op("0/7FFFFFFF\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); clear_hex_errno(hex_errno); n = format_helper_exit_status(0xFF, -0x80000000, hex_errno); - tt_str_op("FF/-80000000\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); - tt_int_op(n,==, HEX_ERRNO_SIZE); + tt_str_op("FF/-80000000\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); + tt_int_op(n,OP_EQ, HEX_ERRNO_SIZE); #elif SIZEOF_INT == 8 clear_hex_errno(hex_errno); n = format_helper_exit_status(0, 0x7FFFFFFFFFFFFFFF, hex_errno); - tt_str_op("0/7FFFFFFFFFFFFFFF\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); + tt_str_op("0/7FFFFFFFFFFFFFFF\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); clear_hex_errno(hex_errno); n = format_helper_exit_status(0xFF, -0x8000000000000000, hex_errno); - tt_str_op("FF/-8000000000000000\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); - tt_int_op(n,==, HEX_ERRNO_SIZE); + tt_str_op("FF/-8000000000000000\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); + tt_int_op(n,OP_EQ, HEX_ERRNO_SIZE); #endif clear_hex_errno(hex_errno); n = format_helper_exit_status(0x7F, 0, hex_errno); - tt_str_op("7F/0\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); + tt_str_op("7F/0\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); clear_hex_errno(hex_errno); n = format_helper_exit_status(0x08, -0x242, hex_errno); - tt_str_op("8/-242\n",==, hex_errno); - tt_int_op(n,==, strlen(hex_errno)); + tt_str_op("8/-242\n",OP_EQ, hex_errno); + tt_int_op(n,OP_EQ, strlen(hex_errno)); clear_hex_errno(hex_errno); - tt_str_op("",==, hex_errno); + tt_str_op("",OP_EQ, hex_errno); done: ; @@ -3417,83 +3417,83 @@ test_util_fgets_eagain(void *ptr) /* Set up a pipe to test on */ retval = pipe(test_pipe); - tt_int_op(retval, ==, 0); + tt_int_op(retval, OP_EQ, 0); /* Set up the read-end to be non-blocking */ retval = fcntl(test_pipe[0], F_SETFL, O_NONBLOCK); - tt_int_op(retval, ==, 0); + tt_int_op(retval, OP_EQ, 0); /* Open it as a stdio stream */ test_stream = fdopen(test_pipe[0], "r"); - tt_ptr_op(test_stream, !=, NULL); + tt_ptr_op(test_stream, OP_NE, NULL); /* Send in a partial line */ retlen = write(test_pipe[1], "A", 1); - tt_int_op(retlen, ==, 1); + tt_int_op(retlen, OP_EQ, 1); retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, EAGAIN); - tt_ptr_op(retptr, ==, buf); - tt_str_op(buf, ==, "A"); + tt_int_op(errno, OP_EQ, EAGAIN); + tt_ptr_op(retptr, OP_EQ, buf); + tt_str_op(buf, OP_EQ, "A"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "B\n", 2); - tt_int_op(retlen, ==, 2); + tt_int_op(retlen, OP_EQ, 2); retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, 0); - tt_ptr_op(retptr, ==, buf); - tt_str_op(buf, ==, "B\n"); + tt_int_op(errno, OP_EQ, 0); + tt_ptr_op(retptr, OP_EQ, buf); + tt_str_op(buf, OP_EQ, "B\n"); errno = 0; /* Send in a full line */ retlen = write(test_pipe[1], "CD\n", 3); - tt_int_op(retlen, ==, 3); + tt_int_op(retlen, OP_EQ, 3); retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, 0); - tt_ptr_op(retptr, ==, buf); - tt_str_op(buf, ==, "CD\n"); + tt_int_op(errno, OP_EQ, 0); + tt_ptr_op(retptr, OP_EQ, buf); + tt_str_op(buf, OP_EQ, "CD\n"); errno = 0; /* Send in a partial line */ retlen = write(test_pipe[1], "E", 1); - tt_int_op(retlen, ==, 1); + tt_int_op(retlen, OP_EQ, 1); retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, EAGAIN); - tt_ptr_op(retptr, ==, buf); - tt_str_op(buf, ==, "E"); + tt_int_op(errno, OP_EQ, EAGAIN); + tt_ptr_op(retptr, OP_EQ, buf); + tt_str_op(buf, OP_EQ, "E"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "F\n", 2); - tt_int_op(retlen, ==, 2); + tt_int_op(retlen, OP_EQ, 2); retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, 0); - tt_ptr_op(retptr, ==, buf); - tt_str_op(buf, ==, "F\n"); + tt_int_op(errno, OP_EQ, 0); + tt_ptr_op(retptr, OP_EQ, buf); + tt_str_op(buf, OP_EQ, "F\n"); errno = 0; /* Send in a full line and close */ retlen = write(test_pipe[1], "GH", 2); - tt_int_op(retlen, ==, 2); + tt_int_op(retlen, OP_EQ, 2); retval = close(test_pipe[1]); - tt_int_op(retval, ==, 0); + tt_int_op(retval, OP_EQ, 0); test_pipe[1] = -1; retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, 0); - tt_ptr_op(retptr, ==, buf); - tt_str_op(buf, ==, "GH"); + tt_int_op(errno, OP_EQ, 0); + tt_ptr_op(retptr, OP_EQ, buf); + tt_str_op(buf, OP_EQ, "GH"); errno = 0; /* Check for EOF */ retptr = fgets(buf, sizeof(buf), test_stream); - tt_int_op(errno, ==, 0); - tt_ptr_op(retptr, ==, NULL); + tt_int_op(errno, OP_EQ, 0); + tt_ptr_op(retptr, OP_EQ, NULL); retval = feof(test_stream); - tt_int_op(retval, !=, 0); + tt_int_op(retval, OP_NE, 0); errno = 0; /* Check that buf is unchanged according to C99 and C11 */ - tt_str_op(buf, ==, "GH"); + tt_str_op(buf, OP_EQ, "GH"); done: if (test_stream != NULL) @@ -3568,7 +3568,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out, * but we still need to handle PROCESS_STATUS_RUNNING_OR_NOTRUNNING */ tt_assert(MATCH_PROCESS_STATUS(expected_status, status)); if (status == PROCESS_STATUS_ERROR) { - tt_ptr_op(process_handle, ==, NULL); + tt_ptr_op(process_handle, OP_EQ, NULL); return; } @@ -3611,20 +3611,20 @@ run_util_spawn_background(const char *argv[], const char *expected_out, sizeof(stdout_buf) - 1); tt_assert(pos >= 0); stdout_buf[pos] = '\0'; - tt_int_op(strlen(expected_out),==, pos); - tt_str_op(expected_out,==, stdout_buf); + tt_int_op(strlen(expected_out),OP_EQ, pos); + tt_str_op(expected_out,OP_EQ, stdout_buf); notify_pending_waitpid_callbacks(); /* Check it terminated correctly */ retval = tor_get_exit_code(process_handle, 1, &exit_code); - tt_int_op(PROCESS_EXIT_EXITED,==, retval); - tt_int_op(expected_exit,==, exit_code); + tt_int_op(PROCESS_EXIT_EXITED,OP_EQ, retval); + tt_int_op(expected_exit,OP_EQ, exit_code); // TODO: Make test-child exit with something other than 0 #ifndef _WIN32 notify_pending_waitpid_callbacks(); - tt_ptr_op(process_handle->waitpid_cb, ==, NULL); + tt_ptr_op(process_handle->waitpid_cb, OP_EQ, NULL); #endif /* Check stderr */ @@ -3632,8 +3632,8 @@ run_util_spawn_background(const char *argv[], const char *expected_out, sizeof(stderr_buf) - 1); tt_assert(pos >= 0); stderr_buf[pos] = '\0'; - tt_str_op(expected_err,==, stderr_buf); - tt_int_op(strlen(expected_err),==, pos); + tt_str_op(expected_err,OP_EQ, stderr_buf); + tt_int_op(strlen(expected_err),OP_EQ, pos); notify_pending_waitpid_callbacks(); @@ -3722,9 +3722,9 @@ test_util_spawn_background_partial_read_impl(int exit_early) #else status = tor_spawn_background(argv[0], argv, NULL, &process_handle); #endif - tt_int_op(expected_status,==, status); + tt_int_op(expected_status,OP_EQ, status); tt_assert(process_handle); - tt_int_op(expected_status,==, process_handle->status); + tt_int_op(expected_status,OP_EQ, process_handle->status); /* Check stdout */ for (expected_out_ctr = 0; expected_out[expected_out_ctr] != NULL;) { @@ -3745,8 +3745,8 @@ test_util_spawn_background_partial_read_impl(int exit_early) tt_assert(pos > 0); stdout_buf[pos] = '\0'; - tt_str_op(expected_out[expected_out_ctr],==, stdout_buf); - tt_int_op(strlen(expected_out[expected_out_ctr]),==, pos); + tt_str_op(expected_out[expected_out_ctr],OP_EQ, stdout_buf); + tt_int_op(strlen(expected_out[expected_out_ctr]),OP_EQ, pos); expected_out_ctr++; } @@ -3761,14 +3761,14 @@ test_util_spawn_background_partial_read_impl(int exit_early) pos = tor_read_all_handle(process_handle->stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1, process_handle); - tt_int_op(0,==, pos); + tt_int_op(0,OP_EQ, pos); #else if (!eof) { /* We should have got all the data, but maybe not the EOF flag */ pos = tor_read_all_handle(process_handle->stdout_handle, stdout_buf, sizeof(stdout_buf) - 1, process_handle, &eof); - tt_int_op(0,==, pos); + tt_int_op(0,OP_EQ, pos); tt_assert(eof); } /* Otherwise, we got the EOF on the last read */ @@ -3776,8 +3776,8 @@ test_util_spawn_background_partial_read_impl(int exit_early) /* Check it terminated correctly */ retval = tor_get_exit_code(process_handle, 1, &exit_code); - tt_int_op(PROCESS_EXIT_EXITED,==, retval); - tt_int_op(expected_exit,==, exit_code); + tt_int_op(PROCESS_EXIT_EXITED,OP_EQ, retval); + tt_int_op(expected_exit,OP_EQ, exit_code); // TODO: Make test-child exit with something other than 0 @@ -3786,8 +3786,8 @@ test_util_spawn_background_partial_read_impl(int exit_early) sizeof(stderr_buf) - 1); tt_assert(pos >= 0); stderr_buf[pos] = '\0'; - tt_str_op(expected_err,==, stderr_buf); - tt_int_op(strlen(expected_err),==, pos); + tt_str_op(expected_err,OP_EQ, stderr_buf); + tt_int_op(strlen(expected_err),OP_EQ, pos); done: tor_process_handle_destroy(process_handle, 1); @@ -3825,8 +3825,8 @@ test_util_spawn_background_waitpid_notify(void *arg) status = tor_spawn_background(argv[0], argv, NULL, &process_handle); #endif - tt_int_op(status, ==, PROCESS_STATUS_RUNNING); - tt_ptr_op(process_handle, !=, NULL); + tt_int_op(status, OP_EQ, PROCESS_STATUS_RUNNING); + tt_ptr_op(process_handle, OP_NE, NULL); /* We're not going to look at the stdout/stderr output this time. Instead, * we're testing whether notify_pending_waitpid_calbacks() can report the @@ -3835,14 +3835,14 @@ test_util_spawn_background_waitpid_notify(void *arg) #ifndef _WIN32 ms_timer = 30*1000; - tt_ptr_op(process_handle->waitpid_cb, !=, NULL); + tt_ptr_op(process_handle->waitpid_cb, OP_NE, NULL); while (process_handle->waitpid_cb && ms_timer > 0) { tor_sleep_msec(100); ms_timer -= 100; notify_pending_waitpid_callbacks(); } - tt_int_op(ms_timer, >, 0); - tt_ptr_op(process_handle->waitpid_cb, ==, NULL); + tt_int_op(ms_timer, OP_GT, 0); + tt_ptr_op(process_handle->waitpid_cb, OP_EQ, NULL); #endif ms_timer = 30*1000; @@ -3851,9 +3851,9 @@ test_util_spawn_background_waitpid_notify(void *arg) tor_sleep_msec(100); ms_timer -= 100; } - tt_int_op(ms_timer, >, 0); + tt_int_op(ms_timer, OP_GT, 0); - tt_int_op(retval, ==, PROCESS_EXIT_EXITED); + tt_int_op(retval, OP_EQ, PROCESS_EXIT_EXITED); done: tor_process_handle_destroy(process_handle, 1); @@ -3899,15 +3899,15 @@ test_util_format_hex_number(void *ptr) for (i = 0; test_data[i].str != NULL; ++i) { len = format_hex_number_sigsafe(test_data[i].x, buf, sizeof(buf)); - tt_int_op(len,!=, 0); - tt_int_op(len,==, strlen(buf)); - tt_str_op(buf,==, test_data[i].str); + tt_int_op(len,OP_NE, 0); + tt_int_op(len,OP_EQ, strlen(buf)); + tt_str_op(buf,OP_EQ, test_data[i].str); } - tt_int_op(4,==, format_hex_number_sigsafe(0xffff, buf, 5)); - tt_str_op(buf,==, "FFFF"); - tt_int_op(0,==, format_hex_number_sigsafe(0xffff, buf, 4)); - tt_int_op(0,==, format_hex_number_sigsafe(0, buf, 1)); + tt_int_op(4,OP_EQ, format_hex_number_sigsafe(0xffff, buf, 5)); + tt_str_op(buf,OP_EQ, "FFFF"); + tt_int_op(0,OP_EQ, format_hex_number_sigsafe(0xffff, buf, 4)); + tt_int_op(0,OP_EQ, format_hex_number_sigsafe(0, buf, 1)); done: return; @@ -3943,21 +3943,21 @@ test_util_format_dec_number(void *ptr) for (i = 0; test_data[i].str != NULL; ++i) { len = format_dec_number_sigsafe(test_data[i].x, buf, sizeof(buf)); - tt_int_op(len,!=, 0); - tt_int_op(len,==, strlen(buf)); - tt_str_op(buf,==, test_data[i].str); + tt_int_op(len,OP_NE, 0); + tt_int_op(len,OP_EQ, strlen(buf)); + tt_str_op(buf,OP_EQ, test_data[i].str); len = format_dec_number_sigsafe(test_data[i].x, buf, (int)(strlen(test_data[i].str) + 1)); - tt_int_op(len,==, strlen(buf)); - tt_str_op(buf,==, test_data[i].str); + tt_int_op(len,OP_EQ, strlen(buf)); + tt_str_op(buf,OP_EQ, test_data[i].str); } - tt_int_op(4,==, format_dec_number_sigsafe(7331, buf, 5)); - tt_str_op(buf,==, "7331"); - tt_int_op(0,==, format_dec_number_sigsafe(7331, buf, 4)); - tt_int_op(1,==, format_dec_number_sigsafe(0, buf, 2)); - tt_int_op(0,==, format_dec_number_sigsafe(0, buf, 1)); + tt_int_op(4,OP_EQ, format_dec_number_sigsafe(7331, buf, 5)); + tt_str_op(buf,OP_EQ, "7331"); + tt_int_op(0,OP_EQ, format_dec_number_sigsafe(7331, buf, 4)); + tt_int_op(1,OP_EQ, format_dec_number_sigsafe(0, buf, 2)); + tt_int_op(0,OP_EQ, format_dec_number_sigsafe(0, buf, 1)); done: return; @@ -4006,7 +4006,7 @@ test_util_join_win_cmdline(void *ptr) for (i=0; cmdlines[i]!=NULL; i++) { log_info(LD_GENERAL, "Joining argvs[%d], expecting <%s>", i, cmdlines[i]); joined_argv = tor_join_win_cmdline(argvs[i]); - tt_str_op(cmdlines[i],==, joined_argv); + tt_str_op(cmdlines[i],OP_EQ, joined_argv); tor_free(joined_argv); } @@ -4061,17 +4061,17 @@ test_util_split_lines(void *ptr) i, tests[i].orig_length); SMARTLIST_FOREACH_BEGIN(sl, const char *, line) { /* Check we have not got too many lines */ - tt_int_op(MAX_SPLIT_LINE_COUNT, >, j); + tt_int_op(MAX_SPLIT_LINE_COUNT, OP_GT, j); /* Check that there actually should be a line here */ tt_assert(tests[i].split_line[j] != NULL); log_info(LD_GENERAL, "Line %d of test %d, should be <%s>", j, i, tests[i].split_line[j]); /* Check that the line is as expected */ - tt_str_op(line,==, tests[i].split_line[j]); + tt_str_op(line,OP_EQ, tests[i].split_line[j]); j++; } SMARTLIST_FOREACH_END(line); /* Check that we didn't miss some lines */ - tt_ptr_op(NULL,==, tests[i].split_line[j]); + tt_ptr_op(NULL,OP_EQ, tests[i].split_line[j]); tor_free(orig_line); smartlist_free(sl); sl = NULL; @@ -4107,7 +4107,7 @@ test_util_di_ops(void *arg) for (i = 0; examples[i].a; ++i) { size_t len = strlen(examples[i].a); int eq1, eq2, neq1, neq2, cmp1, cmp2; - tt_int_op(len,==, strlen(examples[i].b)); + tt_int_op(len,OP_EQ, strlen(examples[i].b)); /* We do all of the operations, with operands in both orders. */ eq1 = tor_memeq(examples[i].a, examples[i].b, len); eq2 = tor_memeq(examples[i].b, examples[i].a, len); @@ -4125,11 +4125,11 @@ test_util_di_ops(void *arg) TT_DIE(("Assertion failed.")); /* Check for consistency of everything else with cmp1 */ - tt_int_op(eq1,==, eq2); - tt_int_op(neq1,==, neq2); - tt_int_op(cmp1,==, -cmp2); - tt_int_op(eq1,==, cmp1 == 0); - tt_int_op(neq1,==, !eq1); + tt_int_op(eq1,OP_EQ, eq2); + tt_int_op(neq1,OP_EQ, neq2); + tt_int_op(cmp1,OP_EQ, -cmp2); + tt_int_op(eq1,OP_EQ, cmp1 == 0); + tt_int_op(neq1,OP_EQ, !eq1); } { @@ -4144,22 +4144,22 @@ test_util_di_ops(void *arg) for (i = 0; i < 256; i++) { ii = (uint8_t)i; zz = (uint8_t)z; - tt_int_op(tor_memeq(&zz, &ii, 1),==, zz == ii); - tt_int_op(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ,==, zz > ii ? GT : EQ); - tt_int_op(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ,==, ii < zz ? LT : EQ); + tt_int_op(tor_memeq(&zz, &ii, 1),OP_EQ, zz == ii); + tt_int_op(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ,OP_EQ, zz > ii ? GT : EQ); + tt_int_op(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ,OP_EQ, ii < zz ? LT : EQ); } } } - tt_int_op(1, ==, safe_mem_is_zero("", 0)); - tt_int_op(1, ==, safe_mem_is_zero("", 1)); - tt_int_op(0, ==, safe_mem_is_zero("a", 1)); - tt_int_op(0, ==, safe_mem_is_zero("a", 2)); - tt_int_op(0, ==, safe_mem_is_zero("\0a", 2)); - tt_int_op(1, ==, safe_mem_is_zero("\0\0a", 2)); - tt_int_op(1, ==, safe_mem_is_zero("\0\0\0\0\0\0\0\0", 8)); - tt_int_op(1, ==, safe_mem_is_zero("\0\0\0\0\0\0\0\0a", 8)); - tt_int_op(0, ==, safe_mem_is_zero("\0\0\0\0\0\0\0\0a", 9)); + tt_int_op(1, OP_EQ, safe_mem_is_zero("", 0)); + tt_int_op(1, OP_EQ, safe_mem_is_zero("", 1)); + tt_int_op(0, OP_EQ, safe_mem_is_zero("a", 1)); + tt_int_op(0, OP_EQ, safe_mem_is_zero("a", 2)); + tt_int_op(0, OP_EQ, safe_mem_is_zero("\0a", 2)); + tt_int_op(1, OP_EQ, safe_mem_is_zero("\0\0a", 2)); + tt_int_op(1, OP_EQ, safe_mem_is_zero("\0\0\0\0\0\0\0\0", 8)); + tt_int_op(1, OP_EQ, safe_mem_is_zero("\0\0\0\0\0\0\0\0a", 8)); + tt_int_op(0, OP_EQ, safe_mem_is_zero("\0\0\0\0\0\0\0\0a", 9)); done: ; @@ -4172,12 +4172,12 @@ static void test_util_n_bits_set(void *ptr) { (void)ptr; - tt_int_op(0,==, n_bits_set_u8(0)); - tt_int_op(1,==, n_bits_set_u8(1)); - tt_int_op(3,==, n_bits_set_u8(7)); - tt_int_op(1,==, n_bits_set_u8(8)); - tt_int_op(2,==, n_bits_set_u8(129)); - tt_int_op(8,==, n_bits_set_u8(255)); + tt_int_op(0,OP_EQ, n_bits_set_u8(0)); + tt_int_op(1,OP_EQ, n_bits_set_u8(1)); + tt_int_op(3,OP_EQ, n_bits_set_u8(7)); + tt_int_op(1,OP_EQ, n_bits_set_u8(8)); + tt_int_op(2,OP_EQ, n_bits_set_u8(129)); + tt_int_op(8,OP_EQ, n_bits_set_u8(255)); done: ; } @@ -4198,78 +4198,78 @@ test_util_eat_whitespace(void *ptr) strlcpy(str, "fuubaar", sizeof(str)); for (i = 0; i < sizeof(ws); ++i) { str[0] = ws[i]; - tt_ptr_op(str + 1,==, eat_whitespace(str)); - tt_ptr_op(str + 1,==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str + 1,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str + 1,==, eat_whitespace_eos_no_nl(str, str + strlen(str))); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); } str[0] = '\n'; - tt_ptr_op(str + 1,==, eat_whitespace(str)); - tt_ptr_op(str + 1,==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str + strlen(str))); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); /* Empty string */ strlcpy(str, "", sizeof(str)); - tt_ptr_op(str,==, eat_whitespace(str)); - tt_ptr_op(str,==, eat_whitespace_eos(str, str)); - tt_ptr_op(str,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str)); + tt_ptr_op(str,OP_EQ, eat_whitespace(str)); + tt_ptr_op(str,OP_EQ, eat_whitespace_eos(str, str)); + tt_ptr_op(str,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str,OP_EQ, eat_whitespace_eos_no_nl(str, str)); /* Only ws */ strlcpy(str, " \t\r\n", sizeof(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str + strlen(str) - 1,==, + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str + strlen(str) - 1,OP_EQ, eat_whitespace_no_nl(str)); - tt_ptr_op(str + strlen(str) - 1,==, + tt_ptr_op(str + strlen(str) - 1,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); strlcpy(str, " \t\r ", sizeof(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace(str)); - tt_ptr_op(str + strlen(str),==, + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str + strlen(str),==, eat_whitespace_no_nl(str)); - tt_ptr_op(str + strlen(str),==, + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); /* Multiple ws */ strlcpy(str, "fuubaar", sizeof(str)); for (i = 0; i < sizeof(ws); ++i) str[i] = ws[i]; - tt_ptr_op(str + sizeof(ws),==, eat_whitespace(str)); - tt_ptr_op(str + sizeof(ws),==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str + sizeof(ws),==, eat_whitespace_no_nl(str)); - tt_ptr_op(str + sizeof(ws),==, + tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); /* Eat comment */ strlcpy(str, "# Comment \n No Comment", sizeof(str)); - tt_str_op("No Comment",==, eat_whitespace(str)); - tt_str_op("No Comment",==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str + strlen(str))); + tt_str_op("No Comment",OP_EQ, eat_whitespace(str)); + tt_str_op("No Comment",OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); /* Eat comment & ws mix */ strlcpy(str, " # \t Comment \n\t\nNo Comment", sizeof(str)); - tt_str_op("No Comment",==, eat_whitespace(str)); - tt_str_op("No Comment",==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str + 1,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str + 1,==, eat_whitespace_eos_no_nl(str, str + strlen(str))); + tt_str_op("No Comment",OP_EQ, eat_whitespace(str)); + tt_str_op("No Comment",OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str + 1,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); /* Eat entire comment */ strlcpy(str, "#Comment", sizeof(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str + strlen(str))); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); /* Blank line, then comment */ strlcpy(str, " \t\n # Comment", sizeof(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace(str)); - tt_ptr_op(str + strlen(str),==, eat_whitespace_eos(str, str + strlen(str))); - tt_ptr_op(str + 2,==, eat_whitespace_no_nl(str)); - tt_ptr_op(str + 2,==, eat_whitespace_eos_no_nl(str, str + strlen(str))); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str)); + tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str))); + tt_ptr_op(str + 2,OP_EQ, eat_whitespace_no_nl(str)); + tt_ptr_op(str + 2,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str))); done: ; @@ -4308,11 +4308,11 @@ test_util_sl_new_from_text_lines(void *ptr) smartlist_t *sl = smartlist_new_from_text_lines("foo\nbar\nbaz\n"); int sl_len = smartlist_len(sl); - tt_want_int_op(sl_len, ==, 3); + tt_want_int_op(sl_len, OP_EQ, 3); - if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), ==, "foo"); - if (sl_len > 1) tt_want_str_op(smartlist_get(sl, 1), ==, "bar"); - if (sl_len > 2) tt_want_str_op(smartlist_get(sl, 2), ==, "baz"); + if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), OP_EQ, "foo"); + if (sl_len > 1) tt_want_str_op(smartlist_get(sl, 1), OP_EQ, "bar"); + if (sl_len > 2) tt_want_str_op(smartlist_get(sl, 2), OP_EQ, "baz"); SMARTLIST_FOREACH(sl, void *, x, tor_free(x)); smartlist_free(sl); @@ -4322,11 +4322,11 @@ test_util_sl_new_from_text_lines(void *ptr) smartlist_t *sl = smartlist_new_from_text_lines("foo\nbar\nbaz"); int sl_len = smartlist_len(sl); - tt_want_int_op(sl_len, ==, 3); + tt_want_int_op(sl_len, OP_EQ, 3); - if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), ==, "foo"); - if (sl_len > 1) tt_want_str_op(smartlist_get(sl, 1), ==, "bar"); - if (sl_len > 2) tt_want_str_op(smartlist_get(sl, 2), ==, "baz"); + if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), OP_EQ, "foo"); + if (sl_len > 1) tt_want_str_op(smartlist_get(sl, 1), OP_EQ, "bar"); + if (sl_len > 2) tt_want_str_op(smartlist_get(sl, 2), OP_EQ, "baz"); SMARTLIST_FOREACH(sl, void *, x, tor_free(x)); smartlist_free(sl); @@ -4336,9 +4336,9 @@ test_util_sl_new_from_text_lines(void *ptr) smartlist_t *sl = smartlist_new_from_text_lines("foo"); int sl_len = smartlist_len(sl); - tt_want_int_op(sl_len, ==, 1); + tt_want_int_op(sl_len, OP_EQ, 1); - if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), ==, "foo"); + if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), OP_EQ, "foo"); SMARTLIST_FOREACH(sl, void *, x, tor_free(x)); smartlist_free(sl); @@ -4348,7 +4348,7 @@ test_util_sl_new_from_text_lines(void *ptr) smartlist_t *sl = smartlist_new_from_text_lines(""); int sl_len = smartlist_len(sl); - tt_want_int_op(sl_len, ==, 0); + tt_want_int_op(sl_len, OP_EQ, 0); SMARTLIST_FOREACH(sl, void *, x, tor_free(x)); smartlist_free(sl); @@ -4431,7 +4431,7 @@ test_util_make_environment(void *ptr) smartlist_sort_strings(env_vars_sorted); smartlist_sort_strings(env_vars_in_unixoid_env_block_sorted); - tt_want_int_op(smartlist_len(env_vars_sorted), ==, + tt_want_int_op(smartlist_len(env_vars_sorted), OP_EQ, smartlist_len(env_vars_in_unixoid_env_block_sorted)); { int len = smartlist_len(env_vars_sorted); @@ -4442,7 +4442,7 @@ test_util_make_environment(void *ptr) } for (i = 0; i < len; ++i) { - tt_want_str_op(smartlist_get(env_vars_sorted, i), ==, + tt_want_str_op(smartlist_get(env_vars_sorted, i), OP_EQ, smartlist_get(env_vars_in_unixoid_env_block_sorted, i)); } } @@ -4524,7 +4524,7 @@ test_util_set_env_var_in_sl(void *ptr) smartlist_sort_strings(merged_env_vars); smartlist_sort_strings(expected_resulting_env_vars); - tt_want_int_op(smartlist_len(merged_env_vars), ==, + tt_want_int_op(smartlist_len(merged_env_vars), OP_EQ, smartlist_len(expected_resulting_env_vars)); { int len = smartlist_len(merged_env_vars); @@ -4535,7 +4535,7 @@ test_util_set_env_var_in_sl(void *ptr) } for (i = 0; i < len; ++i) { - tt_want_str_op(smartlist_get(merged_env_vars, i), ==, + tt_want_str_op(smartlist_get(merged_env_vars, i), OP_EQ, smartlist_get(expected_resulting_env_vars, i)); } } @@ -4562,8 +4562,8 @@ test_util_weak_random(void *arg) for (i = 1; i <= 256; ++i) { for (j=0;j<100;++j) { int r = tor_weak_random_range(&rng, i); - tt_int_op(0, <=, r); - tt_int_op(r, <, i); + tt_int_op(0, OP_LE, r); + tt_int_op(r, OP_LT, i); } } @@ -4573,7 +4573,7 @@ test_util_weak_random(void *arg) } for (i=0;i<16;++i) - tt_int_op(n[i], >, 0); + tt_int_op(n[i], OP_GT, 0); done: ; } @@ -4585,9 +4585,9 @@ test_util_mathlog(void *arg) (void) arg; d = tor_mathlog(2.718281828); - tt_double_op(fabs(d - 1.0), <, .000001); + tt_double_op(fabs(d - 1.0), OP_LT, .000001); d = tor_mathlog(10); - tt_double_op(fabs(d - 2.30258509), <, .000001); + tt_double_op(fabs(d - 2.30258509), OP_LT, .000001); done: ; } @@ -4671,36 +4671,36 @@ test_util_socket(void *arg) fd2 = tor_open_socket_with_extensions(AF_INET, SOCK_STREAM, 0, 0, 1); tt_assert(SOCKET_OK(fd1)); tt_assert(SOCKET_OK(fd2)); - tt_int_op(get_n_open_sockets(), ==, n + 2); + tt_int_op(get_n_open_sockets(), OP_EQ, n + 2); //fd3 = tor_open_socket_with_extensions(AF_INET, SOCK_STREAM, 0, 1, 0); //fd4 = tor_open_socket_with_extensions(AF_INET, SOCK_STREAM, 0, 1, 1); fd3 = tor_open_socket(AF_INET, SOCK_STREAM, 0); fd4 = tor_open_socket_nonblocking(AF_INET, SOCK_STREAM, 0); tt_assert(SOCKET_OK(fd3)); tt_assert(SOCKET_OK(fd4)); - tt_int_op(get_n_open_sockets(), ==, n + 4); + tt_int_op(get_n_open_sockets(), OP_EQ, n + 4); #ifdef CAN_CHECK_CLOEXEC - tt_int_op(fd_is_cloexec(fd1), ==, 0); - tt_int_op(fd_is_cloexec(fd2), ==, 0); - tt_int_op(fd_is_cloexec(fd3), ==, 1); - tt_int_op(fd_is_cloexec(fd4), ==, 1); + tt_int_op(fd_is_cloexec(fd1), OP_EQ, 0); + tt_int_op(fd_is_cloexec(fd2), OP_EQ, 0); + tt_int_op(fd_is_cloexec(fd3), OP_EQ, 1); + tt_int_op(fd_is_cloexec(fd4), OP_EQ, 1); #endif #ifdef CAN_CHECK_NONBLOCK - tt_int_op(fd_is_nonblocking(fd1), ==, 0); - tt_int_op(fd_is_nonblocking(fd2), ==, 1); - tt_int_op(fd_is_nonblocking(fd3), ==, 0); - tt_int_op(fd_is_nonblocking(fd4), ==, 1); + tt_int_op(fd_is_nonblocking(fd1), OP_EQ, 0); + tt_int_op(fd_is_nonblocking(fd2), OP_EQ, 1); + tt_int_op(fd_is_nonblocking(fd3), OP_EQ, 0); + tt_int_op(fd_is_nonblocking(fd4), OP_EQ, 1); #endif tor_close_socket(fd1); tor_close_socket(fd2); fd1 = fd2 = TOR_INVALID_SOCKET; - tt_int_op(get_n_open_sockets(), ==, n + 2); + tt_int_op(get_n_open_sockets(), OP_EQ, n + 2); tor_close_socket(fd3); tor_close_socket(fd4); fd3 = fd4 = TOR_INVALID_SOCKET; - tt_int_op(get_n_open_sockets(), ==, n); + tt_int_op(get_n_open_sockets(), OP_EQ, n); done: if (SOCKET_OK(fd1)) @@ -4742,17 +4742,17 @@ test_util_socketpair(void *arg) tor_socket_t fds[2] = {TOR_INVALID_SOCKET, TOR_INVALID_SOCKET}; const int family = AF_UNIX; - tt_int_op(0, ==, tor_socketpair_fn(family, SOCK_STREAM, 0, fds)); + tt_int_op(0, OP_EQ, tor_socketpair_fn(family, SOCK_STREAM, 0, fds)); tt_assert(SOCKET_OK(fds[0])); tt_assert(SOCKET_OK(fds[1])); - tt_int_op(get_n_open_sockets(), ==, n + 2); + tt_int_op(get_n_open_sockets(), OP_EQ, n + 2); #ifdef CAN_CHECK_CLOEXEC - tt_int_op(fd_is_cloexec(fds[0]), ==, 1); - tt_int_op(fd_is_cloexec(fds[1]), ==, 1); + tt_int_op(fd_is_cloexec(fds[0]), OP_EQ, 1); + tt_int_op(fd_is_cloexec(fds[1]), OP_EQ, 1); #endif #ifdef CAN_CHECK_NONBLOCK - tt_int_op(fd_is_nonblocking(fds[0]), ==, 0); - tt_int_op(fd_is_nonblocking(fds[1]), ==, 0); + tt_int_op(fd_is_nonblocking(fds[0]), OP_EQ, 0); + tt_int_op(fd_is_nonblocking(fds[1]), OP_EQ, 0); #endif done: @@ -4771,18 +4771,18 @@ test_util_max_mem(void *arg) r = get_total_system_memory(&memory1); r2 = get_total_system_memory(&memory2); - tt_int_op(r, ==, r2); - tt_uint_op(memory2, ==, memory1); + tt_int_op(r, OP_EQ, r2); + tt_uint_op(memory2, OP_EQ, memory1); TT_BLATHER(("System memory: "U64_FORMAT, U64_PRINTF_ARG(memory1))); if (r==0) { /* You have at least a megabyte. */ - tt_uint_op(memory1, >, (1<<20)); + tt_uint_op(memory1, OP_GT, (1<<20)); } else { /* You do not have a petabyte. */ #if SIZEOF_SIZE_T == SIZEOF_UINT64_T - tt_uint_op(memory1, <, (U64_LITERAL(1)<<50)); + tt_uint_op(memory1, OP_LT, (U64_LITERAL(1)<<50)); #endif } |