<commit_before>/*
 * Copyright 2012 Troels Blum <troels@blum.dk>
 *
 * This file is part of cphVB <http://code.google.com/p/cphvb/>.
 *
 * cphVB is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * cphVB is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with cphVB. If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <sstream>
#include <cassert>
#include "GenerateSourceCode.hpp"
#include "UserFunctionReduce.hpp"

cphvb_error cphvb_reduce(cphvb_userfunc* arg, void* ve_arg)
{
    cphvb_reduce_type* reduceDef = (cphvb_reduce_type*)arg;
    UserFuncArg* userFuncArg = (UserFuncArg*)ve_arg;
    assert(reduceDef->nout = 1);
    assert(reduceDef->nin = 1);
    assert(reduceDef->operand[0]->ndim + 1 == reduceDef->operand[1]->ndim);
    assert(reduceDef->operand[0]->type == reduceDef->operand[1]->type);
    assert(userFuncArg->operandBase.size() == 2);
    UserFunctionReduce::run(reduceDef, userFuncArg);
    return CPHVB_SUCCESS;
}

void UserFunctionReduce::run(cphvb_reduce_type* reduceDef, UserFuncArg* userFuncArg)
{
    Kernel kernel = UserFunctionReduce::generateKernel(reduceDef, userFuncArg);
    Kernel::Parameters kernelParameters;
    kernelParameters.push_back(std::make_pair(userFuncArg->operandBase[0], true));
    kernelParameters.push_back(std::make_pair(userFuncArg->operandBase[1], false));
    std::vector<cphvb_index> shape =
        std::vector<cphvb_index>(reduceDef->operand[0]->shape,
                                 reduceDef->operand[0]->shape + reduceDef->operand[0]->ndim);
    kernel.call(kernelParameters, shape);
}

Kernel UserFunctionReduce::generateKernel(cphvb_reduce_type* reduceDef, UserFuncArg* userFuncArg)
{
    std::stringstream ss;
    ss << "reduce" << kernel++;
    std::string code = UserFunctionReduce::generateCode(reduceDef, userFuncArg->operandBase, ss.str());
    std::vector<OCLtype> signature;
    signature.push_back(OCL_BUFFER);
    signature.push_back(OCL_BUFFER);
    return Kernel(userFuncArg->resourceManager, reduceDef->operand[0]->ndim , signature, code, ss.str());
}

std::string UserFunctionReduce::generateCode(cphvb_reduce_type* reduceDef,
                                             const std::vector<BaseArray*>& operandBase,
                                             const std::string& kernelName)
{
    cphvb_array* out = reduceDef->operand[0];
    cphvb_array* in = reduceDef->operand[1];
    std::stringstream source;
    std::vector<std::string> operands(3);
    operands[0] = "accu";
    operands[1] = "accu";
    operands[2] = "in[element]";
    source << "__kernel void " << kernelName << "(" <<
        " __global " << oclTypeStr(operandBase[0]->type()) << "* out\n"
        "                     , __global " << oclTypeStr(operandBase[1]->type()) << "* in"
        //", __local  " << oclTypeStr(oclType(CPHVB_INDEX)) << " axis"
        ")\n{\n";

    source << "\tsize_t element = ";
    int a = 0;
    int i = 0;
    if (i == reduceDef->axis)
        ++a;
    source << "get_global_id(" << i << ")*" << in->stride[a++];
    for (++i; a < out->ndim; ++i)
    {
        if (i == reduceDef->axis)
            ++a;
        source << " + get_global_id(" << i << ")*" << in->stride[a++];
    }
    source << " + " << in->start << ";\n";
    source << "\t" << oclTypeStr(operandBase[0]->type()) << " accu = in[element];\n";
    source << "\tfor (int i = 1; i < " << in->shape[reduceDef->axis] << "; ++i)\n\t{\n";
    source << "\t\telement += " << in->stride[reduceDef->axis] << ";\n\t";
    generateInstructionSource(reduceDef->opcode, operands, source);
    source << "\t}\n\tout[";
    i = 0;
    source << "get_global_id(" << i << ")*" << out->stride[i];
    for (++i; i < out->ndim; ++i)
    {
        source << " + get_global_id(" << i << ")*" << out->stride[i];
    }
    source << " + " << out->start << "] = accu;\n}\n";
    return source.str();
}
<commit_msg>Bugfix Reduce: NOw works correctly up to 4 dim<commit_after>/*
 * Copyright 2012 Troels Blum <troels@blum.dk>
 *
 * This file is part of cphVB <http://code.google.com/p/cphvb/>.
 *
 * cphVB is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * cphVB is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with cphVB. If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <sstream>
#include <cassert>
#include "GenerateSourceCode.hpp"
#include "UserFunctionReduce.hpp"

cphvb_error cphvb_reduce(cphvb_userfunc* arg, void* ve_arg)
{
    cphvb_reduce_type* reduceDef = (cphvb_reduce_type*)arg;
    UserFuncArg* userFuncArg = (UserFuncArg*)ve_arg;
    assert(reduceDef->nout = 1);
    assert(reduceDef->nin = 1);
    assert(reduceDef->operand[0]->ndim + 1 == reduceDef->operand[1]->ndim);
    assert(reduceDef->operand[0]->type == reduceDef->operand[1]->type);
    assert(userFuncArg->operandBase.size() == 2);
    UserFunctionReduce::run(reduceDef, userFuncArg);
    return CPHVB_SUCCESS;
}

void UserFunctionReduce::run(cphvb_reduce_type* reduceDef, UserFuncArg* userFuncArg)
{
    Kernel kernel = UserFunctionReduce::generateKernel(reduceDef, userFuncArg);
    Kernel::Parameters kernelParameters;
    kernelParameters.push_back(std::make_pair(userFuncArg->operandBase[0], true));
    kernelParameters.push_back(std::make_pair(userFuncArg->operandBase[1], false));
    std::vector<cphvb_index> shape =
        std::vector<cphvb_index>(reduceDef->operand[0]->shape,
                                 reduceDef->operand[0]->shape + reduceDef->operand[0]->ndim);
    kernel.call(kernelParameters, shape);
}

Kernel UserFunctionReduce::generateKernel(cphvb_reduce_type* reduceDef, UserFuncArg* userFuncArg)
{
    std::stringstream ss;
    ss << "reduce" << kernel++;
    std::string code = UserFunctionReduce::generateCode(reduceDef, userFuncArg->operandBase, ss.str());
    std::vector<OCLtype> signature;
    signature.push_back(OCL_BUFFER);
    signature.push_back(OCL_BUFFER);
    return Kernel(userFuncArg->resourceManager, reduceDef->operand[0]->ndim , signature, code, ss.str());
}

std::string UserFunctionReduce::generateCode(cphvb_reduce_type* reduceDef,
                                             const std::vector<BaseArray*>& operandBase,
                                             const std::string& kernelName)
{
    cphvb_array* out = reduceDef->operand[0];
    cphvb_array* in = reduceDef->operand[1];
    std::stringstream source;
    std::vector<std::string> operands(3);
    operands[0] = "accu";
    operands[1] = "accu";
    operands[2] = "in[element]";
    source << "__kernel void " << kernelName << "(" <<
        " __global " << oclTypeStr(operandBase[0]->type()) << "* out\n"
        "                     , __global " << oclTypeStr(operandBase[1]->type()) << "* in"
        //", __local  " << oclTypeStr(oclType(CPHVB_INDEX)) << " axis"
        ")\n{\n";

    source << "\tsize_t element = ";
    int i = 0;
    int a = (reduceDef->axis)?0:1;
    source << "get_global_id(" << i++ << ")*" << in->stride[a++];
    if (i == reduceDef->axis)
        ++a;
    while (a < in->ndim)
    {
        source << " + get_global_id(" << i++ << ")*" << in->stride[a++];
        if (i == reduceDef->axis)
            ++a;
    }
    source << " + " << in->start << ";\n";
    source << "\t" << oclTypeStr(operandBase[0]->type()) << " accu = in[element];\n";
    source << "\tfor (int i = 1; i < " << in->shape[reduceDef->axis] << "; ++i)\n\t{\n";
    source << "\t\telement += " << in->stride[reduceDef->axis] << ";\n\t";
    generateInstructionSource(reduceDef->opcode, operands, source);
    source << "\t}\n\tout[";
    i = 0;
    source << "get_global_id(" << i << ")*" << out->stride[i];
    for (++i; i < out->ndim; ++i)
    {
        source << " + get_global_id(" << i << ")*" << out->stride[i];
    }
    source << " + " << out->start << "] = accu;\n}\n";
    return source.str();
}
<|endoftext|>


<commit_before>#ifndef DUNE_STUFF_LA_CONTAINER_SEPARABLE_HH
#define DUNE_STUFF_LA_CONTAINER_SEPARABLE_HH

#include <dune/common/exceptions.hh>
#include <dune/common/shared_ptr.hh>

#include <dune/stuff/la/container/eigen.hh>
#include <dune/stuff/common/parameter.hh>
#include <dune/stuff/function/parametric/separable/coefficient.hh>

namespace Dune {
namespace Stuff {
namespace LA {
namespace Container {

#if HAVE_EIGEN
template< class EigenContainerImp >
class Separable
{
public:
  typedef Separable< EigenContainerImp >  ThisType;

  typedef typename LA::Container::EigenInterface< typename EigenContainerImp::Traits >::derived_type  ComponentType;
  typedef Stuff::Function::Coefficient< typename EigenContainerImp::ElementType >                     CoefficientType;

  typedef typename Stuff::Common::Parameter::Type ParamType;

public:
  Separable(const size_t _paramSize,
            std::vector< Dune::shared_ptr< ComponentType > >& _components,
            const std::vector< Dune::shared_ptr< const CoefficientType > >& _coefficients)
    : paramSize_(_paramSize)
    , components_(_components)
    , coefficients_(_coefficients)
  {
    // sanity checks
    if (components_.size() < 1)
      DUNE_THROW(Dune::RangeError,
                 "\nERROR: not enough '_components' given!");
    if (!(coefficients_.size() == components_.size()
          || coefficients_.size() == (components_.size() - 1)))
      DUNE_THROW(Dune::RangeError,
                 "\nERROR: wrong number of 'coefficients_' given!");
    if (coefficients_.size() == 0) {
      if (paramSize_ > 0)
        DUNE_THROW(Dune::RangeError,
                   "\nERROR: '_paramSize' has to be zero!");
    } else {
      if (paramSize_ < 1)
        DUNE_THROW(Dune::RangeError,
                   "\nERROR: '_paramSize' has to be positive!");
    }
  }

  Separable(Dune::shared_ptr< ComponentType > _component)
    : paramSize_(0)
  {
    components_.push_back(_component);
  }

  bool parametric() const
  {
    return numCoefficients() > 0;
  }

  const size_t paramSize() const
  {
    return paramSize_;
  }

  const size_t numComponents() const
  {
    return components_.size();
  }

  std::vector< Dune::shared_ptr< ComponentType > > components()
  {
    return components_;
  }

  const std::vector< Dune::shared_ptr< ComponentType > >& components() const
  {
    return components_;
  }

  const size_t numCoefficients() const
  {
    return coefficients_.size();
  }

  const std::vector< Dune::shared_ptr< const CoefficientType > >& coefficients() const
  {
    return coefficients_;
  }

  Dune::shared_ptr< ComponentType > fix(const ParamType& _mu) const
  {
    assert(false && "Implement me!");
//    assert(parametric() && "Call fix() instead of fix(mu) for nonparametric container!");
//    assert(mu.size() == BaseType::paramSize());
//    Dune::shared_ptr< ComponentType > ret = Dune::make_shared< ComponentType >(*(BaseType::components()[0]));
//    // since we are parametric, at leas one coefficient has to exist
//    ParamType coefficient = BaseType::coefficients()[0]->evaluate(mu);
//    assert(coefficient.size() == 1);
//    ret->backend() *= coefficient[0];
//    size_t qq = 1;
//    for (; qq < BaseType::numCoefficients(); ++qq) {
//      coefficient = BaseType::coefficients()[qq]->evaluate(mu);
//      assert(coefficient.size() == 1);
//      ret->backend() += BaseType::components()[qq]->backend() * coefficient[0];
//    }
//    if (BaseType::numComponents() > qq)
//      ret->backend() += BaseType::components()[qq + 1]->backend();
//    return ret;
  } // Dune::shared_ptr< ComponentType > fix(const ParamType& mu) const

private:
  const size_t paramSize_;
  std::vector< Dune::shared_ptr< ComponentType > > components_;
  const std::vector< Dune::shared_ptr< const CoefficientType > > coefficients_;
}; // class Separable
#endif // HAVE_EIGEN

} // namespace Container
} // namespace LA
} // namespace Stuff
} // namespace Dune

#endif // DUNE_STUFF_LA_CONTAINER_SEPARABLE_HH
<commit_msg>[la.container.separable] implemented fix() * still not superhappy about the fact, that we always return a copy, even if there is only one component * there should be a generic version which fails at compiletime and one for the eigen containers<commit_after>#ifndef DUNE_STUFF_LA_CONTAINER_SEPARABLE_HH
#define DUNE_STUFF_LA_CONTAINER_SEPARABLE_HH

#include <dune/common/exceptions.hh>
#include <dune/common/shared_ptr.hh>

#include <dune/stuff/la/container/eigen.hh>
#include <dune/stuff/common/parameter.hh>
#include <dune/stuff/function/parametric/separable/coefficient.hh>

namespace Dune {
namespace Stuff {
namespace LA {
namespace Container {

#if HAVE_EIGEN
template< class EigenContainerImp >
class Separable
{
public:
  typedef Separable< EigenContainerImp >  ThisType;

  typedef typename LA::Container::EigenInterface< typename EigenContainerImp::Traits >::derived_type  ComponentType;
  typedef Stuff::Function::Coefficient< typename EigenContainerImp::ElementType >                     CoefficientType;

  typedef typename Stuff::Common::Parameter::Type ParamType;

public:
  Separable(const size_t _paramSize,
            std::vector< Dune::shared_ptr< ComponentType > >& _components,
            const std::vector< Dune::shared_ptr< const CoefficientType > >& _coefficients)
    : paramSize_(_paramSize)
    , components_(_components)
    , coefficients_(_coefficients)
  {
    // sanity checks
    if (components_.size() < 1)
      DUNE_THROW(Dune::RangeError,
                 "\nERROR: not enough '_components' given!");
    if (!(coefficients_.size() == components_.size()
          || coefficients_.size() == (components_.size() - 1)))
      DUNE_THROW(Dune::RangeError,
                 "\nERROR: wrong number of 'coefficients_' given!");
    if (coefficients_.size() == 0) {
      if (paramSize_ > 0)
        DUNE_THROW(Dune::RangeError,
                   "\nERROR: '_paramSize' has to be zero!");
    } else {
      if (paramSize_ < 1)
        DUNE_THROW(Dune::RangeError,
                   "\nERROR: '_paramSize' has to be positive!");
    }
  }

  Separable(Dune::shared_ptr< ComponentType > _component)
    : paramSize_(0)
  {
    components_.push_back(_component);
  }

  bool parametric() const
  {
    return numCoefficients() > 0;
  }

  const size_t paramSize() const
  {
    return paramSize_;
  }

  const size_t numComponents() const
  {
    return components_.size();
  }

  std::vector< Dune::shared_ptr< ComponentType > > components()
  {
    return components_;
  }

  const std::vector< Dune::shared_ptr< ComponentType > >& components() const
  {
    return components_;
  }

  const size_t numCoefficients() const
  {
    return coefficients_.size();
  }

  const std::vector< Dune::shared_ptr< const CoefficientType > >& coefficients() const
  {
    return coefficients_;
  }

  Dune::shared_ptr< ComponentType > fix(const ParamType _mu = ParamType()) const
  {
    // in any case, there exists at least one component
    Dune::shared_ptr< ComponentType > ret = Dune::make_shared< ComponentType >(*(components_[0]));
    // if we are parametric, we have to do some more
    if (parametric()) {
      assert(_mu.size() == paramSize());
      // since we are parametric, at least one coefficient has to exist as well
      ret->backend() *= coefficients_[0]->evaluate(_mu);
      // sum over the rest of the component/coefficient combinations
      size_t qq = 1;
      for (; qq < numCoefficients(); ++qq)
        ret->backend() += components_[qq]->backend() * coefficients_[qq]->evaluate(_mu);
      // add the last lonely component if necesarry
      if (numComponents() > qq)
        ret->backend() += components_[qq + 1]->backend();
    } // if (parametric())
    return ret;
  } // Dune::shared_ptr< ComponentType > fix(const ParamType& mu) const

private:
  const size_t paramSize_;
  std::vector< Dune::shared_ptr< ComponentType > > components_;
  const std::vector< Dune::shared_ptr< const CoefficientType > > coefficients_;
}; // class Separable
#endif // HAVE_EIGEN

} // namespace Container
} // namespace LA
} // namespace Stuff
} // namespace Dune

#endif // DUNE_STUFF_LA_CONTAINER_SEPARABLE_HH
<|endoftext|>


<commit_before>/*
 * #%L
 * %%
 * Copyright (C) 2016 - 2016 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
#include "AbstractRobustnessTest.h"
#include "joynr/OnChangeSubscriptionQos.h"

using joynr::OnChangeSubscriptionQos;

class RobustnessTestProviderCrash : public AbstractRobustnessTest
{
};

TEST_F(RobustnessTestProviderCrash, call_methodWithStringParameters)
{
    callMethodWithStringParameters();
}

TEST_F(RobustnessTestProviderCrash, call_methodWithStringParametersAfterProviderRestart)
{
    killProvider();
    startProvider();
    callMethodWithStringParameters();
}

TEST_F(RobustnessTestProviderCrash, call_methodWithStringParametersBeforeProviderRestart)
{
    // kill the provider before the request is sent
    callMethodWithStringParametersBeforeCcOrProviderRestart(false, true);
}

template <typename T>
class MockSubscriptionListenerOneType : public joynr::ISubscriptionListener<T>
{
public:
    MOCK_METHOD1_T(onReceive, void(const T& value));
    MOCK_METHOD1(onError, void(const joynr::exceptions::JoynrRuntimeException&));
};

TEST_F(RobustnessTestProviderCrash, subscribeTo_broadcastWithSingleStringParameter)
{
    Semaphore semaphore(0);
    auto mockListener = std::make_shared<MockSubscriptionListenerOneType<std::string>>();

    // Use a semaphore to count and wait on calls to the mock listener
    EXPECT_CALL(*mockListener, onReceive(_)).WillRepeatedly(ReleaseSemaphore(&semaphore));

    OnChangeSubscriptionQos subscriptionQos;
    subscriptionQos.setValidityMs(600000);
    proxy->subscribeToBroadcastWithSingleStringParameterBroadcast(mockListener, subscriptionQos);
    // This wait is necessary, because subcriptions are async, and a broadcast could occur
    // before the subscription has started.
    std::this_thread::sleep_for(std::chrono::seconds(3));

    killProvider();
    startProvider();

    try {
        proxy->startFireBroadcastWithSingleStringParameter();
        // Wait for a subscription message to arrive
        ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(60)))
                << "broadcastWithSingleStringParameter did not arrive in time";
    } catch (const joynr::exceptions::JoynrRuntimeException& e) {
        ADD_FAILURE() << "startFireBroadcastWithSingleStringParameter failed with: "
                      << e.getMessage();
    }
    try {
        proxy->stopFireBroadcastWithSingleStringParameter();
    } catch (const joynr::exceptions::JoynrRuntimeException& e) {
        ADD_FAILURE() << "stopFireBroadcastWithSingleStringParameter failed with: "
                      << e.getMessage();
    }
    // TOOD similar test for subscriptions after provider restart and before provider restart
}
<commit_msg>[Tests] Robustness: C++ Provider crashes - Subscription test OK<commit_after>/*
 * #%L
 * %%
 * Copyright (C) 2016 - 2016 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
#include "AbstractRobustnessTest.h"
#include "joynr/OnChangeSubscriptionQos.h"
#include "joynr/OnChangeWithKeepAliveSubscriptionQos.h"

using joynr::OnChangeSubscriptionQos;
using joynr::OnChangeWithKeepAliveSubscriptionQos;

class RobustnessTestProviderCrash : public AbstractRobustnessTest
{
};

TEST_F(RobustnessTestProviderCrash, call_methodWithStringParameters)
{
    callMethodWithStringParameters();
}

TEST_F(RobustnessTestProviderCrash, call_methodWithStringParametersAfterProviderRestart)
{
    killProvider();
    startProvider();
    callMethodWithStringParameters();
}

TEST_F(RobustnessTestProviderCrash, call_methodWithStringParametersBeforeProviderRestart)
{
    // kill the provider before the request is sent
    callMethodWithStringParametersBeforeCcOrProviderRestart(false, true);
}

template <typename T>
class MockSubscriptionListenerOneType : public joynr::ISubscriptionListener<T>
{
public:
    MOCK_METHOD1_T(onReceive, void(const T& value));
    MOCK_METHOD1(onError, void(const joynr::exceptions::JoynrRuntimeException&));
};

TEST_F(RobustnessTestProviderCrash, subscribeTo_broadcastWithSingleStringParameter)
{
    Semaphore semaphore(0);
    auto mockListener = std::make_shared<MockSubscriptionListenerOneType<std::string>>();

    // Use a semaphore to count and wait on calls to the mock listener
    EXPECT_CALL(*mockListener, onReceive(_)).WillRepeatedly(ReleaseSemaphore(&semaphore));

    OnChangeSubscriptionQos subscriptionQos;
    subscriptionQos.setValidityMs(600000);
    proxy->subscribeToBroadcastWithSingleStringParameterBroadcast(mockListener, subscriptionQos);
    // This wait is necessary, because subcriptions are async, and a broadcast could occur
    // before the subscription has started.
    std::this_thread::sleep_for(std::chrono::seconds(3));

    killProvider();
    startProvider();

    try {
        proxy->startFireBroadcastWithSingleStringParameter();
        // Wait for a subscription message to arrive
        ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(60)))
                << "broadcastWithSingleStringParameter did not arrive in time";
    } catch (const joynr::exceptions::JoynrRuntimeException& e) {
        ADD_FAILURE() << "startFireBroadcastWithSingleStringParameter failed with: "
                      << e.getMessage();
    }
    try {
        proxy->stopFireBroadcastWithSingleStringParameter();
    } catch (const joynr::exceptions::JoynrRuntimeException& e) {
        ADD_FAILURE() << "stopFireBroadcastWithSingleStringParameter failed with: "
                      << e.getMessage();
    }
}

TEST_F(RobustnessTestProviderCrash, subscribeToAttributeString)
{
    Semaphore semaphore(0);
    auto mockListener = std::make_shared<MockSubscriptionListenerOneType<std::string>>();

    // Use a semaphore to count and wait on calls to the mock listener
    EXPECT_CALL(*mockListener, onReceive(_)).WillRepeatedly(ReleaseSemaphore(&semaphore));

    OnChangeWithKeepAliveSubscriptionQos subscriptionQos;
    subscriptionQos.setMinIntervalMs(5 * 1000);
    subscriptionQos.setMaxIntervalMs(30 * 1000);
    subscriptionQos.setValidityMs(120 * 1000);
    proxy->subscribeToAttributeString(mockListener, subscriptionQos);

    // the first publication should arrive immediately after subscription is done
    try {
        // Wait for a subscription message to arrive
        ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(60)))
                << "attribute publication did not arrive in time";
    } catch (const joynr::exceptions::JoynrRuntimeException& e) {
        ADD_FAILURE() << "waiting for attribute publication failed with: " << e.getMessage();
    }

    // kill and restart the provider while the time period until the next
    // publication happens is passing; the time period must be long enough
    // so that no further publication is sent until the provider got killed
    killProvider();
    startProvider();

    try {
        // Wait for a subscription message to arrive
        ASSERT_TRUE(semaphore.waitFor(std::chrono::seconds(60)))
                << "attribute publication did not arrive in time";
    } catch (const joynr::exceptions::JoynrRuntimeException& e) {
        ADD_FAILURE() << "waiting for attribute publication failed with: " << e.getMessage();
    }
}
<|endoftext|>


<commit_before><commit_msg>Revert "Run tests faster."<commit_after><|endoftext|>


<commit_before>#ifndef LDID_HPP
#define LDID_HPP

#include <cstdlib>
#include <map>
#include <streambuf>
#include <string>

namespace ldid {

// I wish Apple cared about providing quality toolchains :/

template <typename Function_>
class Functor;

template <typename Type_, typename... Args_>
class Functor<Type_ (Args_...)> {
  public:
    virtual Type_ operator ()(Args_... args) const = 0;
};

template <typename Function_>
class FunctorImpl;

template <typename Value_, typename Type_, typename... Args_>
class FunctorImpl<Type_ (Value_::*)(Args_...) const> :
    public Functor<Type_ (Args_...)>
{
  private:
    const Value_ *value_;

  public:
    FunctorImpl(const Value_ &value) :
        value_(&value)
    {
    }

    virtual Type_ operator ()(Args_... args) const {
        return (*value_)(args...);
    }
};

template <typename Function_>
FunctorImpl<decltype(&Function_::operator())> fun(const Function_ &value) {
    return value;
}

class Folder {
  public:
    virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code) = 0;
    virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code) = 0;
    virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code) = 0;
};

class DiskFolder :
    public Folder
{
  private:
    const std::string path_;
    std::map<std::string, std::string> commit_;

    std::string Path(const std::string &path);

    void Find(const std::string &root, const std::string &base, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)>&code);

  public:
    DiskFolder(const std::string &path);
    ~DiskFolder();

    virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
};

class SubFolder :
    public Folder
{
  private:
    Folder *parent_;
    std::string path_;

  public:
    SubFolder(Folder *parent, const std::string &path);

    virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
};

typedef std::map<uint32_t, std::vector<char>> Slots;

void Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &key, const Slots &slots);

}

#endif//LDID_HPP
<commit_msg>Add ldid::Bundle to the header file, for Impactor.<commit_after>#ifndef LDID_HPP
#define LDID_HPP

#include <cstdlib>
#include <map>
#include <streambuf>
#include <string>

namespace ldid {

// I wish Apple cared about providing quality toolchains :/

template <typename Function_>
class Functor;

template <typename Type_, typename... Args_>
class Functor<Type_ (Args_...)> {
  public:
    virtual Type_ operator ()(Args_... args) const = 0;
};

template <typename Function_>
class FunctorImpl;

template <typename Value_, typename Type_, typename... Args_>
class FunctorImpl<Type_ (Value_::*)(Args_...) const> :
    public Functor<Type_ (Args_...)>
{
  private:
    const Value_ *value_;

  public:
    FunctorImpl(const Value_ &value) :
        value_(&value)
    {
    }

    virtual Type_ operator ()(Args_... args) const {
        return (*value_)(args...);
    }
};

template <typename Function_>
FunctorImpl<decltype(&Function_::operator())> fun(const Function_ &value) {
    return value;
}

class Folder {
  public:
    virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code) = 0;
    virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code) = 0;
    virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code) = 0;
};

class DiskFolder :
    public Folder
{
  private:
    const std::string path_;
    std::map<std::string, std::string> commit_;

    std::string Path(const std::string &path);

    void Find(const std::string &root, const std::string &base, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)>&code);

  public:
    DiskFolder(const std::string &path);
    ~DiskFolder();

    virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
};

class SubFolder :
    public Folder
{
  private:
    Folder *parent_;
    std::string path_;

  public:
    SubFolder(Folder *parent, const std::string &path);

    virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
    virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
};

std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map<std::string, std::vector<char>> &remote);

typedef std::map<uint32_t, std::vector<char>> Slots;

void Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &key, const Slots &slots);

}

#endif//LDID_HPP
<|endoftext|>


<commit_before>#pragma once
//=====================================================================//
/*!	@file
	@brief	RX24T グループ・SCI 定義 @n
			Copyright 2016 Kunihito Hiramatsu
	@author	平松邦仁 (hira@rvf-rc45.net)
*/
//=====================================================================//
#include "common/io_utils.hpp"
#include "RX24T/peripheral.hpp"
#include "RX24T/icu.hpp"

