aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_accounting.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-01-09 10:26:10 -0500
committerNick Mathewson <nickm@torproject.org>2020-01-09 11:09:22 -0500
commit23c77f79fd6e05b4eba83c5e1fced571bb2a362a (patch)
tree5a9495e4d55039a4000ce62a712e3b19274fefa6 /src/test/test_accounting.c
parentc9855f23c161d305433ff86c5fb68988777df5a8 (diff)
downloadtor-23c77f79fd6e05b4eba83c5e1fced571bb2a362a.tar.gz
tor-23c77f79fd6e05b4eba83c5e1fced571bb2a362a.zip
Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following kludgey perl script. It results in a number of wide lines, which I'll clean up in a subsequent commit. #/usr/bin/perl -w -i $mod = "NS_MODULE"; $submod = "NS_SUBMODULE"; $last_was_empty = 0; while (<>) { s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/; if (/# *define +NS_MODULE +(\w+)/) { $mod = $1; next; } elsif (/# *define +NS_SUBMODULE +(\w+)/) { $submod = $1; next; } next if (/#undef NS_(SUB)?MODULE/); s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/; s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g; s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/; s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1 ${mod}_${submod}_$2)/; s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/; s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/; s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/; s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/; s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/; if (/^$/) { print if (! $last_was_empty); $last_was_empty = 1; } else { $last_was_empty = 0; print; } if (eof) { $mod = "NS_MODULE"; $submod = "NS_SUBMODULE"; $last_was_empty = 0; } } # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # Date: Thu Jan 9 10:26:10 2020 -0500 # # On branch disable_ns_macro # Changes to be committed: # modified: src/test/test_accounting.c # modified: src/test/test_compat_libevent.c # modified: src/test/test_dir.c # modified: src/test/test_dir_handle_get.c # modified: src/test/test_dns.c # modified: src/test/test_options.c # modified: src/test/test_procmon.c # modified: src/test/test_rendcache.c # modified: src/test/test_router.c # modified: src/test/test_routerset.c # modified: src/test/test_status.c # modified: src/test/test_tortls.c # modified: src/test/test_tortls_openssl.c # modified: src/test/test_util_format.c # modified: src/test/test_util_process.c # # Untracked files: # experiments/ # locate_options.sh # un_ns.pl # # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # Date: Thu Jan 9 10:26:10 2020 -0500 # # On branch disable_ns_macro # Changes to be committed: # modified: src/test/test_accounting.c # modified: src/test/test_compat_libevent.c # modified: src/test/test_dir.c # modified: src/test/test_dir_handle_get.c # modified: src/test/test_dns.c # modified: src/test/test_options.c # modified: src/test/test_procmon.c # modified: src/test/test_rendcache.c # modified: src/test/test_router.c # modified: src/test/test_routerset.c # modified: src/test/test_status.c # modified: src/test/test_tortls.c # modified: src/test/test_tortls_openssl.c # modified: src/test/test_util_format.c # modified: src/test/test_util_process.c # # Untracked files: # experiments/ # locate_options.sh # un_ns.pl #
Diffstat (limited to 'src/test/test_accounting.c')
-rw-r--r--src/test/test_accounting.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/test/test_accounting.c b/src/test/test_accounting.c
index 58a1dbf815..7933df5e35 100644
--- a/src/test/test_accounting.c
+++ b/src/test/test_accounting.c
@@ -11,19 +11,16 @@
#include "app/config/or_state_st.h"
-#define NS_MODULE acct
-
-#define NS_SUBMODULE limits
-
/*
* Test to make sure accounting triggers hibernation
* correctly with both sum or max rules set
*/
static or_state_t *or_state;
-NS_DECL(or_state_t *, get_or_state, (void));
+static or_state_t * acct_limits_get_or_state(void);
+ATTR_UNUSED static int acct_limits_get_or_state_called = 0;
static or_state_t *
-NS(get_or_state)(void)
+acct_limits_get_or_state(void)
{
return or_state;
}
@@ -35,7 +32,8 @@ test_accounting_limits(void *arg)
time_t fake_time = time(NULL);
(void) arg;
- NS_MOCK(get_or_state);
+ MOCK(get_or_state,
+ acct_limits_get_or_state);
or_state = or_state_new();
options->AccountingMax = 100;
@@ -94,12 +92,10 @@ test_accounting_limits(void *arg)
goto done;
done:
- NS_UNMOCK(get_or_state);
+ UNMOCK(get_or_state);
or_state_free(or_state);
}
-#undef NS_SUBMODULE
-
struct testcase_t accounting_tests[] = {
{ "bwlimits", test_accounting_limits, TT_FORK, NULL, NULL },
END_OF_TESTCASES