Skip to content

Commit 526195a

Browse files
authored
Merge pull request #1797 from peternewman/0.10-clang-latest
Cherry-pick some easy stuff from #1761
2 parents 4d7bbbe + cad5a73 commit 526195a

12 files changed

Lines changed: 158 additions & 28 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ libs/acn/e131_loadtest
175175
libs/acn/e131_loadtest.exe
176176
libs/acn/e131_transmit_test
177177
libs/acn/e131_transmit_test.exe
178+
ola-*/
178179
ola.spec
179180
olad/olad
180181
olad/olad.exe
@@ -224,6 +225,7 @@ tools/ola_trigger/ola_trigger
224225
tools/ola_trigger/ola_trigger.exe
225226
tools/ola_trigger/FileValidateTest.sh
226227
tools/rdm/DataLocation.py
228+
tools/rdm/ExpectedResultsTest.sh
227229
tools/rdm/ResponderTestTest.sh
228230
tools/rdm/TestHelpersTest.sh
229231
tools/rdm/TestStateTest.sh

.travis-ci.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ if [[ $TASK = 'lint' ]]; then
5353
# the following is a bit of a hack to build the files normally built during
5454
# the build, so they are present for linting to run against
5555
travis_fold start "make_builtfiles"
56-
make builtfiles;
56+
make builtfiles VERBOSE=1;
5757
travis_fold end "make_builtfiles"
5858
# first check we've not got any generic NOLINTs
5959
# count the number of generic NOLINTs
@@ -67,7 +67,7 @@ if [[ $TASK = 'lint' ]]; then
6767
echo "Found $nolints generic NOLINTs"
6868
fi;
6969
# run the cpplint tool, fetching it if necessary
70-
make cpplint
70+
make cpplint VERBOSE=1
7171
elif [[ $TASK = 'check-licences' ]]; then
7272
# check licences only if it is the requested task
7373
travis_fold start "autoreconf"
@@ -79,7 +79,7 @@ elif [[ $TASK = 'check-licences' ]]; then
7979
# the following is a bit of a hack to build the files normally built during
8080
# the build, so they are present for licence checking to run against
8181
travis_fold start "make_builtfiles"
82-
make builtfiles;
82+
make builtfiles VERBOSE=1;
8383
travis_fold end "make_builtfiles"
8484
./scripts/enforce_licence.py
8585
if [[ $? -ne 0 ]]; then
@@ -96,7 +96,7 @@ elif [[ $TASK = 'spellintian' ]]; then
9696
# the following is a bit of a hack to build the files normally built during
9797
# the build, so they are present for spellintian to run against
9898
travis_fold start "make_builtfiles"
99-
make builtfiles;
99+
make builtfiles VERBOSE=1;
100100
travis_fold end "make_builtfiles"
101101
spellingfiles=$(eval "find ./ -type f -and ! \( \
102102
$SPELLINGBLACKLIST \
@@ -122,7 +122,7 @@ elif [[ $TASK = 'spellintian-duplicates' ]]; then
122122
# the following is a bit of a hack to build the files normally built during
123123
# the build, so they are present for spellintian to run against
124124
travis_fold start "make_builtfiles"
125-
make builtfiles;
125+
make builtfiles VERBOSE=1;
126126
travis_fold end "make_builtfiles"
127127
spellingfiles=$(eval "find ./ -type f -and ! \( \
128128
$SPELLINGBLACKLIST \
@@ -148,7 +148,7 @@ elif [[ $TASK = 'codespell' ]]; then
148148
# the following is a bit of a hack to build the files normally built during
149149
# the build, so they are present for codespell to run against
150150
travis_fold start "make_builtfiles"
151-
make builtfiles;
151+
make builtfiles VERBOSE=1;
152152
travis_fold end "make_builtfiles"
153153
spellingfiles=$(eval "find ./ -type f -and ! \( \
154154
$SPELLINGBLACKLIST \
@@ -175,13 +175,13 @@ elif [[ $TASK = 'doxygen' ]]; then
175175
# the following is a bit of a hack to build the files normally built during
176176
# the build, so they are present for Doxygen to run against
177177
travis_fold start "make_builtfiles"
178-
make builtfiles;
178+
make builtfiles VERBOSE=1;
179179
travis_fold end "make_builtfiles"
180180
# count the number of warnings
181181
warnings=$(make doxygen-doc 2>&1 >/dev/null | wc -l)
182182
if [[ $warnings -ne 0 ]]; then
183183
# print the output for info
184-
make doxygen-doc
184+
make doxygen-doc VERBOSE=1
185185
echo "Found $warnings doxygen warnings"
186186
exit 1;
187187
else
@@ -227,7 +227,7 @@ elif [[ $TASK = 'flake8' ]]; then
227227
# the following is a bit of a hack to build the files normally built during
228228
# the build, so they are present for flake8 to run against
229229
travis_fold start "make_builtfiles"
230-
make builtfiles;
230+
make builtfiles VERBOSE=1;
231231
travis_fold end "make_builtfiles"
232232
make flake8
233233
else
@@ -245,7 +245,7 @@ else
245245
./configure $DISTCHECK_CONFIGURE_FLAGS;
246246
travis_fold end "configure"
247247
travis_fold start "make_distcheck"
248-
make distcheck;
248+
make distcheck VERBOSE=1;
249249
travis_fold end "make_distcheck"
250250
travis_fold start "make_dist"
251251
make dist;

NEWS

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
x/y/2020 ola-0.10.9
1+
x/y/2022 ola-0.10.9
22
Features:
3-
*
3+
*
44

55
API:
6-
*
6+
* Python: Add a fetch current DMX example.
77

88
RDM Tests:
99
*
1010

1111
Bugs:
12+
* Fix some tests not working on Big Endian machines because our RPC is encoded
13+
with native format and those tests used sample data from a Little Endian
14+
machine
1215
* Renamed EndpointNoticationEvent(sic) to EndpointNotificationEvent in the
1316
E1.33 EndpointManager code
1417

python/examples/ola_candidate_ports.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
__author__ = 'simon.marchi@polymtl.ca (Simon Marchi)'
2727

28+
wrapper = None
29+
2830

2931
def ParseArgs():
3032
desc = 'Show the candidate ports to patch to a universe.'
@@ -52,11 +54,21 @@ def GetCandidatePortsCallback(status, devices):
5254
else:
5355
print('Error: %s' % status.message, file=sys.stderr)
5456

57+
global wrapper
58+
if wrapper:
59+
wrapper.Stop()
60+
61+
62+
def main():
63+
args = ParseArgs()
64+
universe = args.universe
65+
66+
global wrapper
67+
wrapper = ClientWrapper()
68+
client = wrapper.Client()
69+
client.GetCandidatePorts(GetCandidatePortsCallback, universe)
70+
wrapper.Run()
5571

56-
args = ParseArgs()
57-
universe = args.universe
5872

59-
wrapper = ClientWrapper()
60-
client = wrapper.Client()
61-
client.GetCandidatePorts(GetCandidatePortsCallback, universe)
62-
wrapper.Run()
73+
if __name__ == "__main__":
74+
main()

python/examples/ola_devices.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ def main():
5757
client = wrapper.Client()
5858
client.FetchDevices(Devices)
5959
wrapper.Run()
60+
61+
62+
if __name__ == "__main__":
63+
main()

tools/rdm/ExpectedResults.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
# Expected result classes are broken down as follows:
1919
#
2020
# BaseExpectedResult - the base class
21-
# BroadcastResult - expects the request to be broadcast
21+
# BroadcastResult - expects the request to be broadcast, hence no response
22+
# TimeoutResult - expects the response to be a timeout
23+
# InvalidResult - expects the response to be invalid
24+
# UnsupportedResult - expects RDM Discovery to be unsupported
25+
# DUBResult - expects an RDM DUB response
2226
# SuccessfulResult - expects a well formed response from the device
2327
# NackResult - parent NACK class
28+
# NackDiscoveryResult - expects DISCOVERY_COMMAND_RESPONSE with a NACK
2429
# NackGetResult - expects GET_COMMAND_RESPONSE with a NACK
2530
# NackSetResult - expects SET_COMMAND_RESPONSE with a NACK
2631
# AckResult - parent ACK class
32+
# AckDiscoveryResult - expects DISCOVERY_COMMAND_RESPONSE with an ACK
2733
# AckGetResult - expects GET_COMMAND_RESPONSE with an ACK
2834
# AckSetResult - expects SET_COMMAND_RESPONSE with an ACK
2935
# QueuedMessageResult - expects an ACK or NACK for any PID other than
@@ -134,8 +140,8 @@ class SuccessfulResult(BaseExpectedResult):
134140
"""This checks that we received a valid response from the device.
135141
136142
This doesn't check that the response was a certain type, but simply that the
137-
message was formed correctly. Other classes inherit from this an perform more
138-
specific checking.
143+
message was formed correctly. Other classes inherit from this and perform
144+
more specific checking.
139145
"""
140146
def __str__(self):
141147
return 'RDM_COMPLETED_OK'

tools/rdm/ExpectedResultsTest.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env python
2+
# This program is free software; you can redistribute it and/or modify
3+
# it under the terms of the GNU General Public License as published by
4+
# the Free Software Foundation; either version 2 of the License, or
5+
# (at your option) any later version.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU Library General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, write to the Free Software
14+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15+
#
16+
# ExpectedResultsTest.py
17+
# Copyright (C) 2021 Peter Newman
18+
19+
import unittest
20+
from ExpectedResults import (BroadcastResult, DUBResult, InvalidResponse,
21+
TimeoutResult, SuccessfulResult, UnsupportedResult)
22+
from ola.OlaClient import OlaClient
23+
from collections import namedtuple
24+
25+
"""Test cases for ExpectedResults classes."""
26+
27+
__author__ = 'nomis52@gmail.com (Simon Newton)'
28+
29+
30+
class ExpectedResultsTest(unittest.TestCase):
31+
MockResponse = namedtuple('MockResponse', ['response_code'])
32+
MockBroadcastResponse = MockResponse(OlaClient.RDM_WAS_BROADCAST)
33+
MockTimeoutResponse = MockResponse(OlaClient.RDM_TIMEOUT)
34+
MockInvalidResponse = MockResponse(OlaClient.RDM_INVALID_RESPONSE)
35+
MockUnsupportedResult = MockResponse(
36+
OlaClient.RDM_PLUGIN_DISCOVERY_NOT_SUPPORTED)
37+
MockDUBResult = MockResponse(OlaClient.RDM_DUB_RESPONSE)
38+
MockSuccessfulResult = MockResponse(OlaClient.RDM_COMPLETED_OK)
39+
40+
def testBroadcastResult(self):
41+
br = BroadcastResult()
42+
self.assertTrue(br.Matches(self.MockBroadcastResponse, {}))
43+
self.assertFalse(br.Matches(self.MockTimeoutResponse, {}))
44+
self.assertFalse(br.Matches(self.MockInvalidResponse, {}))
45+
self.assertFalse(br.Matches(self.MockUnsupportedResult, {}))
46+
self.assertFalse(br.Matches(self.MockDUBResult, {}))
47+
self.assertFalse(br.Matches(self.MockSuccessfulResult, {}))
48+
49+
def testTimeoutResult(self):
50+
tr = TimeoutResult()
51+
self.assertFalse(tr.Matches(self.MockBroadcastResponse, {}))
52+
self.assertTrue(tr.Matches(self.MockTimeoutResponse, {}))
53+
self.assertFalse(tr.Matches(self.MockInvalidResponse, {}))
54+
self.assertFalse(tr.Matches(self.MockUnsupportedResult, {}))
55+
self.assertFalse(tr.Matches(self.MockDUBResult, {}))
56+
self.assertFalse(tr.Matches(self.MockSuccessfulResult, {}))
57+
58+
def testInvalidResponse(self):
59+
ir = InvalidResponse()
60+
self.assertFalse(ir.Matches(self.MockBroadcastResponse, {}))
61+
self.assertFalse(ir.Matches(self.MockTimeoutResponse, {}))
62+
self.assertTrue(ir.Matches(self.MockInvalidResponse, {}))
63+
self.assertFalse(ir.Matches(self.MockUnsupportedResult, {}))
64+
self.assertFalse(ir.Matches(self.MockDUBResult, {}))
65+
self.assertFalse(ir.Matches(self.MockSuccessfulResult, {}))
66+
67+
def testUnsupportedResult(self):
68+
ur = UnsupportedResult()
69+
self.assertFalse(ur.Matches(self.MockBroadcastResponse, {}))
70+
self.assertFalse(ur.Matches(self.MockTimeoutResponse, {}))
71+
self.assertFalse(ur.Matches(self.MockInvalidResponse, {}))
72+
self.assertTrue(ur.Matches(self.MockUnsupportedResult, {}))
73+
self.assertFalse(ur.Matches(self.MockDUBResult, {}))
74+
self.assertFalse(ur.Matches(self.MockSuccessfulResult, {}))
75+
76+
def testDUBResult(self):
77+
dr = DUBResult()
78+
self.assertFalse(dr.Matches(self.MockBroadcastResponse, {}))
79+
self.assertFalse(dr.Matches(self.MockTimeoutResponse, {}))
80+
self.assertFalse(dr.Matches(self.MockInvalidResponse, {}))
81+
self.assertFalse(dr.Matches(self.MockUnsupportedResult, {}))
82+
self.assertTrue(dr.Matches(self.MockDUBResult, {}))
83+
self.assertFalse(dr.Matches(self.MockSuccessfulResult, {}))
84+
85+
def testSuccessfulResult(self):
86+
sr = SuccessfulResult()
87+
self.assertFalse(sr.Matches(self.MockBroadcastResponse, {}))
88+
self.assertFalse(sr.Matches(self.MockTimeoutResponse, {}))
89+
self.assertFalse(sr.Matches(self.MockInvalidResponse, {}))
90+
self.assertFalse(sr.Matches(self.MockUnsupportedResult, {}))
91+
self.assertFalse(sr.Matches(self.MockDUBResult, {}))
92+
self.assertTrue(sr.Matches(self.MockSuccessfulResult, {}))
93+
94+
95+
if __name__ == '__main__':
96+
unittest.main()

tools/rdm/Makefile.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ launcher_files = \
5555

5656
EXTRA_DIST += $(launcher_files)
5757

58+
tools/rdm/ExpectedResultsTest.sh: tools/rdm/Makefile.mk
59+
mkdir -p $(top_builddir)/python/ola
60+
echo "PYTHONPATH=${top_builddir}/python $(PYTHON) ${srcdir}/tools/rdm/ExpectedResultsTest.py; exit \$$?" > $(top_builddir)/tools/rdm/ExpectedResultsTest.sh
61+
chmod +x $(top_builddir)/tools/rdm/ExpectedResultsTest.sh
62+
5863
tools/rdm/ResponderTestTest.sh: tools/rdm/Makefile.mk
5964
mkdir -p $(top_builddir)/python/ola
6065
echo "PYTHONPATH=${top_builddir}/python $(PYTHON) ${srcdir}/tools/rdm/ResponderTestTest.py; exit \$$?" > $(top_builddir)/tools/rdm/ResponderTestTest.sh
@@ -71,19 +76,22 @@ tools/rdm/TestStateTest.sh: tools/rdm/Makefile.mk
7176
chmod +x $(top_builddir)/tools/rdm/TestStateTest.sh
7277

7378
dist_check_SCRIPTS += \
79+
tools/rdm/ExpectedResultsTest.py \
7480
tools/rdm/ResponderTestTest.py \
7581
tools/rdm/TestHelpersTest.py \
7682
tools/rdm/TestStateTest.py
7783

7884
if BUILD_PYTHON_LIBS
7985
test_scripts += \
86+
tools/rdm/ExpectedResultsTest.sh \
8087
tools/rdm/ResponderTestTest.sh \
8188
tools/rdm/TestHelpersTest.sh \
8289
tools/rdm/TestStateTest.sh
8390
endif
8491

8592
CLEANFILES += \
8693
tools/rdm/*.pyc \
94+
tools/rdm/ExpectedResultsTest.sh \
8795
tools/rdm/ResponderTestTest.sh \
8896
tools/rdm/TestHelpersTest.sh \
8997
tools/rdm/TestStateTest.sh \

tools/rdm/ModelCollector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _GetDevice(self):
103103
def _GetVersion(self):
104104
this_device = self._GetDevice()
105105
software_versions = this_device['software_versions']
106-
return software_versions[software_versions.keys()[0]]
106+
return software_versions[list(software_versions.keys())[0]]
107107

108108
def _GetCurrentPersonality(self):
109109
this_device = self._GetDevice()

tools/rdm/ResponderTestTest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class ZTestFixture(TestFixture):
3333

3434

3535
class TestFixtureTest(unittest.TestCase):
36-
3736
def testCmp(self):
3837
base = TestFixture({}, 2, 123, None)
3938
base2 = TestFixture({}, 3, 456, None)

0 commit comments

Comments
 (0)