namespace device {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief  SCIg 定義基底クラス
		@param[in]	base	ベース・アドレス
		@param[in]	t		ペリフェラル型
		@param[in]	txv		送信ベクター
		@param[in]	rxv		受信ベクター
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <uint32_t base, peripheral t, ICU::VECTOR txv, ICU::VECTOR rxv>
	struct scig_t {

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアルモードレジスタ (SMR)
		*/
		//-----------------------------------------------------------------//
		struct smr_t : public rw8_t<base + 0x00> {
			typedef rw8_t<base + 0x00> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bits_rw_t<io_, bitpos::B0, 2> CKS;
			bit_rw_t <io_, bitpos::B2>	  MP;
			bit_rw_t <io_, bitpos::B3>	  STOP;
			bit_rw_t <io_, bitpos::B4>	  PM;
			bit_rw_t <io_, bitpos::B5>	  PE;
			bit_rw_t <io_, bitpos::B6>	  CHR;
			bit_rw_t <io_, bitpos::B7>	  CM;

			bits_rw_t<io_, bitpos::B2, 2> BCP;
			bit_rw_t <io_, bitpos::B6>	  BLK;
			bit_rw_t <io_, bitpos::B7>	  GM;
		};
		static smr_t SMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  ビットレートレジスタ (BRR)
		*/
		//-----------------------------------------------------------------//
		static rw8_t<base + 0x01> BRR;

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアルコントロールレジスタ (SCR)
		*/
		//-----------------------------------------------------------------//
		struct scr_t : public rw8_t<base + 0x02> {
			typedef rw8_t<base + 0x02> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bits_rw_t<io_, bitpos::B0, 2> CKE;
			bit_rw_t <io_, bitpos::B2>	  TEIE;
			bit_rw_t <io_, bitpos::B3>	  MPIE;
			bit_rw_t <io_, bitpos::B4>	  RE;
			bit_rw_t <io_, bitpos::B5>	  TE;
			bit_rw_t <io_, bitpos::B6>	  RIE;
			bit_rw_t <io_, bitpos::B7>	  TIE;
		};
		static scr_t SCR;

