2009-09-22 19:29:55 +02:00
|
|
|
/* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2015-01-02 20:27:39 +01:00
|
|
|
* Copyright (c) 2007-2015, The Tor Project, Inc. */
|
2009-09-22 19:29:55 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
#include "orconfig.h"
|
2013-08-02 16:36:36 +02:00
|
|
|
#define COMPAT_PRIVATE
|
2009-09-22 19:29:55 +02:00
|
|
|
#define CONTROL_PRIVATE
|
2010-06-16 20:47:06 +02:00
|
|
|
#define UTIL_PRIVATE
|
2009-09-22 19:29:55 +02:00
|
|
|
#include "or.h"
|
2010-07-22 10:22:51 +02:00
|
|
|
#include "config.h"
|
2010-07-22 11:35:09 +02:00
|
|
|
#include "control.h"
|
2009-09-22 19:29:55 +02:00
|
|
|
#include "test.h"
|
|
|
|
#include "memarea.h"
|
2014-04-30 18:50:00 +02:00
|
|
|
#include "util_process.h"
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-06-07 17:59:32 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <tchar.h>
|
|
|
|
#endif
|
2013-02-01 22:09:16 +01:00
|
|
|
#include <math.h>
|
2014-10-12 11:50:10 +02:00
|
|
|
#include <ctype.h>
|
2015-03-27 10:37:07 +01:00
|
|
|
#include <float.h>
|
2012-06-07 17:59:32 +02:00
|
|
|
|
2012-09-11 16:41:59 +02:00
|
|
|
/* XXXX this is a minimal wrapper to make the unit tests compile with the
|
|
|
|
* changed tor_timegm interface. */
|
|
|
|
static time_t
|
|
|
|
tor_timegm_wrapper(const struct tm *tm)
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
if (tor_timegm(tm, &t) < 0)
|
|
|
|
return -1;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define tor_timegm tor_timegm_wrapper
|
|
|
|
|
2012-09-12 21:26:34 +02:00
|
|
|
static void
|
2012-09-14 18:23:31 +02:00
|
|
|
test_util_read_until_eof_impl(const char *fname, size_t file_len,
|
|
|
|
size_t read_limit)
|
2012-09-12 21:26:34 +02:00
|
|
|
{
|
|
|
|
char *fifo_name = NULL;
|
2012-09-14 18:23:31 +02:00
|
|
|
char *test_str = NULL;
|
2012-09-12 21:26:34 +02:00
|
|
|
char *str = NULL;
|
2012-09-14 18:23:31 +02:00
|
|
|
size_t sz = 9999999;
|
2012-09-12 21:26:34 +02:00
|
|
|
int fd = -1;
|
2012-09-14 18:23:31 +02:00
|
|
|
int r;
|
2012-09-12 21:26:34 +02:00
|
|
|
|
2012-09-14 18:23:31 +02:00
|
|
|
fifo_name = tor_strdup(get_fname(fname));
|
|
|
|
test_str = tor_malloc(file_len);
|
|
|
|
crypto_rand(test_str, file_len);
|
2012-09-12 21:26:34 +02:00
|
|
|
|
2012-09-14 18:23:31 +02:00
|
|
|
r = write_bytes_to_file(fifo_name, test_str, file_len, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, 0);
|
2012-09-14 18:23:31 +02:00
|
|
|
|
|
|
|
fd = open(fifo_name, O_RDONLY|O_BINARY);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(fd, OP_GE, 0);
|
2012-09-14 18:23:31 +02:00
|
|
|
str = read_file_to_str_until_eof(fd, read_limit, &sz);
|
|
|
|
tt_assert(str != NULL);
|
2012-09-12 21:26:34 +02:00
|
|
|
|
2012-09-14 18:23:31 +02:00
|
|
|
if (read_limit < file_len)
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(sz, OP_EQ, read_limit);
|
2012-09-14 18:23:31 +02:00
|
|
|
else
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(sz, OP_EQ, file_len);
|
2012-09-12 21:26:34 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(test_str, OP_EQ, str, sz);
|
|
|
|
tt_int_op(str[sz], OP_EQ, '\0');
|
2012-09-12 21:26:34 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
unlink(fifo_name);
|
|
|
|
tor_free(fifo_name);
|
2012-09-14 18:23:31 +02:00
|
|
|
tor_free(test_str);
|
2012-09-12 21:26:34 +02:00
|
|
|
tor_free(str);
|
2013-02-11 21:20:20 +01:00
|
|
|
if (fd >= 0)
|
|
|
|
close(fd);
|
2012-09-12 21:26:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-14 18:23:31 +02:00
|
|
|
test_util_read_file_eof_tiny_limit(void *arg)
|
2012-09-12 21:26:34 +02:00
|
|
|
{
|
|
|
|
(void)arg;
|
2012-09-14 18:23:31 +02:00
|
|
|
// purposely set limit shorter than what we wrote to the FIFO to
|
|
|
|
// test the maximum, and that it puts the NUL in the right spot
|
2012-09-12 21:26:34 +02:00
|
|
|
|
2012-09-14 18:23:31 +02:00
|
|
|
test_util_read_until_eof_impl("tor_test_fifo_tiny", 5, 4);
|
|
|
|
}
|
2012-09-12 21:26:34 +02:00
|
|
|
|
2014-09-02 19:29:11 +02:00
|
|
|
static void
|
|
|
|
test_util_read_file_eof_one_loop_a(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
test_util_read_until_eof_impl("tor_test_fifo_1ka", 1024, 1023);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_util_read_file_eof_one_loop_b(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
test_util_read_until_eof_impl("tor_test_fifo_1kb", 1024, 1024);
|
|
|
|
}
|
|
|
|
|
2012-09-14 18:23:31 +02:00
|
|
|
static void
|
|
|
|
test_util_read_file_eof_two_loops(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
2012-09-12 21:26:34 +02:00
|
|
|
// write more than 1024 bytes to the FIFO to test two passes through
|
|
|
|
// the loop in the method; if the re-alloc size is changed this
|
|
|
|
// should be updated as well.
|
|
|
|
|
2012-09-14 18:23:31 +02:00
|
|
|
test_util_read_until_eof_impl("tor_test_fifo_2k", 2048, 10000);
|
2012-09-12 21:26:34 +02:00
|
|
|
}
|
|
|
|
|
2014-09-02 19:29:11 +02:00
|
|
|
static void
|
|
|
|
test_util_read_file_eof_two_loops_b(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
test_util_read_until_eof_impl("tor_test_fifo_2kb", 2048, 2048);
|
|
|
|
}
|
|
|
|
|
2012-09-12 21:26:34 +02:00
|
|
|
static void
|
2012-09-14 18:23:31 +02:00
|
|
|
test_util_read_file_eof_zero_bytes(void *arg)
|
2012-09-12 21:26:34 +02:00
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
// zero-byte fifo
|
2012-09-14 18:23:31 +02:00
|
|
|
test_util_read_until_eof_impl("tor_test_fifo_empty", 0, 10000);
|
2012-09-12 21:26:34 +02:00
|
|
|
}
|
|
|
|
|
2013-09-05 00:25:41 +02:00
|
|
|
/* Test the basic expected behaviour for write_chunks_to_file.
|
2013-10-11 18:51:07 +02:00
|
|
|
* NOTE: This will need to be updated if we ever change the tempfile location
|
|
|
|
* or extension */
|
2013-09-05 00:25:41 +02:00
|
|
|
static void
|
|
|
|
test_util_write_chunks_to_file(void *arg)
|
|
|
|
{
|
2013-10-11 18:51:07 +02:00
|
|
|
char *fname = NULL;
|
|
|
|
char *tempname = NULL;
|
|
|
|
char *str = NULL;
|
2013-09-05 00:25:41 +02:00
|
|
|
int r;
|
2013-10-11 18:51:07 +02:00
|
|
|
struct stat st;
|
2013-09-05 00:25:41 +02:00
|
|
|
|
|
|
|
/* These should be two different sizes to ensure the data is different
|
2013-10-11 18:51:07 +02:00
|
|
|
* between the data file and the temp file's 'known string' */
|
2013-09-05 00:25:41 +02:00
|
|
|
int temp_str_len = 1024;
|
|
|
|
int data_str_len = 512;
|
2013-10-11 18:51:07 +02:00
|
|
|
char *data_str = tor_malloc(data_str_len);
|
|
|
|
char *temp_str = tor_malloc(temp_str_len);
|
2013-09-05 00:25:41 +02:00
|
|
|
|
|
|
|
smartlist_t *chunks = smartlist_new();
|
|
|
|
sized_chunk_t c = {data_str, data_str_len/2};
|
|
|
|
sized_chunk_t c2 = {data_str + data_str_len/2, data_str_len/2};
|
2013-10-11 18:51:07 +02:00
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
crypto_rand(temp_str, temp_str_len);
|
|
|
|
crypto_rand(data_str, data_str_len);
|
|
|
|
|
|
|
|
// Ensure it can write multiple chunks
|
|
|
|
|
2013-09-05 00:25:41 +02:00
|
|
|
smartlist_add(chunks, &c);
|
|
|
|
smartlist_add(chunks, &c2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if it writes using a tempfile
|
|
|
|
*/
|
2013-10-11 18:51:07 +02:00
|
|
|
fname = tor_strdup(get_fname("write_chunks_with_tempfile"));
|
2013-09-05 00:25:41 +02:00
|
|
|
tor_asprintf(&tempname, "%s.tmp", fname);
|
|
|
|
|
|
|
|
// write a known string to a file where the tempfile will be
|
|
|
|
r = write_bytes_to_file(tempname, temp_str, temp_str_len, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, 0);
|
2013-09-05 00:25:41 +02:00
|
|
|
|
|
|
|
// call write_chunks_to_file
|
|
|
|
r = write_chunks_to_file(fname, chunks, 1, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, 0);
|
2013-09-05 00:25:41 +02:00
|
|
|
|
|
|
|
// assert the file has been written (expected size)
|
2013-10-11 18:51:07 +02:00
|
|
|
str = read_file_to_str(fname, RFTS_BIN, &st);
|
2013-09-05 00:25:41 +02:00
|
|
|
tt_assert(str != NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_u64_op((uint64_t)st.st_size, OP_EQ, data_str_len);
|
|
|
|
tt_mem_op(data_str, OP_EQ, str, data_str_len);
|
2013-09-05 00:25:41 +02:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
// assert that the tempfile is removed (should not leave artifacts)
|
2013-10-11 18:51:07 +02:00
|
|
|
str = read_file_to_str(tempname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
|
2013-09-05 00:25:41 +02:00
|
|
|
tt_assert(str == NULL);
|
|
|
|
|
|
|
|
// Remove old testfile for second test
|
|
|
|
r = unlink(fname);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, 0);
|
2013-09-05 00:25:41 +02:00
|
|
|
tor_free(fname);
|
|
|
|
tor_free(tempname);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if it skips using a tempfile with flags
|
|
|
|
*/
|
2013-10-11 18:51:07 +02:00
|
|
|
fname = tor_strdup(get_fname("write_chunks_with_no_tempfile"));
|
2013-09-05 00:25:41 +02:00
|
|
|
tor_asprintf(&tempname, "%s.tmp", fname);
|
|
|
|
|
|
|
|
// write a known string to a file where the tempfile will be
|
|
|
|
r = write_bytes_to_file(tempname, temp_str, temp_str_len, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, 0);
|
2013-09-05 00:25:41 +02:00
|
|
|
|
|
|
|
// call write_chunks_to_file with no_tempfile = true
|
|
|
|
r = write_chunks_to_file(fname, chunks, 1, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, 0);
|
2013-09-05 00:25:41 +02:00
|
|
|
|
|
|
|
// assert the file has been written (expected size)
|
2013-10-11 18:51:07 +02:00
|
|
|
str = read_file_to_str(fname, RFTS_BIN, &st);
|
2013-09-05 00:25:41 +02:00
|
|
|
tt_assert(str != NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_u64_op((uint64_t)st.st_size, OP_EQ, data_str_len);
|
|
|
|
tt_mem_op(data_str, OP_EQ, str, data_str_len);
|
2013-09-05 00:25:41 +02:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
// assert the tempfile still contains the known string
|
2013-10-11 18:51:07 +02:00
|
|
|
str = read_file_to_str(tempname, RFTS_BIN, &st);
|
2013-09-05 00:25:41 +02:00
|
|
|
tt_assert(str != NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_u64_op((uint64_t)st.st_size, OP_EQ, temp_str_len);
|
|
|
|
tt_mem_op(temp_str, OP_EQ, str, temp_str_len);
|
2013-10-11 18:51:07 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
unlink(fname);
|
|
|
|
unlink(tempname);
|
|
|
|
smartlist_free(chunks);
|
|
|
|
tor_free(fname);
|
|
|
|
tor_free(tempname);
|
|
|
|
tor_free(str);
|
|
|
|
tor_free(data_str);
|
|
|
|
tor_free(temp_str);
|
2013-09-05 00:25:41 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
#define _TFE(a, b, f) tt_int_op((a).f, OP_EQ, (b).f)
|
2014-10-19 17:52:21 +02:00
|
|
|
/** 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) \
|
|
|
|
TT_STMT_BEGIN \
|
|
|
|
_TFE(a, b, tm_year); \
|
|
|
|
_TFE(a, b, tm_mon ); \
|
|
|
|
_TFE(a, b, tm_mday); \
|
|
|
|
_TFE(a, b, tm_hour); \
|
|
|
|
_TFE(a, b, tm_min ); \
|
|
|
|
_TFE(a, b, tm_sec ); \
|
|
|
|
TT_STMT_END
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_time(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
struct timeval start, end;
|
2014-10-19 17:52:21 +02:00
|
|
|
struct tm a_time, b_time;
|
2012-01-11 16:48:05 +01:00
|
|
|
char timestr[128];
|
2009-09-22 19:29:55 +02:00
|
|
|
time_t t_res;
|
|
|
|
int i;
|
2012-01-11 16:48:05 +01:00
|
|
|
struct timeval tv;
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-05 01:21:33 +01:00
|
|
|
/* Test tv_udiff */
|
2012-02-04 12:47:58 +01:00
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:29:55 +02:00
|
|
|
start.tv_sec = 5;
|
|
|
|
start.tv_usec = 5000;
|
|
|
|
|
|
|
|
end.tv_sec = 5;
|
|
|
|
end.tv_usec = 5000;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0L,OP_EQ, tv_udiff(&start, &end));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
end.tv_usec = 7000;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(2000L,OP_EQ, tv_udiff(&start, &end));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
end.tv_sec = 6;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1002000L,OP_EQ, tv_udiff(&start, &end));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
end.tv_usec = 0;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(995000L,OP_EQ, tv_udiff(&start, &end));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
end.tv_sec = 4;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1005000L,OP_EQ, tv_udiff(&start, &end));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2014-10-19 17:52:21 +02:00
|
|
|
/* Test tor_timegm & tor_gmtime_r */
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* The test values here are confirmed to be correct on a platform
|
2014-10-19 17:52:21 +02:00
|
|
|
* with a working timegm & gmtime_r. */
|
|
|
|
|
|
|
|
/* Start with known-zero a_time and b_time.
|
|
|
|
* This avoids passing uninitialised values to TM_EQUAL in a_time.
|
|
|
|
* Zeroing may not be needed for b_time, as long as tor_gmtime_r
|
|
|
|
* never reads the existing values in the structure.
|
|
|
|
* But we really don't want intermittently failing tests. */
|
|
|
|
memset(&a_time, 0, sizeof(struct tm));
|
|
|
|
memset(&b_time, 0, sizeof(struct tm));
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
a_time.tm_year = 2003-1900;
|
|
|
|
a_time.tm_mon = 7;
|
|
|
|
a_time.tm_mday = 30;
|
|
|
|
a_time.tm_hour = 6;
|
|
|
|
a_time.tm_min = 14;
|
|
|
|
a_time.tm_sec = 55;
|
2014-10-19 17:52:21 +02:00
|
|
|
t_res = 1062224095UL;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(t_res, OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
TM_EQUAL(a_time, b_time);
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
a_time.tm_year = 2004-1900; /* Try a leap year, after feb. */
|
2014-10-19 17:52:21 +02:00
|
|
|
t_res = 1093846495UL;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(t_res, OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
TM_EQUAL(a_time, b_time);
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
a_time.tm_mon = 1; /* Try a leap year, in feb. */
|
|
|
|
a_time.tm_mday = 10;
|
2014-10-19 17:52:21 +02:00
|
|
|
t_res = 1076393695UL;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(t_res, OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
TM_EQUAL(a_time, b_time);
|
|
|
|
|
2012-02-20 13:19:03 +01:00
|
|
|
a_time.tm_mon = 0;
|
2014-10-19 17:52:21 +02:00
|
|
|
t_res = 1073715295UL;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(t_res, OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
TM_EQUAL(a_time, b_time);
|
|
|
|
|
|
|
|
/* Test tor_timegm out of range */
|
|
|
|
|
|
|
|
/* year */
|
|
|
|
|
|
|
|
/* Wrong year < 1970 */
|
|
|
|
a_time.tm_year = 1969-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = -1-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
2014-10-20 23:44:10 +02:00
|
|
|
#if SIZEOF_INT == 4 || SIZEOF_INT == 8
|
2014-10-19 17:52:21 +02:00
|
|
|
a_time.tm_year = -1*(1 << 16);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* one of the smallest tm_year values my 64 bit system supports:
|
|
|
|
* t_res = -9223372036854775LL without clamping */
|
|
|
|
a_time.tm_year = -292275055-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = INT32_MIN;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-20 23:44:10 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
2014-10-20 23:44:10 +02:00
|
|
|
#if SIZEOF_INT == 8
|
|
|
|
a_time.tm_year = -1*(1 << 48);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* while unlikely, the system's gmtime(_r) could return
|
|
|
|
* a "correct" retrospective gregorian negative year value,
|
|
|
|
* which I'm pretty sure is:
|
|
|
|
* -1*(2^63)/60/60/24*2000/730485 + 1970 = -292277022657
|
|
|
|
* 730485 is the number of days in two millenia, including leap days */
|
2014-10-20 23:44:10 +02:00
|
|
|
a_time.tm_year = -292277022657-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = INT64_MIN;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-20 23:44:10 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* Wrong year >= INT32_MAX - 1900 */
|
2014-10-20 23:44:10 +02:00
|
|
|
#if SIZEOF_INT == 4 || SIZEOF_INT == 8
|
2014-10-19 17:52:21 +02:00
|
|
|
a_time.tm_year = INT32_MAX-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = INT32_MAX;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-20 23:44:10 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
2014-10-20 23:44:10 +02:00
|
|
|
#if SIZEOF_INT == 8
|
2014-10-19 17:52:21 +02:00
|
|
|
/* one of the largest tm_year values my 64 bit system supports */
|
2014-10-20 23:44:10 +02:00
|
|
|
a_time.tm_year = 292278994-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* while unlikely, the system's gmtime(_r) could return
|
|
|
|
* a "correct" proleptic gregorian year value,
|
|
|
|
* which I'm pretty sure is:
|
|
|
|
* (2^63-1)/60/60/24*2000/730485 + 1970 = 292277026596
|
|
|
|
* 730485 is the number of days in two millenia, including leap days */
|
2014-10-20 23:44:10 +02:00
|
|
|
a_time.tm_year = 292277026596-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = INT64_MAX-1900;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = INT64_MAX;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-20 23:44:10 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* month */
|
|
|
|
a_time.tm_year = 2007-1900; /* restore valid year */
|
|
|
|
|
2012-02-20 13:19:03 +01:00
|
|
|
a_time.tm_mon = 12; /* Wrong month, it's 0-based */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
2012-02-20 13:19:03 +01:00
|
|
|
a_time.tm_mon = -1; /* Wrong month */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2014-10-19 17:52:21 +02:00
|
|
|
/* day */
|
|
|
|
a_time.tm_mon = 6; /* Try July */
|
|
|
|
a_time.tm_mday = 32; /* Wrong day */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_mon = 5; /* Try June */
|
|
|
|
a_time.tm_mday = 31; /* Wrong day */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_year = 2008-1900; /* Try a leap year */
|
|
|
|
a_time.tm_mon = 1; /* in feb. */
|
|
|
|
a_time.tm_mday = 30; /* Wrong day */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
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 */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_mday = 0; /* Wrong day, it's 1-based (to be different) */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* hour */
|
|
|
|
a_time.tm_mday = 3; /* restore valid month day */
|
|
|
|
|
|
|
|
a_time.tm_hour = 24; /* Wrong hour, it's 0-based */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_hour = -1; /* Wrong hour */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* minute */
|
|
|
|
a_time.tm_hour = 22; /* restore valid hour */
|
|
|
|
|
|
|
|
a_time.tm_min = 60; /* Wrong minute, it's 0-based */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_min = -1; /* Wrong minute */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* second */
|
|
|
|
a_time.tm_min = 37; /* restore valid minute */
|
|
|
|
|
|
|
|
a_time.tm_sec = 61; /* Wrong second: 0-based with leap seconds */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
a_time.tm_sec = -1; /* Wrong second */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* Test tor_gmtime_r out of range */
|
|
|
|
|
|
|
|
/* time_t < 0 yields a year clamped to 1 or 1970,
|
|
|
|
* depending on whether the implementation of the system gmtime(_r)
|
|
|
|
* sets struct tm (1) or not (1970) */
|
|
|
|
t_res = -1;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (1970-1900) ||
|
|
|
|
b_time.tm_year == (1969-1900));
|
|
|
|
|
|
|
|
if (sizeof(time_t) == 4 || sizeof(time_t) == 8) {
|
|
|
|
t_res = -1*(1 << 30);
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (1970-1900) ||
|
|
|
|
b_time.tm_year == (1935-1900));
|
|
|
|
|
|
|
|
t_res = INT32_MIN;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (1970-1900) ||
|
|
|
|
b_time.tm_year == (1901-1900));
|
|
|
|
}
|
|
|
|
|
2014-10-22 18:57:21 +02:00
|
|
|
#if SIZEOF_TIME_T == 8
|
|
|
|
{
|
2014-10-19 17:52:21 +02:00
|
|
|
/* one of the smallest tm_year values my 64 bit system supports:
|
|
|
|
* b_time.tm_year == (-292275055LL-1900LL) without clamping */
|
|
|
|
t_res = -9223372036854775LL;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (1970-1900) ||
|
|
|
|
b_time.tm_year == (1-1900));
|
|
|
|
|
|
|
|
/* while unlikely, the system's gmtime(_r) could return
|
|
|
|
* a "correct" retrospective gregorian negative year value,
|
|
|
|
* which I'm pretty sure is:
|
|
|
|
* -1*(2^63)/60/60/24*2000/730485 + 1970 = -292277022657
|
|
|
|
* 730485 is the number of days in two millenia, including leap days
|
|
|
|
* (int64_t)b_time.tm_year == (-292277022657LL-1900LL) without clamping */
|
|
|
|
t_res = INT64_MIN;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (1970-1900) ||
|
|
|
|
b_time.tm_year == (1-1900));
|
|
|
|
}
|
2014-10-22 18:57:21 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
|
|
|
/* time_t >= INT_MAX yields a year clamped to 2037 or 9999,
|
|
|
|
* depending on whether the implementation of the system gmtime(_r)
|
|
|
|
* sets struct tm (9999) or not (2037) */
|
2014-10-22 18:57:21 +02:00
|
|
|
#if SIZEOF_TIME_T == 4 || SIZEOF_TIME_T == 8
|
|
|
|
{
|
2014-10-19 17:52:21 +02:00
|
|
|
t_res = 3*(1 << 29);
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (2021-1900));
|
|
|
|
|
|
|
|
t_res = INT32_MAX;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (2037-1900) ||
|
|
|
|
b_time.tm_year == (2038-1900));
|
|
|
|
}
|
2014-10-22 18:57:21 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
2014-10-22 18:57:21 +02:00
|
|
|
#if SIZEOF_TIME_T == 8
|
|
|
|
{
|
2014-10-19 17:52:21 +02:00
|
|
|
/* one of the largest tm_year values my 64 bit system supports:
|
|
|
|
* b_time.tm_year == (292278994L-1900L) without clamping */
|
|
|
|
t_res = 9223372036854775LL;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (2037-1900) ||
|
|
|
|
b_time.tm_year == (9999-1900));
|
|
|
|
|
|
|
|
/* while unlikely, the system's gmtime(_r) could return
|
|
|
|
* a "correct" proleptic gregorian year value,
|
|
|
|
* which I'm pretty sure is:
|
|
|
|
* (2^63-1)/60/60/24*2000/730485 + 1970 = 292277026596
|
|
|
|
* 730485 is the number of days in two millenia, including leap days
|
|
|
|
* (int64_t)b_time.tm_year == (292277026596L-1900L) without clamping */
|
|
|
|
t_res = INT64_MAX;
|
|
|
|
tor_gmtime_r(&t_res, &b_time);
|
|
|
|
tt_assert(b_time.tm_year == (2037-1900) ||
|
|
|
|
b_time.tm_year == (9999-1900));
|
|
|
|
}
|
2014-10-22 18:57:21 +02:00
|
|
|
#endif
|
2014-10-19 17:52:21 +02:00
|
|
|
|
2012-02-05 01:21:33 +01:00
|
|
|
/* Test {format,parse}_rfc1123_time */
|
2012-02-04 12:47:58 +01:00
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
format_rfc1123_time(timestr, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("Thu, 01 Jan 1970 00:00:00 GMT",OP_EQ, timestr);
|
2009-09-22 19:29:55 +02:00
|
|
|
format_rfc1123_time(timestr, (time_t)1091580502UL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("Wed, 04 Aug 2004 00:48:22 GMT",OP_EQ, timestr);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
t_res = 0;
|
|
|
|
i = parse_rfc1123_time(timestr, &t_res);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
|
|
|
tt_int_op(t_res,OP_EQ, (time_t)1091580502UL);
|
2012-02-20 13:19:03 +01:00
|
|
|
/* The timezone doesn't matter */
|
|
|
|
t_res = 0;
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
|
|
|
parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(t_res,OP_EQ, (time_t)1091580502UL);
|
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, zz Aug 2004 99-99x99 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 32 Mar 2011 00:00:00 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Mar 2011 24:00:00 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Mar 2011 23:60:00 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Mar 2011 23:59:62 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Mar 1969 23:59:59 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Ene 2011 23:59:59 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Mar 2011 23:59:59 GM", &t_res));
|
2012-02-20 13:19:03 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-10-19 17:52:21 +02:00
|
|
|
parse_rfc1123_time("Wed, 29 Feb 2011 16:00:00 GMT", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-10-19 17:52:21 +02:00
|
|
|
parse_rfc1123_time("Wed, 30 Mar 2011 23:59:61 GMT", &t_res));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-20 16:57:30 +01:00
|
|
|
/* Test parse_iso_time */
|
|
|
|
|
|
|
|
t_res = 0;
|
|
|
|
i = parse_iso_time("", &t_res);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ, i);
|
2012-02-20 16:57:30 +01:00
|
|
|
t_res = 0;
|
|
|
|
i = parse_iso_time("2004-08-32 00:48:22", &t_res);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ, i);
|
2012-02-20 16:57:30 +01:00
|
|
|
t_res = 0;
|
|
|
|
i = parse_iso_time("1969-08-03 00:48:22", &t_res);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ, i);
|
2012-02-20 16:57:30 +01:00
|
|
|
|
|
|
|
t_res = 0;
|
|
|
|
i = parse_iso_time("2004-08-04 00:48:22", &t_res);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
|
|
|
tt_int_op(t_res,OP_EQ, (time_t)1091580502UL);
|
2012-02-20 16:57:30 +01:00
|
|
|
t_res = 0;
|
|
|
|
i = parse_iso_time("2004-8-4 0:48:22", &t_res);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
|
|
|
tt_int_op(t_res,OP_EQ, (time_t)1091580502UL);
|
2013-07-19 05:45:40 +02:00
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2004-08-zz 99-99x99", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-32 00:00:00", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 24:00:00", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 23:60:00", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2011-03-30 23:59:62", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("1969-03-30 23:59:59", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2011-00-30 23:59:59", &t_res));
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2013-07-19 05:45:40 +02:00
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2004-08-04 00:48:22.100", &t_res));
|
|
|
|
tt_int_op(-1,OP_EQ, parse_iso_time("2004-08-04 00:48:22XYZ", &t_res));
|
2012-02-20 16:57:30 +01:00
|
|
|
|
2012-02-05 01:21:33 +01:00
|
|
|
/* Test tor_gettimeofday */
|
2012-02-04 12:47:58 +01:00
|
|
|
|
|
|
|
end.tv_sec = 4;
|
|
|
|
end.tv_usec = 999990;
|
|
|
|
start.tv_sec = 1;
|
|
|
|
start.tv_usec = 500;
|
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
tor_gettimeofday(&start);
|
|
|
|
/* now make sure time works. */
|
|
|
|
tor_gettimeofday(&end);
|
|
|
|
/* We might've timewarped a little. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(tv_udiff(&start, &end), OP_GE, -5000);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-05 01:21:33 +01:00
|
|
|
/* Test format_iso_time */
|
2012-02-04 12:47:58 +01:00
|
|
|
|
2012-01-11 16:48:05 +01:00
|
|
|
tv.tv_sec = (time_t)1326296338;
|
|
|
|
tv.tv_usec = 3060;
|
2014-05-12 01:16:06 +02:00
|
|
|
format_iso_time(timestr, (time_t)tv.tv_sec);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("2012-01-11 15:38:58",OP_EQ, timestr);
|
2012-01-11 16:48:05 +01:00
|
|
|
/* 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.
|
|
|
|
format_local_iso_time(timestr, tv.tv_sec);
|
|
|
|
test_streq("2012-01-11 10:38:58", timestr);
|
|
|
|
*/
|
2014-05-12 01:16:06 +02:00
|
|
|
format_iso_time_nospace(timestr, (time_t)tv.tv_sec);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("2012-01-11T15:38:58",OP_EQ, timestr);
|
|
|
|
tt_int_op(strlen(timestr),OP_EQ, ISO_TIME_LEN);
|
2012-01-11 16:48:05 +01:00
|
|
|
format_iso_time_nospace_usec(timestr, &tv);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("2012-01-11T15:38:58.003060",OP_EQ, timestr);
|
|
|
|
tt_int_op(strlen(timestr),OP_EQ, ISO_TIME_USEC_LEN);
|
2012-01-11 16:48:05 +01:00
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-20 17:40:37 +01:00
|
|
|
static void
|
|
|
|
test_util_parse_http_time(void *arg)
|
|
|
|
{
|
|
|
|
struct tm a_time;
|
2012-05-16 18:19:56 +02:00
|
|
|
char b[ISO_TIME_LEN+1];
|
2012-02-20 17:40:37 +01:00
|
|
|
(void)arg;
|
|
|
|
|
2012-05-16 18:19:56 +02:00
|
|
|
#define T(s) do { \
|
|
|
|
format_iso_time(b, tor_timegm(&a_time)); \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(b, OP_EQ, (s)); \
|
2012-05-16 18:19:56 +02:00
|
|
|
b[0]='\0'; \
|
|
|
|
} while (0)
|
|
|
|
|
2012-02-20 17:40:37 +01:00
|
|
|
/* Test parse_http_time */
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Sunday, 32 Aug 2004 00:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Sunday, 3 Aug 1869 00:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Sunday, 32-Aug-94 00:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Sunday, 3-Ago-04 00:48:22", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Sunday, August the third", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Wednesday,,04 Aug 1994 00:48:22 GMT", &a_time));
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Wednesday, 04 Aug 1994 00:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Wednesday, 4 Aug 1994 0:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Miercoles, 4 Aug 1994 0:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
parse_http_time("Wednesday, 04-Aug-94 00:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
|
|
|
parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
|
|
|
parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("1994-08-04 00:48:22");
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0,OP_EQ,parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)1325376000UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("2012-01-01 00:00:00");
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0,OP_EQ,parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((time_t)1356912000UL,OP_EQ, tor_timegm(&a_time));
|
2012-05-16 18:19:56 +02:00
|
|
|
T("2012-12-31 00:00:00");
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-02-20 17:40:37 +01:00
|
|
|
|
2012-05-16 18:19:56 +02:00
|
|
|
#undef T
|
2012-02-20 17:40:37 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_config_line(void *arg)
|
2009-09-22 19:39:27 +02:00
|
|
|
{
|
|
|
|
char buf[1024];
|
2009-10-27 03:18:05 +01:00
|
|
|
char *k=NULL, *v=NULL;
|
2009-09-22 19:39:27 +02:00
|
|
|
const char *str;
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Test parse_config_line_from_str */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:29:55 +02:00
|
|
|
strlcpy(buf, "k v\n" " key value with spaces \n" "keykey val\n"
|
|
|
|
"k2\n"
|
|
|
|
"k3 \n" "\n" " \n" "#comment\n"
|
|
|
|
"k4#a\n" "k5#abc\n" "k6 val #with comment\n"
|
|
|
|
"kseven \"a quoted 'string\"\n"
|
|
|
|
"k8 \"a \\x71uoted\\n\\\"str\\\\ing\\t\\001\\01\\1\\\"\"\n"
|
2010-09-10 15:19:10 +02:00
|
|
|
"k9 a line that\\\n spans two lines.\n\n"
|
|
|
|
"k10 more than\\\n one contin\\\nuation\n"
|
|
|
|
"k11 \\\ncontinuation at the start\n"
|
2010-09-11 01:25:48 +02:00
|
|
|
"k12 line with a\\\n#comment\n embedded\n"
|
|
|
|
"k13\\\ncontinuation at the very start\n"
|
2010-09-23 22:39:58 +02:00
|
|
|
"k14 a line that has a comment and # ends with a slash \\\n"
|
|
|
|
"k15 this should be the next new line\n"
|
|
|
|
"k16 a line that has a comment and # ends without a slash \n"
|
|
|
|
"k17 this should be the next new line\n"
|
2009-09-22 19:29:55 +02:00
|
|
|
, sizeof(buf));
|
|
|
|
str = buf;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k");
|
|
|
|
tt_str_op(v,OP_EQ, "v");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "key value with"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "key");
|
|
|
|
tt_str_op(v,OP_EQ, "value with spaces");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "keykey"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "keykey");
|
|
|
|
tt_str_op(v,OP_EQ, "val");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "k2\n"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k2");
|
|
|
|
tt_str_op(v,OP_EQ, "");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "k3 \n"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k3");
|
|
|
|
tt_str_op(v,OP_EQ, "");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "#comment"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k4");
|
|
|
|
tt_str_op(v,OP_EQ, "");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "k5#abc"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k5");
|
|
|
|
tt_str_op(v,OP_EQ, "");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "k6"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k6");
|
|
|
|
tt_str_op(v,OP_EQ, "val");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "kseven"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "kseven");
|
|
|
|
tt_str_op(v,OP_EQ, "a quoted \'string");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!strcmpstart(str, "k8 "));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k8");
|
|
|
|
tt_str_op(v,OP_EQ, "a quoted\n\"str\\ing\t\x01\x01\x01\"");
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(k); tor_free(v);
|
2010-09-10 15:19:10 +02:00
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k9");
|
|
|
|
tt_str_op(v,OP_EQ, "a line that spans two lines.");
|
2010-09-10 15:19:10 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k10");
|
|
|
|
tt_str_op(v,OP_EQ, "more than one continuation");
|
2010-09-10 15:19:10 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k11");
|
|
|
|
tt_str_op(v,OP_EQ, "continuation at the start");
|
2010-09-10 15:19:10 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2010-09-11 01:25:48 +02:00
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k12");
|
|
|
|
tt_str_op(v,OP_EQ, "line with a embedded");
|
2010-09-11 01:25:48 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k13");
|
|
|
|
tt_str_op(v,OP_EQ, "continuation at the very start");
|
2010-09-11 01:25:48 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2010-09-23 22:39:58 +02:00
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k14");
|
|
|
|
tt_str_op(v,OP_EQ, "a line that has a comment and" );
|
2010-09-23 22:39:58 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k15");
|
|
|
|
tt_str_op(v,OP_EQ, "this should be the next new line");
|
2010-09-23 22:39:58 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k16");
|
|
|
|
tt_str_op(v,OP_EQ, "a line that has a comment and" );
|
2010-09-23 22:39:58 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k17");
|
|
|
|
tt_str_op(v,OP_EQ, "this should be the next new line");
|
2010-09-23 22:39:58 +02:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(str,OP_EQ, "");
|
2010-09-10 15:19:10 +02:00
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
done:
|
2009-10-27 03:18:05 +01:00
|
|
|
tor_free(k);
|
|
|
|
tor_free(v);
|
2009-09-22 19:39:27 +02:00
|
|
|
}
|
|
|
|
|
2012-02-03 00:12:23 +01:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_config_line_quotes(void *arg)
|
2012-02-03 00:12:23 +01:00
|
|
|
{
|
|
|
|
char buf1[1024];
|
|
|
|
char buf2[128];
|
|
|
|
char buf3[128];
|
|
|
|
char buf4[128];
|
|
|
|
char *k=NULL, *v=NULL;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
/* Test parse_config_line_from_str */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2012-02-03 00:12:23 +01:00
|
|
|
strlcpy(buf1, "kTrailingSpace \"quoted value\" \n"
|
|
|
|
"kTrailingGarbage \"quoted value\"trailing garbage\n"
|
|
|
|
, sizeof(buf1));
|
|
|
|
strlcpy(buf2, "kTrailingSpaceAndGarbage \"quoted value\" trailing space+g\n"
|
|
|
|
, sizeof(buf2));
|
|
|
|
strlcpy(buf3, "kMultilineTrailingSpace \"mline\\ \nvalue w/ trailing sp\"\n"
|
|
|
|
, sizeof(buf3));
|
|
|
|
strlcpy(buf4, "kMultilineNoTrailingBackslash \"naked multiline\nvalue\"\n"
|
|
|
|
, sizeof(buf4));
|
|
|
|
str = buf1;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "kTrailingSpace");
|
|
|
|
tt_str_op(v,OP_EQ, "quoted value");
|
2012-02-03 00:12:23 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 00:12:23 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = buf2;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 00:12:23 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = buf3;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 00:12:23 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = buf4;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 00:12:23 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(k);
|
|
|
|
tor_free(v);
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:43:29 +01:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_config_line_comment_character(void *arg)
|
2012-02-03 23:43:29 +01:00
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
char *k=NULL, *v=NULL;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
/* Test parse_config_line_from_str */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2012-02-03 23:43:29 +01:00
|
|
|
strlcpy(buf, "k1 \"# in quotes\"\n"
|
|
|
|
"k2 some value # some comment\n"
|
|
|
|
"k3 /home/user/myTorNetwork#2\n" /* Testcase for #1323 */
|
|
|
|
, sizeof(buf));
|
|
|
|
str = buf;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k1");
|
|
|
|
tt_str_op(v,OP_EQ, "# in quotes");
|
2012-02-03 23:43:29 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "k2");
|
|
|
|
tt_str_op(v,OP_EQ, "some value");
|
2012-02-03 23:43:29 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(str,OP_EQ, "k3 /home/user/myTorNetwork#2\n");
|
2012-03-30 16:26:34 +02:00
|
|
|
|
2012-02-03 23:43:29 +01:00
|
|
|
#if 0
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
|
|
|
test_streq(k, "k3");
|
|
|
|
test_streq(v, "/home/user/myTorNetwork#2");
|
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
test_streq(str, "");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(k);
|
|
|
|
tor_free(v);
|
|
|
|
}
|
|
|
|
|
2012-02-03 20:52:34 +01:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_config_line_escaped_content(void *arg)
|
2012-02-03 20:52:34 +01:00
|
|
|
{
|
|
|
|
char buf1[1024];
|
|
|
|
char buf2[128];
|
|
|
|
char buf3[128];
|
|
|
|
char buf4[128];
|
2012-02-03 23:28:40 +01:00
|
|
|
char buf5[128];
|
2012-02-20 17:39:43 +01:00
|
|
|
char buf6[128];
|
2012-02-03 20:52:34 +01:00
|
|
|
char *k=NULL, *v=NULL;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
/* Test parse_config_line_from_str */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2012-02-03 20:52:34 +01:00
|
|
|
strlcpy(buf1, "HexadecimalLower \"\\x2a\"\n"
|
|
|
|
"HexadecimalUpper \"\\x2A\"\n"
|
|
|
|
"HexadecimalUpperX \"\\X2A\"\n"
|
|
|
|
"Octal \"\\52\"\n"
|
|
|
|
"Newline \"\\n\"\n"
|
|
|
|
"Tab \"\\t\"\n"
|
|
|
|
"CarriageReturn \"\\r\"\n"
|
2012-02-03 21:05:17 +01:00
|
|
|
"DoubleQuote \"\\\"\"\n"
|
|
|
|
"SimpleQuote \"\\'\"\n"
|
2012-02-03 20:52:34 +01:00
|
|
|
"Backslash \"\\\\\"\n"
|
2012-02-03 21:05:17 +01:00
|
|
|
"Mix \"This is a \\\"star\\\":\\t\\'\\x2a\\'\\nAnd second line\"\n"
|
2012-02-03 20:52:34 +01:00
|
|
|
, sizeof(buf1));
|
|
|
|
|
|
|
|
strlcpy(buf2, "BrokenEscapedContent \"\\a\"\n"
|
|
|
|
, sizeof(buf2));
|
|
|
|
|
|
|
|
strlcpy(buf3, "BrokenEscapedContent \"\\x\"\n"
|
|
|
|
, sizeof(buf3));
|
|
|
|
|
|
|
|
strlcpy(buf4, "BrokenOctal \"\\8\"\n"
|
|
|
|
, sizeof(buf4));
|
|
|
|
|
2012-02-03 23:28:40 +01:00
|
|
|
strlcpy(buf5, "BrokenHex \"\\xg4\"\n"
|
|
|
|
, sizeof(buf5));
|
|
|
|
|
2012-02-20 17:39:43 +01:00
|
|
|
strlcpy(buf6, "BrokenEscape \"\\"
|
|
|
|
, sizeof(buf6));
|
|
|
|
|
2012-02-03 20:52:34 +01:00
|
|
|
str = buf1;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "HexadecimalLower");
|
|
|
|
tt_str_op(v,OP_EQ, "*");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "HexadecimalUpper");
|
|
|
|
tt_str_op(v,OP_EQ, "*");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "HexadecimalUpperX");
|
|
|
|
tt_str_op(v,OP_EQ, "*");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "Octal");
|
|
|
|
tt_str_op(v,OP_EQ, "*");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "Newline");
|
|
|
|
tt_str_op(v,OP_EQ, "\n");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "Tab");
|
|
|
|
tt_str_op(v,OP_EQ, "\t");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "CarriageReturn");
|
|
|
|
tt_str_op(v,OP_EQ, "\r");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "DoubleQuote");
|
|
|
|
tt_str_op(v,OP_EQ, "\"");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2012-02-03 21:05:17 +01:00
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "SimpleQuote");
|
|
|
|
tt_str_op(v,OP_EQ, "'");
|
2012-02-03 21:05:17 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2012-02-03 20:52:34 +01:00
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "Backslash");
|
|
|
|
tt_str_op(v,OP_EQ, "\\");
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2012-02-03 21:05:17 +01:00
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(k,OP_EQ, "Mix");
|
|
|
|
tt_str_op(v,OP_EQ, "This is a \"star\":\t'*'\nAnd second line");
|
2012-02-03 21:05:17 +01:00
|
|
|
tor_free(k); tor_free(v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(str,OP_EQ, "");
|
2012-02-03 21:05:17 +01:00
|
|
|
|
2012-02-03 20:52:34 +01:00
|
|
|
str = buf2;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = buf3;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
|
|
|
str = buf4;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-03 20:52:34 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2012-02-03 23:28:40 +01:00
|
|
|
#if 0
|
|
|
|
str = buf5;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str, OP_EQ, NULL);
|
2012-02-03 23:28:40 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
#endif
|
|
|
|
|
2012-02-20 17:39:43 +01:00
|
|
|
str = buf6;
|
|
|
|
|
|
|
|
str = parse_config_line_from_str(str, &k, &v);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str,OP_EQ, NULL);
|
2012-02-20 17:39:43 +01:00
|
|
|
tor_free(k); tor_free(v);
|
|
|
|
|
2012-02-03 20:52:34 +01:00
|
|
|
done:
|
|
|
|
tor_free(k);
|
|
|
|
tor_free(v);
|
|
|
|
}
|
|
|
|
|
2012-04-27 00:34:47 +02:00
|
|
|
#ifndef _WIN32
|
2012-02-20 17:42:48 +01:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_expand_filename(void *arg)
|
2012-02-20 17:42:48 +01:00
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2012-02-20 17:42:48 +01:00
|
|
|
setenv("HOME", "/home/itv", 1); /* For "internal test value" */
|
|
|
|
|
|
|
|
str = expand_filename("");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("/normal/path");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/normal/path",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("/normal/trailing/path/");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/normal/trailing/path/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("$HOME/nodice");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("$HOME/nodice",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/foobarqux");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/foobarqux",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/../../etc/passwd");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/../../etc/passwd",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/trailing/");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/trailing/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
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) */
|
|
|
|
|
2012-02-20 22:52:15 +01:00
|
|
|
/* $HOME ending in a trailing slash */
|
|
|
|
setenv("HOME", "/home/itv/", 1);
|
|
|
|
|
|
|
|
str = expand_filename("~");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/",OP_EQ, str);
|
2012-02-20 22:52:15 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/",OP_EQ, str);
|
2012-02-20 22:52:15 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/foo");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/home/itv/foo",OP_EQ, str);
|
2012-02-20 22:52:15 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
2012-02-20 17:42:48 +01:00
|
|
|
/* Try with empty $HOME */
|
|
|
|
|
|
|
|
setenv("HOME", "", 1);
|
|
|
|
|
|
|
|
str = expand_filename("~");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/foobar");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/foobar",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
/* Try with $HOME unset */
|
|
|
|
|
|
|
|
unsetenv("HOME");
|
|
|
|
|
|
|
|
str = expand_filename("~");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
str = expand_filename("~/foobar");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("/foobar",OP_EQ, str);
|
2012-02-20 17:42:48 +01:00
|
|
|
tor_free(str);
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(str);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-12 15:36:13 +02:00
|
|
|
/** Test tor_escape_str_for_pt_args(). */
|
2012-12-17 13:14:09 +01:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_escape_string_socks(void *arg)
|
2012-12-17 13:14:09 +01:00
|
|
|
{
|
|
|
|
char *escaped_string = NULL;
|
|
|
|
|
|
|
|
/** Simple backslash escape. */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2013-06-12 15:36:13 +02:00
|
|
|
escaped_string = tor_escape_str_for_pt_args("This is a backslash: \\",";\\");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(escaped_string);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(escaped_string,OP_EQ, "This is a backslash: \\\\");
|
2012-12-17 13:14:09 +01:00
|
|
|
tor_free(escaped_string);
|
|
|
|
|
|
|
|
/** Simple semicolon escape. */
|
2013-06-12 15:36:13 +02:00
|
|
|
escaped_string = tor_escape_str_for_pt_args("First rule:Do not use ;",";\\");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(escaped_string);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(escaped_string,OP_EQ, "First rule:Do not use \\;");
|
2012-12-17 13:14:09 +01:00
|
|
|
tor_free(escaped_string);
|
|
|
|
|
2013-02-09 19:46:10 +01:00
|
|
|
/** Empty string. */
|
2013-06-12 15:36:13 +02:00
|
|
|
escaped_string = tor_escape_str_for_pt_args("", ";\\");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(escaped_string);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(escaped_string,OP_EQ, "");
|
2013-02-09 19:46:10 +01:00
|
|
|
tor_free(escaped_string);
|
2012-12-17 13:14:09 +01:00
|
|
|
|
|
|
|
/** Escape all characters. */
|
2013-06-12 15:36:13 +02:00
|
|
|
escaped_string = tor_escape_str_for_pt_args(";\\;\\", ";\\");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(escaped_string);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(escaped_string,OP_EQ, "\\;\\\\\\;\\\\");
|
2012-12-17 13:14:09 +01:00
|
|
|
tor_free(escaped_string);
|
|
|
|
|
2013-06-12 15:36:13 +02:00
|
|
|
escaped_string = tor_escape_str_for_pt_args(";", ";\\");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(escaped_string);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(escaped_string,OP_EQ, "\\;");
|
2013-02-09 19:46:10 +01:00
|
|
|
tor_free(escaped_string);
|
|
|
|
|
2012-12-17 13:14:09 +01:00
|
|
|
done:
|
|
|
|
tor_free(escaped_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_util_string_is_key_value(void *ptr)
|
|
|
|
{
|
|
|
|
(void)ptr;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(string_is_key_value(LOG_WARN, "key=value"));
|
|
|
|
tt_assert(string_is_key_value(LOG_WARN, "k=v"));
|
|
|
|
tt_assert(string_is_key_value(LOG_WARN, "key="));
|
|
|
|
tt_assert(string_is_key_value(LOG_WARN, "x="));
|
|
|
|
tt_assert(string_is_key_value(LOG_WARN, "xx="));
|
|
|
|
tt_assert(!string_is_key_value(LOG_WARN, "=value"));
|
|
|
|
tt_assert(!string_is_key_value(LOG_WARN, "=x"));
|
|
|
|
tt_assert(!string_is_key_value(LOG_WARN, "="));
|
2012-12-17 13:14:09 +01:00
|
|
|
|
|
|
|
/* ??? */
|
2014-09-16 03:29:48 +02:00
|
|
|
/* tt_assert(!string_is_key_value(LOG_WARN, "===")); */
|
2012-12-17 13:14:09 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
/** Test basic string functionality. */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_strmisc(void *arg)
|
2009-09-22 19:39:27 +02:00
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
int i;
|
2013-03-22 17:38:55 +01:00
|
|
|
char *cp, *cp_tmp = NULL;
|
2009-09-22 19:39:27 +02:00
|
|
|
|
2012-02-05 01:22:29 +01:00
|
|
|
/* Test strl operations */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2014-11-12 19:28:07 +01:00
|
|
|
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");
|
2009-09-22 19:39:27 +02:00
|
|
|
strlcpy(buf, "Hello", sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(10,OP_EQ, strlcat(buf, "Hello", 5));
|
2009-09-22 19:39:27 +02:00
|
|
|
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test strstrip() */
|
2009-09-22 19:39:27 +02:00
|
|
|
strlcpy(buf, "Testing 1 2 3", sizeof(buf));
|
|
|
|
tor_strstrip(buf, ",!");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(buf,OP_EQ, "Testing 1 2 3");
|
2009-09-22 19:39:27 +02:00
|
|
|
strlcpy(buf, "!Testing 1 2 3?", sizeof(buf));
|
|
|
|
tor_strstrip(buf, "!? ");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(buf,OP_EQ, "Testing123");
|
2012-02-05 01:22:29 +01:00
|
|
|
strlcpy(buf, "!!!Testing 1 2 3??", sizeof(buf));
|
|
|
|
tor_strstrip(buf, "!? ");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(buf,OP_EQ, "Testing123");
|
2009-09-22 19:39:27 +02:00
|
|
|
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test parse_long */
|
2012-02-05 01:22:29 +01:00
|
|
|
/* Empty/zero input */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-05 01:22:29 +01:00
|
|
|
/* Normal cases */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-05 01:22:29 +01:00
|
|
|
/* Extra garbage */
|
2014-11-12 19:28:07 +01:00
|
|
|
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");
|
2012-02-05 01:22:29 +01:00
|
|
|
/* Out of bounds */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-05 01:22:29 +01:00
|
|
|
/* Base different than 10 */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2009-09-22 19:39:27 +02:00
|
|
|
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test parse_ulong */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2009-09-22 19:39:27 +02:00
|
|
|
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test parse_uint64 */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
|
|
|
tt_str_op(cp,OP_EQ, " x");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(U64_LITERAL(12345678901) ==
|
2009-09-22 19:39:27 +02:00
|
|
|
tor_parse_uint64("12345678901",10,0,UINT64_MAX, &i, &cp));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
|
|
|
tt_str_op(cp,OP_EQ, "");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(U64_LITERAL(0) ==
|
2009-09-22 19:39:27 +02:00
|
|
|
tor_parse_uint64("12345678901",10,500,INT32_MAX, &i, &cp));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(U64_LITERAL(0) ==
|
2014-01-13 22:38:48 +01:00
|
|
|
tor_parse_uint64("123",-1,0,INT32_MAX, &i, &cp));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
2009-09-22 19:39:27 +02:00
|
|
|
|
|
|
|
{
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test parse_double */
|
2009-09-22 19:39:27 +02:00
|
|
|
double d = tor_parse_double("10", 0, UINT64_MAX,&i,NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(DBL_TO_U64(d) == 10);
|
2009-09-22 19:39:27 +02:00
|
|
|
d = tor_parse_double("0", 0, UINT64_MAX,&i,NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(DBL_TO_U64(d) == 0);
|
2009-09-22 19:39:27 +02:00
|
|
|
d = tor_parse_double(" ", 0, UINT64_MAX,&i,NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
2009-09-22 19:39:27 +02:00
|
|
|
d = tor_parse_double(".0a", 0, UINT64_MAX,&i,NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, i);
|
2009-09-22 19:39:27 +02:00
|
|
|
d = tor_parse_double(".0a", 0, UINT64_MAX,&i,&cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
2009-09-22 19:39:27 +02:00
|
|
|
d = tor_parse_double("-.0", 0, UINT64_MAX,&i,NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(DBL_TO_U64(d) == 0);
|
2012-02-05 01:22:29 +01:00
|
|
|
d = tor_parse_double("-10", -100.0, 100.0,&i,NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, i);
|
|
|
|
tt_int_op(-10.0,OP_EQ, d);
|
2009-09-22 19:39:27 +02:00
|
|
|
}
|
|
|
|
|
2012-05-07 18:25:59 +02:00
|
|
|
{
|
|
|
|
/* Test tor_parse_* where we overflow/underflow the underlying type. */
|
|
|
|
/* This string should overflow 64-bit ints. */
|
|
|
|
#define TOOBIG "100000000000000000000000000"
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(0L, OP_EQ,
|
|
|
|
tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(i,OP_EQ, 0);
|
|
|
|
tt_int_op(0L,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_parse_long("-"TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2012-05-07 18:25:59 +02:00
|
|
|
0, UINT64_MAX, &i, NULL));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(i,OP_EQ, 0);
|
2012-05-07 18:25:59 +02:00
|
|
|
}
|
|
|
|
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test snprintf */
|
2012-02-05 17:53:01 +01:00
|
|
|
/* Returning -1 when there's not enough room in the output buffer */
|
2014-11-12 19:28:07 +01:00
|
|
|
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"));
|
2012-02-05 17:53:01 +01:00
|
|
|
/* Always NUL-terminate the output */
|
|
|
|
tor_snprintf(buf, 5, "abcdef");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, buf[4]);
|
2012-02-05 17:53:01 +01:00
|
|
|
tor_snprintf(buf, 10, "abcdef");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, buf[6]);
|
2012-02-05 17:53:01 +01:00
|
|
|
/* uint64 */
|
2009-09-22 19:39:27 +02:00
|
|
|
tor_snprintf(buf, sizeof(buf), "x!"U64_FORMAT"!x",
|
|
|
|
U64_PRINTF_ARG(U64_LITERAL(12345678901)));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("x!12345678901!x",OP_EQ, buf);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-05 17:52:26 +01:00
|
|
|
/* Test str{,case}cmpstart */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(strcmpstart("abcdef", "abcdef")==0);
|
|
|
|
tt_assert(strcmpstart("abcdef", "abc")==0);
|
|
|
|
tt_assert(strcmpstart("abcdef", "abd")<0);
|
|
|
|
tt_assert(strcmpstart("abcdef", "abb")>0);
|
|
|
|
tt_assert(strcmpstart("ab", "abb")<0);
|
|
|
|
tt_assert(strcmpstart("ab", "")==0);
|
|
|
|
tt_assert(strcmpstart("ab", "ab ")<0);
|
|
|
|
tt_assert(strcasecmpstart("abcdef", "abCdEF")==0);
|
|
|
|
tt_assert(strcasecmpstart("abcDeF", "abc")==0);
|
|
|
|
tt_assert(strcasecmpstart("abcdef", "Abd")<0);
|
|
|
|
tt_assert(strcasecmpstart("Abcdef", "abb")>0);
|
|
|
|
tt_assert(strcasecmpstart("ab", "Abb")<0);
|
|
|
|
tt_assert(strcasecmpstart("ab", "")==0);
|
|
|
|
tt_assert(strcasecmpstart("ab", "ab ")<0);
|
2012-02-05 17:52:26 +01:00
|
|
|
|
|
|
|
/* Test str{,case}cmpend */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(strcmpend("abcdef", "abcdef")==0);
|
|
|
|
tt_assert(strcmpend("abcdef", "def")==0);
|
|
|
|
tt_assert(strcmpend("abcdef", "deg")<0);
|
|
|
|
tt_assert(strcmpend("abcdef", "dee")>0);
|
|
|
|
tt_assert(strcmpend("ab", "aab")>0);
|
|
|
|
tt_assert(strcasecmpend("AbcDEF", "abcdef")==0);
|
|
|
|
tt_assert(strcasecmpend("abcdef", "dEF")==0);
|
|
|
|
tt_assert(strcasecmpend("abcdef", "Deg")<0);
|
|
|
|
tt_assert(strcasecmpend("abcDef", "dee")>0);
|
|
|
|
tt_assert(strcasecmpend("AB", "abb")<0);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Test digest_is_zero */
|
|
|
|
memset(buf,0,20);
|
|
|
|
buf[20] = 'x';
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_digest_is_zero(buf));
|
2012-02-05 22:01:57 +01:00
|
|
|
buf[19] = 'x';
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_digest_is_zero(buf));
|
2012-02-05 22:01:57 +01:00
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
/* Test mem_is_zero */
|
|
|
|
memset(buf,0,128);
|
|
|
|
buf[128] = 'x';
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_mem_is_zero(buf, 10));
|
|
|
|
tt_assert(tor_mem_is_zero(buf, 20));
|
|
|
|
tt_assert(tor_mem_is_zero(buf, 128));
|
|
|
|
tt_assert(!tor_mem_is_zero(buf, 129));
|
2009-09-22 19:29:55 +02:00
|
|
|
buf[60] = (char)255;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_mem_is_zero(buf, 128));
|
2009-09-22 19:29:55 +02:00
|
|
|
buf[0] = (char)1;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_mem_is_zero(buf, 10));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Test 'escaped' */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(NULL == escaped(NULL));
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2012-02-05 22:01:57 +01:00
|
|
|
escaped("unnecessary \'backslashes\'"));
|
|
|
|
/* Non-printable characters appear as octal */
|
2014-11-12 19:28:07 +01:00
|
|
|
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"));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Test strndup and memdup */
|
|
|
|
{
|
|
|
|
const char *s = "abcdefghijklmnopqrstuvwxyz";
|
2013-03-21 12:52:36 +01:00
|
|
|
cp_tmp = tor_strndup(s, 30);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp_tmp,OP_EQ, s); /* same string, */
|
|
|
|
tt_ptr_op(cp_tmp,OP_NE,s); /* but different pointers. */
|
2013-03-21 12:52:36 +01:00
|
|
|
tor_free(cp_tmp);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2013-03-21 12:52:36 +01:00
|
|
|
cp_tmp = tor_strndup(s, 5);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp_tmp,OP_EQ, "abcde");
|
2013-03-21 12:52:36 +01:00
|
|
|
tor_free(cp_tmp);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
s = "a\0b\0c\0d\0e\0";
|
2013-03-21 12:52:36 +01:00
|
|
|
cp_tmp = tor_memdup(s,10);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(cp_tmp,OP_EQ, s, 10); /* same ram, */
|
|
|
|
tt_ptr_op(cp_tmp,OP_NE,s); /* but different pointers. */
|
2013-03-21 12:52:36 +01:00
|
|
|
tor_free(cp_tmp);
|
2009-09-22 19:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test str-foo functions */
|
2014-04-08 05:20:13 +02:00
|
|
|
cp_tmp = tor_strdup("abcdef");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_strisnonupper(cp_tmp));
|
2014-04-08 05:20:13 +02:00
|
|
|
cp_tmp[3] = 'D';
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_strisnonupper(cp_tmp));
|
2014-04-08 05:20:13 +02:00
|
|
|
tor_strupper(cp_tmp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp_tmp,OP_EQ, "ABCDEF");
|
2014-04-08 05:20:13 +02:00
|
|
|
tor_strlower(cp_tmp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cp_tmp,OP_EQ, "abcdef");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_strisnonupper(cp_tmp));
|
|
|
|
tt_assert(tor_strisprint(cp_tmp));
|
2014-04-08 05:20:13 +02:00
|
|
|
cp_tmp[3] = 3;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_strisprint(cp_tmp));
|
2014-04-08 05:20:13 +02:00
|
|
|
tor_free(cp_tmp);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Test memmem and memstr */
|
|
|
|
{
|
|
|
|
const char *haystack = "abcde";
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_memmem(haystack, 5, "ef", 2));
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_memmem(haystack, 4, "cde", 3));
|
2009-09-22 19:29:55 +02:00
|
|
|
haystack = "ababcad";
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_memmem(haystack, 7, "dadad", 5));
|
|
|
|
tt_assert(!tor_memmem(haystack, 7, "abcdefghij", 10));
|
2012-02-05 22:01:57 +01:00
|
|
|
/* memstr */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(tor_memstr(haystack, 7, "abc"),OP_EQ, haystack + 2);
|
|
|
|
tt_ptr_op(tor_memstr(haystack, 7, "cad"),OP_EQ, haystack + 4);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_memstr(haystack, 6, "cad"));
|
|
|
|
tt_assert(!tor_memstr(haystack, 7, "cadd"));
|
|
|
|
tt_assert(!tor_memstr(haystack, 7, "fe"));
|
|
|
|
tt_assert(!tor_memstr(haystack, 7, "ababcade"));
|
2009-09-22 19:29:55 +02:00
|
|
|
}
|
|
|
|
|
2011-10-31 23:36:35 +01:00
|
|
|
/* Test hex_str */
|
|
|
|
{
|
2012-02-20 13:20:32 +01:00
|
|
|
char binary_data[68];
|
2011-10-31 23:36:35 +01:00
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < sizeof(binary_data); ++i)
|
|
|
|
binary_data[i] = i;
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2014-09-16 15:40:38 +02:00
|
|
|
"000102030405060708090A0B0C0D0E0F10");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(hex_str(binary_data, 32),OP_EQ,
|
2011-10-31 23:36:35 +01:00
|
|
|
"000102030405060708090A0B0C0D0E0F"
|
|
|
|
"101112131415161718191A1B1C1D1E1F");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(hex_str(binary_data, 34),OP_EQ,
|
2012-02-20 13:20:32 +01:00
|
|
|
"000102030405060708090A0B0C0D0E0F"
|
|
|
|
"101112131415161718191A1B1C1D1E1F");
|
2012-02-05 22:01:57 +01:00
|
|
|
/* Repeat these tests for shorter strings after longer strings
|
|
|
|
have been tried, to make sure we're correctly terminating strings */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(hex_str(binary_data, 1),OP_EQ, "00");
|
|
|
|
tt_str_op(hex_str(binary_data, 0),OP_EQ, "");
|
2011-10-31 23:36:35 +01:00
|
|
|
}
|
2012-02-20 13:20:32 +01:00
|
|
|
|
|
|
|
/* Test strcmp_opt */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-20 13:20:32 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-20 13:20:32 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strcmp_opt(NULL, "foo"), OP_LT, 0);
|
|
|
|
tt_int_op(strcmp_opt("foo", NULL), OP_GT, 0);
|
2012-02-20 13:20:32 +01:00
|
|
|
|
|
|
|
/* Test strcmp_len */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strcmp_len("foo", "bar", 3), OP_GT, 0);
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(strcmp_len("foo", "bar", 2), OP_LT, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
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 */
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(strcmp_len("foo2", "foo", 3), OP_EQ, 0); /* Really stop at len */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strcmp_len("blah", "", 4), OP_GT, 0);
|
|
|
|
tt_int_op(strcmp_len("blah", "", 0), OP_EQ, 0);
|
2012-02-20 13:20:32 +01:00
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
done:
|
2013-03-21 12:52:36 +01:00
|
|
|
tor_free(cp_tmp);
|
2009-09-22 19:39:27 +02:00
|
|
|
}
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2009-09-22 19:39:27 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_pow2(void *arg)
|
2009-09-22 19:39:27 +02:00
|
|
|
{
|
2009-09-22 19:29:55 +02:00
|
|
|
/* Test tor_log2(). */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-11-12 19:42:01 +01:00
|
|
|
/* incorrect mathematically, but as specified: */
|
|
|
|
tt_int_op(tor_log2(0),OP_EQ, 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Test round_to_power_of_2 */
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2014-05-08 20:01:17 +02:00
|
|
|
U64_LITERAL(1)<<55);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_u64_op(round_to_power_of_2(U64_LITERAL(0xffffffffffffffff)), OP_EQ,
|
2014-05-08 20:01:17 +02:00
|
|
|
U64_LITERAL(1)<<63);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Run unit tests for compression functions */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_gzip(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
char *buf1=NULL, *buf2=NULL, *buf3=NULL, *cp1, *cp2;
|
|
|
|
const char *ccp2;
|
|
|
|
size_t len1, len2;
|
|
|
|
tor_zlib_state_t *state = NULL;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:29:55 +02:00
|
|
|
buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD);
|
2009-09-22 19:29:55 +02:00
|
|
|
if (is_gzip_supported()) {
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
|
2009-09-22 19:29:55 +02:00
|
|
|
GZIP_METHOD));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(buf2);
|
|
|
|
tt_assert(len1 < strlen(buf1));
|
|
|
|
tt_assert(detect_compression_method(buf2, len1) == GZIP_METHOD);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
|
2009-09-22 19:29:55 +02:00
|
|
|
GZIP_METHOD, 1, LOG_INFO));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(buf3);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strlen(buf1) + 1,OP_EQ, len2);
|
|
|
|
tt_str_op(buf1,OP_EQ, buf3);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
tor_free(buf2);
|
|
|
|
tor_free(buf3);
|
|
|
|
}
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(buf2);
|
|
|
|
tt_assert(detect_compression_method(buf2, len1) == ZLIB_METHOD);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD, 1, LOG_INFO));
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(buf3);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strlen(buf1) + 1,OP_EQ, len2);
|
|
|
|
tt_str_op(buf1,OP_EQ, buf3);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Check whether we can uncompress concatenated, compressed strings. */
|
|
|
|
tor_free(buf3);
|
2014-08-13 16:36:06 +02:00
|
|
|
buf2 = tor_reallocarray(buf2, len1, 2);
|
2009-09-22 19:29:55 +02:00
|
|
|
memcpy(buf2+len1, buf2, len1);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1*2,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD, 1, LOG_INFO));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op((strlen(buf1)+1)*2,OP_EQ, len2);
|
|
|
|
tt_mem_op(buf3,OP_EQ,
|
2009-09-22 19:29:55 +02:00
|
|
|
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0"
|
|
|
|
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0",
|
|
|
|
(strlen(buf1)+1)*2);
|
|
|
|
|
|
|
|
tor_free(buf1);
|
|
|
|
tor_free(buf2);
|
|
|
|
tor_free(buf3);
|
|
|
|
|
|
|
|
/* Check whether we can uncompress partial strings. */
|
|
|
|
buf1 =
|
|
|
|
tor_strdup("String with low redundancy that won't be compressed much.");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD));
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(len1>16);
|
2009-09-22 19:29:55 +02:00
|
|
|
/* when we allow an incomplete string, we should succeed.*/
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1-16,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD, 0, LOG_INFO));
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(len2 > 5);
|
2012-02-06 19:22:32 +01:00
|
|
|
buf3[len2]='\0';
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(!strcmpstart(buf1, buf3));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* when we demand a complete string, this must fail. */
|
|
|
|
tor_free(buf3);
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(tor_gzip_uncompress(&buf3, &len2, buf2, len1-16,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD, 1, LOG_INFO));
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(!buf3);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Now, try streaming compression. */
|
|
|
|
tor_free(buf1);
|
|
|
|
tor_free(buf2);
|
|
|
|
tor_free(buf3);
|
2014-11-17 17:43:50 +01:00
|
|
|
state = tor_zlib_new(1, ZLIB_METHOD, HIGH_COMPRESSION);
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(state);
|
2009-09-22 19:29:55 +02:00
|
|
|
cp1 = buf1 = tor_malloc(1024);
|
|
|
|
len1 = 1024;
|
|
|
|
ccp2 = "ABCDEFGHIJABCDEFGHIJ";
|
|
|
|
len2 = 21;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 0)
|
2009-09-22 19:29:55 +02:00
|
|
|
== TOR_ZLIB_OK);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, len2); /* Make sure we compressed it all. */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp1 > buf1);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
len2 = 0;
|
|
|
|
cp2 = cp1;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 1)
|
2009-09-22 19:29:55 +02:00
|
|
|
== TOR_ZLIB_DONE);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, len2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp1 > cp2); /* Make sure we really added something. */
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2011-06-09 02:33:53 +02:00
|
|
|
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf1, 1024-len1,
|
2009-09-22 19:29:55 +02:00
|
|
|
ZLIB_METHOD, 1, LOG_WARN));
|
2014-11-12 19:42:01 +01:00
|
|
|
/* Make sure it compressed right. */
|
|
|
|
tt_str_op(buf3, OP_EQ, "ABCDEFGHIJABCDEFGHIJ");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(21,OP_EQ, len2);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (state)
|
|
|
|
tor_zlib_free(state);
|
|
|
|
tor_free(buf2);
|
|
|
|
tor_free(buf3);
|
|
|
|
tor_free(buf1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Run unit tests for mmap() wrapper functionality. */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_mmap(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
char *fname1 = tor_strdup(get_fname("mapped_1"));
|
|
|
|
char *fname2 = tor_strdup(get_fname("mapped_2"));
|
|
|
|
char *fname3 = tor_strdup(get_fname("mapped_3"));
|
|
|
|
const size_t buflen = 17000;
|
|
|
|
char *buf = tor_malloc(17000);
|
|
|
|
tor_mmap_t *mapping = NULL;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:29:55 +02:00
|
|
|
crypto_rand(buf, buflen);
|
|
|
|
|
|
|
|
mapping = tor_mmap_file(fname1);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(! mapping);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
write_str_to_file(fname1, "Short file.", 1);
|
|
|
|
|
|
|
|
mapping = tor_mmap_file(fname1);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(mapping);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(mapping->size,OP_EQ, strlen("Short file."));
|
|
|
|
tt_str_op(mapping->data,OP_EQ, "Short file.");
|
2012-01-31 16:59:42 +01:00
|
|
|
#ifdef _WIN32
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0, OP_EQ, tor_munmap_file(mapping));
|
2009-09-22 19:29:55 +02:00
|
|
|
mapping = NULL;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(unlink(fname1) == 0);
|
2009-09-22 19:29:55 +02:00
|
|
|
#else
|
|
|
|
/* make sure we can unlink. */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(unlink(fname1) == 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(mapping->data,OP_EQ, "Short file.");
|
|
|
|
tt_int_op(0, OP_EQ, tor_munmap_file(mapping));
|
2009-09-22 19:29:55 +02:00
|
|
|
mapping = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Now a zero-length file. */
|
|
|
|
write_str_to_file(fname1, "", 1);
|
|
|
|
mapping = tor_mmap_file(fname1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(mapping,OP_EQ, NULL);
|
|
|
|
tt_int_op(ERANGE,OP_EQ, errno);
|
2009-09-22 19:29:55 +02:00
|
|
|
unlink(fname1);
|
|
|
|
|
|
|
|
/* Make sure that we fail to map a no-longer-existent file. */
|
|
|
|
mapping = tor_mmap_file(fname1);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(! mapping);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* Now try a big file that stretches across a few pages and isn't aligned */
|
2012-02-06 19:45:52 +01:00
|
|
|
write_bytes_to_file(fname2, buf, buflen, 1);
|
2009-09-22 19:29:55 +02:00
|
|
|
mapping = tor_mmap_file(fname2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(mapping);
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2009-09-22 19:29:55 +02:00
|
|
|
mapping = NULL;
|
|
|
|
|
|
|
|
/* Now try a big aligned file. */
|
2012-02-06 19:45:52 +01:00
|
|
|
write_bytes_to_file(fname3, buf, 16384, 1);
|
2009-09-22 19:29:55 +02:00
|
|
|
mapping = tor_mmap_file(fname3);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(mapping);
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2009-09-22 19:29:55 +02:00
|
|
|
mapping = NULL;
|
|
|
|
|
|
|
|
done:
|
|
|
|
unlink(fname1);
|
|
|
|
unlink(fname2);
|
|
|
|
unlink(fname3);
|
|
|
|
|
|
|
|
tor_free(fname1);
|
|
|
|
tor_free(fname2);
|
|
|
|
tor_free(fname3);
|
|
|
|
tor_free(buf);
|
|
|
|
|
2014-03-31 17:40:00 +02:00
|
|
|
tor_munmap_file(mapping);
|
2009-09-22 19:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Run unit tests for escaping/unescaping data for use by controllers. */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_control_formats(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
char *out = NULL;
|
|
|
|
const char *inp =
|
2012-02-06 19:53:07 +01:00
|
|
|
"..This is a test\r\n.of the emergency \n..system.\r\n\rZ.\r\n";
|
2009-09-22 19:29:55 +02:00
|
|
|
size_t sz;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:29:55 +02:00
|
|
|
sz = read_escaped_data(inp, strlen(inp), &out);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(out,OP_EQ,
|
2012-02-06 19:53:07 +01:00
|
|
|
".This is a test\nof the emergency \n.system.\n\rZ.\n");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(sz,OP_EQ, strlen(out));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(out);
|
|
|
|
}
|
|
|
|
|
2011-10-06 19:25:04 +02:00
|
|
|
#define test_feq(value1,value2) do { \
|
|
|
|
double v1 = (value1), v2=(value2); \
|
|
|
|
double tf_diff = v1-v2; \
|
|
|
|
double tf_tolerance = ((v1+v2)/2.0)/1e8; \
|
|
|
|
if (tf_diff<0) tf_diff=-tf_diff; \
|
|
|
|
if (tf_tolerance<0) tf_tolerance=-tf_tolerance; \
|
|
|
|
if (tf_diff<tf_tolerance) { \
|
|
|
|
TT_BLATHER(("%s ~~ %s: %f ~~ %f",#value1,#value2,v1,v2)); \
|
|
|
|
} else { \
|
|
|
|
TT_FAIL(("%s ~~ %s: %f != %f",#value1,#value2,v1,v2)); \
|
|
|
|
} \
|
2012-06-28 21:40:08 +02:00
|
|
|
} while (0)
|
2011-10-06 19:25:04 +02:00
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_sscanf(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
unsigned u1, u2, u3;
|
2014-09-11 05:57:31 +02:00
|
|
|
unsigned long ulng;
|
2012-03-27 14:04:15 +02:00
|
|
|
char s1[20], s2[10], s3[10], ch;
|
2009-09-22 19:29:55 +02:00
|
|
|
int r;
|
2011-10-06 19:25:04 +02:00
|
|
|
long lng1,lng2;
|
|
|
|
int int1, int2;
|
|
|
|
double d1,d2,d3,d4;
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2012-02-20 22:53:08 +01:00
|
|
|
/* Simple tests (malformed patterns, literal matching, ...) */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(-1,OP_EQ, tor_sscanf("123", "%i", &r)); /* %i is not supported */
|
|
|
|
tt_int_op(-1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("wrong", "%5c", s1)); /* %c cannot have a number. */
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-03-09 03:01:19 +01:00
|
|
|
#if 0
|
|
|
|
/* GCC thinks these two are illegal. */
|
|
|
|
test_eq(-1, tor_sscanf("prettylongstring", "%0s", s1));
|
2012-02-20 22:53:08 +01:00
|
|
|
test_eq(0, tor_sscanf("prettylongstring", "%10s", NULL));
|
2012-03-09 03:01:19 +01:00
|
|
|
#endif
|
2012-02-06 22:05:47 +01:00
|
|
|
/* No '%'-strings: always "success" */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("hello world", "hello world"));
|
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("hello world", "good bye"));
|
2012-02-20 17:00:16 +01:00
|
|
|
/* Excess data */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("hello 3", "%u", &u1)); /* have to match the start */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf(" 3 hello", "%u", &u1));
|
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf(" 3 hello", "%2u", &u1)); /* not even in this case */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("3 hello", "%u", &u1)); /* but trailing is alright */
|
2012-02-06 22:05:47 +01:00
|
|
|
|
|
|
|
/* Numbers (ie. %u) */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */
|
2014-11-12 19:28:07 +01:00
|
|
|
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 */
|
2012-02-06 22:05:47 +01:00
|
|
|
|
|
|
|
/* Numbers with size (eg. %2u) */
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("67:8:099", "%2u:%2u:%3u", &u1, &u2, &u3)); /* 0s */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(67u,OP_EQ, u1);
|
|
|
|
tt_int_op(8u,OP_EQ, u2);
|
|
|
|
tt_int_op(99u,OP_EQ, u3);
|
2009-09-22 19:29:55 +02:00
|
|
|
/* %u does not match space.*/
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2009-09-22 19:29:55 +02:00
|
|
|
/* %u does not match negative numbers. */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2009-09-22 19:29:55 +02:00
|
|
|
/* Arbitrary amounts of 0-padding are okay */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(3,OP_EQ, tor_sscanf("12:03:000000000000000099", "%2u:%2u:%u",
|
2012-02-06 22:05:47 +01:00
|
|
|
&u1, &u2, &u3));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(12u,OP_EQ, u1);
|
|
|
|
tt_int_op(3u,OP_EQ, u2);
|
|
|
|
tt_int_op(99u,OP_EQ, u3);
|
2012-02-06 22:05:47 +01:00
|
|
|
|
|
|
|
/* Hex (ie. %x) */
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(3,OP_EQ,
|
|
|
|
tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0x1234,OP_EQ, u1);
|
|
|
|
tt_int_op(0x2ABCDEF,OP_EQ, u2);
|
|
|
|
tt_int_op(0xFF,OP_EQ, u3);
|
2010-10-11 16:50:47 +02:00
|
|
|
/* Width works on %x */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-06 22:05:47 +01:00
|
|
|
|
|
|
|
/* Literal '%' (ie. '%%') */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-02-06 22:05:47 +01:00
|
|
|
|
|
|
|
/* Strings (ie. %s) */
|
2014-11-12 19:28:07 +01:00
|
|
|
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");
|
2012-02-06 22:05:47 +01:00
|
|
|
/* %s doesn't eat spaces */
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("hi", "%9s%9s%3s", s1, s2, s3)); /* %s can be empty. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(s1,OP_EQ, "hi");
|
|
|
|
tt_str_op(s2,OP_EQ, "");
|
|
|
|
tt_str_op(s3,OP_EQ, "");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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,
|
2014-09-16 15:40:38 +02:00
|
|
|
tor_sscanf("1.2.3 foobar", "%u.%u.%u%c", &u1, &u2, &u3, &ch));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(' ',OP_EQ, ch);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2011-10-06 19:25:04 +02:00
|
|
|
r = tor_sscanf("12345 -67890 -1", "%d %ld %d", &int1, &lng1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2011-10-06 19:25:04 +02:00
|
|
|
|
|
|
|
#if SIZEOF_INT == 4
|
2014-09-11 05:57:31 +02:00
|
|
|
/* %u */
|
|
|
|
/* UINT32_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("4294967295", "%u", &u1));
|
|
|
|
tt_int_op(4294967295U,OP_EQ, u1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT32_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("4294967296", "%u", &u1));
|
2014-09-11 05:57:31 +02:00
|
|
|
/* but parsing only 9... */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("4294967296", "%9u", &u1));
|
|
|
|
tt_int_op(429496729U,OP_EQ, u1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %x */
|
|
|
|
/* UINT32_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFF", "%x", &u1));
|
|
|
|
tt_int_op(0xFFFFFFFF,OP_EQ, u1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT32_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("100000000", "%x", &u1));
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %d */
|
|
|
|
/* INT32_MIN and INT32_MAX should work */
|
2011-10-06 19:25:04 +02:00
|
|
|
r = tor_sscanf("-2147483648. 2147483647.", "%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(int1,OP_EQ, -2147483647 - 1);
|
|
|
|
tt_int_op(int2,OP_EQ, 2147483647);
|
2011-10-06 19:25:04 +02:00
|
|
|
|
2014-09-11 05:57:31 +02:00
|
|
|
/* But INT32_MIN - 1 and INT32_MAX + 1 shouldn't work */
|
|
|
|
r = tor_sscanf("-2147483649.", "%d.", &int1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2011-10-06 19:25:04 +02:00
|
|
|
|
2014-09-11 05:57:31 +02:00
|
|
|
r = tor_sscanf("2147483648.", "%d.", &int1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* and the first failure stops further processing */
|
|
|
|
r = tor_sscanf("-2147483648. 2147483648.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("-2147483649. 2147483647.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("2147483648. -2147483649.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2011-10-06 19:25:04 +02:00
|
|
|
#elif SIZEOF_INT == 8
|
2014-09-11 05:57:31 +02:00
|
|
|
/* %u */
|
|
|
|
/* UINT64_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551615", "%u", &u1));
|
|
|
|
tt_int_op(18446744073709551615U,OP_EQ, u1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT64_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("18446744073709551616", "%u", &u1));
|
2014-09-11 05:57:31 +02:00
|
|
|
/* but parsing only 19... */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551616", "%19u", &u1));
|
|
|
|
tt_int_op(1844674407370955161U,OP_EQ, u1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %x */
|
|
|
|
/* UINT64_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFFFFFFFFFF", "%x", &u1));
|
|
|
|
tt_int_op(0xFFFFFFFFFFFFFFFF,OP_EQ, u1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT64_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("10000000000000000", "%x", &u1));
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %d */
|
|
|
|
/* INT64_MIN and INT64_MAX should work */
|
2011-10-06 19:25:04 +02:00
|
|
|
r = tor_sscanf("-9223372036854775808. 9223372036854775807.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(int1,OP_EQ, -9223372036854775807 - 1);
|
|
|
|
tt_int_op(int2,OP_EQ, 9223372036854775807);
|
2011-10-06 19:25:04 +02:00
|
|
|
|
2014-09-11 05:57:31 +02:00
|
|
|
/* But INT64_MIN - 1 and INT64_MAX + 1 shouldn't work */
|
2011-10-06 19:25:04 +02:00
|
|
|
r = tor_sscanf("-9223372036854775809.", "%d.", &int1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2011-10-06 19:25:04 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("9223372036854775808.", "%d.", &int1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* and the first failure stops further processing */
|
|
|
|
r = tor_sscanf("-9223372036854775808. 9223372036854775808.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("-9223372036854775809. 9223372036854775807.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("9223372036854775808. -9223372036854775809.",
|
|
|
|
"%d. %d.", &int1, &int2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2011-10-06 19:25:04 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SIZEOF_LONG == 4
|
2014-09-11 05:57:31 +02:00
|
|
|
/* %lu */
|
|
|
|
/* UINT32_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("4294967295", "%lu", &ulng));
|
|
|
|
tt_int_op(4294967295UL,OP_EQ, ulng);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT32_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("4294967296", "%lu", &ulng));
|
2014-09-11 05:57:31 +02:00
|
|
|
/* but parsing only 9... */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("4294967296", "%9lu", &ulng));
|
|
|
|
tt_int_op(429496729UL,OP_EQ, ulng);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %lx */
|
|
|
|
/* UINT32_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFF", "%lx", &ulng));
|
|
|
|
tt_int_op(0xFFFFFFFFUL,OP_EQ, ulng);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT32_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("100000000", "%lx", &ulng));
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %ld */
|
|
|
|
/* INT32_MIN and INT32_MAX should work */
|
2012-07-05 22:44:07 +02:00
|
|
|
r = tor_sscanf("-2147483648. 2147483647.", "%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(lng1,OP_EQ, -2147483647L - 1L);
|
|
|
|
tt_int_op(lng2,OP_EQ, 2147483647L);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But INT32_MIN - 1 and INT32_MAX + 1 shouldn't work */
|
|
|
|
r = tor_sscanf("-2147483649.", "%ld.", &lng1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("2147483648.", "%ld.", &lng1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* and the first failure stops further processing */
|
|
|
|
r = tor_sscanf("-2147483648. 2147483648.",
|
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("-2147483649. 2147483647.",
|
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("2147483648. -2147483649.",
|
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2011-10-06 19:25:04 +02:00
|
|
|
#elif SIZEOF_LONG == 8
|
2014-09-11 05:57:31 +02:00
|
|
|
/* %lu */
|
|
|
|
/* UINT64_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551615", "%lu", &ulng));
|
|
|
|
tt_int_op(18446744073709551615UL,OP_EQ, ulng);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT64_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("18446744073709551616", "%lu", &ulng));
|
2014-09-11 05:57:31 +02:00
|
|
|
/* but parsing only 19... */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("18446744073709551616", "%19lu", &ulng));
|
|
|
|
tt_int_op(1844674407370955161UL,OP_EQ, ulng);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %lx */
|
|
|
|
/* UINT64_MAX should work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(1,OP_EQ, tor_sscanf("FFFFFFFFFFFFFFFF", "%lx", &ulng));
|
|
|
|
tt_int_op(0xFFFFFFFFFFFFFFFFUL,OP_EQ, ulng);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* But UINT64_MAX + 1 shouldn't work */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0,OP_EQ, tor_sscanf("10000000000000000", "%lx", &ulng));
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* %ld */
|
|
|
|
/* INT64_MIN and INT64_MAX should work */
|
2011-10-06 19:25:04 +02:00
|
|
|
r = tor_sscanf("-9223372036854775808. 9223372036854775807.",
|
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(lng1,OP_EQ, -9223372036854775807L - 1L);
|
|
|
|
tt_int_op(lng2,OP_EQ, 9223372036854775807L);
|
2011-10-06 19:25:04 +02:00
|
|
|
|
2014-09-11 05:57:31 +02:00
|
|
|
/* But INT64_MIN - 1 and INT64_MAX + 1 shouldn't work */
|
|
|
|
r = tor_sscanf("-9223372036854775809.", "%ld.", &lng1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("9223372036854775808.", "%ld.", &lng1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
/* and the first failure stops further processing */
|
2011-10-06 19:25:04 +02:00
|
|
|
r = tor_sscanf("-9223372036854775808. 9223372036854775808.",
|
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 1);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("-9223372036854775809. 9223372036854775807.",
|
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2014-09-11 05:57:31 +02:00
|
|
|
|
|
|
|
r = tor_sscanf("9223372036854775808. -9223372036854775809.",
|
2011-10-06 19:25:04 +02:00
|
|
|
"%ld. %ld.", &lng1, &lng2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 0);
|
2011-10-06 19:25:04 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
r = tor_sscanf("123.456 .000007 -900123123.2000787 00003.2",
|
|
|
|
"%lf %lf %lf %lf", &d1,&d2,&d3,&d4);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 4);
|
2011-10-06 19:25:04 +02:00
|
|
|
test_feq(d1, 123.456);
|
|
|
|
test_feq(d2, .000007);
|
|
|
|
test_feq(d3, -900123123.2000787);
|
|
|
|
test_feq(d4, 3.2);
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
#define tt_char_op(a,op,b) tt_assert_op_type(a,op,b,char,"%c")
|
|
|
|
#define tt_ci_char_op(a,op,b) tt_char_op(tolower(a),op,tolower(b))
|
|
|
|
|
2014-10-13 20:59:17 +02:00
|
|
|
#ifndef HAVE_STRNLEN
|
|
|
|
static size_t
|
|
|
|
strnlen(const char *s, size_t len)
|
|
|
|
{
|
|
|
|
const char *p = memchr(s, 0, len);
|
|
|
|
if (!p)
|
|
|
|
return len;
|
|
|
|
return p - s;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
static void
|
|
|
|
test_util_format_time_interval(void *arg)
|
|
|
|
{
|
|
|
|
/* use the same sized buffer and integers as tor uses */
|
|
|
|
#define DBUF_SIZE 64
|
|
|
|
char dbuf[DBUF_SIZE];
|
|
|
|
#define T_ "%ld"
|
|
|
|
long sec, min, hour, day;
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* we don't care about the exact spelling of the
|
|
|
|
* second(s), minute(s), hour(s), day(s) labels */
|
|
|
|
#define LABEL_SIZE 21
|
|
|
|
#define L_ "%20s"
|
|
|
|
char label_s[LABEL_SIZE];
|
|
|
|
char label_m[LABEL_SIZE];
|
|
|
|
char label_h[LABEL_SIZE];
|
|
|
|
char label_d[LABEL_SIZE];
|
|
|
|
|
|
|
|
#define TL_ T_ " " L_
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
int r;
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
(void)arg;
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* In these tests, we're not picky about
|
|
|
|
* spelling or abbreviations */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* seconds: 0, 1, 9, 10, 59 */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "second(s)"*/
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 0);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_ci_char_op(label_s[0],OP_EQ, 's');
|
|
|
|
tt_int_op(sec,OP_EQ, 0);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_ci_char_op(label_s[0],OP_EQ, 's');
|
|
|
|
tt_int_op(sec,OP_EQ, 1);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 10);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_ci_char_op(label_s[0],OP_EQ, 's');
|
|
|
|
tt_int_op(sec,OP_EQ, 10);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 59);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_ci_char_op(label_s[0],OP_EQ, 's');
|
|
|
|
tt_int_op(sec,OP_EQ, 59);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* negative seconds are reported as their absolute value */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -4);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -32);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* minutes: 1:00, 1:01, 1:59, 2:00, 2:01, 59:59 */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore trailing "0 second(s)", if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-10-12 11:50:10 +02:00
|
|
|
|
|
|
|
/* ignore exact spelling of "minute(s)," and "second(s)" */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60 + 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&min, label_m, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*2 - 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&min, label_m, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore trailing "0 second(s)", if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(min,OP_EQ, 2);
|
|
|
|
tt_ci_char_op(label_m[0],OP_EQ, 'm');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "minute(s)," and "second(s)" */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*2 + 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&min, label_m, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*60 - 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&min, label_m, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* negative minutes are reported as their absolute value */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore trailing "0 second(s)", if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -3*60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(min,OP_EQ, 3);
|
|
|
|
tt_ci_char_op(label_m[0],OP_EQ, 'm');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "minute(s)," and "second(s)" */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -96);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&min, label_m, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -2815);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&min, label_m, &sec, label_s);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* hours: 1:00, 1:00:01, 1:01, 23:59, 23:59:59 */
|
|
|
|
/* always ignore trailing seconds, if present */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore trailing "0 minute(s)" etc., if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &hour, label_h);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(hour,OP_EQ, 1);
|
|
|
|
tt_ci_char_op(label_h[0],OP_EQ, 'h');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*60 + 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &hour, label_h);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(hour,OP_EQ, 1);
|
|
|
|
tt_ci_char_op(label_h[0],OP_EQ, 'h');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "hour(s)," etc. */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 60*60 + 60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* negative hours are reported as their absolute value */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "hour(s)," etc., if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -2*60*60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &hour, label_h);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(hour,OP_EQ, 2);
|
|
|
|
tt_ci_char_op(label_h[0],OP_EQ, 'h');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -75804);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* days: 1:00, 1:00:00:01, 1:00:01, 1:01 */
|
|
|
|
/* always ignore trailing seconds, if present */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore trailing "0 hours(s)" etc., if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 24*60*60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &day, label_d);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(day,OP_EQ, 1);
|
|
|
|
tt_ci_char_op(label_d[0],OP_EQ, 'd');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_, &day, label_d);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r,OP_EQ, 2);
|
|
|
|
tt_int_op(day,OP_EQ, 1);
|
|
|
|
tt_ci_char_op(label_d[0],OP_EQ, 'd');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "days(s)," etc. */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
|
|
|
if (r == -1) {
|
|
|
|
/* ignore 0 hours(s), if present */
|
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&day, label_d, &min, label_m);
|
|
|
|
}
|
|
|
|
tt_assert(r == 4 || r == 6);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(day,OP_EQ, 1);
|
|
|
|
tt_ci_char_op(label_d[0],OP_EQ, 'd');
|
2014-10-12 11:50:10 +02:00
|
|
|
if (r == 6) {
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(hour,OP_EQ, 0);
|
|
|
|
tt_ci_char_op(label_h[0],OP_EQ, 'h');
|
2014-10-12 11:50:10 +02:00
|
|
|
}
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(min,OP_EQ, 1);
|
|
|
|
tt_ci_char_op(label_m[0],OP_EQ, 'm');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore trailing "0 minutes(s)" etc., if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60*60);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* negative days are reported as their absolute value */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -21936184);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* periods > 1 year are reported in days (warn?) */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* ignore exact spelling of "days(s)," etc., if present */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 758635154);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* negative periods > 1 year are reported in days (warn?) */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
format_time_interval(dbuf, sizeof(dbuf), -1427014922);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
#if SIZEOF_LONG == 4 || SIZEOF_LONG == 8
|
|
|
|
|
|
|
|
/* We can try INT32_MIN/MAX */
|
|
|
|
/* Always ignore second(s) */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* INT32_MAX */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 2147483647);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-12 11:50:10 +02:00
|
|
|
/* and 7 seconds - ignored */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* 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);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-12 11:50:10 +02:00
|
|
|
/* and 7 or 8 seconds - ignored */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SIZEOF_LONG == 8
|
|
|
|
|
|
|
|
/* We can try INT64_MIN/MAX */
|
|
|
|
/* Always ignore second(s) */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* INT64_MAX */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf), 9223372036854775807L);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-12 11:50:10 +02:00
|
|
|
/* and 7 seconds - ignored */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
/* INT64_MIN: check that we get the absolute value of interval,
|
|
|
|
* which doesn't actually fit in int64_t.
|
|
|
|
* We expect INT64_MAX */
|
|
|
|
format_time_interval(dbuf, sizeof(dbuf),
|
|
|
|
-9223372036854775807L - 1L);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strnlen(dbuf, DBUF_SIZE),OP_LE, DBUF_SIZE - 1);
|
2014-10-12 11:50:10 +02:00
|
|
|
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
|
|
|
|
&day, label_d, &hour, label_h, &min, label_m);
|
2014-11-12 19:28:07 +01:00
|
|
|
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');
|
2014-10-12 11:50:10 +02:00
|
|
|
/* and 7 or 8 seconds - ignored */
|
2014-10-13 19:20:07 +02:00
|
|
|
|
2014-10-12 11:50:10 +02:00
|
|
|
#endif
|
|
|
|
|
2014-10-13 19:20:07 +02:00
|
|
|
done:
|
2014-10-12 11:50:10 +02:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef tt_char_op
|
|
|
|
#undef tt_ci_char_op
|
|
|
|
#undef DBUF_SIZE
|
|
|
|
#undef T_
|
|
|
|
#undef LABEL_SIZE
|
|
|
|
#undef L_
|
|
|
|
#undef TL_
|
|
|
|
|
2012-02-20 22:53:25 +01:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_path_is_relative(void *arg)
|
2012-02-20 22:53:25 +01:00
|
|
|
{
|
|
|
|
/* OS-independent tests */
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2014-11-12 19:28:07 +01:00
|
|
|
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"));
|
2012-02-20 22:53:25 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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/"));
|
2012-02-20 22:53:25 +01:00
|
|
|
|
|
|
|
/* Windows */
|
2012-04-27 00:34:47 +02:00
|
|
|
#ifdef _WIN32
|
2012-02-20 22:53:25 +01:00
|
|
|
/* 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 */
|
2014-11-12 19:28:07 +01:00
|
|
|
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"));
|
2012-02-20 22:53:25 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
/** Run unittests for memory area allocator */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_memarea(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
memarea_t *area = memarea_new();
|
|
|
|
char *p1, *p2, *p3, *p1_orig;
|
|
|
|
void *malloced_ptr = NULL;
|
|
|
|
int i;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(area);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
p1_orig = p1 = memarea_alloc(area,64);
|
|
|
|
p2 = memarea_alloc_zero(area,52);
|
|
|
|
p3 = memarea_alloc(area,11);
|
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(memarea_owns_ptr(area, p1));
|
|
|
|
tt_assert(memarea_owns_ptr(area, p2));
|
|
|
|
tt_assert(memarea_owns_ptr(area, p3));
|
2009-09-22 19:29:55 +02:00
|
|
|
/* Make sure we left enough space. */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(p1+64 <= p2);
|
|
|
|
tt_assert(p2+52 <= p3);
|
2009-09-22 19:29:55 +02:00
|
|
|
/* Make sure we aligned. */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!memarea_owns_ptr(area, p3+8192));
|
|
|
|
tt_assert(!memarea_owns_ptr(area, p3+30));
|
|
|
|
tt_assert(tor_mem_is_zero(p2, 52));
|
2009-09-22 19:29:55 +02:00
|
|
|
/* Make sure we don't overalign. */
|
|
|
|
p1 = memarea_alloc(area, 1);
|
|
|
|
p2 = memarea_alloc(area, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(p1+sizeof(void*),OP_EQ, p2);
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
malloced_ptr = tor_malloc(64);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!memarea_owns_ptr(area, malloced_ptr));
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(malloced_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memarea_memdup */
|
|
|
|
{
|
|
|
|
malloced_ptr = tor_malloc(64);
|
|
|
|
crypto_rand((char*)malloced_ptr, 64);
|
|
|
|
p1 = memarea_memdup(area, malloced_ptr, 64);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(p1 != malloced_ptr);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(p1,OP_EQ, malloced_ptr, 64);
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(malloced_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memarea_strdup. */
|
|
|
|
p1 = memarea_strdup(area,"");
|
|
|
|
p2 = memarea_strdup(area, "abcd");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(p1);
|
|
|
|
tt_assert(p2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(p1,OP_EQ, "");
|
|
|
|
tt_str_op(p2,OP_EQ, "abcd");
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
/* memarea_strndup. */
|
|
|
|
{
|
|
|
|
const char *s = "Ad ogni porta batte la morte e grida: il nome!";
|
|
|
|
/* (From Turandot, act 3.) */
|
|
|
|
size_t len = strlen(s);
|
|
|
|
p1 = memarea_strndup(area, s, 1000);
|
|
|
|
p2 = memarea_strndup(area, s, 10);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(p1,OP_EQ, s);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(p2 >= p1 + len + 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(s,OP_EQ, p2, 10);
|
|
|
|
tt_int_op(p2[10],OP_EQ, '\0');
|
2009-09-22 19:29:55 +02:00
|
|
|
p3 = memarea_strndup(area, s, len);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(p3,OP_EQ, s);
|
2009-09-22 19:29:55 +02:00
|
|
|
p3 = memarea_strndup(area, s, len-1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_mem_op(s,OP_EQ, p3, len-1);
|
|
|
|
tt_int_op(p3[len-1],OP_EQ, '\0');
|
2009-09-22 19:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memarea_clear(area);
|
|
|
|
p1 = memarea_alloc(area, 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(p1,OP_EQ, p1_orig);
|
2009-09-22 19:29:55 +02:00
|
|
|
memarea_clear(area);
|
|
|
|
|
|
|
|
/* Check for running over an area's size. */
|
|
|
|
for (i = 0; i < 512; ++i) {
|
|
|
|
p1 = memarea_alloc(area, crypto_rand_int(5)+1);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(memarea_owns_ptr(area, p1));
|
2009-09-22 19:29:55 +02:00
|
|
|
}
|
|
|
|
memarea_assert_ok(area);
|
|
|
|
/* Make sure we can allocate a too-big object. */
|
|
|
|
p1 = memarea_alloc_zero(area, 9000);
|
|
|
|
p2 = memarea_alloc_zero(area, 16);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(memarea_owns_ptr(area, p1));
|
|
|
|
tt_assert(memarea_owns_ptr(area, p2));
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
memarea_drop_all(area);
|
|
|
|
tor_free(malloced_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Run unit tests for utility functions to get file names relative to
|
|
|
|
* the data directory. */
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_datadir(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
char *f = NULL;
|
|
|
|
char *temp_dir = NULL;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2009-09-22 19:29:55 +02:00
|
|
|
temp_dir = get_datadir_fname(NULL);
|
|
|
|
f = get_datadir_fname("state");
|
|
|
|
tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"state", temp_dir);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(f,OP_EQ, buf);
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(f);
|
|
|
|
f = get_datadir_fname2("cache", "thingy");
|
|
|
|
tor_snprintf(buf, sizeof(buf),
|
|
|
|
"%s"PATH_SEPARATOR"cache"PATH_SEPARATOR"thingy", temp_dir);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(f,OP_EQ, buf);
|
2009-09-22 19:29:55 +02:00
|
|
|
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);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(f,OP_EQ, buf);
|
2009-09-22 19:29:55 +02:00
|
|
|
tor_free(f);
|
|
|
|
f = get_datadir_fname_suffix("cache", ".foo");
|
|
|
|
tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"cache.foo",
|
|
|
|
temp_dir);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(f,OP_EQ, buf);
|
2009-09-22 19:29:55 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(f);
|
|
|
|
tor_free(temp_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_strtok(void *arg)
|
2009-09-22 19:29:55 +02:00
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
char buf2[128];
|
2012-03-30 17:01:21 +02:00
|
|
|
int i;
|
2009-09-22 19:29:55 +02:00
|
|
|
char *cp1, *cp2;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2012-03-30 17:01:21 +02:00
|
|
|
for (i = 0; i < 3; i++) {
|
2012-06-04 17:07:52 +02:00
|
|
|
const char *pad1="", *pad2="";
|
2012-03-30 17:01:21 +02:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pad1 = " ";
|
|
|
|
pad2 = "!";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pad1 = " ";
|
|
|
|
pad2 = ";!";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tor_snprintf(buf, sizeof(buf), "%s", pad1);
|
|
|
|
tor_snprintf(buf2, sizeof(buf2), "%s", pad2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(NULL == tor_strtok_r_impl(buf, " ", &cp1));
|
|
|
|
tt_assert(NULL == tor_strtok_r_impl(buf2, ".!..;!", &cp2));
|
2012-03-30 17:01:21 +02:00
|
|
|
|
|
|
|
tor_snprintf(buf, sizeof(buf),
|
|
|
|
"%sGraved on the dark in gestures of descent%s", pad1, pad1);
|
|
|
|
tor_snprintf(buf2, sizeof(buf2),
|
2012-05-11 19:01:07 +02:00
|
|
|
"%sthey.seemed;;their!.own;most.perfect;monument%s",pad2,pad2);
|
2012-03-30 17:01:21 +02:00
|
|
|
/* -- "Year's End", Richard Wilbur */
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("Graved",OP_EQ, tor_strtok_r_impl(buf, " ", &cp1));
|
|
|
|
tt_str_op("they",OP_EQ, tor_strtok_r_impl(buf2, ".!..;!", &cp2));
|
2009-09-22 19:29:55 +02:00
|
|
|
#define S1() tor_strtok_r_impl(NULL, " ", &cp1)
|
|
|
|
#define S2() tor_strtok_r_impl(NULL, ".!..;!", &cp2)
|
2014-11-12 19:28:07 +01:00
|
|
|
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());
|
2012-03-30 17:01:21 +02:00
|
|
|
}
|
2012-02-08 23:28:21 +01:00
|
|
|
|
|
|
|
buf[0] = 0;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, " ", &cp1));
|
|
|
|
tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, "!", &cp1));
|
2012-02-08 23:28:21 +01:00
|
|
|
|
|
|
|
strlcpy(buf, "Howdy!", sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("Howdy",OP_EQ, tor_strtok_r_impl(buf, "!", &cp1));
|
|
|
|
tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(NULL, "!", &cp1));
|
2012-02-08 23:28:21 +01:00
|
|
|
|
|
|
|
strlcpy(buf, " ", sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, " ", &cp1));
|
2012-02-08 23:28:21 +01:00
|
|
|
strlcpy(buf, " ", sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(buf, " ", &cp1));
|
2012-02-08 23:28:21 +01:00
|
|
|
|
|
|
|
strlcpy(buf, "something ", sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("something",OP_EQ, tor_strtok_r_impl(buf, " ", &cp1));
|
|
|
|
tt_ptr_op(NULL,OP_EQ, tor_strtok_r_impl(NULL, ";", &cp1));
|
2009-09-22 19:29:55 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-12-18 00:29:37 +01:00
|
|
|
static void
|
|
|
|
test_util_find_str_at_start_of_line(void *ptr)
|
|
|
|
{
|
|
|
|
const char *long_string =
|
2012-02-08 23:45:53 +01:00
|
|
|
"howdy world. how are you? i hope it's fine.\n"
|
|
|
|
"hello kitty\n"
|
|
|
|
"third line";
|
|
|
|
char *line2 = strchr(long_string,'\n')+1;
|
|
|
|
char *line3 = strchr(line2,'\n')+1;
|
|
|
|
const char *short_string = "hello kitty\n"
|
2012-02-11 22:33:49 +01:00
|
|
|
"second line\n";
|
2012-02-08 23:45:53 +01:00
|
|
|
char *short_line2 = strchr(short_string,'\n')+1;
|
2009-12-18 00:29:37 +01:00
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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"));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_ptr_op(line2,OP_EQ,
|
|
|
|
find_str_at_start_of_line(long_string, "hello kitty\n"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(line2,OP_EQ,
|
2014-09-16 15:40:38 +02:00
|
|
|
find_str_at_start_of_line(long_string, "hello kitty\nt"));
|
2014-11-12 19:28:07 +01:00
|
|
|
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"));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_ptr_op(NULL, OP_EQ,
|
|
|
|
find_str_at_start_of_line(long_string, "third line\n"));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(short_line2,OP_EQ, find_str_at_start_of_line(short_string,
|
2012-02-11 22:33:49 +01:00
|
|
|
"second line\n"));
|
2009-12-18 00:29:37 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2012-02-20 13:24:22 +01:00
|
|
|
static void
|
|
|
|
test_util_string_is_C_identifier(void *ptr)
|
|
|
|
{
|
|
|
|
(void)ptr;
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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("ñ"));
|
2012-02-20 13:24:22 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2010-02-25 21:58:55 +01:00
|
|
|
static void
|
|
|
|
test_util_asprintf(void *ptr)
|
|
|
|
{
|
|
|
|
#define LOREMIPSUM \
|
|
|
|
"Lorem ipsum dolor sit amet, consectetur adipisicing elit"
|
|
|
|
char *cp=NULL, *cp2=NULL;
|
|
|
|
int r;
|
|
|
|
(void)ptr;
|
|
|
|
|
2012-02-10 00:21:00 +01:00
|
|
|
/* simple string */
|
|
|
|
r = tor_asprintf(&cp, "simple string 100%% safe");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("simple string 100% safe",OP_EQ, cp);
|
|
|
|
tt_int_op(strlen(cp),OP_EQ, r);
|
2014-04-26 06:13:27 +02:00
|
|
|
tor_free(cp);
|
2012-02-10 00:21:00 +01:00
|
|
|
|
|
|
|
/* empty string */
|
2010-02-25 21:58:55 +01:00
|
|
|
r = tor_asprintf(&cp, "%s", "");
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("",OP_EQ, cp);
|
|
|
|
tt_int_op(strlen(cp),OP_EQ, r);
|
2014-04-26 06:13:27 +02:00
|
|
|
tor_free(cp);
|
2012-02-10 00:21:00 +01:00
|
|
|
|
|
|
|
/* numbers (%i) */
|
|
|
|
r = tor_asprintf(&cp, "I like numbers-%2i, %i, etc.", -1, 2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("I like numbers--1, 2, etc.",OP_EQ, cp);
|
|
|
|
tt_int_op(strlen(cp),OP_EQ, r);
|
2014-04-26 06:13:27 +02:00
|
|
|
/* don't free cp; next test uses it. */
|
2010-02-25 21:58:55 +01:00
|
|
|
|
2012-02-10 00:21:00 +01:00
|
|
|
/* numbers (%d) */
|
2010-02-25 21:58:55 +01:00
|
|
|
r = tor_asprintf(&cp2, "First=%d, Second=%d", 101, 202);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strlen(cp2),OP_EQ, r);
|
|
|
|
tt_str_op("First=101, Second=202",OP_EQ, cp2);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp != cp2);
|
2010-02-25 21:58:55 +01:00
|
|
|
tor_free(cp);
|
|
|
|
tor_free(cp2);
|
|
|
|
|
|
|
|
/* Glass-box test: a string exactly 128 characters long. */
|
|
|
|
r = tor_asprintf(&cp, "Lorem1: %sLorem2: %s", LOREMIPSUM, LOREMIPSUM);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2010-02-25 21:58:55 +01:00
|
|
|
tor_free(cp);
|
|
|
|
|
|
|
|
/* String longer than 128 characters */
|
|
|
|
r = tor_asprintf(&cp, "1: %s 2: %s 3: %s",
|
|
|
|
LOREMIPSUM, LOREMIPSUM, LOREMIPSUM);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(cp);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strlen(cp),OP_EQ, r);
|
|
|
|
tt_str_op("1: "LOREMIPSUM" 2: "LOREMIPSUM" 3: "LOREMIPSUM,OP_EQ, cp);
|
2010-02-25 21:58:55 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(cp);
|
|
|
|
tor_free(cp2);
|
|
|
|
}
|
|
|
|
|
2010-08-20 19:24:54 +02:00
|
|
|
static void
|
|
|
|
test_util_listdir(void *ptr)
|
|
|
|
{
|
|
|
|
smartlist_t *dir_contents = NULL;
|
2012-02-10 00:42:08 +01:00
|
|
|
char *fname1=NULL, *fname2=NULL, *fname3=NULL, *dir1=NULL, *dirname=NULL;
|
|
|
|
int r;
|
2010-08-20 19:24:54 +02:00
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
fname1 = tor_strdup(get_fname("hopscotch"));
|
|
|
|
fname2 = tor_strdup(get_fname("mumblety-peg"));
|
2012-02-10 00:42:08 +01:00
|
|
|
fname3 = tor_strdup(get_fname(".hidden-file"));
|
|
|
|
dir1 = tor_strdup(get_fname("some-directory"));
|
2010-08-20 19:24:54 +02:00
|
|
|
dirname = tor_strdup(get_fname(NULL));
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-04-27 00:34:47 +02:00
|
|
|
#ifdef _WIN32
|
2012-02-10 00:42:08 +01:00
|
|
|
r = mkdir(dir1);
|
|
|
|
#else
|
|
|
|
r = mkdir(dir1, 0700);
|
|
|
|
#endif
|
|
|
|
if (r) {
|
|
|
|
fprintf(stderr, "Can't create directory %s:", dir1);
|
|
|
|
perror("");
|
|
|
|
exit(1);
|
|
|
|
}
|
2010-08-20 19:24:54 +02:00
|
|
|
|
|
|
|
dir_contents = tor_listdir(dirname);
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(dir_contents);
|
2010-08-20 19:24:54 +02:00
|
|
|
/* make sure that each filename is listed. */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(smartlist_contains_string_case(dir_contents, "hopscotch"));
|
|
|
|
tt_assert(smartlist_contains_string_case(dir_contents, "mumblety-peg"));
|
|
|
|
tt_assert(smartlist_contains_string_case(dir_contents, ".hidden-file"));
|
|
|
|
tt_assert(smartlist_contains_string_case(dir_contents, "some-directory"));
|
2012-02-10 00:42:08 +01:00
|
|
|
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(!smartlist_contains_string(dir_contents, "."));
|
|
|
|
tt_assert(!smartlist_contains_string(dir_contents, ".."));
|
2010-08-20 19:24:54 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(fname1);
|
|
|
|
tor_free(fname2);
|
2014-04-08 05:20:13 +02:00
|
|
|
tor_free(fname3);
|
|
|
|
tor_free(dir1);
|
2010-08-20 19:24:54 +02:00
|
|
|
tor_free(dirname);
|
|
|
|
if (dir_contents) {
|
|
|
|
SMARTLIST_FOREACH(dir_contents, char *, cp, tor_free(cp));
|
|
|
|
smartlist_free(dir_contents);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-13 21:15:41 +02:00
|
|
|
static void
|
|
|
|
test_util_parent_dir(void *ptr)
|
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
(void)ptr;
|
|
|
|
|
2012-02-10 23:33:37 +01:00
|
|
|
#define T(output,expect_ok,input) \
|
2011-05-13 21:15:41 +02:00
|
|
|
do { \
|
|
|
|
int ok; \
|
|
|
|
cp = tor_strdup(input); \
|
|
|
|
ok = get_parent_directory(cp); \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(expect_ok, OP_EQ, ok); \
|
2011-05-13 21:15:41 +02:00
|
|
|
if (ok==0) \
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(output, OP_EQ, cp); \
|
2011-05-13 21:15:41 +02:00
|
|
|
tor_free(cp); \
|
|
|
|
} while (0);
|
|
|
|
|
2012-02-10 23:33:37 +01:00
|
|
|
T("/home/wombat", 0, "/home/wombat/knish");
|
|
|
|
T("/home/wombat", 0, "/home/wombat/knish/");
|
|
|
|
T("/home/wombat", 0, "/home/wombat/knish///");
|
|
|
|
T("./home/wombat", 0, "./home/wombat/knish/");
|
2012-02-11 22:43:42 +01:00
|
|
|
T("/", 0, "/home");
|
|
|
|
T("/", 0, "/home//");
|
2012-02-10 23:33:37 +01:00
|
|
|
T(".", 0, "./wombat");
|
|
|
|
T(".", 0, "./wombat/");
|
|
|
|
T(".", 0, "./wombat//");
|
|
|
|
T("wombat", 0, "wombat/foo");
|
|
|
|
T("wombat/..", 0, "wombat/../foo");
|
|
|
|
T("wombat/../", 0, "wombat/..//foo"); /* Is this correct? */
|
2012-02-11 22:43:42 +01:00
|
|
|
T("wombat/.", 0, "wombat/./foo");
|
|
|
|
T("wombat/./", 0, "wombat/.//foo"); /* Is this correct? */
|
2012-02-10 23:33:37 +01:00
|
|
|
T("wombat", 0, "wombat/..//");
|
|
|
|
T("wombat", 0, "wombat/foo/");
|
|
|
|
T("wombat", 0, "wombat/.foo");
|
|
|
|
T("wombat", 0, "wombat/.foo/");
|
|
|
|
|
2012-05-31 21:12:45 +02:00
|
|
|
T("wombat", -1, "");
|
|
|
|
T("w", -1, "");
|
2012-05-31 22:21:54 +02:00
|
|
|
T("wombat", 0, "wombat/knish");
|
|
|
|
|
2012-05-24 18:56:31 +02:00
|
|
|
T("/", 0, "/");
|
2012-05-31 22:21:54 +02:00
|
|
|
T("/", 0, "////");
|
2011-05-13 21:15:41 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(cp);
|
|
|
|
}
|
|
|
|
|
2014-07-16 13:58:55 +02:00
|
|
|
static void
|
|
|
|
test_util_ftruncate(void *ptr)
|
|
|
|
{
|
|
|
|
char *buf = NULL;
|
|
|
|
const char *fname;
|
|
|
|
int fd = -1;
|
|
|
|
const char *message = "Hello world";
|
|
|
|
const char *message2 = "Hola mundo";
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
(void) ptr;
|
|
|
|
|
|
|
|
fname = get_fname("ftruncate");
|
|
|
|
|
|
|
|
fd = tor_open_cloexec(fname, O_WRONLY|O_CREAT, 0600);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(fd, OP_GE, 0);
|
2014-07-16 13:58:55 +02:00
|
|
|
|
|
|
|
/* Make the file be there. */
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_int_op(strlen(message), OP_EQ, write_all(fd, message, strlen(message),0));
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2014-07-16 13:58:55 +02:00
|
|
|
|
|
|
|
/* Truncate and see if it got truncated */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-07-16 13:58:55 +02:00
|
|
|
|
|
|
|
/* Replace, and see if it got replaced */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(strlen(message2), OP_EQ,
|
2014-07-16 13:58:55 +02:00
|
|
|
write_all(fd, message2, strlen(message2), 0));
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2014-07-16 13:58:55 +02:00
|
|
|
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
|
|
|
|
buf = read_file_to_str(fname, 0, NULL);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(message2, OP_EQ, buf);
|
2014-07-16 13:58:55 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (fd >= 0)
|
|
|
|
close(fd);
|
|
|
|
tor_free(buf);
|
|
|
|
}
|
|
|
|
|
2012-01-31 16:59:42 +01:00
|
|
|
#ifdef _WIN32
|
2010-09-21 19:07:11 +02:00
|
|
|
static void
|
|
|
|
test_util_load_win_lib(void *ptr)
|
|
|
|
{
|
2012-06-07 17:59:32 +02:00
|
|
|
HANDLE h = load_windows_system_library(_T("advapi32.dll"));
|
2010-12-26 12:13:47 +01:00
|
|
|
(void) ptr;
|
2010-09-21 19:07:11 +02:00
|
|
|
|
|
|
|
tt_assert(h);
|
|
|
|
done:
|
|
|
|
if (h)
|
2012-12-06 16:59:02 +01:00
|
|
|
FreeLibrary(h);
|
2010-09-21 19:07:11 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-15 18:17:23 +02:00
|
|
|
#ifndef _WIN32
|
2010-06-16 20:47:06 +02:00
|
|
|
static void
|
|
|
|
clear_hex_errno(char *hex_errno)
|
|
|
|
{
|
2010-10-04 15:14:11 +02:00
|
|
|
memset(hex_errno, '\0', HEX_ERRNO_SIZE + 1);
|
2010-06-16 20:47:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_util_exit_status(void *ptr)
|
|
|
|
{
|
2010-10-04 15:14:11 +02:00
|
|
|
/* Leave an extra byte for a \0 so we can do string comparison */
|
2010-06-16 20:47:06 +02:00
|
|
|
char hex_errno[HEX_ERRNO_SIZE + 1];
|
2012-06-23 21:30:01 +02:00
|
|
|
int n;
|
2010-06-16 20:47:06 +02:00
|
|
|
|
|
|
|
(void)ptr;
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
clear_hex_errno(hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("",OP_EQ, hex_errno);
|
2010-06-16 20:47:06 +02:00
|
|
|
|
|
|
|
clear_hex_errno(hex_errno);
|
2012-06-23 21:30:01 +02:00
|
|
|
n = format_helper_exit_status(0, 0, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("0/0\n",OP_EQ, hex_errno);
|
|
|
|
tt_int_op(n,OP_EQ, strlen(hex_errno));
|
2010-06-16 20:47:06 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
#if SIZEOF_INT == 4
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2010-06-16 20:47:06 +02:00
|
|
|
clear_hex_errno(hex_errno);
|
2012-06-23 21:30:01 +02:00
|
|
|
n = format_helper_exit_status(0, 0x7FFFFFFF, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("0/7FFFFFFF\n",OP_EQ, hex_errno);
|
|
|
|
tt_int_op(n,OP_EQ, strlen(hex_errno));
|
2010-06-16 20:47:06 +02:00
|
|
|
|
|
|
|
clear_hex_errno(hex_errno);
|
2012-06-23 21:30:01 +02:00
|
|
|
n = format_helper_exit_status(0xFF, -0x80000000, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
#elif SIZEOF_INT == 8
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
clear_hex_errno(hex_errno);
|
|
|
|
n = format_helper_exit_status(0, 0x7FFFFFFFFFFFFFFF, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("0/7FFFFFFFFFFFFFFF\n",OP_EQ, hex_errno);
|
|
|
|
tt_int_op(n,OP_EQ, strlen(hex_errno));
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
clear_hex_errno(hex_errno);
|
|
|
|
n = format_helper_exit_status(0xFF, -0x8000000000000000, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
#endif
|
2010-06-16 20:47:06 +02:00
|
|
|
|
|
|
|
clear_hex_errno(hex_errno);
|
2012-06-23 21:30:01 +02:00
|
|
|
n = format_helper_exit_status(0x7F, 0, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("7F/0\n",OP_EQ, hex_errno);
|
|
|
|
tt_int_op(n,OP_EQ, strlen(hex_errno));
|
2010-06-16 20:47:06 +02:00
|
|
|
|
|
|
|
clear_hex_errno(hex_errno);
|
2012-06-23 21:30:01 +02:00
|
|
|
n = format_helper_exit_status(0x08, -0x242, hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("8/-242\n",OP_EQ, hex_errno);
|
|
|
|
tt_int_op(n,OP_EQ, strlen(hex_errno));
|
2014-09-11 20:37:12 +02:00
|
|
|
|
2014-09-11 06:00:13 +02:00
|
|
|
clear_hex_errno(hex_errno);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op("",OP_EQ, hex_errno);
|
2010-06-16 20:47:06 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
2013-07-15 18:17:23 +02:00
|
|
|
#endif
|
2010-06-16 20:47:06 +02:00
|
|
|
|
2012-01-31 16:59:42 +01:00
|
|
|
#ifndef _WIN32
|
2014-07-16 09:50:09 +02:00
|
|
|
/* Check that fgets with a non-blocking pipe returns partial lines and sets
|
|
|
|
* EAGAIN, returns full lines and sets no error, and returns NULL on EOF and
|
|
|
|
* sets no error */
|
2010-10-08 22:31:15 +02:00
|
|
|
static void
|
|
|
|
test_util_fgets_eagain(void *ptr)
|
|
|
|
{
|
|
|
|
int test_pipe[2] = {-1, -1};
|
|
|
|
int retval;
|
|
|
|
ssize_t retlen;
|
|
|
|
char *retptr;
|
|
|
|
FILE *test_stream = NULL;
|
2014-07-16 09:50:09 +02:00
|
|
|
char buf[4] = { 0 };
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
|
|
|
|
2010-10-08 22:31:15 +02:00
|
|
|
/* Set up a pipe to test on */
|
|
|
|
retval = pipe(test_pipe);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retval, OP_EQ, 0);
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Set up the read-end to be non-blocking */
|
|
|
|
retval = fcntl(test_pipe[0], F_SETFL, O_NONBLOCK);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retval, OP_EQ, 0);
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Open it as a stdio stream */
|
|
|
|
test_stream = fdopen(test_pipe[0], "r");
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(test_stream, OP_NE, NULL);
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Send in a partial line */
|
|
|
|
retlen = write(test_pipe[1], "A", 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retlen, OP_EQ, 1);
|
2010-10-08 22:31:15 +02:00
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, EAGAIN);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, buf);
|
|
|
|
tt_str_op(buf, OP_EQ, "A");
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Send in the rest */
|
|
|
|
retlen = write(test_pipe[1], "B\n", 2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retlen, OP_EQ, 2);
|
2010-10-08 22:31:15 +02:00
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, 0);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, buf);
|
|
|
|
tt_str_op(buf, OP_EQ, "B\n");
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Send in a full line */
|
|
|
|
retlen = write(test_pipe[1], "CD\n", 3);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retlen, OP_EQ, 3);
|
2010-10-08 22:31:15 +02:00
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, 0);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, buf);
|
|
|
|
tt_str_op(buf, OP_EQ, "CD\n");
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Send in a partial line */
|
|
|
|
retlen = write(test_pipe[1], "E", 1);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retlen, OP_EQ, 1);
|
2010-10-08 22:31:15 +02:00
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, EAGAIN);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, buf);
|
|
|
|
tt_str_op(buf, OP_EQ, "E");
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Send in the rest */
|
|
|
|
retlen = write(test_pipe[1], "F\n", 2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retlen, OP_EQ, 2);
|
2010-10-08 22:31:15 +02:00
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, 0);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, buf);
|
|
|
|
tt_str_op(buf, OP_EQ, "F\n");
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Send in a full line and close */
|
|
|
|
retlen = write(test_pipe[1], "GH", 2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retlen, OP_EQ, 2);
|
2010-10-08 22:31:15 +02:00
|
|
|
retval = close(test_pipe[1]);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retval, OP_EQ, 0);
|
2014-07-16 09:50:09 +02:00
|
|
|
test_pipe[1] = -1;
|
2010-10-08 22:31:15 +02:00
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, 0);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, buf);
|
|
|
|
tt_str_op(buf, OP_EQ, "GH");
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
/* Check for EOF */
|
|
|
|
retptr = fgets(buf, sizeof(buf), test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(errno, OP_EQ, 0);
|
|
|
|
tt_ptr_op(retptr, OP_EQ, NULL);
|
2014-07-16 09:50:09 +02:00
|
|
|
retval = feof(test_stream);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(retval, OP_NE, 0);
|
2014-07-16 09:50:09 +02:00
|
|
|
errno = 0;
|
|
|
|
|
|
|
|
/* Check that buf is unchanged according to C99 and C11 */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(buf, OP_EQ, "GH");
|
2010-10-08 22:31:15 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (test_stream != NULL)
|
|
|
|
fclose(test_stream);
|
|
|
|
if (test_pipe[0] != -1)
|
|
|
|
close(test_pipe[0]);
|
|
|
|
if (test_pipe[1] != -1)
|
|
|
|
close(test_pipe[1]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-21 03:38:07 +02:00
|
|
|
/**
|
2013-07-15 18:26:55 +02:00
|
|
|
* Test for format_hex_number_sigsafe()
|
2012-06-21 03:38:07 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_util_format_hex_number(void *ptr)
|
|
|
|
{
|
|
|
|
int i, len;
|
2013-07-15 18:39:47 +02:00
|
|
|
char buf[33];
|
2012-06-21 03:38:07 +02:00
|
|
|
const struct {
|
|
|
|
const char *str;
|
|
|
|
unsigned int x;
|
|
|
|
} test_data[] = {
|
|
|
|
{"0", 0},
|
|
|
|
{"1", 1},
|
|
|
|
{"273A", 0x273a},
|
|
|
|
{"FFFF", 0xffff},
|
2013-07-15 18:52:29 +02:00
|
|
|
{"7FFFFFFF", 0x7fffffff},
|
|
|
|
{"FFFFFFFF", 0xffffffff},
|
2012-06-21 03:38:07 +02:00
|
|
|
#if UINT_MAX >= 0xffffffff
|
|
|
|
{"31BC421D", 0x31bc421d},
|
|
|
|
{"FFFFFFFF", 0xffffffff},
|
|
|
|
#endif
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
for (i = 0; test_data[i].str != NULL; ++i) {
|
2013-07-15 18:52:29 +02:00
|
|
|
len = format_hex_number_sigsafe(test_data[i].x, buf, sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2012-06-21 03:38:07 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2013-07-15 18:52:29 +02:00
|
|
|
|
2012-06-21 03:38:07 +02:00
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-19 19:03:23 +02:00
|
|
|
/**
|
|
|
|
* Test for format_hex_number_sigsafe()
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_util_format_dec_number(void *ptr)
|
|
|
|
{
|
|
|
|
int i, len;
|
|
|
|
char buf[33];
|
|
|
|
const struct {
|
|
|
|
const char *str;
|
|
|
|
unsigned int x;
|
|
|
|
} test_data[] = {
|
|
|
|
{"0", 0},
|
|
|
|
{"1", 1},
|
|
|
|
{"1234", 1234},
|
|
|
|
{"12345678", 12345678},
|
|
|
|
{"99999999", 99999999},
|
|
|
|
{"100000000", 100000000},
|
|
|
|
{"4294967295", 4294967295u},
|
|
|
|
#if UINT_MAX > 0xffffffff
|
|
|
|
{"18446744073709551615", 18446744073709551615u },
|
|
|
|
#endif
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
for (i = 0; test_data[i].str != NULL; ++i) {
|
|
|
|
len = format_dec_number_sigsafe(test_data[i].x, buf, sizeof(buf));
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2013-07-19 19:03:23 +02:00
|
|
|
|
|
|
|
len = format_dec_number_sigsafe(test_data[i].x, buf,
|
|
|
|
(int)(strlen(test_data[i].str) + 1));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(len,OP_EQ, strlen(buf));
|
|
|
|
tt_str_op(buf,OP_EQ, test_data[i].str);
|
2013-07-19 19:03:23 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2013-07-19 19:03:23 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-30 15:55:51 +02:00
|
|
|
/**
|
2013-07-15 18:52:29 +02:00
|
|
|
* Test that we can properly format a Windows command line
|
2011-08-30 15:55:51 +02:00
|
|
|
*/
|
2011-08-29 13:26:55 +02:00
|
|
|
static void
|
2011-08-30 22:00:08 +02:00
|
|
|
test_util_join_win_cmdline(void *ptr)
|
2011-08-29 13:26:55 +02:00
|
|
|
{
|
2011-08-30 22:00:08 +02:00
|
|
|
/* Based on some test cases from "Parsing C++ Command-Line Arguments" in
|
|
|
|
* MSDN but we don't exercise all quoting rules because tor_join_win_cmdline
|
|
|
|
* will try to only generate simple cases for the child process to parse;
|
|
|
|
* i.e. we never embed quoted strings in arguments. */
|
2011-08-29 13:26:55 +02:00
|
|
|
|
|
|
|
const char *argvs[][4] = {
|
|
|
|
{"a", "bb", "CCC", NULL}, // Normal
|
|
|
|
{NULL, NULL, NULL, NULL}, // Empty argument list
|
|
|
|
{"", NULL, NULL, NULL}, // Empty argument
|
|
|
|
{"\"a", "b\"b", "CCC\"", NULL}, // Quotes
|
|
|
|
{"a\tbc", "dd dd", "E", NULL}, // Whitespace
|
|
|
|
{"a\\\\\\b", "de fg", "H", NULL}, // Backslashes
|
|
|
|
{"a\\\"b", "\\c", "D\\", NULL}, // Backslashes before quote
|
|
|
|
{"a\\\\b c", "d", "E", NULL}, // Backslashes not before quote
|
2011-11-12 05:49:02 +01:00
|
|
|
{ NULL } // Terminator
|
2011-08-29 13:26:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const char *cmdlines[] = {
|
|
|
|
"a bb CCC",
|
|
|
|
"",
|
|
|
|
"\"\"",
|
|
|
|
"\\\"a b\\\"b CCC\\\"",
|
|
|
|
"\"a\tbc\" \"dd dd\" E",
|
|
|
|
"a\\\\\\b \"de fg\" H",
|
|
|
|
"a\\\\\\\"b \\c D\\",
|
|
|
|
"\"a\\\\b c\" d E",
|
|
|
|
NULL // Terminator
|
|
|
|
};
|
|
|
|
|
|
|
|
int i;
|
2013-02-15 21:57:15 +01:00
|
|
|
char *joined_argv = NULL;
|
2011-08-29 13:26:55 +02:00
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
for (i=0; cmdlines[i]!=NULL; i++) {
|
|
|
|
log_info(LD_GENERAL, "Joining argvs[%d], expecting <%s>", i, cmdlines[i]);
|
2011-08-30 22:00:08 +02:00
|
|
|
joined_argv = tor_join_win_cmdline(argvs[i]);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(cmdlines[i],OP_EQ, joined_argv);
|
2011-08-29 13:26:55 +02:00
|
|
|
tor_free(joined_argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2013-02-11 20:57:10 +01:00
|
|
|
tor_free(joined_argv);
|
2011-08-29 13:26:55 +02:00
|
|
|
}
|
|
|
|
|
2012-02-11 00:30:11 +01:00
|
|
|
#define MAX_SPLIT_LINE_COUNT 4
|
2011-08-30 15:55:51 +02:00
|
|
|
struct split_lines_test_t {
|
|
|
|
const char *orig_line; // Line to be split (may contain \0's)
|
|
|
|
int orig_length; // Length of orig_line
|
|
|
|
const char *split_line[MAX_SPLIT_LINE_COUNT]; // Split lines
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that we properly split a buffer into lines
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_util_split_lines(void *ptr)
|
|
|
|
{
|
|
|
|
/* Test cases. orig_line of last test case must be NULL.
|
|
|
|
* The last element of split_line[i] must be NULL. */
|
|
|
|
struct split_lines_test_t tests[] = {
|
|
|
|
{"", 0, {NULL}},
|
|
|
|
{"foo", 3, {"foo", NULL}},
|
|
|
|
{"\n\rfoo\n\rbar\r\n", 12, {"foo", "bar", NULL}},
|
|
|
|
{"fo o\r\nb\tar", 10, {"fo o", "b.ar", NULL}},
|
|
|
|
{"\x0f""f\0o\0\n\x01""b\0r\0\r", 12, {".f.o.", ".b.r.", NULL}},
|
2012-02-11 00:30:11 +01:00
|
|
|
{"line 1\r\nline 2", 14, {"line 1", "line 2", NULL}},
|
|
|
|
{"line 1\r\n\r\nline 2", 16, {"line 1", "line 2", NULL}},
|
|
|
|
{"line 1\r\n\r\r\r\nline 2", 18, {"line 1", "line 2", NULL}},
|
|
|
|
{"line 1\r\n\n\n\n\rline 2", 18, {"line 1", "line 2", NULL}},
|
|
|
|
{"line 1\r\n\r\t\r\nline 3", 18, {"line 1", ".", "line 3", NULL}},
|
|
|
|
{"\n\t\r\t\nline 3", 11, {".", ".", "line 3", NULL}},
|
2011-11-12 05:49:02 +01:00
|
|
|
{NULL, 0, { NULL }}
|
2011-08-30 15:55:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
int i, j;
|
2011-12-01 00:08:07 +01:00
|
|
|
char *orig_line=NULL;
|
2011-11-30 18:16:08 +01:00
|
|
|
smartlist_t *sl=NULL;
|
2011-08-30 15:55:51 +02:00
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
for (i=0; tests[i].orig_line; i++) {
|
2012-01-18 21:53:30 +01:00
|
|
|
sl = smartlist_new();
|
2011-09-01 00:40:29 +02:00
|
|
|
/* Allocate space for string and trailing NULL */
|
2011-09-01 04:14:38 +02:00
|
|
|
orig_line = tor_memdup(tests[i].orig_line, tests[i].orig_length + 1);
|
2011-08-30 15:55:51 +02:00
|
|
|
tor_split_lines(sl, orig_line, tests[i].orig_length);
|
|
|
|
|
|
|
|
j = 0;
|
|
|
|
log_info(LD_GENERAL, "Splitting test %d of length %d",
|
|
|
|
i, tests[i].orig_length);
|
2012-07-17 15:33:38 +02:00
|
|
|
SMARTLIST_FOREACH_BEGIN(sl, const char *, line) {
|
2011-08-30 15:55:51 +02:00
|
|
|
/* Check we have not got too many lines */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(MAX_SPLIT_LINE_COUNT, OP_GT, j);
|
2011-08-30 15:55:51 +02:00
|
|
|
/* Check that there actually should be a line here */
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
tt_assert(tests[i].split_line[j] != NULL);
|
2011-08-30 15:55:51 +02:00
|
|
|
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 */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_str_op(line,OP_EQ, tests[i].split_line[j]);
|
2011-08-30 15:55:51 +02:00
|
|
|
j++;
|
2012-07-17 15:33:38 +02:00
|
|
|
} SMARTLIST_FOREACH_END(line);
|
2011-08-30 15:55:51 +02:00
|
|
|
/* Check that we didn't miss some lines */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(NULL,OP_EQ, tests[i].split_line[j]);
|
2011-08-30 15:55:51 +02:00
|
|
|
tor_free(orig_line);
|
|
|
|
smartlist_free(sl);
|
2011-11-30 18:16:08 +01:00
|
|
|
sl = NULL;
|
2011-08-30 15:55:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2011-11-30 18:16:08 +01:00
|
|
|
tor_free(orig_line);
|
|
|
|
smartlist_free(sl);
|
2011-08-30 15:55:51 +02:00
|
|
|
}
|
|
|
|
|
2011-05-11 22:25:51 +02:00
|
|
|
static void
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
test_util_di_ops(void *arg)
|
2011-05-11 22:25:51 +02:00
|
|
|
{
|
|
|
|
#define LT -1
|
|
|
|
#define GT 1
|
|
|
|
#define EQ 0
|
|
|
|
const struct {
|
|
|
|
const char *a; int want_sign; const char *b;
|
|
|
|
} examples[] = {
|
|
|
|
{ "Foo", EQ, "Foo" },
|
|
|
|
{ "foo", GT, "bar", },
|
|
|
|
{ "foobar", EQ ,"foobar" },
|
|
|
|
{ "foobar", LT, "foobaw" },
|
|
|
|
{ "foobar", GT, "f00bar" },
|
|
|
|
{ "foobar", GT, "boobar" },
|
|
|
|
{ "", EQ, "" },
|
|
|
|
{ NULL, 0, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
(void)arg;
|
2011-05-11 22:25:51 +02:00
|
|
|
for (i = 0; examples[i].a; ++i) {
|
|
|
|
size_t len = strlen(examples[i].a);
|
|
|
|
int eq1, eq2, neq1, neq2, cmp1, cmp2;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(len,OP_EQ, strlen(examples[i].b));
|
2011-05-11 22:25:51 +02:00
|
|
|
/* 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);
|
|
|
|
neq1 = tor_memneq(examples[i].a, examples[i].b, len);
|
|
|
|
neq2 = tor_memneq(examples[i].b, examples[i].a, len);
|
|
|
|
cmp1 = tor_memcmp(examples[i].a, examples[i].b, len);
|
|
|
|
cmp2 = tor_memcmp(examples[i].b, examples[i].a, len);
|
|
|
|
|
|
|
|
/* Check for correctness of cmp1 */
|
|
|
|
if (cmp1 < 0 && examples[i].want_sign != LT)
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
TT_DIE(("Assertion failed."));
|
2011-05-11 22:25:51 +02:00
|
|
|
else if (cmp1 > 0 && examples[i].want_sign != GT)
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
TT_DIE(("Assertion failed."));
|
2011-05-11 22:25:51 +02:00
|
|
|
else if (cmp1 == 0 && examples[i].want_sign != EQ)
|
Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions. Some are in macros and will need manual cleanup, though.
This patch is for 13119, and was automatically generated with these
scripts. The perl scripts are there because coccinelle hates
operators as macro arguments.
------------------------------
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
------------------------------
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_fail_msg
+TT_DIE
(
+(
a
+)
)
...>
}
@@
identifier func;
@@
func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
...>
}
@@
expression a;
identifier func;
@@
func (...) {
<...
-test_assert
+tt_assert
(a)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq
+tt_int_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_neq
+tt_int_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_streq
+tt_str_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_strneq
+tt_str_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func (...) {
<...
-test_eq_ptr
+tt_ptr_op
(a,
+_X_EQ_,
b)
...>
}
@@
expression a, b;
identifier func;
@@
func() {
<...
-test_neq_ptr
+tt_ptr_op
(a,
+_X_NEQ_,
b)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memeq
+tt_mem_op
(a,
+_X_EQ_,
b, len)
...>
}
@@
expression a, b, len;
identifier func;
@@
func (...) {
<...
-test_memneq
+tt_mem_op
(a,
+_X_NEQ_,
b, len)
...>
}
------------------------------
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a == b
+a, _X_EQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a != b
+a, _X_NEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a >= b
+a, _X_GEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a <= b
+a, _X_LEQ_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a > b
+a, _X_GT_, b
)
...>
}
@@
char a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_int_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned int a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
@@
unsigned long a, b;
identifier func;
@@
func (...) {
<...
-tt_assert
+tt_uint_op
(
-a < b
+a, _X_LT_, b
)
...>
}
------------------------------
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
s/test_mem_op\(/tt_mem_op\(/g;
2014-09-16 03:18:21 +02:00
|
|
|
TT_DIE(("Assertion failed."));
|
2011-05-11 22:25:51 +02:00
|
|
|
|
|
|
|
/* Check for consistency of everything else with cmp1 */
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2011-05-11 22:25:51 +02:00
|
|
|
}
|
|
|
|
|
2014-09-11 06:10:53 +02:00
|
|
|
{
|
2014-09-15 20:04:19 +02:00
|
|
|
uint8_t zz = 0;
|
|
|
|
uint8_t ii = 0;
|
|
|
|
int z;
|
|
|
|
|
|
|
|
/* exhaustively test tor_memeq and tor_memcmp
|
|
|
|
* against each possible single-byte numeric difference
|
|
|
|
* some arithmetic bugs only appear with certain bit patterns */
|
|
|
|
for (z = 0; z < 256; z++) {
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
ii = (uint8_t)i;
|
|
|
|
zz = (uint8_t)z;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(tor_memeq(&zz, &ii, 1),OP_EQ, zz == ii);
|
2014-11-12 19:42:01 +01:00
|
|
|
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);
|
2014-09-15 20:04:19 +02:00
|
|
|
}
|
2014-09-11 14:28:46 +02:00
|
|
|
}
|
2014-09-11 05:58:02 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2012-12-26 04:22:07 +01:00
|
|
|
|
2011-05-11 22:25:51 +02:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2015-08-17 18:52:01 +02:00
|
|
|
static void
|
|
|
|
test_util_di_map(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
di_digest256_map_t *dimap = NULL;
|
|
|
|
uint8_t key1[] = "Robert Anton Wilson ";
|
|
|
|
uint8_t key2[] = "Martin Gardner, _Fads&fallacies";
|
|
|
|
uint8_t key3[] = "Tom Lehrer, _Be Prepared_. ";
|
|
|
|
uint8_t key4[] = "Ursula Le Guin,_A Wizard of... ";
|
|
|
|
|
|
|
|
char dflt_entry[] = "'You have made a good beginning', but no more";
|
|
|
|
|
|
|
|
tt_int_op(32, ==, sizeof(key1));
|
|
|
|
tt_int_op(32, ==, sizeof(key2));
|
|
|
|
tt_int_op(32, ==, sizeof(key3));
|
|
|
|
|
|
|
|
tt_ptr_op(dflt_entry, ==, dimap_search(dimap, key1, dflt_entry));
|
|
|
|
|
|
|
|
char *str1 = tor_strdup("You are precisely as big as what you love"
|
|
|
|
" and precisely as small as what you allow"
|
|
|
|
" to annoy you.");
|
|
|
|
char *str2 = tor_strdup("Let us hope that Lysenko's success in Russia will"
|
|
|
|
" serve for many generations to come as another"
|
|
|
|
" reminder to the world of how quickly and easily"
|
|
|
|
" a science can be corrupted when ignorant"
|
|
|
|
" political leaders deem themselves competent"
|
|
|
|
" to arbitrate scientific disputes");
|
|
|
|
char *str3 = tor_strdup("Don't write naughty words on walls "
|
|
|
|
"if you can't spell.");
|
|
|
|
|
|
|
|
dimap_add_entry(&dimap, key1, str1);
|
|
|
|
dimap_add_entry(&dimap, key2, str2);
|
|
|
|
dimap_add_entry(&dimap, key3, str3);
|
|
|
|
|
|
|
|
tt_ptr_op(str1, ==, dimap_search(dimap, key1, dflt_entry));
|
|
|
|
tt_ptr_op(str3, ==, dimap_search(dimap, key3, dflt_entry));
|
|
|
|
tt_ptr_op(str2, ==, dimap_search(dimap, key2, dflt_entry));
|
|
|
|
tt_ptr_op(dflt_entry, ==, dimap_search(dimap, key4, dflt_entry));
|
|
|
|
|
|
|
|
done:
|
|
|
|
dimap_free(dimap, tor_free_);
|
|
|
|
}
|
|
|
|
|
2011-10-31 23:47:11 +01:00
|
|
|
/**
|
|
|
|
* Test counting high bits
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_util_n_bits_set(void *ptr)
|
|
|
|
{
|
|
|
|
(void)ptr;
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2011-10-31 23:47:11 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2011-10-31 23:48:29 +01:00
|
|
|
/**
|
|
|
|
* Test LHS whitespace (and comment) eater
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_util_eat_whitespace(void *ptr)
|
|
|
|
{
|
|
|
|
const char ws[] = { ' ', '\t', '\r' }; /* Except NL */
|
|
|
|
char str[80];
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
/* Try one leading ws */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, "fuubaar", sizeof(str));
|
2011-10-31 23:48:29 +01:00
|
|
|
for (i = 0; i < sizeof(ws); ++i) {
|
|
|
|
str[0] = ws[i];
|
2014-11-12 19:28:07 +01:00
|
|
|
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)));
|
2011-10-31 23:48:29 +01:00
|
|
|
}
|
|
|
|
str[0] = '\n';
|
2014-11-12 19:28:07 +01:00
|
|
|
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)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
/* Empty string */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, "", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
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));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
/* Only ws */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, " \t\r\n", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ,
|
|
|
|
eat_whitespace_eos(str, str + strlen(str)));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str) - 1,OP_EQ,
|
2012-02-11 01:27:50 +01:00
|
|
|
eat_whitespace_no_nl(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str) - 1,OP_EQ,
|
2012-02-11 01:27:50 +01:00
|
|
|
eat_whitespace_eos_no_nl(str, str + strlen(str)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, " \t\r ", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ,
|
2012-02-11 01:27:50 +01:00
|
|
|
eat_whitespace_eos(str, str + strlen(str)));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_no_nl(str));
|
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ,
|
2012-02-11 01:27:50 +01:00
|
|
|
eat_whitespace_eos_no_nl(str, str + strlen(str)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
/* Multiple ws */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, "fuubaar", sizeof(str));
|
2011-10-31 23:48:29 +01:00
|
|
|
for (i = 0; i < sizeof(ws); ++i)
|
|
|
|
str[i] = ws[i];
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace(str));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_ptr_op(str + sizeof(ws),OP_EQ,
|
|
|
|
eat_whitespace_eos(str, str + strlen(str)));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace_no_nl(str));
|
|
|
|
tt_ptr_op(str + sizeof(ws),OP_EQ,
|
2012-02-11 01:27:50 +01:00
|
|
|
eat_whitespace_eos_no_nl(str, str + strlen(str)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
/* Eat comment */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, "# Comment \n No Comment", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
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)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
/* Eat comment & ws mix */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, " # \t Comment \n\t\nNo Comment", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
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)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
/* Eat entire comment */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, "#Comment", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ,
|
|
|
|
eat_whitespace_eos(str, str + strlen(str)));
|
2014-11-12 19:28:07 +01:00
|
|
|
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)));
|
2012-02-11 01:27:50 +01:00
|
|
|
|
|
|
|
/* Blank line, then comment */
|
2013-05-11 23:06:22 +02:00
|
|
|
strlcpy(str, " \t\n # Comment", sizeof(str));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
2014-11-12 19:42:01 +01:00
|
|
|
tt_ptr_op(str + strlen(str),OP_EQ,
|
|
|
|
eat_whitespace_eos(str, str + strlen(str)));
|
2014-11-12 19:28:07 +01:00
|
|
|
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)));
|
2011-10-31 23:48:29 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2012-02-16 07:41:49 +01:00
|
|
|
/** Return a newly allocated smartlist containing the lines of text in
|
|
|
|
* <b>lines</b>. The returned strings are heap-allocated, and must be
|
|
|
|
* freed by the caller.
|
|
|
|
*
|
|
|
|
* XXXX? Move to container.[hc] ? */
|
|
|
|
static smartlist_t *
|
|
|
|
smartlist_new_from_text_lines(const char *lines)
|
|
|
|
{
|
|
|
|
smartlist_t *sl = smartlist_new();
|
|
|
|
char *last_line;
|
|
|
|
|
|
|
|
smartlist_split_string(sl, lines, "\n", 0, 0);
|
|
|
|
|
|
|
|
last_line = smartlist_pop_last(sl);
|
|
|
|
if (last_line != NULL && *last_line != '\0') {
|
|
|
|
smartlist_add(sl, last_line);
|
2014-04-26 06:13:49 +02:00
|
|
|
} else {
|
|
|
|
tor_free(last_line);
|
2012-02-16 07:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return sl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Test smartlist_new_from_text_lines */
|
|
|
|
static void
|
|
|
|
test_util_sl_new_from_text_lines(void *ptr)
|
|
|
|
{
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
{ /* Normal usage */
|
|
|
|
smartlist_t *sl = smartlist_new_from_text_lines("foo\nbar\nbaz\n");
|
|
|
|
int sl_len = smartlist_len(sl);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(sl_len, OP_EQ, 3);
|
2012-02-16 07:41:49 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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");
|
2012-02-16 07:41:49 +01:00
|
|
|
|
|
|
|
SMARTLIST_FOREACH(sl, void *, x, tor_free(x));
|
|
|
|
smartlist_free(sl);
|
|
|
|
}
|
|
|
|
|
|
|
|
{ /* No final newline */
|
|
|
|
smartlist_t *sl = smartlist_new_from_text_lines("foo\nbar\nbaz");
|
|
|
|
int sl_len = smartlist_len(sl);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(sl_len, OP_EQ, 3);
|
2012-02-16 07:41:49 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
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");
|
2012-02-16 07:41:49 +01:00
|
|
|
|
|
|
|
SMARTLIST_FOREACH(sl, void *, x, tor_free(x));
|
|
|
|
smartlist_free(sl);
|
|
|
|
}
|
|
|
|
|
|
|
|
{ /* No newlines */
|
|
|
|
smartlist_t *sl = smartlist_new_from_text_lines("foo");
|
|
|
|
int sl_len = smartlist_len(sl);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(sl_len, OP_EQ, 1);
|
2012-02-16 07:41:49 +01:00
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
if (sl_len > 0) tt_want_str_op(smartlist_get(sl, 0), OP_EQ, "foo");
|
2012-02-16 07:41:49 +01:00
|
|
|
|
|
|
|
SMARTLIST_FOREACH(sl, void *, x, tor_free(x));
|
|
|
|
smartlist_free(sl);
|
|
|
|
}
|
|
|
|
|
|
|
|
{ /* No text at all */
|
|
|
|
smartlist_t *sl = smartlist_new_from_text_lines("");
|
|
|
|
int sl_len = smartlist_len(sl);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(sl_len, OP_EQ, 0);
|
2012-02-16 07:41:49 +01:00
|
|
|
|
|
|
|
SMARTLIST_FOREACH(sl, void *, x, tor_free(x));
|
|
|
|
smartlist_free(sl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-26 16:50:37 +02:00
|
|
|
static void
|
|
|
|
test_util_envnames(void *ptr)
|
|
|
|
{
|
|
|
|
(void) ptr;
|
|
|
|
|
|
|
|
tt_assert(environment_variable_names_equal("abc", "abc"));
|
|
|
|
tt_assert(environment_variable_names_equal("abc", "abc="));
|
|
|
|
tt_assert(environment_variable_names_equal("abc", "abc=def"));
|
|
|
|
tt_assert(environment_variable_names_equal("abc=def", "abc"));
|
|
|
|
tt_assert(environment_variable_names_equal("abc=def", "abc=ghi"));
|
|
|
|
|
|
|
|
tt_assert(environment_variable_names_equal("abc", "abc"));
|
|
|
|
tt_assert(environment_variable_names_equal("abc", "abc="));
|
|
|
|
tt_assert(environment_variable_names_equal("abc", "abc=def"));
|
|
|
|
tt_assert(environment_variable_names_equal("abc=def", "abc"));
|
|
|
|
tt_assert(environment_variable_names_equal("abc=def", "abc=ghi"));
|
|
|
|
|
|
|
|
tt_assert(!environment_variable_names_equal("abc", "abcd"));
|
|
|
|
tt_assert(!environment_variable_names_equal("abc=", "abcd"));
|
|
|
|
tt_assert(!environment_variable_names_equal("abc=", "abcd"));
|
|
|
|
tt_assert(!environment_variable_names_equal("abc=", "def"));
|
|
|
|
tt_assert(!environment_variable_names_equal("abc=", "def="));
|
|
|
|
tt_assert(!environment_variable_names_equal("abc=x", "def=x"));
|
|
|
|
|
|
|
|
tt_assert(!environment_variable_names_equal("", "a=def"));
|
|
|
|
/* A bit surprising. */
|
|
|
|
tt_assert(environment_variable_names_equal("", "=def"));
|
|
|
|
tt_assert(environment_variable_names_equal("=y", "=x"));
|
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2012-02-16 07:41:49 +01:00
|
|
|
/** Test process_environment_make */
|
|
|
|
static void
|
|
|
|
test_util_make_environment(void *ptr)
|
|
|
|
{
|
|
|
|
const char *env_vars_string =
|
|
|
|
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin\n"
|
|
|
|
"HOME=/home/foozer\n";
|
|
|
|
const char expected_windows_env_block[] =
|
|
|
|
"HOME=/home/foozer\000"
|
|
|
|
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin\000"
|
|
|
|
"\000";
|
2012-02-20 14:12:50 +01:00
|
|
|
size_t expected_windows_env_block_len =
|
|
|
|
sizeof(expected_windows_env_block) - 1;
|
2012-02-16 07:41:49 +01:00
|
|
|
|
|
|
|
smartlist_t *env_vars = smartlist_new_from_text_lines(env_vars_string);
|
|
|
|
smartlist_t *env_vars_sorted = smartlist_new();
|
|
|
|
smartlist_t *env_vars_in_unixoid_env_block_sorted = smartlist_new();
|
|
|
|
|
|
|
|
process_environment_t *env;
|
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
env = process_environment_make(env_vars);
|
|
|
|
|
|
|
|
/* Check that the Windows environment block is correct. */
|
|
|
|
tt_want(tor_memeq(expected_windows_env_block, env->windows_environment_block,
|
|
|
|
expected_windows_env_block_len));
|
|
|
|
|
|
|
|
/* Now for the Unixoid environment block. We don't care which order
|
|
|
|
* these environment variables are in, so we sort both lists first. */
|
|
|
|
|
|
|
|
smartlist_add_all(env_vars_sorted, env_vars);
|
|
|
|
|
|
|
|
{
|
|
|
|
char **v;
|
|
|
|
for (v = env->unixoid_environment_block; *v; ++v) {
|
|
|
|
smartlist_add(env_vars_in_unixoid_env_block_sorted, *v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
smartlist_sort_strings(env_vars_sorted);
|
|
|
|
smartlist_sort_strings(env_vars_in_unixoid_env_block_sorted);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(smartlist_len(env_vars_sorted), OP_EQ,
|
2012-02-16 07:41:49 +01:00
|
|
|
smartlist_len(env_vars_in_unixoid_env_block_sorted));
|
|
|
|
{
|
|
|
|
int len = smartlist_len(env_vars_sorted);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (smartlist_len(env_vars_in_unixoid_env_block_sorted) < len) {
|
|
|
|
len = smartlist_len(env_vars_in_unixoid_env_block_sorted);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; ++i) {
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_str_op(smartlist_get(env_vars_sorted, i), OP_EQ,
|
2012-02-16 07:41:49 +01:00
|
|
|
smartlist_get(env_vars_in_unixoid_env_block_sorted, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up. */
|
|
|
|
smartlist_free(env_vars_in_unixoid_env_block_sorted);
|
|
|
|
smartlist_free(env_vars_sorted);
|
|
|
|
|
|
|
|
SMARTLIST_FOREACH(env_vars, char *, x, tor_free(x));
|
|
|
|
smartlist_free(env_vars);
|
|
|
|
|
|
|
|
process_environment_free(env);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Test set_environment_variable_in_smartlist */
|
|
|
|
static void
|
|
|
|
test_util_set_env_var_in_sl(void *ptr)
|
|
|
|
{
|
|
|
|
/* The environment variables in these strings are in arbitrary
|
|
|
|
* order; we sort the resulting lists before comparing them.
|
|
|
|
*
|
|
|
|
* (They *will not* end up in the order shown in
|
|
|
|
* expected_resulting_env_vars_string.) */
|
|
|
|
|
|
|
|
const char *base_env_vars_string =
|
|
|
|
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin\n"
|
|
|
|
"HOME=/home/foozer\n"
|
|
|
|
"TERM=xterm\n"
|
|
|
|
"SHELL=/bin/ksh\n"
|
|
|
|
"USER=foozer\n"
|
|
|
|
"LOGNAME=foozer\n"
|
|
|
|
"USERNAME=foozer\n"
|
|
|
|
"LANG=en_US.utf8\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
const char *new_env_vars_string =
|
|
|
|
"TERM=putty\n"
|
|
|
|
"DISPLAY=:18.0\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
const char *expected_resulting_env_vars_string =
|
|
|
|
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin\n"
|
|
|
|
"HOME=/home/foozer\n"
|
|
|
|
"TERM=putty\n"
|
|
|
|
"SHELL=/bin/ksh\n"
|
|
|
|
"USER=foozer\n"
|
|
|
|
"LOGNAME=foozer\n"
|
|
|
|
"USERNAME=foozer\n"
|
|
|
|
"LANG=en_US.utf8\n"
|
|
|
|
"DISPLAY=:18.0\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
smartlist_t *merged_env_vars =
|
|
|
|
smartlist_new_from_text_lines(base_env_vars_string);
|
|
|
|
smartlist_t *new_env_vars =
|
|
|
|
smartlist_new_from_text_lines(new_env_vars_string);
|
|
|
|
smartlist_t *expected_resulting_env_vars =
|
|
|
|
smartlist_new_from_text_lines(expected_resulting_env_vars_string);
|
|
|
|
|
|
|
|
/* Elements of merged_env_vars are heap-allocated, and must be
|
|
|
|
* freed. Some of them are (or should) be freed by
|
|
|
|
* set_environment_variable_in_smartlist.
|
|
|
|
*
|
|
|
|
* Elements of new_env_vars are heap-allocated, but are copied into
|
|
|
|
* merged_env_vars, so they are not freed separately at the end of
|
|
|
|
* the function.
|
|
|
|
*
|
|
|
|
* Elements of expected_resulting_env_vars are heap-allocated, and
|
|
|
|
* must be freed. */
|
|
|
|
|
|
|
|
(void)ptr;
|
|
|
|
|
|
|
|
SMARTLIST_FOREACH(new_env_vars, char *, env_var,
|
|
|
|
set_environment_variable_in_smartlist(merged_env_vars,
|
|
|
|
env_var,
|
2012-10-12 18:22:13 +02:00
|
|
|
tor_free_,
|
2012-02-16 07:41:49 +01:00
|
|
|
1));
|
|
|
|
|
|
|
|
smartlist_sort_strings(merged_env_vars);
|
|
|
|
smartlist_sort_strings(expected_resulting_env_vars);
|
|
|
|
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_int_op(smartlist_len(merged_env_vars), OP_EQ,
|
2012-02-16 07:41:49 +01:00
|
|
|
smartlist_len(expected_resulting_env_vars));
|
|
|
|
{
|
|
|
|
int len = smartlist_len(merged_env_vars);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (smartlist_len(expected_resulting_env_vars) < len) {
|
|
|
|
len = smartlist_len(expected_resulting_env_vars);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; ++i) {
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_want_str_op(smartlist_get(merged_env_vars, i), OP_EQ,
|
2012-02-16 07:41:49 +01:00
|
|
|
smartlist_get(expected_resulting_env_vars, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up. */
|
|
|
|
SMARTLIST_FOREACH(merged_env_vars, char *, x, tor_free(x));
|
|
|
|
smartlist_free(merged_env_vars);
|
|
|
|
|
|
|
|
smartlist_free(new_env_vars);
|
|
|
|
|
|
|
|
SMARTLIST_FOREACH(expected_resulting_env_vars, char *, x, tor_free(x));
|
|
|
|
smartlist_free(expected_resulting_env_vars);
|
|
|
|
}
|
|
|
|
|
2013-02-08 22:46:35 +01:00
|
|
|
static void
|
|
|
|
test_util_weak_random(void *arg)
|
|
|
|
{
|
|
|
|
int i, j, n[16];
|
|
|
|
tor_weak_rng_t rng;
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
tor_init_weak_random(&rng, (unsigned)time(NULL));
|
|
|
|
|
|
|
|
for (i = 1; i <= 256; ++i) {
|
|
|
|
for (j=0;j<100;++j) {
|
|
|
|
int r = tor_weak_random_range(&rng, i);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(0, OP_LE, r);
|
|
|
|
tt_int_op(r, OP_LT, i);
|
2013-02-08 22:46:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(n,0,sizeof(n));
|
|
|
|
for (j=0;j<8192;++j) {
|
|
|
|
n[tor_weak_random_range(&rng, 16)]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0;i<16;++i)
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(n[i], OP_GT, 0);
|
2013-02-08 22:46:35 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2013-02-01 22:09:16 +01:00
|
|
|
static void
|
|
|
|
test_util_mathlog(void *arg)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
d = tor_mathlog(2.718281828);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_double_op(fabs(d - 1.0), OP_LT, .000001);
|
2013-02-01 22:09:16 +01:00
|
|
|
d = tor_mathlog(10);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_double_op(fabs(d - 2.30258509), OP_LT, .000001);
|
2013-02-01 22:09:16 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2013-03-02 16:56:57 +01:00
|
|
|
static void
|
|
|
|
test_util_round_to_next_multiple_of(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
2015-01-15 16:41:25 +01:00
|
|
|
tt_u64_op(round_uint64_to_next_multiple_of(0,1), ==, 0);
|
|
|
|
tt_u64_op(round_uint64_to_next_multiple_of(0,7), ==, 0);
|
2013-03-02 16:56:57 +01:00
|
|
|
|
2015-01-15 16:41:25 +01:00
|
|
|
tt_u64_op(round_uint64_to_next_multiple_of(99,1), ==, 99);
|
|
|
|
tt_u64_op(round_uint64_to_next_multiple_of(99,7), ==, 105);
|
|
|
|
tt_u64_op(round_uint64_to_next_multiple_of(99,9), ==, 99);
|
2013-03-02 16:56:57 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_u64_op(round_uint64_to_next_multiple_of(UINT64_MAX,2), ==,
|
2015-11-12 17:32:14 +01:00
|
|
|
UINT64_MAX);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-01-15 16:41:25 +01:00
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(0,1), ==, 0);
|
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(0,7), ==, 0);
|
2014-12-08 15:00:58 +01:00
|
|
|
|
2015-01-15 16:41:25 +01:00
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(99,1), ==, 99);
|
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(99,7), ==, 105);
|
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(99,9), ==, 99);
|
2014-12-08 15:00:58 +01:00
|
|
|
|
2015-01-15 16:41:25 +01:00
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(-99,1), ==, -99);
|
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(-99,7), ==, -98);
|
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(-99,9), ==, -99);
|
2014-12-08 15:00:58 +01:00
|
|
|
|
2015-01-15 16:41:25 +01:00
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(INT64_MIN,2), ==, INT64_MIN);
|
|
|
|
tt_i64_op(round_int64_to_next_multiple_of(INT64_MAX,2), ==,
|
2015-11-12 17:32:14 +01:00
|
|
|
INT64_MAX);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_int_op(round_uint32_to_next_multiple_of(0,1), ==, 0);
|
|
|
|
tt_int_op(round_uint32_to_next_multiple_of(0,7), ==, 0);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_int_op(round_uint32_to_next_multiple_of(99,1), ==, 99);
|
|
|
|
tt_int_op(round_uint32_to_next_multiple_of(99,7), ==, 105);
|
|
|
|
tt_int_op(round_uint32_to_next_multiple_of(99,9), ==, 99);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_int_op(round_uint32_to_next_multiple_of(UINT32_MAX,2), ==,
|
2015-11-12 17:32:14 +01:00
|
|
|
UINT32_MAX);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_uint_op(round_to_next_multiple_of(0,1), ==, 0);
|
|
|
|
tt_uint_op(round_to_next_multiple_of(0,7), ==, 0);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_uint_op(round_to_next_multiple_of(99,1), ==, 99);
|
|
|
|
tt_uint_op(round_to_next_multiple_of(99,7), ==, 105);
|
|
|
|
tt_uint_op(round_to_next_multiple_of(99,9), ==, 99);
|
2014-12-25 10:52:10 +01:00
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_uint_op(round_to_next_multiple_of(UINT_MAX,2), ==,
|
2015-11-12 17:32:14 +01:00
|
|
|
UINT_MAX);
|
2014-12-08 15:00:58 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_util_laplace(void *arg)
|
|
|
|
{
|
|
|
|
/* Sample values produced using Python's SciPy:
|
|
|
|
*
|
|
|
|
* >>> from scipy.stats import laplace
|
|
|
|
* >>> laplace.ppf([-0.01, 0.0, 0.01, 0.5, 0.51, 0.99, 1.0, 1.01],
|
|
|
|
... loc = 24, scale = 24)
|
|
|
|
* array([ nan, -inf, -69.88855213, 24. ,
|
|
|
|
* 24.48486498, 117.88855213, inf, nan])
|
|
|
|
*/
|
|
|
|
const double mu = 24.0, b = 24.0;
|
|
|
|
const double delta_f = 15.0, epsilon = 0.3; /* b = 15.0 / 0.3 = 50.0 */
|
|
|
|
(void)arg;
|
|
|
|
|
2015-01-15 16:14:33 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==, sample_laplace_distribution(mu, b, 0.0));
|
|
|
|
tt_i64_op(-69, ==, sample_laplace_distribution(mu, b, 0.01));
|
|
|
|
tt_i64_op(24, ==, sample_laplace_distribution(mu, b, 0.5));
|
|
|
|
tt_i64_op(24, ==, sample_laplace_distribution(mu, b, 0.51));
|
|
|
|
tt_i64_op(117, ==, sample_laplace_distribution(mu, b, 0.99));
|
2014-12-08 15:00:58 +01:00
|
|
|
|
|
|
|
/* >>> laplace.ppf([0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99],
|
|
|
|
* ... loc = 0, scale = 50)
|
|
|
|
* array([ -inf, -80.47189562, -34.65735903, 0. ,
|
|
|
|
* 34.65735903, 80.47189562, 195.60115027])
|
|
|
|
*/
|
2015-01-15 16:14:33 +01:00
|
|
|
tt_i64_op(INT64_MIN + 20, ==,
|
2014-12-08 15:00:58 +01:00
|
|
|
add_laplace_noise(20, 0.0, delta_f, epsilon));
|
2014-12-25 10:30:18 +01:00
|
|
|
|
2015-01-15 16:14:33 +01:00
|
|
|
tt_i64_op(-60, ==, add_laplace_noise(20, 0.1, delta_f, epsilon));
|
|
|
|
tt_i64_op(-14, ==, add_laplace_noise(20, 0.25, delta_f, epsilon));
|
|
|
|
tt_i64_op(20, ==, add_laplace_noise(20, 0.5, delta_f, epsilon));
|
|
|
|
tt_i64_op(54, ==, add_laplace_noise(20, 0.75, delta_f, epsilon));
|
|
|
|
tt_i64_op(100, ==, add_laplace_noise(20, 0.9, delta_f, epsilon));
|
|
|
|
tt_i64_op(215, ==, add_laplace_noise(20, 0.99, delta_f, epsilon));
|
2015-01-15 15:42:10 +01:00
|
|
|
|
2014-12-25 10:30:18 +01:00
|
|
|
/* Test extreme values of signal with maximally negative values of noise
|
|
|
|
* 1.0000000000000002 is the smallest number > 1
|
|
|
|
* 0.0000000000000002 is the double epsilon (error when calculating near 1)
|
|
|
|
* this is approximately 1/(2^52)
|
|
|
|
* per https://en.wikipedia.org/wiki/Double_precision
|
|
|
|
* (let's not descend into the world of subnormals)
|
|
|
|
* >>> laplace.ppf([0, 0.0000000000000002], loc = 0, scale = 1)
|
|
|
|
* array([ -inf, -35.45506713])
|
|
|
|
*/
|
|
|
|
const double noscale_df = 1.0, noscale_eps = 1.0;
|
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(0, 0.0, noscale_df, noscale_eps));
|
|
|
|
|
|
|
|
/* is it clipped to INT64_MIN? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(-1, 0.0, noscale_df, noscale_eps));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MIN, 0.0,
|
|
|
|
noscale_df, noscale_eps));
|
|
|
|
/* ... even when scaled? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(0, 0.0, delta_f, epsilon));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(0, 0.0,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MIN, 0.0,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2014-12-25 10:30:18 +01:00
|
|
|
|
|
|
|
/* does it play nice with INT64_MAX? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op((INT64_MIN + INT64_MAX), ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, 0.0,
|
|
|
|
noscale_df, noscale_eps));
|
|
|
|
|
|
|
|
/* do near-zero fractional values work? */
|
|
|
|
const double min_dbl_error = 0.0000000000000002;
|
|
|
|
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(-35, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(0, min_dbl_error,
|
|
|
|
noscale_df, noscale_eps));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MIN, min_dbl_error,
|
|
|
|
noscale_df, noscale_eps));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op((-35 + INT64_MAX), ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, min_dbl_error,
|
|
|
|
noscale_df, noscale_eps));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(0, min_dbl_error,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op((INT64_MAX + INT64_MIN), ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, min_dbl_error,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MIN, min_dbl_error,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2014-12-25 10:30:18 +01:00
|
|
|
|
|
|
|
/* does it play nice with INT64_MAX? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op((INT64_MAX - 35), ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, min_dbl_error,
|
|
|
|
noscale_df, noscale_eps));
|
|
|
|
|
|
|
|
/* Test extreme values of signal with maximally positive values of noise
|
|
|
|
* 1.0000000000000002 is the smallest number > 1
|
|
|
|
* 0.9999999999999998 is the greatest number < 1 by calculation
|
|
|
|
* per https://en.wikipedia.org/wiki/Double_precision
|
|
|
|
* >>> laplace.ppf([1.0, 0.9999999999999998], loc = 0, scale = 1)
|
|
|
|
* array([inf, 35.35050621])
|
|
|
|
* but the function rejects p == 1.0, so we just use max_dbl_lt_one
|
|
|
|
*/
|
|
|
|
const double max_dbl_lt_one = 0.9999999999999998;
|
|
|
|
|
|
|
|
/* do near-one fractional values work? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(35, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(0, max_dbl_lt_one, noscale_df, noscale_eps));
|
|
|
|
|
|
|
|
/* is it clipped to INT64_MAX? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX - 35, max_dbl_lt_one,
|
|
|
|
noscale_df, noscale_eps));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX - 34, max_dbl_lt_one,
|
|
|
|
noscale_df, noscale_eps));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
|
|
|
noscale_df, noscale_eps));
|
|
|
|
/* ... even when scaled? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
|
|
|
delta_f, epsilon));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op((INT64_MIN + INT64_MAX), ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MIN, max_dbl_lt_one,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
2015-02-12 17:36:35 +01:00
|
|
|
DBL_MAX, 1));
|
2014-12-25 10:30:18 +01:00
|
|
|
/* does it play nice with INT64_MIN? */
|
2015-02-13 11:32:35 +01:00
|
|
|
tt_i64_op((INT64_MIN + 35), ==,
|
2014-12-25 10:30:18 +01:00
|
|
|
add_laplace_noise(INT64_MIN, max_dbl_lt_one,
|
|
|
|
noscale_df, noscale_eps));
|
|
|
|
|
2013-03-02 16:56:57 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2015-05-06 10:08:18 +02:00
|
|
|
static void
|
2015-07-09 22:54:17 +02:00
|
|
|
test_util_clamp_double_to_int64(void *arg)
|
2015-05-06 10:08:18 +02:00
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
2015-07-09 22:54:17 +02:00
|
|
|
tt_i64_op(INT64_MIN, ==, clamp_double_to_int64(-INFINITY));
|
2015-05-06 10:08:18 +02:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(-1.0 * pow(2.0, 64.0) - 1.0));
|
2015-05-06 10:08:18 +02:00
|
|
|
tt_i64_op(INT64_MIN, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(-1.0 * pow(2.0, 63.0) - 1.0));
|
2015-03-27 10:37:07 +01:00
|
|
|
tt_i64_op(((uint64_t) -1) << 53, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(-1.0 * pow(2.0, 53.0)));
|
2015-03-27 10:37:07 +01:00
|
|
|
tt_i64_op((((uint64_t) -1) << 53) + 1, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(-1.0 * pow(2.0, 53.0) + 1.0));
|
|
|
|
tt_i64_op(-1, ==, clamp_double_to_int64(-1.0));
|
|
|
|
tt_i64_op(0, ==, clamp_double_to_int64(-0.9));
|
|
|
|
tt_i64_op(0, ==, clamp_double_to_int64(-0.1));
|
|
|
|
tt_i64_op(0, ==, clamp_double_to_int64(0.0));
|
|
|
|
tt_i64_op(0, ==, clamp_double_to_int64(NAN));
|
|
|
|
tt_i64_op(0, ==, clamp_double_to_int64(0.1));
|
|
|
|
tt_i64_op(0, ==, clamp_double_to_int64(0.9));
|
|
|
|
tt_i64_op(1, ==, clamp_double_to_int64(1.0));
|
2015-05-06 10:08:18 +02:00
|
|
|
tt_i64_op((((int64_t) 1) << 53) - 1, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(pow(2.0, 53.0) - 1.0));
|
2015-05-06 10:08:18 +02:00
|
|
|
tt_i64_op(((int64_t) 1) << 53, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(pow(2.0, 53.0)));
|
2015-05-06 10:08:18 +02:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(pow(2.0, 63.0)));
|
2015-05-06 10:08:18 +02:00
|
|
|
tt_i64_op(INT64_MAX, ==,
|
2015-07-09 22:54:17 +02:00
|
|
|
clamp_double_to_int64(pow(2.0, 64.0)));
|
|
|
|
tt_i64_op(INT64_MAX, ==, clamp_double_to_int64(INFINITY));
|
2015-05-06 10:08:18 +02:00
|
|
|
|
2013-03-02 16:56:57 +01:00
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
#define UTIL_LEGACY(name) \
|
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
2014-09-16 15:30:22 +02:00
|
|
|
{ #name, test_util_ ## name , 0, NULL, NULL }
|
2009-09-22 19:29:55 +02:00
|
|
|
|
2009-12-18 00:29:37 +01:00
|
|
|
#define UTIL_TEST(name, flags) \
|
|
|
|
{ #name, test_util_ ## name, flags, NULL, NULL }
|
|
|
|
|
2013-08-02 16:05:17 +02:00
|
|
|
#ifdef FD_CLOEXEC
|
|
|
|
#define CAN_CHECK_CLOEXEC
|
|
|
|
static int
|
|
|
|
fd_is_cloexec(tor_socket_t fd)
|
|
|
|
{
|
|
|
|
int flags = fcntl(fd, F_GETFD, 0);
|
|
|
|
return (flags & FD_CLOEXEC) == FD_CLOEXEC;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#define CAN_CHECK_NONBLOCK
|
|
|
|
static int
|
|
|
|
fd_is_nonblocking(tor_socket_t fd)
|
|
|
|
{
|
|
|
|
int flags = fcntl(fd, F_GETFL, 0);
|
|
|
|
return (flags & O_NONBLOCK) == O_NONBLOCK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 13:25:21 +01:00
|
|
|
/* Test for tor_open_socket*, using IPv4 or IPv6 depending on arg. */
|
2013-08-02 16:05:17 +02:00
|
|
|
static void
|
|
|
|
test_util_socket(void *arg)
|
|
|
|
{
|
2015-11-18 13:25:21 +01:00
|
|
|
const int domain = !strcmp(arg, "4") ? AF_INET : AF_INET6;
|
2013-08-02 16:05:17 +02:00
|
|
|
tor_socket_t fd1 = TOR_INVALID_SOCKET;
|
|
|
|
tor_socket_t fd2 = TOR_INVALID_SOCKET;
|
|
|
|
tor_socket_t fd3 = TOR_INVALID_SOCKET;
|
|
|
|
tor_socket_t fd4 = TOR_INVALID_SOCKET;
|
|
|
|
int n = get_n_open_sockets();
|
|
|
|
|
|
|
|
TT_BLATHER(("Starting with %d open sockets.", n));
|
|
|
|
|
|
|
|
(void)arg;
|
|
|
|
|
2015-11-18 13:25:21 +01:00
|
|
|
fd1 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 0, 0);
|
2015-11-19 09:08:22 +01:00
|
|
|
if (tor_socket_errno(fd1) == SOCK_ERRNO(EPROTONOSUPPORT)) {
|
2015-11-18 13:25:21 +01:00
|
|
|
/* Assume we're on an IPv4-only or IPv6-only system, and give up now. */
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
fd2 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 0, 1);
|
2013-08-02 16:05:17 +02:00
|
|
|
tt_assert(SOCKET_OK(fd1));
|
|
|
|
tt_assert(SOCKET_OK(fd2));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(get_n_open_sockets(), OP_EQ, n + 2);
|
2015-11-18 13:25:21 +01:00
|
|
|
//fd3 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 1, 0);
|
|
|
|
//fd4 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 1, 1);
|
|
|
|
fd3 = tor_open_socket(domain, SOCK_STREAM, 0);
|
|
|
|
fd4 = tor_open_socket_nonblocking(domain, SOCK_STREAM, 0);
|
2013-08-02 16:05:17 +02:00
|
|
|
tt_assert(SOCKET_OK(fd3));
|
|
|
|
tt_assert(SOCKET_OK(fd4));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(get_n_open_sockets(), OP_EQ, n + 4);
|
2013-08-02 16:05:17 +02:00
|
|
|
|
|
|
|
#ifdef CAN_CHECK_CLOEXEC
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2013-08-02 16:05:17 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CAN_CHECK_NONBLOCK
|
2014-11-12 19:28:07 +01:00
|
|
|
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);
|
2013-08-02 16:05:17 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
tor_close_socket(fd1);
|
|
|
|
tor_close_socket(fd2);
|
|
|
|
fd1 = fd2 = TOR_INVALID_SOCKET;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(get_n_open_sockets(), OP_EQ, n + 2);
|
2013-08-02 16:05:17 +02:00
|
|
|
tor_close_socket(fd3);
|
|
|
|
tor_close_socket(fd4);
|
|
|
|
fd3 = fd4 = TOR_INVALID_SOCKET;
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(get_n_open_sockets(), OP_EQ, n);
|
2013-08-02 16:05:17 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (SOCKET_OK(fd1))
|
|
|
|
tor_close_socket(fd1);
|
|
|
|
if (SOCKET_OK(fd2))
|
|
|
|
tor_close_socket(fd2);
|
|
|
|
if (SOCKET_OK(fd3))
|
|
|
|
tor_close_socket(fd3);
|
|
|
|
if (SOCKET_OK(fd4))
|
|
|
|
tor_close_socket(fd4);
|
|
|
|
}
|
|
|
|
|
2013-08-02 16:36:36 +02:00
|
|
|
/* Test for socketpair and ersatz_socketpair(). We test them both, since
|
|
|
|
* the latter is a tolerably good way to exersize tor_accept_socket(). */
|
|
|
|
static void
|
|
|
|
test_util_socketpair(void *arg)
|
|
|
|
{
|
|
|
|
const int ersatz = !strcmp(arg, "1");
|
|
|
|
int (*const tor_socketpair_fn)(int, int, int, tor_socket_t[2]) =
|
|
|
|
ersatz ? tor_ersatz_socketpair : tor_socketpair;
|
|
|
|
int n = get_n_open_sockets();
|
|
|
|
tor_socket_t fds[2] = {TOR_INVALID_SOCKET, TOR_INVALID_SOCKET};
|
|
|
|
const int family = AF_UNIX;
|
2015-11-18 13:25:21 +01:00
|
|
|
int socketpair_result = 0;
|
2013-08-02 16:36:36 +02:00
|
|
|
|
2015-11-18 13:25:21 +01:00
|
|
|
socketpair_result = tor_socketpair_fn(family, SOCK_STREAM, 0, fds);
|
2015-11-19 09:08:22 +01:00
|
|
|
/* If there is no 127.0.0.1 or ::1, tor_ersatz_socketpair will and must fail.
|
|
|
|
* Otherwise, we risk exposing a socketpair on a routable IP address. (Some
|
|
|
|
* BSD jails use a routable address for localhost. Fortunately, they have
|
|
|
|
* the real AF_UNIX socketpair.) */
|
2015-11-18 13:25:21 +01:00
|
|
|
tt_int_op(0, OP_EQ, socketpair_result);
|
2013-08-02 16:36:36 +02:00
|
|
|
tt_assert(SOCKET_OK(fds[0]));
|
|
|
|
tt_assert(SOCKET_OK(fds[1]));
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(get_n_open_sockets(), OP_EQ, n + 2);
|
2013-08-02 16:36:36 +02:00
|
|
|
#ifdef CAN_CHECK_CLOEXEC
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(fd_is_cloexec(fds[0]), OP_EQ, 1);
|
|
|
|
tt_int_op(fd_is_cloexec(fds[1]), OP_EQ, 1);
|
2013-08-02 16:36:36 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CAN_CHECK_NONBLOCK
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(fd_is_nonblocking(fds[0]), OP_EQ, 0);
|
|
|
|
tt_int_op(fd_is_nonblocking(fds[1]), OP_EQ, 0);
|
2013-08-02 16:36:36 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (SOCKET_OK(fds[0]))
|
|
|
|
tor_close_socket(fds[0]);
|
|
|
|
if (SOCKET_OK(fds[1]))
|
|
|
|
tor_close_socket(fds[1]);
|
|
|
|
}
|
|
|
|
|
2014-04-03 17:46:01 +02:00
|
|
|
static void
|
|
|
|
test_util_max_mem(void *arg)
|
|
|
|
{
|
|
|
|
size_t memory1, memory2;
|
|
|
|
int r, r2;
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
r = get_total_system_memory(&memory1);
|
|
|
|
r2 = get_total_system_memory(&memory2);
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_int_op(r, OP_EQ, r2);
|
|
|
|
tt_uint_op(memory2, OP_EQ, memory1);
|
2014-04-03 17:46:01 +02:00
|
|
|
|
|
|
|
TT_BLATHER(("System memory: "U64_FORMAT, U64_PRINTF_ARG(memory1)));
|
|
|
|
|
|
|
|
if (r==0) {
|
|
|
|
/* You have at least a megabyte. */
|
2014-11-12 19:28:07 +01:00
|
|
|
tt_uint_op(memory1, OP_GT, (1<<20));
|
2014-04-03 17:46:01 +02:00
|
|
|
} else {
|
|
|
|
/* You do not have a petabyte. */
|
|
|
|
#if SIZEOF_SIZE_T == SIZEOF_UINT64_T
|
2015-01-08 16:44:30 +01:00
|
|
|
tt_u64_op(memory1, OP_LT, (U64_LITERAL(1)<<50));
|
2014-04-03 17:46:01 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2014-10-12 18:33:08 +02:00
|
|
|
static void
|
|
|
|
test_util_hostname_validation(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
// Lets try valid hostnames first.
|
|
|
|
tt_assert(string_is_valid_hostname("torproject.org"));
|
|
|
|
tt_assert(string_is_valid_hostname("ocw.mit.edu"));
|
|
|
|
tt_assert(string_is_valid_hostname("i.4cdn.org"));
|
|
|
|
tt_assert(string_is_valid_hostname("stanford.edu"));
|
|
|
|
tt_assert(string_is_valid_hostname("multiple-words-with-hypens.jp"));
|
|
|
|
|
2015-06-24 15:52:29 +02:00
|
|
|
// Subdomain name cannot start with '-' or '_'.
|
2014-10-12 18:33:08 +02:00
|
|
|
tt_assert(!string_is_valid_hostname("-torproject.org"));
|
|
|
|
tt_assert(!string_is_valid_hostname("subdomain.-domain.org"));
|
|
|
|
tt_assert(!string_is_valid_hostname("-subdomain.domain.org"));
|
2015-06-24 15:52:29 +02:00
|
|
|
tt_assert(!string_is_valid_hostname("___abc.org"));
|
2014-10-12 19:39:00 +02:00
|
|
|
|
2014-10-12 18:33:08 +02:00
|
|
|
// Hostnames cannot contain non-alphanumeric characters.
|
2014-10-12 19:39:00 +02:00
|
|
|
tt_assert(!string_is_valid_hostname("%%domain.\\org."));
|
2014-10-12 18:33:08 +02:00
|
|
|
tt_assert(!string_is_valid_hostname("***x.net"));
|
|
|
|
tt_assert(!string_is_valid_hostname("\xff\xffxyz.org"));
|
|
|
|
tt_assert(!string_is_valid_hostname("word1 word2.net"));
|
|
|
|
|
2015-06-24 15:52:29 +02:00
|
|
|
// Test workaround for nytimes.com stupidity, technically invalid,
|
|
|
|
// but we allow it since they are big, even though they are failing to
|
|
|
|
// comply with a ~30 year old standard.
|
|
|
|
tt_assert(string_is_valid_hostname("core3_euw1.fabrik.nytimes.com"));
|
|
|
|
|
2015-07-27 14:58:40 +02:00
|
|
|
// Firefox passes FQDNs with trailing '.'s directly to the SOCKS proxy,
|
|
|
|
// which is redundant since the spec states DOMAINNAME addresses are fully
|
|
|
|
// qualified. While unusual, this should be tollerated.
|
|
|
|
tt_assert(string_is_valid_hostname("core9_euw1.fabrik.nytimes.com."));
|
|
|
|
tt_assert(!string_is_valid_hostname("..washingtonpost.is.better.com"));
|
|
|
|
tt_assert(!string_is_valid_hostname("so.is..ft.com"));
|
|
|
|
tt_assert(!string_is_valid_hostname("..."));
|
|
|
|
|
2014-10-12 18:33:08 +02:00
|
|
|
// XXX: do we allow single-label DNS names?
|
2015-07-27 14:58:40 +02:00
|
|
|
// We shouldn't for SOCKS (spec says "contains a fully-qualified domain name"
|
|
|
|
// but only test pathologically malformed traling '.' cases for now.
|
|
|
|
tt_assert(!string_is_valid_hostname("."));
|
|
|
|
tt_assert(!string_is_valid_hostname(".."));
|
2014-10-12 18:33:08 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-12 19:39:00 +02:00
|
|
|
static void
|
|
|
|
test_util_ipv4_validation(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
tt_assert(string_is_valid_ipv4_address("192.168.0.1"));
|
|
|
|
tt_assert(string_is_valid_ipv4_address("8.8.8.8"));
|
|
|
|
|
|
|
|
tt_assert(!string_is_valid_ipv4_address("abcd"));
|
|
|
|
tt_assert(!string_is_valid_ipv4_address("300.300.300.300"));
|
|
|
|
tt_assert(!string_is_valid_ipv4_address("8.8."));
|
|
|
|
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-18 20:03:49 +02:00
|
|
|
static void
|
|
|
|
test_util_writepid(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
|
|
|
|
char *contents = NULL;
|
|
|
|
const char *fname = get_fname("tmp_pid");
|
|
|
|
unsigned long pid;
|
|
|
|
char c;
|
|
|
|
|
|
|
|
write_pidfile(fname);
|
|
|
|
|
|
|
|
contents = read_file_to_str(fname, 0, NULL);
|
|
|
|
tt_assert(contents);
|
|
|
|
|
|
|
|
int n = sscanf(contents, "%lu\n%c", &pid, &c);
|
|
|
|
tt_int_op(n, OP_EQ, 1);
|
2015-06-02 19:52:31 +02:00
|
|
|
|
2014-09-18 20:03:49 +02:00
|
|
|
#ifdef _WIN32
|
2015-06-02 19:52:31 +02:00
|
|
|
tt_uint_op(pid, OP_EQ, _getpid());
|
2014-09-18 20:03:49 +02:00
|
|
|
#else
|
2015-06-02 19:52:31 +02:00
|
|
|
tt_uint_op(pid, OP_EQ, getpid());
|
2014-09-18 20:03:49 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
|
|
|
tor_free(contents);
|
|
|
|
}
|
|
|
|
|
2015-08-05 20:01:49 +02:00
|
|
|
static void
|
|
|
|
test_util_get_avail_disk_space(void *arg)
|
|
|
|
{
|
|
|
|
(void) arg;
|
|
|
|
int64_t val;
|
|
|
|
|
|
|
|
/* No answer for nonexistent directory */
|
|
|
|
val = tor_get_avail_disk_space("/akljasdfklsajdklasjkldjsa");
|
2015-08-11 15:07:27 +02:00
|
|
|
tt_i64_op(val, OP_EQ, -1);
|
2015-08-05 20:01:49 +02:00
|
|
|
|
|
|
|
/* Try the current directory */
|
|
|
|
val = tor_get_avail_disk_space(".");
|
|
|
|
|
|
|
|
#if !defined(HAVE_STATVFS) && !defined(_WIN32)
|
|
|
|
tt_i64_op(val, OP_EQ, -1); /* You don't have an implementation for this */
|
|
|
|
#else
|
|
|
|
tt_i64_op(val, OP_GT, 0); /* You have some space. */
|
|
|
|
tt_i64_op(val, OP_LT, ((int64_t)1)<<56); /* You don't have a zebibyte */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2009-09-22 19:29:55 +02:00
|
|
|
struct testcase_t util_tests[] = {
|
2009-09-22 19:39:27 +02:00
|
|
|
UTIL_LEGACY(time),
|
2012-02-20 17:40:37 +01:00
|
|
|
UTIL_TEST(parse_http_time, 0),
|
2009-09-22 19:39:27 +02:00
|
|
|
UTIL_LEGACY(config_line),
|
2012-02-03 00:12:23 +01:00
|
|
|
UTIL_LEGACY(config_line_quotes),
|
2012-02-03 23:43:29 +01:00
|
|
|
UTIL_LEGACY(config_line_comment_character),
|
2012-02-03 20:52:34 +01:00
|
|
|
UTIL_LEGACY(config_line_escaped_content),
|
2012-04-27 00:34:47 +02:00
|
|
|
#ifndef _WIN32
|
2012-02-20 17:42:48 +01:00
|
|
|
UTIL_LEGACY(expand_filename),
|
2012-04-27 00:34:47 +02:00
|
|
|
#endif
|
2012-12-17 13:14:09 +01:00
|
|
|
UTIL_LEGACY(escape_string_socks),
|
|
|
|
UTIL_LEGACY(string_is_key_value),
|
2009-09-22 19:39:27 +02:00
|
|
|
UTIL_LEGACY(strmisc),
|
|
|
|
UTIL_LEGACY(pow2),
|
2009-09-22 19:29:55 +02:00
|
|
|
UTIL_LEGACY(gzip),
|
|
|
|
UTIL_LEGACY(datadir),
|
|
|
|
UTIL_LEGACY(memarea),
|
|
|
|
UTIL_LEGACY(control_formats),
|
|
|
|
UTIL_LEGACY(mmap),
|
|
|
|
UTIL_LEGACY(sscanf),
|
2014-10-12 11:50:10 +02:00
|
|
|
UTIL_LEGACY(format_time_interval),
|
2012-02-20 22:53:25 +01:00
|
|
|
UTIL_LEGACY(path_is_relative),
|
2009-09-22 19:29:55 +02:00
|
|
|
UTIL_LEGACY(strtok),
|
2011-05-11 22:25:51 +02:00
|
|
|
UTIL_LEGACY(di_ops),
|
2015-08-17 18:52:01 +02:00
|
|
|
UTIL_TEST(di_map, 0),
|
2013-03-02 16:56:57 +01:00
|
|
|
UTIL_TEST(round_to_next_multiple_of, 0),
|
2014-12-08 15:00:58 +01:00
|
|
|
UTIL_TEST(laplace, 0),
|
2015-07-09 22:54:17 +02:00
|
|
|
UTIL_TEST(clamp_double_to_int64, 0),
|
2009-12-18 00:29:37 +01:00
|
|
|
UTIL_TEST(find_str_at_start_of_line, 0),
|
2012-02-20 13:24:22 +01:00
|
|
|
UTIL_TEST(string_is_C_identifier, 0),
|
2010-02-25 21:58:55 +01:00
|
|
|
UTIL_TEST(asprintf, 0),
|
2010-08-20 19:24:54 +02:00
|
|
|
UTIL_TEST(listdir, 0),
|
2011-05-13 21:15:41 +02:00
|
|
|
UTIL_TEST(parent_dir, 0),
|
2014-07-16 13:58:55 +02:00
|
|
|
UTIL_TEST(ftruncate, 0),
|
2012-01-31 16:59:42 +01:00
|
|
|
#ifdef _WIN32
|
2010-09-21 19:07:11 +02:00
|
|
|
UTIL_TEST(load_win_lib, 0),
|
|
|
|
#endif
|
2012-01-31 16:59:42 +01:00
|
|
|
#ifndef _WIN32
|
2013-07-15 18:17:23 +02:00
|
|
|
UTIL_TEST(exit_status, 0),
|
2014-07-16 09:50:09 +02:00
|
|
|
UTIL_TEST(fgets_eagain, 0),
|
2011-07-21 17:34:48 +02:00
|
|
|
#endif
|
2012-06-21 03:38:07 +02:00
|
|
|
UTIL_TEST(format_hex_number, 0),
|
2013-07-19 19:03:23 +02:00
|
|
|
UTIL_TEST(format_dec_number, 0),
|
2011-08-30 22:00:08 +02:00
|
|
|
UTIL_TEST(join_win_cmdline, 0),
|
2011-08-30 15:55:51 +02:00
|
|
|
UTIL_TEST(split_lines, 0),
|
2011-10-31 23:47:11 +01:00
|
|
|
UTIL_TEST(n_bits_set, 0),
|
2011-10-31 23:48:29 +01:00
|
|
|
UTIL_TEST(eat_whitespace, 0),
|
2012-02-16 07:41:49 +01:00
|
|
|
UTIL_TEST(sl_new_from_text_lines, 0),
|
2012-06-26 16:50:37 +02:00
|
|
|
UTIL_TEST(envnames, 0),
|
2012-02-16 07:41:49 +01:00
|
|
|
UTIL_TEST(make_environment, 0),
|
|
|
|
UTIL_TEST(set_env_var_in_sl, 0),
|
2012-09-14 18:23:31 +02:00
|
|
|
UTIL_TEST(read_file_eof_tiny_limit, 0),
|
2014-09-02 19:29:11 +02:00
|
|
|
UTIL_TEST(read_file_eof_one_loop_a, 0),
|
|
|
|
UTIL_TEST(read_file_eof_one_loop_b, 0),
|
2012-09-14 18:23:31 +02:00
|
|
|
UTIL_TEST(read_file_eof_two_loops, 0),
|
2014-09-02 19:29:11 +02:00
|
|
|
UTIL_TEST(read_file_eof_two_loops_b, 0),
|
2012-09-14 18:23:31 +02:00
|
|
|
UTIL_TEST(read_file_eof_zero_bytes, 0),
|
2013-09-05 00:25:41 +02:00
|
|
|
UTIL_TEST(write_chunks_to_file, 0),
|
2013-02-01 22:09:16 +01:00
|
|
|
UTIL_TEST(mathlog, 0),
|
2013-02-08 22:46:35 +01:00
|
|
|
UTIL_TEST(weak_random, 0),
|
2015-11-18 13:25:21 +01:00
|
|
|
{ "socket_ipv4", test_util_socket, TT_FORK, &passthrough_setup,
|
|
|
|
(void*)"4" },
|
|
|
|
{ "socket_ipv6", test_util_socket, TT_FORK,
|
|
|
|
&passthrough_setup, (void*)"6" },
|
2013-09-28 05:15:53 +02:00
|
|
|
{ "socketpair", test_util_socketpair, TT_FORK, &passthrough_setup,
|
2013-08-02 16:36:36 +02:00
|
|
|
(void*)"0" },
|
|
|
|
{ "socketpair_ersatz", test_util_socketpair, TT_FORK,
|
2013-09-28 05:15:53 +02:00
|
|
|
&passthrough_setup, (void*)"1" },
|
2014-04-03 17:46:01 +02:00
|
|
|
UTIL_TEST(max_mem, 0),
|
2014-10-12 18:33:08 +02:00
|
|
|
UTIL_TEST(hostname_validation, 0),
|
2014-10-12 19:39:00 +02:00
|
|
|
UTIL_TEST(ipv4_validation, 0),
|
2014-09-18 20:03:49 +02:00
|
|
|
UTIL_TEST(writepid, 0),
|
2015-08-05 20:01:49 +02:00
|
|
|
UTIL_TEST(get_avail_disk_space, 0),
|
2009-09-22 19:29:55 +02:00
|
|
|
END_OF_TESTCASES
|
|
|
|
};
|
2014-09-11 20:40:19 +02:00
|
|
|
|