summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Joseph Davis <davisp@apache.org>2009-05-31 00:22:25 +0000
committerPaul Joseph Davis <davisp@apache.org>2009-05-31 00:22:25 +0000
commit3f6d703833af0c2c7b6aa31525b6593588312e94 (patch)
tree3458f76061f5d6d5d14f8275881eab3081b4ac0a
parent2b21b31c73dfc500762360253b6e390024c7cf28 (diff)
Had to swap macro definitions to support R12B.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@780350 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-xtest/etap/010-file-basics.t6
-rwxr-xr-xtest/etap/011-file-headers.t12
-rwxr-xr-xtest/etap/020-btree-basics.t8
-rwxr-xr-xtest/etap/021-btree-reductions.t24
-rwxr-xr-xtest/etap/031-doc-to-json.t1
5 files changed, 26 insertions, 25 deletions
diff --git a/test/etap/010-file-basics.t b/test/etap/010-file-basics.t
index 62704a1b..7c1c80eb 100755
--- a/test/etap/010-file-basics.t
+++ b/test/etap/010-file-basics.t
@@ -2,7 +2,7 @@
%% -*- erlang -*-
%%! -pa ./src/couchdb -sasl errlog_type error -boot start_sasl -noshell
--define(FILE_NAME, "./test/etap/temp.010").
+filename() -> "./test/etap/temp.010".
main(_) ->
code:add_pathz("src/couchdb"),
@@ -22,11 +22,11 @@ test() ->
etap:fun_is(
fun({ok, _}) -> true; (_) -> false end,
- couch_file:open(?FILE_NAME ++ ".1", [create, invalid_option]),
+ couch_file:open(filename() ++ ".1", [create, invalid_option]),
"Invalid flags to open are ignored."
),
- {ok, Fd} = couch_file:open(?FILE_NAME ++ ".0", [create, overwrite]),
+ {ok, Fd} = couch_file:open(filename() ++ ".0", [create, overwrite]),
etap:ok(is_pid(Fd),
"Returned file descriptor is a Pid"),
diff --git a/test/etap/011-file-headers.t b/test/etap/011-file-headers.t
index f9d0c948..83478d34 100755
--- a/test/etap/011-file-headers.t
+++ b/test/etap/011-file-headers.t
@@ -2,8 +2,8 @@
%% -*- erlang -*-
%%! -pa ./src/couchdb -sasl errlog_type error -boot start_sasl -noshell
--define(FILE_NAME, "./test/etap/temp.011").
--define(SIZE_BLOCK, 4096). % Need to keep this in sync with couch_file.erl
+filename() -> "./test/etap/temp.011".
+sizeblock() -> 4096. % Need to keep this in sync with couch_file.erl
main(_) ->
code:add_pathz("src/couchdb"),
@@ -21,7 +21,7 @@ main(_) ->
ok.
test() ->
- {ok, Fd} = couch_file:open(?FILE_NAME, [create,overwrite]),
+ {ok, Fd} = couch_file:open(filename(), [create,overwrite]),
etap:is({ok, 0}, couch_file:bytes(Fd),
"File should be initialized to contain zero bytes."),
@@ -103,8 +103,8 @@ test() ->
ok.
check_header_recovery(CheckFun) ->
- {ok, Fd} = couch_file:open(?FILE_NAME, [create,overwrite]),
- {ok, RawFd} = file:open(?FILE_NAME, [read, write, raw, binary]),
+ {ok, Fd} = couch_file:open(filename(), [create,overwrite]),
+ {ok, RawFd} = file:open(filename(), [read, write, raw, binary]),
{ok, _} = write_random_data(Fd),
ExpectHeader = {some_atom, <<"a binary">>, 756},
@@ -124,7 +124,7 @@ write_random_data(Fd) ->
write_random_data(Fd, 0) ->
{ok, Bytes} = couch_file:bytes(Fd),
- {ok, (1 + Bytes div ?SIZE_BLOCK) * ?SIZE_BLOCK};
+ {ok, (1 + Bytes div sizeblock()) * sizeblock()};
write_random_data(Fd, N) ->
Choices = [foo, bar, <<"bizzingle">>, "bank", ["rough", stuff]],
Term = lists:nth(random:uniform(4) + 1, Choices),
diff --git a/test/etap/020-btree-basics.t b/test/etap/020-btree-basics.t
index 2cc5723d..fbc895c1 100755
--- a/test/etap/020-btree-basics.t
+++ b/test/etap/020-btree-basics.t
@@ -2,8 +2,8 @@
%% -*- erlang -*-
%%! -pa ./src/couchdb -sasl errlog_type error -boot start_sasl -noshell
--define(FILE_NAME, "./test/etap/temp.020").
--define(ROWS, 250).
+filename() -> "./test/etap/temp.020".
+rows() -> 250.
-record(btree, {fd, root, extract_kv, assemble_kv, less, reduce}).
@@ -23,7 +23,7 @@ main(_) ->
%% broken into multiple nodes. AKA "How do we appropiately detect if multiple
%% nodes were created."
test()->
- Sorted = [{Seq, random:uniform()} || Seq <- lists:seq(1, ?ROWS)],
+ Sorted = [{Seq, random:uniform()} || Seq <- lists:seq(1, rows())],
etap:ok(test_kvs(Sorted), "Testing sorted keys"),
etap:ok(test_kvs(lists:reverse(Sorted)), "Testing reversed sorted keys"),
etap:ok(test_kvs(shuffle(Sorted)), "Testing shuffled keys."),
@@ -39,7 +39,7 @@ test_kvs(KeyValues) ->
Keys = [K || {K, _} <- KeyValues],
- {ok, Fd} = couch_file:open(?FILE_NAME, [create,overwrite]),
+ {ok, Fd} = couch_file:open(filename(), [create,overwrite]),
{ok, Btree} = couch_btree:open(nil, Fd),
etap:ok(is_record(Btree, btree), "Created btree is really a btree record"),
etap:is(Btree#btree.fd, Fd, "Btree#btree.fd is set correctly."),
diff --git a/test/etap/021-btree-reductions.t b/test/etap/021-btree-reductions.t
index eb84f09b..9ae7dbbf 100755
--- a/test/etap/021-btree-reductions.t
+++ b/test/etap/021-btree-reductions.t
@@ -2,8 +2,8 @@
%% -*- erlang -*-
%%! -pa ./src/couchdb -sasl errlog_type error -boot start_sasl -noshell
--define(FILE_NAME, "./test/etap/temp.021").
--define(ROWS, 1000).
+filename() -> "./test/etap/temp.021".
+rows() -> 1000.
main(_) ->
code:add_pathz("src/couchdb"),
@@ -23,7 +23,7 @@ test()->
(rereduce, Reds) -> lists:sum(Reds)
end,
- {ok, Fd} = couch_file:open(?FILE_NAME, [create,overwrite]),
+ {ok, Fd} = couch_file:open(filename(), [create,overwrite]),
{ok, Btree} = couch_btree:open(nil, Fd, [{reduce, ReduceFun}]),
% Create a list, of {"even", Value} or {"odd", Value} pairs.
@@ -32,7 +32,7 @@ test()->
"even" -> {"odd", [{{Key, Idx}, 1} | Acc]};
_ -> {"even", [{{Key, Idx}, 1} | Acc]}
end
- end, {"odd", []}, lists:seq(1, ?ROWS)),
+ end, {"odd", []}, lists:seq(1, rows())),
{ok, Btree2} = couch_btree:add_remove(Btree, EvenOddKVs, []),
@@ -46,7 +46,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"odd", _}, ?ROWS div 2}, {{"even", _}, ?ROWS div 2}]}) ->
+ ({ok, [{{"odd", _}, 500}, {{"even", _}, 500}]}) ->
true;
(_) ->
false
@@ -57,7 +57,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"odd", _}, ?ROWS div 2}, {{"even", _}, ?ROWS div 2}]}) ->
+ ({ok, [{{"odd", _}, 500}, {{"even", _}, 500}]}) ->
true;
(_) ->
false
@@ -68,7 +68,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"even", _}, ?ROWS div 2}, {{"odd", _}, ?ROWS div 2}]}) ->
+ ({ok, [{{"even", _}, 500}, {{"odd", _}, 500}]}) ->
true;
(_) ->
false
@@ -79,7 +79,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"odd", _}, ?ROWS div 2}, {{"even", _}, ?ROWS div 2}]}) ->
+ ({ok, [{{"odd", _}, 500}, {{"even", _}, 500}]}) ->
true;
(_) ->
false
@@ -90,7 +90,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"even", _}, ?ROWS div 2}]}) -> true;
+ ({ok, [{{"even", _}, 500}]}) -> true;
(_) -> false
end,
couch_btree:fold_reduce(Btree2, fwd, SK1, EK1, GroupFun, FoldFun, []),
@@ -99,7 +99,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"odd", _}, ?ROWS div 2}]}) -> true;
+ ({ok, [{{"odd", _}, 500}]}) -> true;
(_) -> false
end,
couch_btree:fold_reduce(Btree2, fwd, SK2, EK2, GroupFun, FoldFun, []),
@@ -108,7 +108,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"odd", _}, ?ROWS div 2}]}) -> true;
+ ({ok, [{{"odd", _}, 500}]}) -> true;
(_) -> false
end,
couch_btree:fold_reduce(Btree2, rev, EK2, SK2, GroupFun, FoldFun, []),
@@ -117,7 +117,7 @@ test()->
etap:fun_is(
fun
- ({ok, [{{"even", _}, ?ROWS div 2}, {{"odd", _}, ?ROWS div 2}]}) ->
+ ({ok, [{{"even", _}, 500}, {{"odd", _}, 500}]}) ->
true;
(_) ->
false
diff --git a/test/etap/031-doc-to-json.t b/test/etap/031-doc-to-json.t
index 02a09616..37b23848 100755
--- a/test/etap/031-doc-to-json.t
+++ b/test/etap/031-doc-to-json.t
@@ -150,3 +150,4 @@ test_to_json_success() ->
etap:is(couch_doc:to_json_obj(Doc, Options), EJson, Mesg)
end, Cases),
ok.
+