		//-----------------------------------------------------------------//
		/*!
			@brief  トランスミットデータレジスタ (TDR)
		*/
		//-----------------------------------------------------------------//
		static rw8_t<base + 0x03> TDR;

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアルステータスレジスタ (SSR)
		*/
		//-----------------------------------------------------------------//
		struct ssr_t : public rw8_t<base + 0x04> {
			typedef rw8_t<base + 0x04> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> MPBT;
			bit_rw_t<io_, bitpos::B1> MPB;
			bit_rw_t<io_, bitpos::B2> TEND;
			bit_rw_t<io_, bitpos::B3> PER;
			bit_rw_t<io_, bitpos::B4> FER;
			bit_rw_t<io_, bitpos::B5> ORER;
			bit_rw_t<io_, bitpos::B6> RDRF;
			bit_rw_t<io_, bitpos::B7> TDRE;
		};
		static ssr_t SSR;

		//-----------------------------------------------------------------//
		/*!
			@brief  レシーブデータレジスタ (RDR)
		*/
		//-----------------------------------------------------------------//
		static ro8_t<base + 0x05> RDR;

 		//-----------------------------------------------------------------//
		/*!
			@brief  スマートカードモードレジスタ (SCMR)
		*/
		//-----------------------------------------------------------------//
		struct scmr_t : public rw8_t<base + 0x06> {
			typedef rw8_t<base + 0x06> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> SMIF;
			bit_rw_t<io_, bitpos::B2> SINV;
			bit_rw_t<io_, bitpos::B3> SDIR;
			bit_rw_t<io_, bitpos::B4> CHR1;
			bit_rw_t<io_, bitpos::B7> BCP2;
		};
		static scmr_t SCMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアル拡張レジスタ (SEMR)
		*/
		//-----------------------------------------------------------------//
		struct semr_t : public rw8_t<base + 0x07> {
			typedef rw8_t<base + 0x07> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> ACS0;
			bit_rw_t<io_, bitpos::B2> BRME;
			bit_rw_t<io_, bitpos::B4> ABCS;
			bit_rw_t<io_, bitpos::B5> NFEN;
			bit_rw_t<io_, bitpos::B6> BGDM;
			bit_rw_t<io_, bitpos::B7> RXDESEL;
		};
		static semr_t SEMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  ノイズフィルタ設定レジスタ (SNFR)
		*/
		//-----------------------------------------------------------------//
		struct snfr_t : public rw8_t<base + 0x08> {
			typedef rw8_t<base + 0x08> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bits_rw_t<io_, bitpos::B0, 3> NFCS;
		};
		static snfr_t SNFR;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C モードレジスタ１ (SIMR1)
		*/
		//-----------------------------------------------------------------//
		struct simr1_t : public rw8_t<base + 0x09> {
			typedef rw8_t<base + 0x09> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t <io_, bitpos::B0>    IICM;
			bits_rw_t<io_, bitpos::B3, 5> IICDL;
		};
		static simr1_t SIMR1;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C モードレジスタ２ (SIMR2)
		*/
		//-----------------------------------------------------------------//
		struct simr2_t : public rw8_t<base + 0x0A> {
			typedef rw8_t<base + 0x0A> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> IICINTM;
			bit_rw_t<io_, bitpos::B1> IICCSC;
			bit_rw_t<io_, bitpos::B5> IICACKT;
		};
		static simr2_t SIMR2;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C モードレジスタ３ (SIMR3)
		*/
		//-----------------------------------------------------------------//
		struct simr3_t : public rw8_t<base + 0x0B> {
			typedef rw8_t<base + 0x0B> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t <io_, bitpos::B0>    IICSTAREQ;
			bit_rw_t <io_, bitpos::B1>    IICRSTAREQ;
			bit_rw_t <io_, bitpos::B2>    IICSTPREQ;
			bit_rw_t <io_, bitpos::B3>    IICSTIF;
			bits_rw_t<io_, bitpos::B4, 2> IICSDAS;
			bits_rw_t<io_, bitpos::B6, 2> IICSCLS;
		};
		static simr3_t SIMR3;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C ステータスレジスタ (SISR)
		*/
		//-----------------------------------------------------------------//
		struct sisr_t : public rw8_t<base + 0x0C> {
			typedef rw8_t<base + 0x0C> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> IICACKR;
		};
		static sisr_t SISR;

