Permalink
Browse files

Merge branch '0.10' of https://github.com/OpenLightingProject/ola int…

…o master-resync
  • Loading branch information...
peternewman committed Oct 27, 2018
2 parents da9d023 + fd114a7 commit f034c40d0f245db09377891aac88ffbe2b62d6de
@@ -246,7 +246,7 @@ elif [[ $TASK = 'flake8' ]]; then
travis_fold start "make_builtfiles"
make builtfiles;
travis_fold end "make_builtfiles"
flake8 --max-line-length 80 --exclude *_pb2.py,.git,__pycache --ignore E111,E114,E121,E127,E129 data/rdm include/ola python scripts tools/ola_mon tools/rdm
flake8 --max-line-length 80 --exclude *_pb2.py,.git,__pycache --ignore E111,E114,E121,E127,E129,W504 data/rdm include/ola python scripts tools/ola_mon tools/rdm
elif [[ $TASK = 'pychecker' ]]; then
travis_fold start "autoreconf"
autoreconf -i;
@@ -293,7 +293,12 @@ elif [[ $TASK = 'pychecker-wip' ]]; then
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST $(find ./ -name "*.py" -and ! \( -name "*_pb2.py" -or -name "OlaClient.py" -or -name "ola_candidate_ports.py" \) | xargs)
else
# Otherwise compile and check as normal
export DISTCHECK_CONFIGURE_FLAGS='--enable-rdm-tests --enable-java-libs --enable-ja-rule --enable-e133'
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
# Silence all deprecated declarations on Linux due to auto_ptr making the build log too long
export DISTCHECK_CONFIGURE_FLAGS='--enable-rdm-tests --enable-java-libs --enable-ja-rule --enable-e133 CPPFLAGS=-Wno-deprecated-declarations'
else
export DISTCHECK_CONFIGURE_FLAGS='--enable-rdm-tests --enable-java-libs --enable-ja-rule --enable-e133'
fi
travis_fold start "autoreconf"
autoreconf -i;
travis_fold end "autoreconf"
@@ -651,19 +651,28 @@ RDMResponse *ResponderHelper::GetListInterfaces(
std::sort(interfaces.begin(), interfaces.end(),
ola::network::InterfaceIndexOrdering());
uint16_t interface_count = std::count_if(
interfaces.begin(), interfaces.end(), IsInterfaceIndexValidInterface);
PACK(
struct list_interfaces_s {
uint32_t index;
uint16_t type;
});
STATIC_ASSERT(sizeof(list_interfaces_s) == 6);
list_interfaces_s list_interfaces[interfaces.size()];
list_interfaces_s list_interfaces[interface_count];
// Reorder so valid interfaces are first
std::stable_partition(interfaces.begin(), interfaces.end(),
IsInterfaceIndexValidInterface);
for (uint16_t i = 0; i < interfaces.size(); i++) {
list_interfaces[i].index = HostToNetwork(interfaces[i].index);
// Then just iterate through the valid ones
vector<Interface>::iterator iter = interfaces.begin();
for (uint16_t i = 0; i < interface_count; i++) {
list_interfaces[i].index = HostToNetwork(iter[i].index);
list_interfaces[i].type = HostToNetwork(
static_cast<uint16_t>(interfaces[i].type));
static_cast<uint16_t>(iter[i].type));
}
return GetResponseFromData(
@@ -1201,10 +1210,24 @@ RDMResponse *ResponderHelper::SetUInt32Value(
bool ResponderHelper::FindInterface(
const NetworkManagerInterface *network_manager,
Interface *interface, uint32_t index) {
if (!IsInterfaceIndexValid(index)) {
// Invalid index
return false;
}
InterfacePicker::Options options;
options.specific_only = true;
return network_manager->GetInterfacePicker()->ChooseInterface(
interface, index, options);
}
bool ResponderHelper::IsInterfaceIndexValid(uint32_t index) {
return (index >= MIN_RDM_INTERFACE_INDEX &&
index <= MAX_RDM_INTERFACE_INDEX);
}
bool ResponderHelper::IsInterfaceIndexValidInterface(Interface interface) {
return IsInterfaceIndexValid(interface.index);
}
} // namespace rdm
} // namespace ola
@@ -692,6 +692,9 @@ typedef enum {
static const uint16_t IPV4_UNCONFIGURED = 0x00000000;
static const uint16_t NO_DEFAULT_ROUTE = 0x00000000;
static const uint32_t MIN_RDM_INTERFACE_INDEX = 0x00000001;
static const uint32_t MAX_RDM_INTERFACE_INDEX = 0xFFFFFF00;
typedef enum {
DHCP_STATUS_INACTIVE = 0x00,
DHCP_STATUS_ACTIVE = 0x01,
@@ -271,6 +271,8 @@ class ResponderHelper {
const NetworkManagerInterface *network_manager,
ola::network::Interface *interface,
uint32_t index);
static bool IsInterfaceIndexValid(uint32_t index);
static bool IsInterfaceIndexValidInterface(ola::network::Interface interface);
};
} // namespace rdm
} // namespace ola
@@ -22,7 +22,7 @@ show this help message and exit
The directory to load the PID definitions from.
.TP
\fB\-d\fR WWW_DIR, \fB\-\-www\-dir\fR=\fIWWW_DIR\fR
The root directory to serve static files.
The root directory to serve static files, this must be absolute.
.TP
\fB\-l\fR LOG_DIRECTORY, \fB\-\-log\-directory\fR=\fILOG_DIRECTORY\fR
The directory to store log files.
@@ -32,6 +32,7 @@
#include "common/rdm/TestHelper.h"
#include "ola/Constants.h"
#include "ola/Logging.h"
#include "ola/network/Interface.h"
#include "ola/network/NetworkUtils.h"
#include "ola/rdm/OpenLightingEnums.h"
#include "ola/rdm/RDMAPI.h"
@@ -47,6 +48,7 @@ namespace plugin {
namespace dummy {
using ola::network::HostToNetwork;
using ola::network::Interface;
using ola::rdm::RDMGetRequest;
using ola::rdm::RDMGetResponse;
using ola::rdm::RDMReply;
@@ -80,12 +82,14 @@ class DummyPortTest: public CppUnit::TestFixture {
CPPUNIT_TEST(testParamDescription);
CPPUNIT_TEST(testOlaManufacturerPidCodeVersion);
CPPUNIT_TEST(testSlotInfo);
CPPUNIT_TEST(testListInterfaces);
CPPUNIT_TEST_SUITE_END();
public:
DummyPortTest()
: TestFixture(),
m_expected_uid(0x7a70, 0xffffff00),
m_network_expected_uid(0x7a70, 0xffffff05),
m_test_source(1, 2) {
ola::InitLogging(ola::OLA_LOG_INFO, ola::OLA_LOG_STDERR);
}
@@ -109,9 +113,11 @@ class DummyPortTest: public CppUnit::TestFixture {
void testParamDescription();
void testOlaManufacturerPidCodeVersion();
void testSlotInfo();
void testListInterfaces();
private:
UID m_expected_uid;
UID m_network_expected_uid;
UID m_test_source;
MockDummyPort m_port;
ola::rdm::RDMStatusCode m_expected_code;
@@ -161,6 +167,13 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DummyPortTest);
void DummyPortTest::HandleRDMResponse(RDMReply *reply) {
OLA_ASSERT_EQ(m_expected_code, reply->StatusCode());
if (m_expected_response) {
OLA_ASSERT(reply->Response());
// Check the param data explicitly first, as it's most likely to be wrong
// and will make developers lives easier
OLA_ASSERT_DATA_EQUALS(m_expected_response->ParamData(),
m_expected_response->ParamDataSize(),
reply->Response()->ParamData(),
reply->Response()->ParamDataSize());
OLA_ASSERT_TRUE(*m_expected_response == *reply->Response());
} else {
OLA_ASSERT_NULL(reply->Response());
@@ -790,6 +803,57 @@ void DummyPortTest::testSlotInfo() {
}
/*
* Check that the list interface command works
*/
void DummyPortTest::testListInterfaces() {
RDMRequest *request = new RDMGetRequest(
m_test_source,
m_network_expected_uid,
0, // transaction #
1, // port id
0, // sub device
ola::rdm::PID_LIST_INTERFACES, // param id
NULL, // data
0); // data length
PACK(
struct list_interface_struct {
uint32_t interface_identifier;
uint16_t interface_hardware_type;
});
PACK(
struct list_interfaces_s {
list_interface_struct list_interface_s[2];
});
list_interfaces_s list_interfaces = {
{
{HostToNetwork(static_cast<uint32_t>(1)),
HostToNetwork(static_cast<uint16_t>(Interface::ARP_ETHERNET_TYPE))},
{HostToNetwork(static_cast<uint32_t>(2)),
HostToNetwork(static_cast<uint16_t>(Interface::ARP_ETHERNET_TYPE))}
}};
RDMResponse *response = GetResponseFromData(
request,
reinterpret_cast<uint8_t*>(&list_interfaces),
sizeof(list_interfaces));
SetExpectedResponse(ola::rdm::RDM_COMPLETED_OK, response);
m_port.SendRDMRequest(
request,
NewSingleCallback(this, &DummyPortTest::HandleRDMResponse));
Verify();
checkSubDeviceOutOfRange(ola::rdm::PID_LIST_INTERFACES);
checkMalformedRequest(ola::rdm::PID_LIST_INTERFACES);
checkSetRequest(ola::rdm::PID_LIST_INTERFACES);
checkNoBroadcastResponse(ola::rdm::PID_LIST_INTERFACES);
}
void DummyPortTest::VerifyUIDs(const UIDSet &uids) {
UIDSet expected_uids;
for (unsigned int i = 0; i < 6; i++) {
@@ -2174,7 +2174,7 @@ def _GetPersonality(self):
self.Stop()
return
if self._current_index >= MAX_PERSONALITY_NUMBER:
if self._current_index > MAX_PERSONALITY_NUMBER:
# This should never happen because personality_count is a uint8
self.SetFailed('Could not find all personalities')
return
@@ -7150,13 +7150,14 @@ def VerifyResult(self, response, fields):
for interface in fields['interfaces']:
interface_id = interface['interface_identifier']
interfaces.append(interface_id)
if (interface_id < RDM_INTERFACE_INDEX_MIN or
interface_id > RDM_INTERFACE_INDEX_MAX):
self.AddWarning('Interface index %d is outside allowed range (%d to '
'%d)' % (interface_id,
RDM_INTERFACE_INDEX_MIN,
RDM_INTERFACE_INDEX_MAX))
else:
interfaces.append(interface_id)
if (interface['interface_hardware_type'] !=
INTERFACE_HARDWARE_TYPE_ETHERNET):
self.AddAdvisory('Possible error, found unusual hardware type %d for '
@@ -108,7 +108,8 @@ class MyFilter(object):
"""Filter out the ascii coloring."""
def filter(self, record):
msg = record.msg
record.msg = re.sub('\x1b\[\d*m', '', str(msg))
# Use a raw string for the regex
record.msg = re.sub(r'\x1b\[\d*m', '', str(msg))
return True
@@ -970,7 +970,7 @@ def BuildApplication(ola_thread, test_thread, pid_store):
app.RegisterHandler('/RunTests', run_tests_handler.HandleRequest)
app.RegisterHandler('/StatCollector', run_tests_handler.HandleRequest)
app.RegisterHandler('/StatTests', run_tests_handler.HandleRequest)
app.RegisterRegex('/static/.*',
app.RegisterRegex(r'/static/.*',
StaticFileHandler(settings['www_dir']).HandleRequest)
return app
@@ -992,7 +992,8 @@ def parse_options():
parser.add_option('-p', '--pid-location', metavar='DIR',
help='The directory to load the PID definitions from.')
parser.add_option('-d', '--www-dir', default=DataLocation.location,
help='The root directory to serve static files.')
help='The root directory to serve static files, this must '
'be absolute.')
parser.add_option('-l', '--log-directory',
default=os.path.abspath('/tmp/ola-rdm-logs'),
help='The directory to store log files.')

0 comments on commit f034c40

Please sign in to comment.