Skip to content

Commit

Permalink
Added missing commands file
Browse files Browse the repository at this point in the history
Added checks for errors when calling Parse
Removed blocks on sending multiple client signon messages during testing
Fix issue with using rapidjson::Document move constructor in Metadata where a new allocator was not created
  • Loading branch information
langmm committed Aug 31, 2023
1 parent afc3519 commit fa4e5a7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
7 changes: 0 additions & 7 deletions communication/communicators/ClientComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,11 @@ bool ClientComm::signon(const Header& header, Comm_t* async_comm) {
while ((!requests.signon_complete) &&
(tout < 0 ||
(((double)(clock() - start))*1000000/CLOCKS_PER_SEC) < tout)) {
#ifdef YGG_TEST
// Prevent sending extra SIGNON during testing
if (!requests.signonSent()) {
#endif // YGG_TEST
ygglog_debug << "ClientComm(" << name << ")::signon: Sending signon" << std::endl;
if (async_comm->send(YGG_CLIENT_SIGNON, YGG_CLIENT_SIGNON_LEN) < 0) {
ygglog_error << "ClientComm(" << name << ")::signon: Error in sending sign-on" << std::endl;
return false;
}
#ifdef YGG_TEST
}
#endif // YGG_TEST
if ((flags & COMM_FLAG_ASYNC_WRAPPED) && (async_comm != this))
return true;
if (requests.activeComm()->comm_nmsg(RECV) > 0) {
Expand Down
7 changes: 7 additions & 0 deletions communication/datatypes/dtype_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ extern "C" {
generic_t out = init_generic();
rapidjson::Document sd;
sd.Parse(schema);
if (sd.HasParseError()) {
destroy_generic(&out);
return out;
}
rapidjson::SchemaDocument s(sd);
rapidjson::SchemaValidator validator(s);
rapidjson::Document* x = new rapidjson::Document();
Expand Down Expand Up @@ -279,6 +283,9 @@ extern "C" {
rapidjson::Document* x_obj = (rapidjson::Document*)(x.obj);
x_obj->SetNull();
x_obj->Parse(json);
if (x_obj->HasParseError()) {
ygglog_throw_error_c("generic_set_json: Error parsing string %s", json);
}
} catch(...) {
ygglog_error_c("generic_set_json: C++ exception thrown");
return GENERIC_ERROR_;
Expand Down
8 changes: 6 additions & 2 deletions communication/utils/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void Metadata::_init(bool use_generic) {
// }
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
Metadata::Metadata(Metadata&& rhs) :
metadata(std::move(rhs.metadata)), schema(NULL) {
metadata(), schema(NULL) {
metadata.Swap(rhs.metadata);
_update_schema();
rhs._update_schema();
}
Expand All @@ -128,7 +129,7 @@ Metadata& Metadata::operator=(Metadata&& rhs) {
}
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
Metadata& Metadata::operator=(Metadata& rhs) {
metadata = std::move(rhs.metadata);
metadata.Swap(rhs.metadata);
_update_schema();
rhs._update_schema();
return *this;
Expand Down Expand Up @@ -204,6 +205,9 @@ void Metadata::Normalize() {
void Metadata::fromSchema(const std::string schemaStr, bool use_generic) {
rapidjson::Document d;
d.Parse(schemaStr.c_str());
if (d.HasParseError()) {
ygglog_throw_error_c("Metadata::fromSchema: Error parsing string: %s", schemaStr.c_str());
}
fromSchema(d, false, use_generic);
if (hasType()) {
typename rapidjson::Value::MemberIterator it = schema->FindMember(rapidjson::Document::GetTypeString());
Expand Down
1 change: 1 addition & 0 deletions gdb_commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run
8 changes: 6 additions & 2 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DO_PYTHON=""
WITH_ASAN=""
DONT_BUILD=""
NO_CORE=""
CMAKE_FLAGS="" # -DRAPIDJSON_INCLUDE_DIRS=/Users/langmm/rapidjson/include"
CMAKE_FLAGS="-DRAPIDJSON_INCLUDE_DIRS=/Users/langmm/rapidjson/include"
WITH_LLDB=""

while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -46,7 +46,11 @@ if [ -z "$DO_PYTHON" ]; then
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../devel -DYGG_ENABLE_COVERAGE=OFF -DYGG_SKIP_VALGRIND_TESTS=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DYGG_BUILD_TESTS=ON -DBUILD_PYTHON_LIBRARY=OFF $CMAKE_FLAGS
make
make test ARGS="--stop-on-failure"
if [ -n "$WITH_LLDB" ]; then
lldb -o 'run' -o 'quit' -- test/unittest
else
make test ARGS="--stop-on-failure"
fi
cd ../
else
if [ -n "$DONT_BUILD"]; then
Expand Down

0 comments on commit fa4e5a7

Please sign in to comment.