		//-----------------------------------------------------------------//
		/*!
			@brief  SPI モードレジスタ (SPMR)
		*/
		//-----------------------------------------------------------------//
		struct spmr_t : public rw8_t<base + 0x0D> {
			typedef rw8_t<base + 0x0D> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> SSE;
			bit_rw_t<io_, bitpos::B1> CTSE;
			bit_rw_t<io_, bitpos::B2> MSS;
			bit_rw_t<io_, bitpos::B4> MFF;
			bit_rw_t<io_, bitpos::B6> CKPOL;
			bit_rw_t<io_, bitpos::B7> CKPH;
		};
		static spmr_t SPMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  チャネルを返す
			@return チャネル（０、１、２、３、４、５、６、７、１２）
		*/
		//-----------------------------------------------------------------//
		static uint32_t get_chanel() {
			if(base == 0x0008B300) return 12;
			return (base >> 5) & 7;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  ペリフェラル型を返す
			@return ペリフェラル型
		*/
		//-----------------------------------------------------------------//
		static peripheral get_peripheral() { return t; }

		//-----------------------------------------------------------------//
		/*!
			@brief  送信割り込みベクターを返す
			@return ベクター型
		*/
		//-----------------------------------------------------------------//
		static ICU::VECTOR get_tx_vec() { return txv; }

		//-----------------------------------------------------------------//
		/*!
			@brief  受信割り込みベクターを返す
			@return ベクター型
		*/
		//-----------------------------------------------------------------//
		static ICU::VECTOR get_rx_vec() { return rxv; }
	};

	typedef scig_t<0x0008A020, peripheral::SCI1, ICU::VECTOR::TXI1, ICU::VECTOR::RXI1> SCI1;

	typedef scig_t<0x0008A0A0, peripheral::SCI5, ICU::VECTOR::TXI5, ICU::VECTOR::RXI5> SCI5;
	typedef scig_t<0x0008A0C0, peripheral::SCI6, ICU::VECTOR::TXI6, ICU::VECTOR::RXI6> SCI6;
}
<commit_msg>update riic interrupt vector<commit_after>#pragma once
//=====================================================================//
/*!	@file
	@brief	RX24T グループ・SCI 定義 @n
			Copyright 2016 Kunihito Hiramatsu
	@author	平松邦仁 (hira@rvf-rc45.net)
*/
//=====================================================================//
#include "common/io_utils.hpp"
#include "RX24T/peripheral.hpp"
#include "RX24T/icu.hpp"

namespace device {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief  SCIg 定義基底クラス
		@param[in]	base	ベース・アドレス
		@param[in]	t		ペリフェラル型
		@param[in]	rxv		受信ベクター
		@param[in]	txv		送信ベクター
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <uint32_t base, peripheral t, ICU::VECTOR rxv, ICU::VECTOR txv>
	struct scig_t {

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアルモードレジスタ (SMR)
		*/
		//-----------------------------------------------------------------//
		struct smr_t : public rw8_t<base + 0x00> {
			typedef rw8_t<base + 0x00> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bits_rw_t<io_, bitpos::B0, 2> CKS;
			bit_rw_t <io_, bitpos::B2>	  MP;
			bit_rw_t <io_, bitpos::B3>	  STOP;
			bit_rw_t <io_, bitpos::B4>	  PM;
			bit_rw_t <io_, bitpos::B5>	  PE;
			bit_rw_t <io_, bitpos::B6>	  CHR;
			bit_rw_t <io_, bitpos::B7>	  CM;

			bits_rw_t<io_, bitpos::B2, 2> BCP;
			bit_rw_t <io_, bitpos::B6>	  BLK;
			bit_rw_t <io_, bitpos::B7>	  GM;
		};
		static smr_t SMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  ビットレートレジスタ (BRR)
		*/
		//-----------------------------------------------------------------//
		static rw8_t<base + 0x01> BRR;

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアルコントロールレジスタ (SCR)
		*/
		//-----------------------------------------------------------------//
		struct scr_t : public rw8_t<base + 0x02> {
			typedef rw8_t<base + 0x02> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bits_rw_t<io_, bitpos::B0, 2> CKE;
			bit_rw_t <io_, bitpos::B2>	  TEIE;
			bit_rw_t <io_, bitpos::B3>	  MPIE;
			bit_rw_t <io_, bitpos::B4>	  RE;
			bit_rw_t <io_, bitpos::B5>	  TE;
			bit_rw_t <io_, bitpos::B6>	  RIE;
			bit_rw_t <io_, bitpos::B7>	  TIE;
		};
		static scr_t SCR;

		//-----------------------------------------------------------------//
		/*!
			@brief  トランスミットデータレジスタ (TDR)
		*/
		//-----------------------------------------------------------------//
		static rw8_t<base + 0x03> TDR;

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアルステータスレジスタ (SSR)
		*/
		//-----------------------------------------------------------------//
		struct ssr_t : public rw8_t<base + 0x04> {
			typedef rw8_t<base + 0x04> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> MPBT;
			bit_rw_t<io_, bitpos::B1> MPB;
			bit_rw_t<io_, bitpos::B2> TEND;
			bit_rw_t<io_, bitpos::B3> PER;
			bit_rw_t<io_, bitpos::B4> FER;
			bit_rw_t<io_, bitpos::B5> ORER;
			bit_rw_t<io_, bitpos::B6> RDRF;
			bit_rw_t<io_, bitpos::B7> TDRE;
		};
		static ssr_t SSR;

		//-----------------------------------------------------------------//
		/*!
			@brief  レシーブデータレジスタ (RDR)
		*/
		//-----------------------------------------------------------------//
		static ro8_t<base + 0x05> RDR;

