mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-26 23:52:30 +01:00
Fixes bug 4893. These changes are pure mechanical, and were generated with this perl script: /usr/bin/perl -w -i.bak -p s/crypto_pk_env_t/crypto_pk_t/g; s/crypto_dh_env_t/crypto_dh_t/g; s/crypto_cipher_env_t/crypto_cipher_t/g; s/crypto_digest_env_t/crypto_digest_t/g; s/aes_free_cipher/aes_cipher_free/g; s/crypto_free_cipher_env/crypto_cipher_free/g; s/crypto_free_digest_env/crypto_digest_free/g; s/crypto_free_pk_env/crypto_pk_free/g; s/_crypto_dh_env_get_dh/_crypto_dh_get_dh/g; s/_crypto_new_pk_env_rsa/_crypto_new_pk_from_rsa/g; s/_crypto_pk_env_get_evp_pkey/_crypto_pk_get_evp_pkey/g; s/_crypto_pk_env_get_rsa/_crypto_pk_get_rsa/g; s/crypto_new_cipher_env/crypto_cipher_new/g; s/crypto_new_digest_env/crypto_digest_new/g; s/crypto_new_digest256_env/crypto_digest256_new/g; s/crypto_new_pk_env/crypto_pk_new/g; s/crypto_create_crypto_env/crypto_cipher_new/g; s/connection_create_listener/connection_listener_new/g; s/smartlist_create/smartlist_new/g; s/transport_create/transport_new/g;
76 lines
3.1 KiB
C
76 lines
3.1 KiB
C
/* Copyright (c) 2001-2003, Roger Dingledine.
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
|
* Copyright (c) 2007-2011, The Tor Project, Inc. */
|
|
/* See LICENSE for licensing information */
|
|
|
|
#ifndef _TOR_TEST_H
|
|
#define _TOR_TEST_H
|
|
|
|
/**
|
|
* \file test.h
|
|
* \brief Macros and functions used by unit tests.
|
|
*/
|
|
|
|
#include "compat.h"
|
|
#include "tinytest.h"
|
|
#define TT_EXIT_TEST_FUNCTION STMT_BEGIN goto done; STMT_END
|
|
#include "tinytest_macros.h"
|
|
|
|
#ifdef __GNUC__
|
|
#define PRETTY_FUNCTION __PRETTY_FUNCTION__
|
|
#else
|
|
#define PRETTY_FUNCTION ""
|
|
#endif
|
|
|
|
#define test_fail_msg(msg) TT_DIE((msg))
|
|
|
|
#define test_fail() test_fail_msg("Assertion failed.")
|
|
|
|
#define test_assert(expr) tt_assert(expr)
|
|
|
|
#define test_eq(expr1, expr2) tt_int_op((expr1), ==, (expr2))
|
|
#define test_eq_ptr(expr1, expr2) tt_ptr_op((expr1), ==, (expr2))
|
|
#define test_neq(expr1, expr2) tt_int_op((expr1), !=, (expr2))
|
|
#define test_neq_ptr(expr1, expr2) tt_ptr_op((expr1), !=, (expr2))
|
|
#define test_streq(expr1, expr2) tt_str_op((expr1), ==, (expr2))
|
|
#define test_strneq(expr1, expr2) tt_str_op((expr1), !=, (expr2))
|
|
#define test_streq(expr1, expr2) tt_str_op((expr1), ==, (expr2))
|
|
|
|
#define test_mem_op(expr1, op, expr2, len) \
|
|
tt_assert_test_fmt_type(expr1,expr2,#expr1" "#op" "#expr2, \
|
|
const char *, \
|
|
(memcmp(_val1, _val2, len) op 0), \
|
|
char *, "%s", \
|
|
{ size_t printlen = (len)*2+1; \
|
|
_print = tor_malloc(printlen); \
|
|
base16_encode(_print, printlen, _value, \
|
|
(len)); }, \
|
|
{ tor_free(_print); }, \
|
|
TT_EXIT_TEST_FUNCTION \
|
|
);
|
|
|
|
#define test_memeq(expr1, expr2, len) test_mem_op((expr1), ==, (expr2), len)
|
|
#define test_memneq(expr1, expr2, len) test_mem_op((expr1), !=, (expr2), len)
|
|
|
|
/* As test_mem_op, but decodes 'hex' before comparing. There must be a
|
|
* local char* variable called mem_op_hex_tmp for this to work. */
|
|
#define test_mem_op_hex(expr1, op, hex) \
|
|
STMT_BEGIN \
|
|
size_t length = strlen(hex); \
|
|
tor_free(mem_op_hex_tmp); \
|
|
mem_op_hex_tmp = tor_malloc(length/2); \
|
|
tor_assert((length&1)==0); \
|
|
base16_decode(mem_op_hex_tmp, length/2, hex, length); \
|
|
test_mem_op(expr1, op, mem_op_hex_tmp, length/2); \
|
|
STMT_END
|
|
|
|
#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, ==, hex)
|
|
|
|
const char *get_fname(const char *name);
|
|
crypto_pk_t *pk_generate(int idx);
|
|
|
|
void legacy_test_helper(void *data);
|
|
extern const struct testcase_setup_t legacy_setup;
|
|
|
|
#endif
|
|
|