mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-10 06:05:49 +00:00
Don't include unit test sources in code coverage (RIPD-1132):
Most files containing unit test code are moved to src/test. JTx and the test client code are not yet moved.
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -73,10 +73,6 @@ DerivedData
|
||||
# Intel Parallel Studio 2013 XE
|
||||
My Amplifier XE Results - RippleD
|
||||
|
||||
# KeyvaDB files
|
||||
*.key
|
||||
*.val
|
||||
|
||||
# Compiler intermediate output
|
||||
/out.txt
|
||||
|
||||
@@ -87,3 +83,9 @@ rippled-build.log
|
||||
gmon.out
|
||||
|
||||
Builds/VisualStudio2015/*.db
|
||||
Builds/VisualStudio2015/*.user
|
||||
Builds/VisualStudio2015/*.opendb
|
||||
Builds/VisualStudio2015/*.sdf
|
||||
|
||||
# MSVC
|
||||
*.pdb
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -612,11 +612,8 @@ set(soci_extra_includes
|
||||
if (WIN32 OR is_xcode OR unity)
|
||||
prepend(beast_unity_srcs
|
||||
src/ripple/beast/unity/
|
||||
beast_clock_unity.cpp
|
||||
beast_container_unity.cpp
|
||||
beast_insight_unity.cpp
|
||||
beast_net_unity.cpp
|
||||
beast_nudb_unity.cpp
|
||||
beast_utility_unity.cpp)
|
||||
|
||||
prepend(ripple_unity_srcs
|
||||
@@ -625,7 +622,6 @@ if (WIN32 OR is_xcode OR unity)
|
||||
app_main.cpp
|
||||
app_misc.cpp
|
||||
app_paths.cpp
|
||||
app_tests.cpp
|
||||
app_tx.cpp
|
||||
core.cpp
|
||||
basics.cpp
|
||||
@@ -641,7 +637,32 @@ if (WIN32 OR is_xcode OR unity)
|
||||
server.cpp
|
||||
test.cpp)
|
||||
|
||||
list(APPEND src ${beast_unity_srcs} ${ripple_unity_srcs})
|
||||
prepend(test_unity_srcs
|
||||
src/unity/
|
||||
app_test_unity.cpp
|
||||
basics_test_unity.cpp
|
||||
beast_test_unity.cpp
|
||||
core_test_unity.cpp
|
||||
json_test_unity.cpp
|
||||
ledger_test_unity.cpp
|
||||
overlay_test_unity.cpp
|
||||
peerfinder_test_unity.cpp
|
||||
protocol_test_unity.cpp
|
||||
resource_test_unity.cpp
|
||||
rpc_test_unity.cpp
|
||||
server_test_unity.cpp
|
||||
shamap_test_unity.cpp
|
||||
test_unity.cpp)
|
||||
|
||||
list(APPEND src ${beast_unity_srcs} ${ripple_unity_srcs} ${test_unity_srcs})
|
||||
|
||||
|
||||
|
||||
add_with_props(src/unity/nodestore_test_unity.cpp
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/rocksdb2/include
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/snappy/snappy
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/snappy/config
|
||||
${rocks_db_system_header})
|
||||
|
||||
add_with_props(src/ripple/unity/nodestore.cpp
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/rocksdb2/include
|
||||
@@ -651,9 +672,10 @@ if (WIN32 OR is_xcode OR unity)
|
||||
|
||||
add_with_props(src/ripple/unity/soci_ripple.cpp ${soci_extra_includes})
|
||||
|
||||
set(unity_srcs ${beast_unity_srcs} ${ripple_unity_srcs}
|
||||
set(unity_srcs ${beast_unity_srcs} ${ripple_unity_srcs} ${test_unity_srcs}
|
||||
src/ripple/unity/nodestore.cpp
|
||||
src/ripple/unity/soci_ripple.cpp)
|
||||
src/ripple/unity/soci_ripple.cpp
|
||||
src/unity/nodestore_test_unity.cpp)
|
||||
|
||||
set_property(
|
||||
SOURCE ${unity_srcs}
|
||||
@@ -692,6 +714,16 @@ if (WIN32 OR is_xcode OR NOT unity)
|
||||
|
||||
list(APPEND non_unity_srcs "${nodestore_srcs}")
|
||||
|
||||
|
||||
file(GLOB_RECURSE test_srcs src/test/*.cpp)
|
||||
add_with_props("${test_srcs}"
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/rocksdb2/include
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/snappy/snappy
|
||||
-I"${CMAKE_SOURCE_DIR}/"src/snappy/config
|
||||
${rocks_db_system_header})
|
||||
|
||||
list(APPEND non_unity_srcs "${test_srcs}")
|
||||
|
||||
set_property(
|
||||
SOURCE ${non_unity_srcs}
|
||||
APPEND
|
||||
|
||||
39
SConstruct
39
SConstruct
@@ -119,6 +119,7 @@ import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import time
|
||||
import glob
|
||||
import SCons.Action
|
||||
|
||||
sys.path.append(os.path.join('src', 'ripple', 'beast', 'site_scons'))
|
||||
@@ -923,6 +924,23 @@ def get_classic_sources(toolchain):
|
||||
append_sources(result, *list_sources('src/ripple/shamap', '.cpp'))
|
||||
append_sources(result, *list_sources('src/ripple/server', '.cpp'))
|
||||
append_sources(result, *list_sources('src/ripple/test', '.cpp'))
|
||||
append_sources(result,
|
||||
'src/test/BasicNetwork_test.cpp',
|
||||
'src/test/Env_test.cpp',
|
||||
'src/test/WSClient_test.cpp')
|
||||
append_sources(result, *list_sources('src/test/app', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/basics', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/beast', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/core', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/json', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/ledger', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/overlay', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/peerfinder', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/protocol', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/resource', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/rpc', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/server', '.cpp'))
|
||||
append_sources(result, *list_sources('src/test/shamap', '.cpp'))
|
||||
|
||||
if use_shp(toolchain):
|
||||
cc_flags = {'CCFLAGS': ['--system-header-prefix=rocksdb2']}
|
||||
@@ -931,7 +949,7 @@ def get_classic_sources(toolchain):
|
||||
|
||||
append_sources(
|
||||
result,
|
||||
*list_sources('src/ripple/nodestore', '.cpp'),
|
||||
*(list_sources('src/ripple/nodestore', '.cpp') + list_sources('src/test/nodestore', '.cpp')),
|
||||
CPPPATH=[
|
||||
'src/rocksdb2/include',
|
||||
'src/snappy/snappy',
|
||||
@@ -948,17 +966,13 @@ def get_unity_sources(toolchain):
|
||||
result = []
|
||||
append_sources(
|
||||
result,
|
||||
'src/ripple/beast/unity/beast_clock_unity.cpp',
|
||||
'src/ripple/beast/unity/beast_container_unity.cpp',
|
||||
'src/ripple/beast/unity/beast_insight_unity.cpp',
|
||||
'src/ripple/beast/unity/beast_net_unity.cpp',
|
||||
'src/ripple/beast/unity/beast_nudb_unity.cpp',
|
||||
'src/ripple/beast/unity/beast_utility_unity.cpp',
|
||||
'src/ripple/unity/app_ledger.cpp',
|
||||
'src/ripple/unity/app_main.cpp',
|
||||
'src/ripple/unity/app_misc.cpp',
|
||||
'src/ripple/unity/app_paths.cpp',
|
||||
'src/ripple/unity/app_tests.cpp',
|
||||
'src/ripple/unity/app_tx.cpp',
|
||||
'src/ripple/unity/core.cpp',
|
||||
'src/ripple/unity/basics.cpp',
|
||||
@@ -973,6 +987,20 @@ def get_unity_sources(toolchain):
|
||||
'src/ripple/unity/shamap.cpp',
|
||||
'src/ripple/unity/server.cpp',
|
||||
'src/ripple/unity/test.cpp',
|
||||
'src/unity/app_test_unity.cpp',
|
||||
'src/unity/basics_test_unity.cpp',
|
||||
'src/unity/beast_test_unity.cpp',
|
||||
'src/unity/core_test_unity.cpp',
|
||||
'src/unity/json_test_unity.cpp',
|
||||
'src/unity/ledger_test_unity.cpp',
|
||||
'src/unity/overlay_test_unity.cpp',
|
||||
'src/unity/peerfinder_test_unity.cpp',
|
||||
'src/unity/protocol_test_unity.cpp',
|
||||
'src/unity/resource_test_unity.cpp',
|
||||
'src/unity/rpc_test_unity.cpp',
|
||||
'src/unity/server_test_unity.cpp',
|
||||
'src/unity/shamap_test_unity.cpp',
|
||||
'src/unity/test_unity.cpp'
|
||||
)
|
||||
|
||||
if use_shp(toolchain):
|
||||
@@ -983,6 +1011,7 @@ def get_unity_sources(toolchain):
|
||||
append_sources(
|
||||
result,
|
||||
'src/ripple/unity/nodestore.cpp',
|
||||
'src/unity/nodestore_test_unity.cpp',
|
||||
CPPPATH=[
|
||||
'src/rocksdb2/include',
|
||||
'src/snappy/snappy',
|
||||
|
||||
@@ -46,7 +46,10 @@ if [[ $TARGET == "coverage" ]]; then
|
||||
lcov -a baseline.info -a tests.info -o lcov-all.info
|
||||
|
||||
# Only report on src/ripple files
|
||||
lcov -e "lcov-all.info" "*/src/ripple/*" -o lcov.info
|
||||
lcov -e "lcov-all.info" "*/src/ripple/*" -o lcov.pre.info
|
||||
|
||||
# Exclude */src/test directory
|
||||
lcov --remove lcov.pre.info "*/src/ripple/test/*" -o lcov.info
|
||||
|
||||
# Push the results (lcov.info) to codecov
|
||||
codecov -X gcov # don't even try and look for .gcov files ;)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -319,244 +318,4 @@ int compare (SemanticVersion const& lhs, SemanticVersion const& rhs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class SemanticVersion_test: public unit_test::suite
|
||||
{
|
||||
using identifier_list = SemanticVersion::identifier_list;
|
||||
|
||||
public:
|
||||
void checkPass (std::string const& input, bool shouldPass = true)
|
||||
{
|
||||
SemanticVersion v;
|
||||
|
||||
if (shouldPass )
|
||||
{
|
||||
BEAST_EXPECT(v.parse (input));
|
||||
BEAST_EXPECT(v.print () == input);
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(! v.parse (input));
|
||||
}
|
||||
}
|
||||
|
||||
void checkFail (std::string const& input)
|
||||
{
|
||||
checkPass (input, false);
|
||||
}
|
||||
|
||||
// check input and input with appended metadata
|
||||
void checkMeta (std::string const& input, bool shouldPass)
|
||||
{
|
||||
checkPass (input, shouldPass);
|
||||
|
||||
checkPass (input + "+a", shouldPass);
|
||||
checkPass (input + "+1", shouldPass);
|
||||
checkPass (input + "+a.b", shouldPass);
|
||||
checkPass (input + "+ab.cd", shouldPass);
|
||||
|
||||
checkFail (input + "!");
|
||||
checkFail (input + "+");
|
||||
checkFail (input + "++");
|
||||
checkFail (input + "+!");
|
||||
checkFail (input + "+.");
|
||||
checkFail (input + "+a.!");
|
||||
}
|
||||
|
||||
void checkMetaFail (std::string const& input)
|
||||
{
|
||||
checkMeta (input, false);
|
||||
}
|
||||
|
||||
// check input, input with appended release data,
|
||||
// input with appended metadata, and input with both
|
||||
// appended release data and appended metadata
|
||||
//
|
||||
void checkRelease (std::string const& input, bool shouldPass = true)
|
||||
{
|
||||
checkMeta (input, shouldPass);
|
||||
|
||||
checkMeta (input + "-1", shouldPass);
|
||||
checkMeta (input + "-a", shouldPass);
|
||||
checkMeta (input + "-a1", shouldPass);
|
||||
checkMeta (input + "-a1.b1", shouldPass);
|
||||
checkMeta (input + "-ab.cd", shouldPass);
|
||||
checkMeta (input + "--", shouldPass);
|
||||
|
||||
checkMetaFail (input + "+");
|
||||
checkMetaFail (input + "!");
|
||||
checkMetaFail (input + "-");
|
||||
checkMetaFail (input + "-!");
|
||||
checkMetaFail (input + "-.");
|
||||
checkMetaFail (input + "-a.!");
|
||||
checkMetaFail (input + "-0.a");
|
||||
}
|
||||
|
||||
// Checks the major.minor.version string alone and with all
|
||||
// possible combinations of release identifiers and metadata.
|
||||
//
|
||||
void check (std::string const& input, bool shouldPass = true)
|
||||
{
|
||||
checkRelease (input, shouldPass);
|
||||
}
|
||||
|
||||
void negcheck (std::string const& input)
|
||||
{
|
||||
check (input, false);
|
||||
}
|
||||
|
||||
void testParse ()
|
||||
{
|
||||
testcase ("parsing");
|
||||
|
||||
check ("0.0.0");
|
||||
check ("1.2.3");
|
||||
check ("2147483647.2147483647.2147483647"); // max int
|
||||
|
||||
// negative values
|
||||
negcheck ("-1.2.3");
|
||||
negcheck ("1.-2.3");
|
||||
negcheck ("1.2.-3");
|
||||
|
||||
// missing parts
|
||||
negcheck ("");
|
||||
negcheck ("1");
|
||||
negcheck ("1.");
|
||||
negcheck ("1.2");
|
||||
negcheck ("1.2.");
|
||||
negcheck (".2.3");
|
||||
|
||||
// whitespace
|
||||
negcheck (" 1.2.3");
|
||||
negcheck ("1 .2.3");
|
||||
negcheck ("1.2 .3");
|
||||
negcheck ("1.2.3 ");
|
||||
|
||||
// leading zeroes
|
||||
negcheck ("01.2.3");
|
||||
negcheck ("1.02.3");
|
||||
negcheck ("1.2.03");
|
||||
}
|
||||
|
||||
static identifier_list ids ()
|
||||
{
|
||||
return identifier_list ();
|
||||
}
|
||||
|
||||
static identifier_list ids (
|
||||
std::string const& s1)
|
||||
{
|
||||
identifier_list v;
|
||||
v.push_back (s1);
|
||||
return v;
|
||||
}
|
||||
|
||||
static identifier_list ids (
|
||||
std::string const& s1, std::string const& s2)
|
||||
{
|
||||
identifier_list v;
|
||||
v.push_back (s1);
|
||||
v.push_back (s2);
|
||||
return v;
|
||||
}
|
||||
|
||||
static identifier_list ids (
|
||||
std::string const& s1, std::string const& s2, std::string const& s3)
|
||||
{
|
||||
identifier_list v;
|
||||
v.push_back (s1);
|
||||
v.push_back (s2);
|
||||
v.push_back (s3);
|
||||
return v;
|
||||
}
|
||||
|
||||
// Checks the decomposition of the input into appropriate values
|
||||
void checkValues (std::string const& input,
|
||||
int majorVersion,
|
||||
int minorVersion,
|
||||
int patchVersion,
|
||||
identifier_list const& preReleaseIdentifiers = identifier_list (),
|
||||
identifier_list const& metaData = identifier_list ())
|
||||
{
|
||||
SemanticVersion v;
|
||||
|
||||
BEAST_EXPECT(v.parse (input));
|
||||
|
||||
BEAST_EXPECT(v.majorVersion == majorVersion);
|
||||
BEAST_EXPECT(v.minorVersion == minorVersion);
|
||||
BEAST_EXPECT(v.patchVersion == patchVersion);
|
||||
|
||||
BEAST_EXPECT(v.preReleaseIdentifiers == preReleaseIdentifiers);
|
||||
BEAST_EXPECT(v.metaData == metaData);
|
||||
}
|
||||
|
||||
void testValues ()
|
||||
{
|
||||
testcase ("values");
|
||||
|
||||
checkValues ("0.1.2", 0, 1, 2);
|
||||
checkValues ("1.2.3", 1, 2, 3);
|
||||
checkValues ("1.2.3-rc1", 1, 2, 3, ids ("rc1"));
|
||||
checkValues ("1.2.3-rc1.debug", 1, 2, 3, ids ("rc1", "debug"));
|
||||
checkValues ("1.2.3-rc1.debug.asm", 1, 2, 3, ids ("rc1", "debug", "asm"));
|
||||
checkValues ("1.2.3+full", 1, 2, 3, ids (), ids ("full"));
|
||||
checkValues ("1.2.3+full.prod", 1, 2, 3, ids (), ids ("full", "prod"));
|
||||
checkValues ("1.2.3+full.prod.x86", 1, 2, 3, ids (), ids ("full", "prod", "x86"));
|
||||
checkValues ("1.2.3-rc1.debug.asm+full.prod.x86", 1, 2, 3,
|
||||
ids ("rc1", "debug", "asm"), ids ("full", "prod", "x86"));
|
||||
}
|
||||
|
||||
// makes sure the left version is less than the right
|
||||
void checkLessInternal (std::string const& lhs, std::string const& rhs)
|
||||
{
|
||||
SemanticVersion left;
|
||||
SemanticVersion right;
|
||||
|
||||
BEAST_EXPECT(left.parse (lhs));
|
||||
BEAST_EXPECT(right.parse (rhs));
|
||||
|
||||
BEAST_EXPECT(compare (left, left) == 0);
|
||||
BEAST_EXPECT(compare (right, right) == 0);
|
||||
BEAST_EXPECT(compare (left, right) < 0);
|
||||
BEAST_EXPECT(compare (right, left) > 0);
|
||||
|
||||
BEAST_EXPECT(left < right);
|
||||
BEAST_EXPECT(right > left);
|
||||
BEAST_EXPECT(left == left);
|
||||
BEAST_EXPECT(right == right);
|
||||
}
|
||||
|
||||
void checkLess (std::string const& lhs, std::string const& rhs)
|
||||
{
|
||||
checkLessInternal (lhs, rhs);
|
||||
checkLessInternal (lhs + "+meta", rhs);
|
||||
checkLessInternal (lhs, rhs + "+meta");
|
||||
checkLessInternal (lhs + "+meta", rhs + "+meta");
|
||||
}
|
||||
|
||||
void testCompare ()
|
||||
{
|
||||
testcase ("comparisons");
|
||||
|
||||
checkLess ("1.0.0-alpha", "1.0.0-alpha.1");
|
||||
checkLess ("1.0.0-alpha.1", "1.0.0-alpha.beta");
|
||||
checkLess ("1.0.0-alpha.beta", "1.0.0-beta");
|
||||
checkLess ("1.0.0-beta", "1.0.0-beta.2");
|
||||
checkLess ("1.0.0-beta.2", "1.0.0-beta.11");
|
||||
checkLess ("1.0.0-beta.11", "1.0.0-rc.1");
|
||||
checkLess ("1.0.0-rc.1", "1.0.0");
|
||||
checkLess ("0.9.9", "1.0.0");
|
||||
}
|
||||
|
||||
void run ()
|
||||
{
|
||||
testParse ();
|
||||
testValues ();
|
||||
testCompare ();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(SemanticVersion,beast_core,beast);
|
||||
|
||||
} // beast
|
||||
|
||||
@@ -193,7 +193,6 @@
|
||||
#include <ripple/beast/core/SemanticVersion.cpp>
|
||||
#include <ripple/beast/core/SystemStats.cpp>
|
||||
#include <ripple/beast/core/RelativeTime.cpp>
|
||||
#include <ripple/beast/core/LexicalCast.cpp>
|
||||
#include <ripple/beast/core/Thread.cpp>
|
||||
#include <ripple/beast/core/Time.cpp>
|
||||
#include <ripple/beast/core/WaitableEvent.cpp>
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
#include <beast/container/fnv1a.h>
|
||||
#include <beast/container/siphash.h>
|
||||
#include <beast/container/xxhasher.h>
|
||||
#include <beast/rngfill.h>
|
||||
#include <beast/xor_shift_engine.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <random>
|
||||
|
||||
namespace beast {
|
||||
|
||||
class hash_speed_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
using clock_type =
|
||||
std::chrono::high_resolution_clock;
|
||||
template <class Hasher, std::size_t KeySize>
|
||||
void
|
||||
test (std::string const& what, std::size_t n)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
xor_shift_engine g(1);
|
||||
array<std::uint8_t, KeySize> key;
|
||||
auto const start = clock_type::now();
|
||||
while(n--)
|
||||
{
|
||||
rngfill (key, g);
|
||||
Hasher h;
|
||||
h.append(key.data(), KeySize);
|
||||
volatile size_t temp =
|
||||
static_cast<std::size_t>(h);
|
||||
(void)temp;
|
||||
}
|
||||
auto const elapsed = clock_type::now() - start;
|
||||
log << setw(12) << what << " " <<
|
||||
duration<double>(elapsed) << "s" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
run()
|
||||
{
|
||||
enum
|
||||
{
|
||||
N = 100000000
|
||||
};
|
||||
|
||||
#if ! BEAST_NO_XXHASH
|
||||
test<xxhasher,32> ("xxhash", N);
|
||||
#endif
|
||||
test<fnv1a,32> ("fnv1a", N);
|
||||
test<siphash,32> ("siphash", N);
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE_MANUAL(hash_speed,container,beast);
|
||||
|
||||
} // beast
|
||||
@@ -32,7 +32,7 @@ namespace detail {
|
||||
@return `true` if the character matched.
|
||||
*/
|
||||
template <typename InputStream>
|
||||
bool BEAST_EXPECT(InputStream& is, char v)
|
||||
bool expect(InputStream& is, char v)
|
||||
{
|
||||
char c;
|
||||
if (is.get(c) && v == c)
|
||||
|
||||
@@ -170,7 +170,7 @@ std::istream& operator>> (std::istream& is, AddressV4& addr)
|
||||
is >> IP::detail::integer (octet [0]);
|
||||
for (int i = 1; i < 4; ++i)
|
||||
{
|
||||
if (!is || !IP::detail::BEAST_EXPECT(is, '.'))
|
||||
if (!is || !IP::detail::expect(is, '.'))
|
||||
return is;
|
||||
is >> IP::detail::integer (octet [i]);
|
||||
if (!is)
|
||||
|
||||
@@ -24,6 +24,3 @@
|
||||
#include <ripple/beast/hash/impl/xxhash.c>
|
||||
#endif
|
||||
#include <ripple/beast/hash/impl/siphash.cpp>
|
||||
|
||||
#include <ripple/beast/hash/tests/hash_append_test.cpp>
|
||||
#include <ripple/beast/hash/tests/hash_speed_test.cpp>
|
||||
|
||||
@@ -21,5 +21,3 @@
|
||||
#include <ripple/beast/net/impl/IPAddressV6.cpp>
|
||||
#include <ripple/beast/net/impl/IPEndpoint.cpp>
|
||||
#include <ripple/beast/net/impl/IPAddressConversion.cpp>
|
||||
|
||||
#include <ripple/beast/net/tests/IPEndpoint.test.cpp>
|
||||
|
||||
@@ -24,8 +24,3 @@
|
||||
#include <ripple/beast/utility/src/beast_Debug.cpp>
|
||||
#include <ripple/beast/utility/src/beast_Journal.cpp>
|
||||
#include <ripple/beast/utility/src/beast_PropertyStream.cpp>
|
||||
|
||||
#include <ripple/beast/utility/test/beast_Journal_test.cpp>
|
||||
#include <ripple/beast/utility/test/beast_tagged_integer_test.cpp>
|
||||
#include <ripple/beast/utility/test/beast_weak_fn_test.cpp>
|
||||
#include <ripple/beast/utility/test/beast_Zero_test.cpp>
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/utility/Debug.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/core/SystemStats.h>
|
||||
|
||||
namespace beast {
|
||||
@@ -111,51 +110,4 @@ void checkHeap ()
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// A simple unit test to determine the diagnostic settings in a build.
|
||||
//
|
||||
class Debug_test : public unit_test::suite
|
||||
{
|
||||
public:
|
||||
static int envDebug ()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int beastDebug ()
|
||||
{
|
||||
#ifdef BEAST_DEBUG
|
||||
return BEAST_DEBUG;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int beastForceDebug ()
|
||||
{
|
||||
#ifdef BEAST_FORCE_DEBUG
|
||||
return BEAST_FORCE_DEBUG;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void run ()
|
||||
{
|
||||
log <<
|
||||
"_DEBUG = " << envDebug () << '\n' <<
|
||||
"BEAST_DEBUG = " << beastDebug () << '\n' <<
|
||||
"BEAST_FORCE_DEBUG = " << beastForceDebug () << '\n' <<
|
||||
"sizeof(std::size_t) = " << sizeof(std::size_t) << std::endl;
|
||||
pass ();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Debug,utility,beast);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/utility/PropertyStream.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
@@ -574,203 +573,5 @@ void PropertyStream::add (long double value)
|
||||
lexical_add (value);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class PropertyStream_test : public unit_test::suite
|
||||
{
|
||||
public:
|
||||
using Source = PropertyStream::Source;
|
||||
|
||||
void test_peel_name (std::string s, std::string const& expected,
|
||||
std::string const& expected_remainder)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string const peeled_name = Source::peel_name (&s);
|
||||
BEAST_EXPECT(peeled_name == expected);
|
||||
BEAST_EXPECT(s == expected_remainder);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_peel_leading_slash (std::string s, std::string const& expected,
|
||||
bool should_be_found)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool const found (Source::peel_leading_slash (&s));
|
||||
BEAST_EXPECT(found == should_be_found);
|
||||
BEAST_EXPECT(s == expected);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_peel_trailing_slashstar (std::string s,
|
||||
std::string const& expected_remainder, bool should_be_found)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool const found (Source::peel_trailing_slashstar (&s));
|
||||
BEAST_EXPECT(found == should_be_found);
|
||||
BEAST_EXPECT(s == expected_remainder);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find_one (Source& root, Source* expected, std::string const& name)
|
||||
{
|
||||
try
|
||||
{
|
||||
Source* source (root.find_one (name));
|
||||
BEAST_EXPECT(source == expected);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find_path (Source& root, std::string const& path,
|
||||
Source* expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Source* source (root.find_path (path));
|
||||
BEAST_EXPECT(source == expected);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find_one_deep (Source& root, std::string const& name,
|
||||
Source* expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Source* source (root.find_one_deep (name));
|
||||
BEAST_EXPECT(source == expected);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find (Source& root, std::string path, Source* expected,
|
||||
bool expected_star)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto const result (root.find (path));
|
||||
BEAST_EXPECT(result.first == expected);
|
||||
BEAST_EXPECT(result.second == expected_star);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail ("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
Source a ("a");
|
||||
Source b ("b");
|
||||
Source c ("c");
|
||||
Source d ("d");
|
||||
Source e ("e");
|
||||
Source f ("f");
|
||||
Source g ("g");
|
||||
|
||||
//
|
||||
// a { b { d { f }, e }, c { g } }
|
||||
//
|
||||
|
||||
a.add ( b );
|
||||
a.add ( c );
|
||||
c.add ( g );
|
||||
b.add ( d );
|
||||
b.add ( e );
|
||||
d.add ( f );
|
||||
|
||||
testcase ("peel_name");
|
||||
test_peel_name ("a", "a", "");
|
||||
test_peel_name ("foo/bar", "foo", "bar");
|
||||
test_peel_name ("foo/goo/bar", "foo", "goo/bar");
|
||||
test_peel_name ("", "", "");
|
||||
|
||||
testcase ("peel_leading_slash");
|
||||
test_peel_leading_slash ("foo/", "foo/", false);
|
||||
test_peel_leading_slash ("foo", "foo", false);
|
||||
test_peel_leading_slash ("/foo/", "foo/", true);
|
||||
test_peel_leading_slash ("/foo", "foo", true);
|
||||
|
||||
testcase ("peel_trailing_slashstar");
|
||||
test_peel_trailing_slashstar ("/foo/goo/*", "/foo/goo", true);
|
||||
test_peel_trailing_slashstar ("foo/goo/*", "foo/goo", true);
|
||||
test_peel_trailing_slashstar ("/foo/goo/", "/foo/goo", false);
|
||||
test_peel_trailing_slashstar ("foo/goo", "foo/goo", false);
|
||||
test_peel_trailing_slashstar ("", "", false);
|
||||
test_peel_trailing_slashstar ("/", "", false);
|
||||
test_peel_trailing_slashstar ("/*", "", true);
|
||||
test_peel_trailing_slashstar ("//", "/", false);
|
||||
test_peel_trailing_slashstar ("**", "*", true);
|
||||
test_peel_trailing_slashstar ("*/", "*", false);
|
||||
|
||||
testcase ("find_one");
|
||||
test_find_one (a, &b, "b");
|
||||
test_find_one (a, nullptr, "d");
|
||||
test_find_one (b, &e, "e");
|
||||
test_find_one (d, &f, "f");
|
||||
|
||||
testcase ("find_path");
|
||||
test_find_path (a, "a", nullptr);
|
||||
test_find_path (a, "e", nullptr);
|
||||
test_find_path (a, "a/b", nullptr);
|
||||
test_find_path (a, "a/b/e", nullptr);
|
||||
test_find_path (a, "b/e/g", nullptr);
|
||||
test_find_path (a, "b/e/f", nullptr);
|
||||
test_find_path (a, "b", &b);
|
||||
test_find_path (a, "b/e", &e);
|
||||
test_find_path (a, "b/d/f", &f);
|
||||
|
||||
testcase ("find_one_deep");
|
||||
test_find_one_deep (a, "z", nullptr);
|
||||
test_find_one_deep (a, "g", &g);
|
||||
test_find_one_deep (a, "b", &b);
|
||||
test_find_one_deep (a, "d", &d);
|
||||
test_find_one_deep (a, "f", &f);
|
||||
|
||||
testcase ("find");
|
||||
test_find (a, "", &a, false);
|
||||
test_find (a, "*", &a, true);
|
||||
test_find (a, "/b", &b, false);
|
||||
test_find (a, "b", &b, false);
|
||||
test_find (a, "d", &d, false);
|
||||
test_find (a, "/b*", &b, true);
|
||||
test_find (a, "b*", &b, true);
|
||||
test_find (a, "d*", &d, true);
|
||||
test_find (a, "/b/*", &b, true);
|
||||
test_find (a, "b/*", &b, true);
|
||||
test_find (a, "d/*", &d, true);
|
||||
test_find (a, "a", nullptr, false);
|
||||
test_find (a, "/d", nullptr, false);
|
||||
test_find (a, "/d*", nullptr, true);
|
||||
test_find (a, "/d/*", nullptr, true);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(PropertyStream,utility,beast);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <ripple/core/impl/Workers.h>
|
||||
#include <ripple/core/ThreadEntry.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <cassert>
|
||||
|
||||
namespace ripple {
|
||||
@@ -237,66 +236,4 @@ void Workers::Worker::runImpl ()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class Workers_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
struct TestCallback : Workers::Callback
|
||||
{
|
||||
explicit TestCallback (int count_)
|
||||
: finished (false, count_ == 0)
|
||||
, count (count_)
|
||||
{
|
||||
}
|
||||
|
||||
void processTask ()
|
||||
{
|
||||
if (--count == 0)
|
||||
finished.signal ();
|
||||
}
|
||||
|
||||
beast::WaitableEvent finished;
|
||||
std::atomic <int> count;
|
||||
};
|
||||
|
||||
void testThreads (int const threadCount)
|
||||
{
|
||||
testcase ("threadCount = " + std::to_string (threadCount));
|
||||
|
||||
TestCallback cb (threadCount);
|
||||
|
||||
Workers w (cb, "Test", 0);
|
||||
BEAST_EXPECT(w.getNumberOfThreads () == 0);
|
||||
|
||||
w.setNumberOfThreads (threadCount);
|
||||
BEAST_EXPECT(w.getNumberOfThreads () == threadCount);
|
||||
|
||||
for (int i = 0; i < threadCount; ++i)
|
||||
w.addTask ();
|
||||
|
||||
// 10 seconds should be enough to finish on any system
|
||||
//
|
||||
bool signaled = cb.finished.wait (10 * 1000);
|
||||
BEAST_EXPECT(signaled);
|
||||
|
||||
w.pauseAllThreadsAndWait ();
|
||||
|
||||
// We had better finished all our work!
|
||||
BEAST_EXPECT(cb.count.load () == 0);
|
||||
}
|
||||
|
||||
void run ()
|
||||
{
|
||||
testThreads (0);
|
||||
testThreads (1);
|
||||
testThreads (2);
|
||||
testThreads (4);
|
||||
testThreads (16);
|
||||
testThreads (64);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Workers,core,ripple);
|
||||
|
||||
} // beast
|
||||
} // ripple
|
||||
|
||||
@@ -107,7 +107,7 @@ struct Entry
|
||||
clock_type::rep whenExpires;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Entry const& v)
|
||||
inline std::ostream& operator<< (std::ostream& os, Entry const& v)
|
||||
{
|
||||
os << v.to_string();
|
||||
return os;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
|
||||
#include <ripple/app/tests/AccountTxPaging.test.cpp>
|
||||
#include <ripple/app/tests/AmendmentTable.test.cpp>
|
||||
#include <ripple/app/tests/CrossingLimits_test.cpp>
|
||||
#include <ripple/app/tests/DeliverMin.test.cpp>
|
||||
#include <ripple/app/tests/Flow_test.cpp>
|
||||
#include <ripple/app/tests/HashRouter_test.cpp>
|
||||
#include <ripple/app/tests/LoadFeeTrack.test.cpp>
|
||||
#include <ripple/app/tests/MultiSign.test.cpp>
|
||||
#include <ripple/app/tests/OfferStream.test.cpp>
|
||||
#include <ripple/app/tests/Offer.test.cpp>
|
||||
#include <ripple/app/tests/Path_test.cpp>
|
||||
#include <ripple/app/tests/PayChan_test.cpp>
|
||||
#include <ripple/app/tests/Regression_test.cpp>
|
||||
#include <ripple/app/tests/SHAMapStore_test.cpp>
|
||||
#include <ripple/app/tests/SusPay_test.cpp>
|
||||
#include <ripple/app/tests/SetAuth_test.cpp>
|
||||
#include <ripple/app/tests/SetRegularKey.test.cpp>
|
||||
#include <ripple/app/tests/OversizeMeta_test.cpp>
|
||||
#include <ripple/app/tests/Taker.test.cpp>
|
||||
#include <ripple/app/tests/Transaction_ordering_test.cpp>
|
||||
#include <ripple/app/tests/TxQ_test.cpp>
|
||||
#include <ripple/app/tests/ValidatorList_test.cpp>
|
||||
@@ -36,16 +36,6 @@
|
||||
#include <ripple/basics/impl/Time.cpp>
|
||||
#include <ripple/basics/impl/UptimeTimer.cpp>
|
||||
|
||||
#include <ripple/basics/tests/base_uint.test.cpp>
|
||||
#include <ripple/basics/tests/CheckLibraryVersions.test.cpp>
|
||||
#include <ripple/basics/tests/mulDiv.test.cpp>
|
||||
#include <ripple/basics/tests/contract.test.cpp>
|
||||
#include <ripple/basics/tests/hardened_hash_test.cpp>
|
||||
#include <ripple/basics/tests/KeyCache.test.cpp>
|
||||
#include <ripple/basics/tests/RangeSet.test.cpp>
|
||||
#include <ripple/basics/tests/StringUtilities.test.cpp>
|
||||
#include <ripple/basics/tests/TaggedCache.test.cpp>
|
||||
|
||||
#if DOXYGEN
|
||||
#include <ripple/basics/README.md>
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,5 @@
|
||||
// MUST come first!
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/beast/core/core.unity.cpp>
|
||||
#include <ripple/beast/define_print.cpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,3 @@
|
||||
#include <ripple/core/impl/ThreadEntry.cpp>
|
||||
#include <ripple/core/impl/Workers.cpp>
|
||||
|
||||
#include <ripple/core/tests/Config.test.cpp>
|
||||
#include <ripple/core/tests/Coroutine.test.cpp>
|
||||
#include <ripple/core/tests/Stoppable.test.cpp>
|
||||
|
||||
|
||||
@@ -35,8 +35,3 @@
|
||||
#include <ripple/json/impl/Writer.cpp>
|
||||
#include <ripple/json/impl/Object.cpp>
|
||||
#include <ripple/json/impl/Output.cpp>
|
||||
|
||||
#include <ripple/json/tests/json_value.test.cpp>
|
||||
#include <ripple/json/tests/Object.test.cpp>
|
||||
#include <ripple/json/tests/Output.test.cpp>
|
||||
#include <ripple/json/tests/Writer.test.cpp>
|
||||
|
||||
@@ -32,10 +32,3 @@
|
||||
#include <ripple/ledger/impl/ReadView.cpp>
|
||||
#include <ripple/ledger/impl/TxMeta.cpp>
|
||||
#include <ripple/ledger/impl/View.cpp>
|
||||
|
||||
#include <ripple/ledger/tests/BookDirs_test.cpp>
|
||||
#include <ripple/ledger/tests/Directory_test.cpp>
|
||||
#include <ripple/ledger/tests/PaymentSandbox_test.cpp>
|
||||
#include <ripple/ledger/tests/SkipList_test.cpp>
|
||||
#include <ripple/ledger/tests/View_test.cpp>
|
||||
#include <ripple/ledger/tests/PendingSaves_test.cpp>
|
||||
|
||||
@@ -34,9 +34,3 @@
|
||||
#include <ripple/nodestore/impl/ManagerImp.cpp>
|
||||
#include <ripple/nodestore/impl/NodeObject.cpp>
|
||||
|
||||
#include <ripple/nodestore/tests/Backend.test.cpp>
|
||||
#include <ripple/nodestore/tests/Basics.test.cpp>
|
||||
#include <ripple/nodestore/tests/Database.test.cpp>
|
||||
#include <ripple/nodestore/tests/import_test.cpp>
|
||||
#include <ripple/nodestore/tests/Timing.test.cpp>
|
||||
#include <ripple/nodestore/tests/varint_test.cpp>
|
||||
|
||||
@@ -29,11 +29,6 @@
|
||||
#include <ripple/overlay/impl/TMHello.cpp>
|
||||
#include <ripple/overlay/impl/TrafficCount.cpp>
|
||||
|
||||
#include <ripple/overlay/tests/cluster_test.cpp>
|
||||
#include <ripple/overlay/tests/manifest_test.cpp>
|
||||
#include <ripple/overlay/tests/short_read.test.cpp>
|
||||
#include <ripple/overlay/tests/TMHello.test.cpp>
|
||||
|
||||
#if DOXYGEN
|
||||
#include <ripple/overlay/README.md>
|
||||
#endif
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
#include <ripple/peerfinder/sim/NodeSnapshot.h>
|
||||
#include <ripple/peerfinder/sim/Params.h>
|
||||
|
||||
#include <ripple/peerfinder/tests/Livecache.test.cpp>
|
||||
#include <ripple/peerfinder/tests/PeerFinder_test.cpp>
|
||||
|
||||
#if DOXYGEN
|
||||
#include <ripple/peerfinder/README.md>
|
||||
#endif
|
||||
|
||||
@@ -62,23 +62,6 @@
|
||||
#include <ripple/protocol/impl/STVector256.cpp>
|
||||
#include <ripple/protocol/impl/IOUAmount.cpp>
|
||||
|
||||
|
||||
#include <ripple/protocol/tests/BuildInfo.test.cpp>
|
||||
#include <ripple/protocol/tests/digest_test.cpp>
|
||||
#include <ripple/protocol/tests/InnerObjectFormats.test.cpp>
|
||||
#include <ripple/protocol/tests/IOUAmount.test.cpp>
|
||||
#include <ripple/protocol/tests/Issue.test.cpp>
|
||||
#include <ripple/protocol/tests/PublicKey_test.cpp>
|
||||
#include <ripple/protocol/tests/Quality.test.cpp>
|
||||
#include <ripple/protocol/tests/STAccount.test.cpp>
|
||||
#include <ripple/protocol/tests/Seed_test.cpp>
|
||||
#include <ripple/protocol/tests/SecretKey_test.cpp>
|
||||
#include <ripple/protocol/tests/STAmount.test.cpp>
|
||||
#include <ripple/protocol/tests/STObject.test.cpp>
|
||||
#include <ripple/protocol/tests/STTx.test.cpp>
|
||||
#include <ripple/protocol/tests/types_test.cpp>
|
||||
#include <ripple/protocol/tests/XRPAmount.test.cpp>
|
||||
|
||||
#if DOXYGEN
|
||||
#include <ripple/protocol/README.md>
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <ripple/resource/impl/Kind.h>
|
||||
#include <ripple/resource/impl/ResourceManager.cpp>
|
||||
#include <ripple/resource/impl/Tuning.h>
|
||||
#include <ripple/resource/tests/Logic.test.cpp>
|
||||
|
||||
#if DOXYGEN
|
||||
#include <ripple/resource/README.md>
|
||||
|
||||
@@ -95,19 +95,3 @@
|
||||
#include <ripple/rpc/impl/RPCHelpers.cpp>
|
||||
#include <ripple/rpc/impl/ServerHandlerImp.cpp>
|
||||
#include <ripple/rpc/impl/TransactionSign.cpp>
|
||||
|
||||
#include <ripple/rpc/tests/AccountInfo_test.cpp>
|
||||
#include <ripple/rpc/tests/AccountLinesRPC.test.cpp>
|
||||
#include <ripple/rpc/tests/AccountObjects_test.cpp>
|
||||
#include <ripple/rpc/tests/AccountOffers.test.cpp>
|
||||
#include <ripple/rpc/tests/AccountSet.test.cpp>
|
||||
#include <ripple/rpc/tests/Book.test.cpp>
|
||||
#include <ripple/rpc/tests/JSONRPC.test.cpp>
|
||||
#include <ripple/rpc/tests/GatewayBalances.test.cpp>
|
||||
#include <ripple/rpc/tests/LedgerRequestRPC.test.cpp>
|
||||
#include <ripple/rpc/tests/LedgerData.test.cpp>
|
||||
#include <ripple/rpc/tests/KeyGeneration.test.cpp>
|
||||
#include <ripple/rpc/tests/RobustTransaction.test.cpp>
|
||||
#include <ripple/rpc/tests/ServerInfo.test.cpp>
|
||||
#include <ripple/rpc/tests/Status.test.cpp>
|
||||
#include <ripple/rpc/tests/Subscribe.test.cpp>
|
||||
|
||||
@@ -25,5 +25,3 @@
|
||||
|
||||
#include <ripple/server/impl/JSONRPCUtil.cpp>
|
||||
#include <ripple/server/impl/Port.cpp>
|
||||
|
||||
#include <ripple/server/tests/Server_test.cpp>
|
||||
|
||||
@@ -25,6 +25,3 @@
|
||||
#include <ripple/shamap/impl/SHAMapNodeID.cpp>
|
||||
#include <ripple/shamap/impl/SHAMapSync.cpp>
|
||||
#include <ripple/shamap/impl/SHAMapTreeNode.cpp>
|
||||
#include <ripple/shamap/tests/FetchPack.test.cpp>
|
||||
#include <ripple/shamap/tests/SHAMap.test.cpp>
|
||||
#include <ripple/shamap/tests/SHAMapSync.test.cpp>
|
||||
|
||||
@@ -21,4 +21,3 @@
|
||||
|
||||
#include <ripple/core/impl/DummySociDynamicBackend.cpp>
|
||||
#include <ripple/core/impl/SociDB.cpp>
|
||||
#include <ripple/core/tests/SociDB.test.cpp>
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <ripple/test/jtx/impl/balance.cpp>
|
||||
#include <ripple/test/jtx/impl/delivermin.cpp>
|
||||
#include <ripple/test/jtx/impl/Env.cpp>
|
||||
#include <ripple/test/jtx/impl/Env_test.cpp>
|
||||
#include <ripple/test/jtx/impl/fee.cpp>
|
||||
#include <ripple/test/jtx/impl/flags.cpp>
|
||||
#include <ripple/test/jtx/impl/jtx_json.cpp>
|
||||
@@ -47,9 +46,6 @@
|
||||
#include <ripple/test/jtx/impl/utility.cpp>
|
||||
|
||||
#include <ripple/test/mao/impl/Net.cpp>
|
||||
|
||||
#include <ripple/test/impl/BasicNetwork_test.cpp>
|
||||
#include <ripple/test/impl/JSONRPCClient.cpp>
|
||||
#include <ripple/test/impl/ManualTimeKeeper.cpp>
|
||||
#include <ripple/test/impl/WSClient.cpp>
|
||||
#include <ripple/test/impl/WSClient_test.cpp>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/xor_shift_engine.h>
|
||||
|
||||
260
src/test/beast/SemanticVersion_test.cpp
Normal file
260
src/test/beast/SemanticVersion_test.cpp
Normal file
@@ -0,0 +1,260 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/core/SemanticVersion.h>
|
||||
namespace beast {
|
||||
|
||||
class SemanticVersion_test : public unit_test::suite
|
||||
{
|
||||
using identifier_list = SemanticVersion::identifier_list;
|
||||
|
||||
public:
|
||||
void checkPass(std::string const& input, bool shouldPass = true)
|
||||
{
|
||||
SemanticVersion v;
|
||||
|
||||
if (shouldPass)
|
||||
{
|
||||
BEAST_EXPECT(v.parse(input));
|
||||
BEAST_EXPECT(v.print() == input);
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(!v.parse(input));
|
||||
}
|
||||
}
|
||||
|
||||
void checkFail(std::string const& input)
|
||||
{
|
||||
checkPass(input, false);
|
||||
}
|
||||
|
||||
// check input and input with appended metadata
|
||||
void checkMeta(std::string const& input, bool shouldPass)
|
||||
{
|
||||
checkPass(input, shouldPass);
|
||||
|
||||
checkPass(input + "+a", shouldPass);
|
||||
checkPass(input + "+1", shouldPass);
|
||||
checkPass(input + "+a.b", shouldPass);
|
||||
checkPass(input + "+ab.cd", shouldPass);
|
||||
|
||||
checkFail(input + "!");
|
||||
checkFail(input + "+");
|
||||
checkFail(input + "++");
|
||||
checkFail(input + "+!");
|
||||
checkFail(input + "+.");
|
||||
checkFail(input + "+a.!");
|
||||
}
|
||||
|
||||
void checkMetaFail(std::string const& input)
|
||||
{
|
||||
checkMeta(input, false);
|
||||
}
|
||||
|
||||
// check input, input with appended release data,
|
||||
// input with appended metadata, and input with both
|
||||
// appended release data and appended metadata
|
||||
//
|
||||
void checkRelease(std::string const& input, bool shouldPass = true)
|
||||
{
|
||||
checkMeta(input, shouldPass);
|
||||
|
||||
checkMeta(input + "-1", shouldPass);
|
||||
checkMeta(input + "-a", shouldPass);
|
||||
checkMeta(input + "-a1", shouldPass);
|
||||
checkMeta(input + "-a1.b1", shouldPass);
|
||||
checkMeta(input + "-ab.cd", shouldPass);
|
||||
checkMeta(input + "--", shouldPass);
|
||||
|
||||
checkMetaFail(input + "+");
|
||||
checkMetaFail(input + "!");
|
||||
checkMetaFail(input + "-");
|
||||
checkMetaFail(input + "-!");
|
||||
checkMetaFail(input + "-.");
|
||||
checkMetaFail(input + "-a.!");
|
||||
checkMetaFail(input + "-0.a");
|
||||
}
|
||||
|
||||
// Checks the major.minor.version string alone and with all
|
||||
// possible combinations of release identifiers and metadata.
|
||||
//
|
||||
void check(std::string const& input, bool shouldPass = true)
|
||||
{
|
||||
checkRelease(input, shouldPass);
|
||||
}
|
||||
|
||||
void negcheck(std::string const& input)
|
||||
{
|
||||
check(input, false);
|
||||
}
|
||||
|
||||
void testParse()
|
||||
{
|
||||
testcase("parsing");
|
||||
|
||||
check("0.0.0");
|
||||
check("1.2.3");
|
||||
check("2147483647.2147483647.2147483647"); // max int
|
||||
|
||||
// negative values
|
||||
negcheck("-1.2.3");
|
||||
negcheck("1.-2.3");
|
||||
negcheck("1.2.-3");
|
||||
|
||||
// missing parts
|
||||
negcheck("");
|
||||
negcheck("1");
|
||||
negcheck("1.");
|
||||
negcheck("1.2");
|
||||
negcheck("1.2.");
|
||||
negcheck(".2.3");
|
||||
|
||||
// whitespace
|
||||
negcheck(" 1.2.3");
|
||||
negcheck("1 .2.3");
|
||||
negcheck("1.2 .3");
|
||||
negcheck("1.2.3 ");
|
||||
|
||||
// leading zeroes
|
||||
negcheck("01.2.3");
|
||||
negcheck("1.02.3");
|
||||
negcheck("1.2.03");
|
||||
}
|
||||
|
||||
static identifier_list ids()
|
||||
{
|
||||
return identifier_list();
|
||||
}
|
||||
|
||||
static identifier_list ids(
|
||||
std::string const& s1)
|
||||
{
|
||||
identifier_list v;
|
||||
v.push_back(s1);
|
||||
return v;
|
||||
}
|
||||
|
||||
static identifier_list ids(
|
||||
std::string const& s1, std::string const& s2)
|
||||
{
|
||||
identifier_list v;
|
||||
v.push_back(s1);
|
||||
v.push_back(s2);
|
||||
return v;
|
||||
}
|
||||
|
||||
static identifier_list ids(
|
||||
std::string const& s1, std::string const& s2, std::string const& s3)
|
||||
{
|
||||
identifier_list v;
|
||||
v.push_back(s1);
|
||||
v.push_back(s2);
|
||||
v.push_back(s3);
|
||||
return v;
|
||||
}
|
||||
|
||||
// Checks the decomposition of the input into appropriate values
|
||||
void checkValues(std::string const& input,
|
||||
int majorVersion,
|
||||
int minorVersion,
|
||||
int patchVersion,
|
||||
identifier_list const& preReleaseIdentifiers = identifier_list(),
|
||||
identifier_list const& metaData = identifier_list())
|
||||
{
|
||||
SemanticVersion v;
|
||||
|
||||
BEAST_EXPECT(v.parse(input));
|
||||
|
||||
BEAST_EXPECT(v.majorVersion == majorVersion);
|
||||
BEAST_EXPECT(v.minorVersion == minorVersion);
|
||||
BEAST_EXPECT(v.patchVersion == patchVersion);
|
||||
|
||||
BEAST_EXPECT(v.preReleaseIdentifiers == preReleaseIdentifiers);
|
||||
BEAST_EXPECT(v.metaData == metaData);
|
||||
}
|
||||
|
||||
void testValues()
|
||||
{
|
||||
testcase("values");
|
||||
|
||||
checkValues("0.1.2", 0, 1, 2);
|
||||
checkValues("1.2.3", 1, 2, 3);
|
||||
checkValues("1.2.3-rc1", 1, 2, 3, ids("rc1"));
|
||||
checkValues("1.2.3-rc1.debug", 1, 2, 3, ids("rc1", "debug"));
|
||||
checkValues("1.2.3-rc1.debug.asm", 1, 2, 3, ids("rc1", "debug", "asm"));
|
||||
checkValues("1.2.3+full", 1, 2, 3, ids(), ids("full"));
|
||||
checkValues("1.2.3+full.prod", 1, 2, 3, ids(), ids("full", "prod"));
|
||||
checkValues("1.2.3+full.prod.x86", 1, 2, 3, ids(), ids("full", "prod", "x86"));
|
||||
checkValues("1.2.3-rc1.debug.asm+full.prod.x86", 1, 2, 3,
|
||||
ids("rc1", "debug", "asm"), ids("full", "prod", "x86"));
|
||||
}
|
||||
|
||||
// makes sure the left version is less than the right
|
||||
void checkLessInternal(std::string const& lhs, std::string const& rhs)
|
||||
{
|
||||
SemanticVersion left;
|
||||
SemanticVersion right;
|
||||
|
||||
BEAST_EXPECT(left.parse(lhs));
|
||||
BEAST_EXPECT(right.parse(rhs));
|
||||
|
||||
BEAST_EXPECT(compare(left, left) == 0);
|
||||
BEAST_EXPECT(compare(right, right) == 0);
|
||||
BEAST_EXPECT(compare(left, right) < 0);
|
||||
BEAST_EXPECT(compare(right, left) > 0);
|
||||
|
||||
BEAST_EXPECT(left < right);
|
||||
BEAST_EXPECT(right > left);
|
||||
BEAST_EXPECT(left == left);
|
||||
BEAST_EXPECT(right == right);
|
||||
}
|
||||
|
||||
void checkLess(std::string const& lhs, std::string const& rhs)
|
||||
{
|
||||
checkLessInternal(lhs, rhs);
|
||||
checkLessInternal(lhs + "+meta", rhs);
|
||||
checkLessInternal(lhs, rhs + "+meta");
|
||||
checkLessInternal(lhs + "+meta", rhs + "+meta");
|
||||
}
|
||||
|
||||
void testCompare()
|
||||
{
|
||||
testcase("comparisons");
|
||||
|
||||
checkLess("1.0.0-alpha", "1.0.0-alpha.1");
|
||||
checkLess("1.0.0-alpha.1", "1.0.0-alpha.beta");
|
||||
checkLess("1.0.0-alpha.beta", "1.0.0-beta");
|
||||
checkLess("1.0.0-beta", "1.0.0-beta.2");
|
||||
checkLess("1.0.0-beta.2", "1.0.0-beta.11");
|
||||
checkLess("1.0.0-beta.11", "1.0.0-rc.1");
|
||||
checkLess("1.0.0-rc.1", "1.0.0");
|
||||
checkLess("0.9.9", "1.0.0");
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
testParse();
|
||||
testValues();
|
||||
testCompare();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(SemanticVersion, beast_core, beast);
|
||||
}
|
||||
68
src/test/beast/beast_Debug_test.cpp
Normal file
68
src/test/beast/beast_Debug_test.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/utility/Debug.h>
|
||||
namespace beast {
|
||||
|
||||
// A simple unit test to determine the diagnostic settings in a build.
|
||||
//
|
||||
class Debug_test : public unit_test::suite
|
||||
{
|
||||
public:
|
||||
static int envDebug()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int beastDebug()
|
||||
{
|
||||
#ifdef BEAST_DEBUG
|
||||
return BEAST_DEBUG;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int beastForceDebug()
|
||||
{
|
||||
#ifdef BEAST_FORCE_DEBUG
|
||||
return BEAST_FORCE_DEBUG;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
log <<
|
||||
"_DEBUG = " << envDebug() << '\n' <<
|
||||
"BEAST_DEBUG = " << beastDebug() << '\n' <<
|
||||
"BEAST_FORCE_DEBUG = " << beastForceDebug() << '\n' <<
|
||||
"sizeof(std::size_t) = " << sizeof(std::size_t) << std::endl;
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Debug, utility, beast);
|
||||
|
||||
}
|
||||
218
src/test/beast/beast_PropertyStream_test.cpp
Normal file
218
src/test/beast/beast_PropertyStream_test.cpp
Normal file
@@ -0,0 +1,218 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/utility/PropertyStream.h>
|
||||
namespace beast {
|
||||
|
||||
class PropertyStream_test : public unit_test::suite
|
||||
{
|
||||
public:
|
||||
using Source = PropertyStream::Source;
|
||||
|
||||
void test_peel_name(std::string s, std::string const& expected,
|
||||
std::string const& expected_remainder)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string const peeled_name = Source::peel_name(&s);
|
||||
BEAST_EXPECT(peeled_name == expected);
|
||||
BEAST_EXPECT(s == expected_remainder);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_peel_leading_slash(std::string s, std::string const& expected,
|
||||
bool should_be_found)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool const found(Source::peel_leading_slash(&s));
|
||||
BEAST_EXPECT(found == should_be_found);
|
||||
BEAST_EXPECT(s == expected);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_peel_trailing_slashstar(std::string s,
|
||||
std::string const& expected_remainder, bool should_be_found)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool const found(Source::peel_trailing_slashstar(&s));
|
||||
BEAST_EXPECT(found == should_be_found);
|
||||
BEAST_EXPECT(s == expected_remainder);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find_one(Source& root, Source* expected, std::string const& name)
|
||||
{
|
||||
try
|
||||
{
|
||||
Source* source(root.find_one(name));
|
||||
BEAST_EXPECT(source == expected);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find_path(Source& root, std::string const& path,
|
||||
Source* expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Source* source(root.find_path(path));
|
||||
BEAST_EXPECT(source == expected);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find_one_deep(Source& root, std::string const& name,
|
||||
Source* expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
Source* source(root.find_one_deep(name));
|
||||
BEAST_EXPECT(source == expected);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void test_find(Source& root, std::string path, Source* expected,
|
||||
bool expected_star)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto const result(root.find(path));
|
||||
BEAST_EXPECT(result.first == expected);
|
||||
BEAST_EXPECT(result.second == expected_star);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("unhandled exception");;
|
||||
}
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
Source a("a");
|
||||
Source b("b");
|
||||
Source c("c");
|
||||
Source d("d");
|
||||
Source e("e");
|
||||
Source f("f");
|
||||
Source g("g");
|
||||
|
||||
//
|
||||
// a { b { d { f }, e }, c { g } }
|
||||
//
|
||||
|
||||
a.add(b);
|
||||
a.add(c);
|
||||
c.add(g);
|
||||
b.add(d);
|
||||
b.add(e);
|
||||
d.add(f);
|
||||
|
||||
testcase("peel_name");
|
||||
test_peel_name("a", "a", "");
|
||||
test_peel_name("foo/bar", "foo", "bar");
|
||||
test_peel_name("foo/goo/bar", "foo", "goo/bar");
|
||||
test_peel_name("", "", "");
|
||||
|
||||
testcase("peel_leading_slash");
|
||||
test_peel_leading_slash("foo/", "foo/", false);
|
||||
test_peel_leading_slash("foo", "foo", false);
|
||||
test_peel_leading_slash("/foo/", "foo/", true);
|
||||
test_peel_leading_slash("/foo", "foo", true);
|
||||
|
||||
testcase("peel_trailing_slashstar");
|
||||
test_peel_trailing_slashstar("/foo/goo/*", "/foo/goo", true);
|
||||
test_peel_trailing_slashstar("foo/goo/*", "foo/goo", true);
|
||||
test_peel_trailing_slashstar("/foo/goo/", "/foo/goo", false);
|
||||
test_peel_trailing_slashstar("foo/goo", "foo/goo", false);
|
||||
test_peel_trailing_slashstar("", "", false);
|
||||
test_peel_trailing_slashstar("/", "", false);
|
||||
test_peel_trailing_slashstar("/*", "", true);
|
||||
test_peel_trailing_slashstar("//", "/", false);
|
||||
test_peel_trailing_slashstar("**", "*", true);
|
||||
test_peel_trailing_slashstar("*/", "*", false);
|
||||
|
||||
testcase("find_one");
|
||||
test_find_one(a, &b, "b");
|
||||
test_find_one(a, nullptr, "d");
|
||||
test_find_one(b, &e, "e");
|
||||
test_find_one(d, &f, "f");
|
||||
|
||||
testcase("find_path");
|
||||
test_find_path(a, "a", nullptr);
|
||||
test_find_path(a, "e", nullptr);
|
||||
test_find_path(a, "a/b", nullptr);
|
||||
test_find_path(a, "a/b/e", nullptr);
|
||||
test_find_path(a, "b/e/g", nullptr);
|
||||
test_find_path(a, "b/e/f", nullptr);
|
||||
test_find_path(a, "b", &b);
|
||||
test_find_path(a, "b/e", &e);
|
||||
test_find_path(a, "b/d/f", &f);
|
||||
|
||||
testcase("find_one_deep");
|
||||
test_find_one_deep(a, "z", nullptr);
|
||||
test_find_one_deep(a, "g", &g);
|
||||
test_find_one_deep(a, "b", &b);
|
||||
test_find_one_deep(a, "d", &d);
|
||||
test_find_one_deep(a, "f", &f);
|
||||
|
||||
testcase("find");
|
||||
test_find(a, "", &a, false);
|
||||
test_find(a, "*", &a, true);
|
||||
test_find(a, "/b", &b, false);
|
||||
test_find(a, "b", &b, false);
|
||||
test_find(a, "d", &d, false);
|
||||
test_find(a, "/b*", &b, true);
|
||||
test_find(a, "b*", &b, true);
|
||||
test_find(a, "d*", &d, true);
|
||||
test_find(a, "/b/*", &b, true);
|
||||
test_find(a, "b/*", &b, true);
|
||||
test_find(a, "d/*", &d, true);
|
||||
test_find(a, "a", nullptr, false);
|
||||
test_find(a, "/d", nullptr, false);
|
||||
test_find(a, "/d*", nullptr, true);
|
||||
test_find(a, "/d/*", nullptr, true);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(PropertyStream, utility, beast);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ int signum (adl_tester)
|
||||
}
|
||||
|
||||
|
||||
namespace detail {
|
||||
namespace inner_adl_test {
|
||||
|
||||
struct adl_tester2 {};
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
test_adl ()
|
||||
{
|
||||
expect (adl_tester{} == zero, "ADL failure!");
|
||||
expect (detail::adl_tester2{} == zero, "ADL failure!");
|
||||
expect (inner_adl_test::adl_tester2{} == zero, "ADL failure!");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include <ripple/beast/hash/impl/spookyv2.h>
|
||||
#include <ripple/beast/hash/endian.h>
|
||||
#include <ripple/beast/hash/tests/hash_metrics.h>
|
||||
#include <ripple/beast/hash/hash_append.h>
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/hash/endian.h>
|
||||
#include <ripple/beast/hash/fnv1a.h>
|
||||
#include <ripple/beast/hash/siphash.h>
|
||||
#include <ripple/beast/hash/xxhasher.h>
|
||||
@@ -161,11 +161,11 @@ public:
|
||||
checkValues (s);
|
||||
}
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
namespace bfs = boost::filesystem;
|
||||
// Remove the database
|
||||
path dbPath (sc.connectionString ());
|
||||
if (is_regular_file (dbPath))
|
||||
remove (dbPath);
|
||||
bfs::path dbPath (sc.connectionString ());
|
||||
if (bfs::is_regular_file (dbPath))
|
||||
bfs::remove (dbPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,11 +289,11 @@ public:
|
||||
#endif
|
||||
}
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
namespace bfs = boost::filesystem;
|
||||
// Remove the database
|
||||
path dbPath (sc.connectionString ());
|
||||
if (is_regular_file (dbPath))
|
||||
remove (dbPath);
|
||||
bfs::path dbPath (sc.connectionString ());
|
||||
if (bfs::is_regular_file (dbPath))
|
||||
bfs::remove (dbPath);
|
||||
}
|
||||
}
|
||||
void testSQLiteDeleteWithSubselect()
|
||||
@@ -355,11 +355,11 @@ public:
|
||||
BEAST_EXPECT(ledgersLS.size () == numRows &&
|
||||
validationsLH.size () == numRows);
|
||||
}
|
||||
using namespace boost::filesystem;
|
||||
namespace bfs = boost::filesystem;
|
||||
// Remove the database
|
||||
path dbPath (sc.connectionString ());
|
||||
if (is_regular_file (dbPath))
|
||||
remove (dbPath);
|
||||
bfs::path dbPath (sc.connectionString ());
|
||||
if (bfs::is_regular_file (dbPath))
|
||||
bfs::remove (dbPath);
|
||||
}
|
||||
void testSQLite ()
|
||||
{
|
||||
87
src/test/core/Workers_test.cpp
Normal file
87
src/test/core/Workers_test.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/core/impl/Workers.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class Workers_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
struct TestCallback : Workers::Callback
|
||||
{
|
||||
explicit TestCallback(int count_)
|
||||
: finished(false, count_ == 0)
|
||||
, count(count_)
|
||||
{
|
||||
}
|
||||
|
||||
void processTask()
|
||||
{
|
||||
if (--count == 0)
|
||||
finished.signal();
|
||||
}
|
||||
|
||||
beast::WaitableEvent finished;
|
||||
std::atomic <int> count;
|
||||
};
|
||||
|
||||
void testThreads(int const threadCount)
|
||||
{
|
||||
testcase("threadCount = " + std::to_string(threadCount));
|
||||
|
||||
TestCallback cb(threadCount);
|
||||
|
||||
Workers w(cb, "Test", 0);
|
||||
BEAST_EXPECT(w.getNumberOfThreads() == 0);
|
||||
|
||||
w.setNumberOfThreads(threadCount);
|
||||
BEAST_EXPECT(w.getNumberOfThreads() == threadCount);
|
||||
|
||||
for (int i = 0; i < threadCount; ++i)
|
||||
w.addTask();
|
||||
|
||||
// 10 seconds should be enough to finish on any system
|
||||
//
|
||||
bool signaled = cb.finished.wait(10 * 1000);
|
||||
BEAST_EXPECT(signaled);
|
||||
|
||||
w.pauseAllThreadsAndWait();
|
||||
|
||||
// We had better finished all our work!
|
||||
BEAST_EXPECT(cb.count.load() == 0);
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
testThreads(0);
|
||||
testThreads(1);
|
||||
testThreads(2);
|
||||
testThreads(4);
|
||||
testThreads(16);
|
||||
testThreads(64);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(Workers, core, ripple);
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user