 		//-----------------------------------------------------------------//
		/*!
			@brief  スマートカードモードレジスタ (SCMR)
		*/
		//-----------------------------------------------------------------//
		struct scmr_t : public rw8_t<base + 0x06> {
			typedef rw8_t<base + 0x06> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> SMIF;
			bit_rw_t<io_, bitpos::B2> SINV;
			bit_rw_t<io_, bitpos::B3> SDIR;
			bit_rw_t<io_, bitpos::B4> CHR1;
			bit_rw_t<io_, bitpos::B7> BCP2;
		};
		static scmr_t SCMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  シリアル拡張レジスタ (SEMR)
		*/
		//-----------------------------------------------------------------//
		struct semr_t : public rw8_t<base + 0x07> {
			typedef rw8_t<base + 0x07> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> ACS0;
			bit_rw_t<io_, bitpos::B2> BRME;
			bit_rw_t<io_, bitpos::B4> ABCS;
			bit_rw_t<io_, bitpos::B5> NFEN;
			bit_rw_t<io_, bitpos::B6> BGDM;
			bit_rw_t<io_, bitpos::B7> RXDESEL;
		};
		static semr_t SEMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  ノイズフィルタ設定レジスタ (SNFR)
		*/
		//-----------------------------------------------------------------//
		struct snfr_t : public rw8_t<base + 0x08> {
			typedef rw8_t<base + 0x08> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bits_rw_t<io_, bitpos::B0, 3> NFCS;
		};
		static snfr_t SNFR;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C モードレジスタ１ (SIMR1)
		*/
		//-----------------------------------------------------------------//
		struct simr1_t : public rw8_t<base + 0x09> {
			typedef rw8_t<base + 0x09> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t <io_, bitpos::B0>    IICM;
			bits_rw_t<io_, bitpos::B3, 5> IICDL;
		};
		static simr1_t SIMR1;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C モードレジスタ２ (SIMR2)
		*/
		//-----------------------------------------------------------------//
		struct simr2_t : public rw8_t<base + 0x0A> {
			typedef rw8_t<base + 0x0A> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> IICINTM;
			bit_rw_t<io_, bitpos::B1> IICCSC;
			bit_rw_t<io_, bitpos::B5> IICACKT;
		};
		static simr2_t SIMR2;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C モードレジスタ３ (SIMR3)
		*/
		//-----------------------------------------------------------------//
		struct simr3_t : public rw8_t<base + 0x0B> {
			typedef rw8_t<base + 0x0B> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t <io_, bitpos::B0>    IICSTAREQ;
			bit_rw_t <io_, bitpos::B1>    IICRSTAREQ;
			bit_rw_t <io_, bitpos::B2>    IICSTPREQ;
			bit_rw_t <io_, bitpos::B3>    IICSTIF;
			bits_rw_t<io_, bitpos::B4, 2> IICSDAS;
			bits_rw_t<io_, bitpos::B6, 2> IICSCLS;
		};
		static simr3_t SIMR3;

		//-----------------------------------------------------------------//
		/*!
			@brief  I2C ステータスレジスタ (SISR)
		*/
		//-----------------------------------------------------------------//
		struct sisr_t : public rw8_t<base + 0x0C> {
			typedef rw8_t<base + 0x0C> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> IICACKR;
		};
		static sisr_t SISR;

		//-----------------------------------------------------------------//
		/*!
			@brief  SPI モードレジスタ (SPMR)
		*/
		//-----------------------------------------------------------------//
		struct spmr_t : public rw8_t<base + 0x0D> {
			typedef rw8_t<base + 0x0D> io_;
			using io_::operator =;
			using io_::operator ();
			using io_::operator |=;
			using io_::operator &=;

			bit_rw_t<io_, bitpos::B0> SSE;
			bit_rw_t<io_, bitpos::B1> CTSE;
			bit_rw_t<io_, bitpos::B2> MSS;
			bit_rw_t<io_, bitpos::B4> MFF;
			bit_rw_t<io_, bitpos::B6> CKPOL;
			bit_rw_t<io_, bitpos::B7> CKPH;
		};
		static spmr_t SPMR;

		//-----------------------------------------------------------------//
		/*!
			@brief  チャネルを返す
			@return チャネル（０、１、２、３、４、５、６、７、１２）
		*/
		//-----------------------------------------------------------------//
		static uint32_t get_chanel() {
			if(base == 0x0008B300) return 12;
			return (base >> 5) & 7;
		}

		//-----------------------------------------------------------------//
		/*!
			@brief  ペリフェラル型を返す
			@return ペリフェラル型
		*/
		//-----------------------------------------------------------------//
		static peripheral get_peripheral() { return t; }

		//-----------------------------------------------------------------//
		/*!
			@brief  受信割り込みベクターを返す
			@return ベクター型
		*/
		//-----------------------------------------------------------------//
		static ICU::VECTOR get_rx_vec() { return rxv; }

		//-----------------------------------------------------------------//
		/*!
			@brief  送信割り込みベクターを返す
			@return ベクター型
		*/
		//-----------------------------------------------------------------//
		static ICU::VECTOR get_tx_vec() { return txv; }
	};

	typedef scig_t<0x0008A020, peripheral::SCI1, ICU::VECTOR::RXI1, ICU::VECTOR::TXI1> SCI1;

	typedef scig_t<0x0008A0A0, peripheral::SCI5, ICU::VECTOR::RXI5, ICU::VECTOR::TXI5> SCI5;
	typedef scig_t<0x0008A0C0, peripheral::SCI6, ICU::VECTOR::RXI6, ICU::VECTOR::TXI6> SCI6;
}
<|endoftext|>


<commit_before><commit_msg>Do not enable outliner when it was not before only for temporary undo disable<commit_after><|endoftext|>


<commit_before>// Copyright (c) 2018-2020 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "mfx_tracer_test_main.h"
#include "mfx_tracer_test_fixtures.h"

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <mfxvideo.h>
#include <algorithm>
#include <type_traits>
#include "mfx_tracer_test_mocks.h"

enum
{
    MFX_INIT     = 0x0001,
    MFX_INIT_EX  = 0x0002,
};

auto func_case_list = ::testing::Values(
        MFX_INIT,
        MFX_INIT_EX);

TEST_P(TracerLibsTestParametrizedFunc, ShouldSucceedForSeeminglyGoodMockLibrary)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillRepeatedly(Invoke(&mock, &MockCallObj::EmulateAPI));
    EXPECT_CALL(mock, dlclose).Times(1);

    if (func & MFX_INIT)
    {
        EXPECT_CALL(mock, MFXInit).Times(1).WillRepeatedly(DoAll(SetArgPointee<2>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        EXPECT_CALL(mock, MFXInitEx).Times(1).WillRepeatedly(DoAll(SetArgPointee<1>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInitEx(par, &session);
    }
    ASSERT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, MFXClose(MOCK_SESSION_HANDLE)).Times(1);
    sts = MFXClose(session);
    ASSERT_EQ(sts, MFX_ERR_NONE);
}

TEST_P(TracerLibsTestParametrizedFunc, MFXInitShouldFailIfNoLibraryIsFound)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1));
    EXPECT_CALL(mock, dlsym).Times(0);
    EXPECT_CALL(mock, dlclose).Times(0);

    if (func & MFX_INIT)
    {
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        sts = MFXInitEx(par, &session);
    }
    ASSERT_EQ(sts, MFX_ERR_NOT_FOUND);
}

auto impl_case_list = ::testing::Values(
        MFX_IMPL_AUTO,
        MFX_IMPL_HARDWARE,
        MFX_IMPL_HARDWARE_ANY,
        MFX_IMPL_HARDWARE2,
        MFX_IMPL_HARDWARE3,
        MFX_IMPL_HARDWARE4);

TEST_P(TracerLibsTestParametrizedImpl, MFXInitShouldEnumerateCorrectLibNames)
{
    MockCallObj& mock = *g_call_obj_ptr;

#if defined(__i386__)
    const std::string LIBMFXHW("libmfxhw32.so.1");
#elif defined(__x86_64__)
    const std::string LIBMFXHW("libmfxhw64.so.1");
#endif

    std::string modules_dir(MFX_MODULES_DIR);
    mfxIMPL impl = std::get<0>(GetParam());
    mfxI32  func = std::get<1>(GetParam());
    std::vector<std::string> libs;

    if ((impl & MFX_IMPL_HARDWARE) ||
             (impl & MFX_IMPL_HARDWARE_ANY))
    {
        libs.emplace_back(LIBMFXHW);
        libs.emplace_back(modules_dir + "/" + LIBMFXHW);
    }

    for (const std::string& lib : libs)
    {
        EXPECT_CALL(mock, dlopen(StrEq(lib.c_str()),_)).Times(1);
    }

    if (func & MFX_INIT)
    {
        MFXInit(impl, &this->ver, &this->session);
    }
    else if (func & MFX_INIT_EX)
    {
        MFXInitEx(par, &this->session);
    }
}

INSTANTIATE_TEST_CASE_P(EnumeratingLibs, TracerLibsTestParametrizedImpl,
    ::testing::Combine(impl_case_list, func_case_list));

TEST_P(TracerLibsTestParametrizedFunc, ShouldFailIfAvailLibHasNoSymbols)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillRepeatedly(Return(nullptr));
    EXPECT_CALL(mock, dlclose).Times(AtLeast(1));

    if (func & MFX_INIT)
    {
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        sts = MFXInitEx(par, &session);
    }
    EXPECT_EQ(sts, MFX_ERR_NOT_FOUND);
}

TEST_P(TracerLibsTestParametrizedFunc, ShouldSucceedIfFirstLibBadSecondLibGood)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillOnce(Return(nullptr)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillRepeatedly(Invoke(&mock, &MockCallObj::EmulateAPI));
    EXPECT_CALL(mock, dlclose).Times(1);

    if (func & MFX_INIT)
    {
        EXPECT_CALL(mock, MFXInit).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<2>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        EXPECT_CALL(mock, MFXInitEx).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<1>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInitEx(par, &session);
    }
    EXPECT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, MFXClose(MOCK_SESSION_HANDLE)).Times(1);
    sts = MFXClose(session);
    ASSERT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillOnce(Return(nullptr)).WillRepeatedly(Invoke(&mock, &MockCallObj::EmulateAPI));
    EXPECT_CALL(mock, dlclose).Times(AtLeast(1));

    if (func & MFX_INIT)
    {
        EXPECT_CALL(mock, MFXInit).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<2>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        EXPECT_CALL(mock, MFXInitEx).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<1>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInitEx(par, &session);
    }
    EXPECT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, MFXClose(MOCK_SESSION_HANDLE)).Times(1);
    sts = MFXClose(session);
    ASSERT_EQ(sts, MFX_ERR_NONE);
}

INSTANTIATE_TEST_CASE_P(TracerFuncTest, TracerLibsTestParametrizedFunc, func_case_list);
<commit_msg>[tests] Fixed unitialized values<commit_after>// Copyright (c) 2018-2020 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "mfx_tracer_test_main.h"
#include "mfx_tracer_test_fixtures.h"

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <mfxvideo.h>
#include <algorithm>
#include <type_traits>
#include "mfx_tracer_test_mocks.h"

enum
{
    MFX_INIT     = 0x0001,
    MFX_INIT_EX  = 0x0002,
};

auto func_case_list = ::testing::Values(
        MFX_INIT,
        MFX_INIT_EX);

TEST_P(TracerLibsTestParametrizedFunc, ShouldSucceedForSeeminglyGoodMockLibrary)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts = MFX_ERR_UNKNOWN;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillRepeatedly(Invoke(&mock, &MockCallObj::EmulateAPI));
    EXPECT_CALL(mock, dlclose).Times(1);

    if (func & MFX_INIT)
    {
        EXPECT_CALL(mock, MFXInit).Times(1).WillRepeatedly(DoAll(SetArgPointee<2>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        EXPECT_CALL(mock, MFXInitEx).Times(1).WillRepeatedly(DoAll(SetArgPointee<1>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInitEx(par, &session);
    }
    ASSERT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, MFXClose(MOCK_SESSION_HANDLE)).Times(1);
    sts = MFXClose(session);
    ASSERT_EQ(sts, MFX_ERR_NONE);
}

TEST_P(TracerLibsTestParametrizedFunc, MFXInitShouldFailIfNoLibraryIsFound)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts = MFX_ERR_UNKNOWN;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1));
    EXPECT_CALL(mock, dlsym).Times(0);
    EXPECT_CALL(mock, dlclose).Times(0);

    if (func & MFX_INIT)
    {
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        sts = MFXInitEx(par, &session);
    }
    ASSERT_EQ(sts, MFX_ERR_NOT_FOUND);
}

auto impl_case_list = ::testing::Values(
        MFX_IMPL_AUTO,
        MFX_IMPL_HARDWARE,
        MFX_IMPL_HARDWARE_ANY,
        MFX_IMPL_HARDWARE2,
        MFX_IMPL_HARDWARE3,
        MFX_IMPL_HARDWARE4);

TEST_P(TracerLibsTestParametrizedImpl, MFXInitShouldEnumerateCorrectLibNames)
{
    MockCallObj& mock = *g_call_obj_ptr;

#if defined(__i386__)
    const std::string LIBMFXHW("libmfxhw32.so.1");
#elif defined(__x86_64__)
    const std::string LIBMFXHW("libmfxhw64.so.1");
#endif

    std::string modules_dir(MFX_MODULES_DIR);
    mfxIMPL impl = std::get<0>(GetParam());
    mfxI32  func = std::get<1>(GetParam());
    std::vector<std::string> libs;

    if ((impl & MFX_IMPL_HARDWARE) ||
             (impl & MFX_IMPL_HARDWARE_ANY))
    {
        libs.emplace_back(LIBMFXHW);
        libs.emplace_back(modules_dir + "/" + LIBMFXHW);
    }

    for (const std::string& lib : libs)
    {
        EXPECT_CALL(mock, dlopen(StrEq(lib.c_str()),_)).Times(1);
    }

    if (func & MFX_INIT)
    {
        MFXInit(impl, &this->ver, &this->session);
    }
    else if (func & MFX_INIT_EX)
    {
        MFXInitEx(par, &this->session);
    }
}

INSTANTIATE_TEST_CASE_P(EnumeratingLibs, TracerLibsTestParametrizedImpl,
    ::testing::Combine(impl_case_list, func_case_list));

TEST_P(TracerLibsTestParametrizedFunc, ShouldFailIfAvailLibHasNoSymbols)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts = MFX_ERR_UNKNOWN;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillRepeatedly(Return(nullptr));
    EXPECT_CALL(mock, dlclose).Times(AtLeast(1));

    if (func & MFX_INIT)
    {
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        sts = MFXInitEx(par, &session);
    }
    EXPECT_EQ(sts, MFX_ERR_NOT_FOUND);
}

TEST_P(TracerLibsTestParametrizedFunc, ShouldSucceedIfFirstLibBadSecondLibGood)
{
    MockCallObj& mock = *g_call_obj_ptr;
    mfxStatus sts;

    mfxI32 func = GetParam();

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillOnce(Return(nullptr)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillRepeatedly(Invoke(&mock, &MockCallObj::EmulateAPI));
    EXPECT_CALL(mock, dlclose).Times(1);

    if (func & MFX_INIT)
    {
        EXPECT_CALL(mock, MFXInit).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<2>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        EXPECT_CALL(mock, MFXInitEx).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<1>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInitEx(par, &session);
    }
    EXPECT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, MFXClose(MOCK_SESSION_HANDLE)).Times(1);
    sts = MFXClose(session);
    ASSERT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, dlopen).Times(AtLeast(1)).WillRepeatedly(Return(MOCK_DLOPEN_HANDLE));
    EXPECT_CALL(mock, dlsym).Times(AtLeast(1)).WillOnce(Return(nullptr)).WillRepeatedly(Invoke(&mock, &MockCallObj::EmulateAPI));
    EXPECT_CALL(mock, dlclose).Times(AtLeast(1));

    if (func & MFX_INIT)
    {
        EXPECT_CALL(mock, MFXInit).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<2>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInit(impl, &ver, &session);
    }
    else if (func & MFX_INIT_EX)
    {
        EXPECT_CALL(mock, MFXInitEx).Times(AtLeast(1)).WillRepeatedly(DoAll(SetArgPointee<1>(MOCK_SESSION_HANDLE), Return(MFX_ERR_NONE)));
        sts = MFXInitEx(par, &session);
    }
    EXPECT_EQ(sts, MFX_ERR_NONE);

    EXPECT_CALL(mock, MFXClose(MOCK_SESSION_HANDLE)).Times(1);
    sts = MFXClose(session);
    ASSERT_EQ(sts, MFX_ERR_NONE);
}

INSTANTIATE_TEST_CASE_P(TracerFuncTest, TracerLibsTestParametrizedFunc, func_case_list);
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with consumer library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <QString>
#include <QtTest>

#include <mlt++/Mlt.h>
using namespace Mlt;

class TestProperties: public QObject
{
    Q_OBJECT

public:
    TestProperties() {}

private Q_SLOTS:
    void InstantiationIsAReference()
    {
        Properties p;
        QCOMPARE(p.ref_count(), 1);
    }

    void CopyAddsReference()
    {
        Properties p;
        Properties q = p;
        QCOMPARE(p.ref_count(), 2);
    }

    void DestructionRemovesReference()
    {
        Properties p;
        Properties* q = new Properties(p);
        QCOMPARE(p.ref_count(), 2);
        delete q;
        QCOMPARE(p.ref_count(), 1);
    }

    void SetAndGetString()
    {
        Properties p;
        p.set("key", "value");
        QVERIFY(p.get("key"));
        QVERIFY(QString(p.get("key")) != QString(""));
        QCOMPARE(p.get("key"), "value");
    }

    void SetAndGetInt()
    {
        Properties p;
        int i = 1;
        p.set("key", i);
        QCOMPARE(p.get_int("key"), i);
    }

    void SetAndGetDouble()
    {
        Properties p;
        double d = 1.0;
        p.set("key", d);
        QCOMPARE(p.get_double("key"), d);
    }

    void SetAndGetInt64()
    {
        Properties p;
        qint64 i = 1LL << 32;
        p.set("key", (int64_t)i);
        QCOMPARE((qint64)p.get_int64("key"), i);
    }

    void SetAndGetData()
    {
        Properties p;
        const char *value = "value";
        char* const s = strdup(value);
        p.set("key", s, strlen(s), free);
        int size = 0;
        QCOMPARE((char*) p.get_data("key", size), value);
        QCOMPARE(size, int(strlen(value)));
    }

    void IntFromString()
    {
        Properties p;
        const char *s = "-1";
        int i = -1;
        p.set("key", i);
        QCOMPARE(p.get("key"), s);
        p.set("key", s);
        QCOMPARE(p.get_int("key"), i);
    }

    void Int64FromString()
    {
        Properties p;
        const char *s = "-1";
        qint64 i = -1;
        p.set("key", (int64_t)i);
        QCOMPARE(p.get("key"), s);
        p.set("key", s);
        QCOMPARE((qint64)p.get_int64("key"), i);
    }

    void DoubleFromString()
    {
        Properties p;
        const char *s = "-1.234567";
        double d = -1.234567;
        p.set("key", d);
        QCOMPARE(p.get("key"), s);
        p.set("key", s);
        QCOMPARE(p.get_double("key"), d);
    }

    void SetNullRemovesProperty()
    {
        Properties p;
        const char *s = NULL;
        p.set("key", "value");
        p.set("key", s);
        QCOMPARE(p.get("key"), s);
    }

    void SetAndGetHexColor()
    {
        Properties p;
        const char *hexColorString = "0xaabbccdd";
        int hexColorInt = 0xaabbccdd;
        p.set("key", hexColorString);
        QCOMPARE(p.get_int("key"), hexColorInt);
    }

    void SetAndGetCssColor()
    {
        Properties p;
        const char *cssColorString = "#aabbcc";
        int cssColorInt = 0xaabbccff;
        p.set("key", cssColorString);
        QCOMPARE(p.get_int("key"), cssColorInt);

        const char *cssColorAlphaString = "#00aabbcc";
        int cssColorAlphaInt = 0xaabbcc00;
        p.set("key", cssColorAlphaString);
        QCOMPARE(p.get_int("key"), cssColorAlphaInt);
    }

    void SetAndGetTimeCode()
    {
        Profile profile;
        Properties p;
        p.set("_profile", profile.get_profile(), 0);
        const char *timeString = "11:22:33:04";
        p.set("key", timeString);
        QCOMPARE(p.get_int("key"), 1023829);
        p.set("key", 1023829);
        QCOMPARE(p.get_time("key", mlt_time_smpte), timeString);
    }

    void SetAndGetTimeClock()
    {
        Profile profile;
        Properties p;
        p.set("_profile", profile.get_profile(), 0);
        const char *timeString = "11:22:33.400";
        p.set("key", timeString);
        QCOMPARE(p.get_int("key"), 1023835);
        p.set("key", 1023835);
        QCOMPARE(p.get_time("key", mlt_time_clock), timeString);
    }

    void SetSimpleMathExpression()
    {
        Properties p;
        p.set("key", "@16.0/9.0 *2 +3 -1");
        QCOMPARE(p.get_int("key"), 5);
        QCOMPARE(p.get_double("key"), 16.0/9.0 *2 +3 -1);
    }

    void PassOneProperty()
    {
        Properties p[2];
        const char *s = "value";
        p[0].set("key", s);
        QCOMPARE(p[1].get("key"), (void*) 0);
        p[1].pass_property(p[0], "key");
        QCOMPARE(p[1].get("key"), s);
    }

    void PassMultipleByPrefix()
    {
        Properties p[2];
        const char *s = "value";
        p[0].set("key.one", s);
        p[0].set("key.two", s);
        QCOMPARE(p[1].get("key.one"), (void*) 0);
        QCOMPARE(p[1].get("key.two"), (void*) 0);
        p[1].pass_values(p[0], "key.");
        QCOMPARE(p[1].get("one"), s);
        QCOMPARE(p[1].get("two"), s);
    }

    void PassMultipleByList()
    {
        Properties p[2];
        const char *s = "value";
        p[0].set("key.one", s);
        p[0].set("key.two", s);
        QCOMPARE(p[1].get("key.one"), (void*) 0);
        QCOMPARE(p[1].get("key.two"), (void*) 0);
        p[1].pass_list(p[0], "key.one key.two");
        QCOMPARE(p[1].get("key.one"), s);
        QCOMPARE(p[1].get("key.two"), s);
    }

    void MirrorProperties()
    {
        Properties p[2];
        p[0].mirror(p[1]);
        p[0].set("key", "value");
        QCOMPARE(p[1].get("key"), "value");
    }

    void InheritProperties()
    {
        Properties p[2];
        p[0].set("key", "value");
        QVERIFY(p[1].get("key") == 0);
        p[1].inherit(p[0]);
        QCOMPARE(p[1].get("key"), "value");
    }

    void ParseString()
    {
        Properties p;
        QCOMPARE(p.get("key"), (void*) 0);
        p.parse("key=value");
        QCOMPARE(p.get("key"), "value");
        p.parse("key=\"new value\"");
        QCOMPARE(p.get("key"), "new value");
    }

    void RenameProperty()
    {
        Properties p;
        p.set("key", "value");
        QVERIFY(p.get("new key") == 0);
        p.rename("key", "new key");
        QCOMPARE(p.get("new key"), "value");
    }

    void SequenceDetected()
    {
        Properties p;
        p.set("1", 1);
        p.set("2", 2);
        p.set("3", 3);
        QVERIFY(p.is_sequence());
        p.set("four", 4);
        QVERIFY(!p.is_sequence());
    }

    void SerializesToYamlTiny()
    {
        Properties p[2];
        p[0].set("key1", "value1");
        p[0].set("key2", "value2");
        p[1].set("1", "value3");
        p[1].set("2", "value4");
        p[0].set("seq", p[1].get_properties(), 0);
        QCOMPARE(p[0].serialise_yaml(),
                "---\n"
                "key1: value1\n"
                "key2: value2\n"
                "seq:\n"
                "  - value3\n"
                "  - value4\n"
                "...\n");
    }

    void RadixRespondsToLocale()
    {
        Properties p;
        p.set_lcnumeric("en_US");
        p.set("key", "0.125");
        QCOMPARE(p.get_double("key"), double(1) / double(8));
        p.set_lcnumeric("de_DE");
        p.set("key", "0,125");
        QCOMPARE(p.get_double("key"), double(1) / double(8));
    }
};

QTEST_APPLESS_MAIN(TestProperties)

#include "test_properties.moc"
<commit_msg>Cleanup 64 bit int property tests.<commit_after>/*
 * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with consumer library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <QString>
#include <QtTest>

#include <mlt++/Mlt.h>
using namespace Mlt;

class TestProperties: public QObject
{
    Q_OBJECT

public:
    TestProperties() {}

private Q_SLOTS:
    void InstantiationIsAReference()
    {
        Properties p;
        QCOMPARE(p.ref_count(), 1);
    }

    void CopyAddsReference()
    {
        Properties p;
        Properties q = p;
        QCOMPARE(p.ref_count(), 2);
    }

    void DestructionRemovesReference()
    {
        Properties p;
        Properties* q = new Properties(p);
        QCOMPARE(p.ref_count(), 2);
        delete q;
        QCOMPARE(p.ref_count(), 1);
    }

    void SetAndGetString()
    {
        Properties p;
        p.set("key", "value");
        QVERIFY(p.get("key"));
        QVERIFY(QString(p.get("key")) != QString(""));
        QCOMPARE(p.get("key"), "value");
    }

    void SetAndGetInt()
    {
        Properties p;
        int i = 1;
        p.set("key", i);
        QCOMPARE(p.get_int("key"), i);
    }

    void SetAndGetDouble()
    {
        Properties p;
        double d = 1.0;
        p.set("key", d);
        QCOMPARE(p.get_double("key"), d);
    }

    void SetAndGetInt64()
    {
        Properties p;
        int64_t i = 1LL << 32;
        p.set("key", i);
        QCOMPARE(p.get_int64("key"), i);
    }

    void SetAndGetData()
    {
        Properties p;
        const char *value = "value";
        char* const s = strdup(value);
        p.set("key", s, strlen(s), free);
        int size = 0;
        QCOMPARE((char*) p.get_data("key", size), value);
        QCOMPARE(size, int(strlen(value)));
    }

    void IntFromString()
    {
        Properties p;
        const char *s = "-1";
        int i = -1;
        p.set("key", i);
        QCOMPARE(p.get("key"), s);
        p.set("key", s);
        QCOMPARE(p.get_int("key"), i);
    }

    void Int64FromString()
    {
        Properties p;
        const char *s = "-1";
        int64_t i = -1;
        p.set("key", i);
        QCOMPARE(p.get("key"), s);
        p.set("key", s);
        QCOMPARE(p.get_int64("key"), i);
    }

    void DoubleFromString()
    {
        Properties p;
        const char *s = "-1.234567";
        double d = -1.234567;
        p.set("key", d);
        QCOMPARE(p.get("key"), s);
        p.set("key", s);
        QCOMPARE(p.get_double("key"), d);
    }

    void SetNullRemovesProperty()
    {
        Properties p;
        const char *s = NULL;
        p.set("key", "value");
        p.set("key", s);
        QCOMPARE(p.get("key"), s);
    }

    void SetAndGetHexColor()
    {
        Properties p;
        const char *hexColorString = "0xaabbccdd";
        int hexColorInt = 0xaabbccdd;
        p.set("key", hexColorString);
        QCOMPARE(p.get_int("key"), hexColorInt);
    }

    void SetAndGetCssColor()
    {
        Properties p;
        const char *cssColorString = "#aabbcc";
        int cssColorInt = 0xaabbccff;
        p.set("key", cssColorString);
        QCOMPARE(p.get_int("key"), cssColorInt);

        const char *cssColorAlphaString = "#00aabbcc";
        int cssColorAlphaInt = 0xaabbcc00;
        p.set("key", cssColorAlphaString);
        QCOMPARE(p.get_int("key"), cssColorAlphaInt);
    }

    void SetAndGetTimeCode()
    {
        Profile profile;
        Properties p;
        p.set("_profile", profile.get_profile(), 0);
        const char *timeString = "11:22:33:04";
        p.set("key", timeString);
        QCOMPARE(p.get_int("key"), 1023829);
        p.set("key", 1023829);
        QCOMPARE(p.get_time("key", mlt_time_smpte), timeString);
    }

    void SetAndGetTimeClock()
    {
        Profile profile;
        Properties p;
        p.set("_profile", profile.get_profile(), 0);
        const char *timeString = "11:22:33.400";
        p.set("key", timeString);
        QCOMPARE(p.get_int("key"), 1023835);
        p.set("key", 1023835);
        QCOMPARE(p.get_time("key", mlt_time_clock), timeString);
    }

    void SetSimpleMathExpression()
    {
        Properties p;
        p.set("key", "@16.0/9.0 *2 +3 -1");
        QCOMPARE(p.get_int("key"), 5);
        QCOMPARE(p.get_double("key"), 16.0/9.0 *2 +3 -1);
    }

    void PassOneProperty()
    {
        Properties p[2];
        const char *s = "value";
        p[0].set("key", s);
        QCOMPARE(p[1].get("key"), (void*) 0);
        p[1].pass_property(p[0], "key");
        QCOMPARE(p[1].get("key"), s);
    }

    void PassMultipleByPrefix()
    {
        Properties p[2];
        const char *s = "value";
        p[0].set("key.one", s);
        p[0].set("key.two", s);
        QCOMPARE(p[1].get("key.one"), (void*) 0);
        QCOMPARE(p[1].get("key.two"), (void*) 0);
        p[1].pass_values(p[0], "key.");
        QCOMPARE(p[1].get("one"), s);
        QCOMPARE(p[1].get("two"), s);
    }

    void PassMultipleByList()
    {
        Properties p[2];
        const char *s = "value";
        p[0].set("key.one", s);
        p[0].set("key.two", s);
        QCOMPARE(p[1].get("key.one"), (void*) 0);
        QCOMPARE(p[1].get("key.two"), (void*) 0);
        p[1].pass_list(p[0], "key.one key.two");
        QCOMPARE(p[1].get("key.one"), s);
        QCOMPARE(p[1].get("key.two"), s);
    }

    void MirrorProperties()
    {
        Properties p[2];
        p[0].mirror(p[1]);
        p[0].set("key", "value");
        QCOMPARE(p[1].get("key"), "value");
    }

    void InheritProperties()
    {
        Properties p[2];
        p[0].set("key", "value");
        QVERIFY(p[1].get("key") == 0);
        p[1].inherit(p[0]);
        QCOMPARE(p[1].get("key"), "value");
    }

    void ParseString()
    {
        Properties p;
        QCOMPARE(p.get("key"), (void*) 0);
        p.parse("key=value");
        QCOMPARE(p.get("key"), "value");
        p.parse("key=\"new value\"");
        QCOMPARE(p.get("key"), "new value");
    }

    void RenameProperty()
    {
        Properties p;
        p.set("key", "value");
        QVERIFY(p.get("new key") == 0);
        p.rename("key", "new key");
        QCOMPARE(p.get("new key"), "value");
    }

    void SequenceDetected()
    {
        Properties p;
        p.set("1", 1);
        p.set("2", 2);
        p.set("3", 3);
        QVERIFY(p.is_sequence());
        p.set("four", 4);
        QVERIFY(!p.is_sequence());
    }

    void SerializesToYamlTiny()
    {
        Properties p[2];
        p[0].set("key1", "value1");
        p[0].set("key2", "value2");
        p[1].set("1", "value3");
        p[1].set("2", "value4");
        p[0].set("seq", p[1].get_properties(), 0);
        QCOMPARE(p[0].serialise_yaml(),
                "---\n"
                "key1: value1\n"
                "key2: value2\n"
                "seq:\n"
                "  - value3\n"
                "  - value4\n"
                "...\n");
    }

    void RadixRespondsToLocale()
    {
        Properties p;
        p.set_lcnumeric("en_US");
        p.set("key", "0.125");
        QCOMPARE(p.get_double("key"), double(1) / double(8));
        p.set_lcnumeric("de_DE");
        p.set("key", "0,125");
        QCOMPARE(p.get_double("key"), double(1) / double(8));
    }
};

QTEST_APPLESS_MAIN(TestProperties)

#include "test_properties.moc"
<|endoftext|>


<commit_before>/* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */
#include "unittest.h"

#include "command_line/CommandLine.h"
#include "consistent_hashing/HashRing.h"
#include "integration/TurboCluster.h"
#include "integration/TurboRunner.h"
#include "serialize/StringUtil.h"
#include "time/WaitFor.h"

#include <exception>
using std::string;

namespace {
	string hashRingStr(string id)
	{
		return HashRing::hash(id) + ":" + id + " ";
	}
}

TEST_CASE( "MerklePartitionTest/testSync", "[integration-udp]" )
{
	TurboCluster cluster(6, "--udp --no-write-chaining");
	cluster.start();
	assertMsg( cluster.waitForRunning(), cluster.lastError() );

	string response = cluster[1].query("membership");
	assertEquals( "1 127.0.0.1:9001\n"
				  "2 127.0.0.1:9002\n"
				  "3 127.0.0.1:9003\n"
				  "4 127.0.0.1:9004\n"
				  "5 127.0.0.1:9005\n"
				  "6 127.0.0.1:9006", response );

	// the hash ring order is 2, 6, 1, 5, 4, 3.
	// e.g. if the primary location is 2, the secondary is 6, the tertiary is 1...
	string expected = hashRingStr("2") + hashRingStr("6") + hashRingStr("1") + hashRingStr("5") + hashRingStr("4") + hashRingStr("3");
	response = cluster[1].query("ring");
	assertEquals(expected, response);

	// setting n=3 here, so we get 3 "proper" copies of the file instead of 2. (also, if we decide to change the defaults at any point...)
	for (unsigned i = 1; i <= 6; ++i)
	{
		string num = StringUtil::str(i);
		response = CommandLine::run("echo 'write|name=" + num + " n=3|hello" + num + "' | nc -U " + cluster[1].dataChannel());
		assertEquals( "", response );
	}

	//CommandLine::run("sleep 60");

	// wait for files to propagate
	// again, 2,6,1,5,4,3
	response = cluster[2].query("local_list");
	assertEquals( "(2)=>7\n"
				  "(3)=>7\n"
				  "(4)=>7", response );

	response = cluster[3].query("local_list");
	assertEquals( "(3)=>7\n"
				  "(4)=>7\n"
				  "(5)=>7", response );

	response = cluster[4].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(4)=>7\n"
				  "(5)=>7", response );

	response = cluster[5].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(5)=>7\n"
				  "(6)=>7", response );

	response = cluster[6].query("local_list");
	assertEquals( "(2)=>7\n"
				  "(3)=>7\n"
				  "(6)=>7", response );

	// runner1 should drop the files he's not responsible for
	// ... but he doesn't know how yet so he won't. Welp.
	/*response = cluster[1].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(2)=>7\n"
				  "(6)=>7", response );*/
}
<commit_msg>Adding a simpler version of the merkle partitioning integration test. And this one passes! .. because it doesn't rely on the (currently nonexistent) drop functionality.<commit_after>/* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */
#include "unittest.h"

#include "command_line/CommandLine.h"
#include "consistent_hashing/HashRing.h"
#include "integration/TurboCluster.h"
#include "integration/TurboRunner.h"
#include "serialize/StringUtil.h"
#include "time/WaitFor.h"

#include <exception>
using std::string;

namespace {
	string hashRingStr(string id)
	{
		return HashRing::hash(id) + ":" + id + " ";
	}
}

TEST_CASE( "MerklePartitionTest/testSync", "[integration-udp]" )
{
	TurboCluster cluster(6, "--udp --no-write-chaining");
	cluster.start();
	assertMsg( cluster.waitForRunning(), cluster.lastError() );

	string response = cluster[1].query("membership");
	assertEquals( "1 127.0.0.1:9001\n"
				  "2 127.0.0.1:9002\n"
				  "3 127.0.0.1:9003\n"
				  "4 127.0.0.1:9004\n"
				  "5 127.0.0.1:9005\n"
				  "6 127.0.0.1:9006", response );

	// the hash ring order is 2, 6, 1, 5, 4, 3.
	// e.g. if the primary location is 2, the secondary is 6, the tertiary is 1...
	string expected = hashRingStr("2") + hashRingStr("6") + hashRingStr("1") + hashRingStr("5") + hashRingStr("4") + hashRingStr("3");
	response = cluster[1].query("ring");
	assertEquals(expected, response);

	// write each file to its primary location. Rely on healing to synchronize everything else.
	// setting n=3 here, so we get 3 "proper" copies of the file instead of 2. (also, if we decide to change the defaults at any point...)
	for (unsigned i = 1; i <= 6; ++i)
	{
		string num = StringUtil::str(i);
		response = CommandLine::run("echo 'write|name=" + num + " n=3|hello" + num + "' | nc -U " + cluster[i].dataChannel());
		assertEquals( "", response );
	}

	CommandLine::run("sleep 30");

	// wait for files to propagate
	// again, 2,6,1,5,4,3
	response = cluster[1].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(2)=>7\n"
				  "(6)=>7", response );

	response = cluster[2].query("local_list");
	assertEquals( "(2)=>7\n"
				  "(3)=>7\n"
				  "(4)=>7", response );

	response = cluster[3].query("local_list");
	assertEquals( "(3)=>7\n"
				  "(4)=>7\n"
				  "(5)=>7", response );

	response = cluster[4].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(4)=>7\n"
				  "(5)=>7", response );

	response = cluster[5].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(5)=>7\n"
				  "(6)=>7", response );

	response = cluster[6].query("local_list");
	assertEquals( "(2)=>7\n"
				  "(3)=>7\n"
				  "(6)=>7", response );

}

TEST_CASE( "MerklePartitionTest/testRedistribute", "[integration-udp]" )
{
	TurboCluster cluster(6, "--udp --no-write-chaining");
	cluster.start();
	assertMsg( cluster.waitForRunning(), cluster.lastError() );

	string response = cluster[1].query("membership");
	assertEquals( "1 127.0.0.1:9001\n"
				  "2 127.0.0.1:9002\n"
				  "3 127.0.0.1:9003\n"
				  "4 127.0.0.1:9004\n"
				  "5 127.0.0.1:9005\n"
				  "6 127.0.0.1:9006", response );

	// the hash ring order is 2, 6, 1, 5, 4, 3.
	// e.g. if the primary location is 2, the secondary is 6, the tertiary is 1...
	string expected = hashRingStr("2") + hashRingStr("6") + hashRingStr("1") + hashRingStr("5") + hashRingStr("4") + hashRingStr("3");
	response = cluster[1].query("ring");
	assertEquals(expected, response);

	// write ONLY to worker 1.
	// setting n=3 here, so we get 3 "proper" copies of the file instead of 2. (also, if we decide to change the defaults at any point...)
	for (unsigned i = 1; i <= 6; ++i)
	{
		string num = StringUtil::str(i);
		response = CommandLine::run("echo 'write|name=" + num + " n=3|hello" + num + "' | nc -U " + cluster[1].dataChannel());
		assertEquals( "", response );
	}

	//CommandLine::run("sleep 60");

	// wait for files to propagate
	// again, 2,6,1,5,4,3
	response = cluster[2].query("local_list");
	assertEquals( "(2)=>7\n"
				  "(3)=>7\n"
				  "(4)=>7", response );

	response = cluster[3].query("local_list");
	assertEquals( "(3)=>7\n"
				  "(4)=>7\n"
				  "(5)=>7", response );

	response = cluster[4].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(4)=>7\n"
				  "(5)=>7", response );

	response = cluster[5].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(5)=>7\n"
				  "(6)=>7", response );

	response = cluster[6].query("local_list");
	assertEquals( "(2)=>7\n"
				  "(3)=>7\n"
				  "(6)=>7", response );

	// runner1 should drop the files he's not responsible for
	// ... but he doesn't know how yet so he won't. Welp.
	/*response = cluster[1].query("local_list");
	assertEquals( "(1)=>7\n"
				  "(2)=>7\n"
				  "(6)=>7", response );*/
}
<|endoftext|>