Fix this error:
File "/new_devel/apps/zbar/test/barcodetest.py", line 137, in run_zbarimg
'zbarimg returned error status (%d)\n' % rc + err
TypeError: can only concatenate str (not "bytes") to str
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Do some manual coding style adjustments, while keeping
the coding style defined for clang-format.
This also fixes some compilation breakages, due to include
reordering.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
While both work, "config.h" is a more modern convention, and
helps to identify that this file is from the project, and not
from the system's include files.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
As pointed by:
- https://github.com/mchehab/zbar/issues/162
The sysmacros.h header is being included inconditionally.
Yet, that's not the only place where sys/*.h headers are
included without using the config.h feedback.
Fix them.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
As reported by Martin Strunz, The iter for loop was not
properly initialized.
Reported at https://github.com/mchehab/zbar/issues/118
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
It is very useful to run this tool as just:
./test/test_dbus
And run zbarimg on a separate window, as this allows to
quickly check if ZBar dbus code is working fine.
Let's keep accepting such behaviour by making the two log
arguments optional.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Currently, only the dictionary keys are validated.
Dictionary values are variant and could benefit from type checking
now that types other than string are being used.
The D-Bus test program and script now reads and verifies binary data.
Text and binary data are written to separate log files which must be
specified by the test script. The checksums of these log files will
be compared against the expected value.
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Check the correctness of binary data extracted from QR codes.
This specific test can be run with:
make check-images
The binary QR code example is the qr-code.png file, QR encoded:
qrencode --8bit --output examples/qr-code-binary.png < examples/qr-code.png
Tested-by: Peter Moran <petecmo@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
On python3, thie error may occur:
/usr/bin/python3 /devel/v4l/zbar/test/barcodetest.py
F
======================================================================
FAIL: runTest (__main__.BuiltinTestCase)
/devel/v4l/zbar/examples/ean-13.png
----------------------------------------------------------------------
Traceback (most recent call last):
File "/devel/v4l/zbar/test/barcodetest.py", line 168, in runTest
compare_sources(expect, actual[0])
File "/devel/v4l/zbar/test/barcodetest.py", line 248, in compare_sources
compare_maps(map_source(expect), map_source(actual), compare_indices)
File "/devel/v4l/zbar/test/barcodetest.py", line 217, in compare_maps
assert not errors, '\n'.join(errors)
AssertionError: Traceback (most recent call last):
File "/devel/v4l/zbar/test/barcodetest.py", line 200, in compare_maps
compare_func(iexp, iact)
File "/devel/v4l/zbar/test/barcodetest.py", line 269, in compare_indices
compare_maps(map_index(expect), map_index(actual), compare_symbols)
File "/devel/v4l/zbar/test/barcodetest.py", line 211, in compare_maps
errors.append('missing expected result:\n' + toxml(iexp))
File "/devel/v4l/zbar/test/barcodetest.py", line 54, in toxml
ET.ElementTree(node).write(s)
File "/usr/lib64/python3.7/xml/etree/ElementTree.py", line 777, in write
short_empty_elements=short_empty_elements)
File "/usr/lib64/python3.7/contextlib.py", line 119, in __exit__
next(self.gen)
File "/usr/lib64/python3.7/xml/etree/ElementTree.py", line 836, in _get_writer
yield file.write
File "/usr/lib64/python3.7/contextlib.py", line 524, in __exit__
raise exc_details[1]
File "/usr/lib64/python3.7/contextlib.py", line 509, in __exit__
if cb(*exc_details):
File "/usr/lib64/python3.7/contextlib.py", line 384, in _exit_wrapper
callback(*args, **kwds)
TypeError: string argument expected, got 'bytes'
The reason is that iexp.get(str(ET.QName(TS, 'exception')) may
return None. Add a clause to explicitly test for it.
After the change, both python3 and python2 should work:
$ /usr/bin/python3 /devel/v4l/zbar/test/barcodetest.py
.
----------------------------------------------------------------------
Ran 1 test in 0.037s
OK
$ /usr/bin/python2 /devel/v4l/zbar/test/barcodetest.py
.
----------------------------------------------------------------------
Ran 1 test in 0.042s
OK
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Change the script to be used either by printing the decoded
var or check. The behavior depends on having just one argument
(the image) or two: image and expected answer.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Change the code to avoig Gtk3 warnings. We don't care too
much about Gtk2 here, as Gtk2 as issues with GI. Yet, I
suspect that none of those changes will break with the latest
Gtk2 versions.
Among the changes is the import of GdkPixbuf. Without this,
opening an image won't work.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
There is one small mistake at parameter handling with
prevents it to work with python 3.
While here, pass parameters using key-value pairs.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
It doesn't make sense to build ZBar with one python version,
while running the tests with a different one. So, ensure that
the Python scripts will use the same python version as
defined during the build.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
It is very useful to be able to run the test scripts before
installing zbar. So, add the needed logic for running it,
by using some env variables to set the right paths to find the
built libraries and ZBar-1.0.typelib.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Do the authomatic part of the python3 conversion by running
2to3 and adding the needed backward-compatible logic for it to
keep running with python2.
Then, convert the open() logic to avoid a warning with python3
and add a fake discover method for the python3 unittest to
not complain.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Add a converted version of test_pygtk script, modified to use
ZBarGtk bindings via gi.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
In order to use the pygtk test script without installing, one
needs to use PYTHONPATH var.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
There's a mess at configure.ac at the java detection code,
and on its usage at check-java target.
Place the Java detection code in just one place, reorganizing
the code in a way that it will use the canonical name of the
javac directory as default, in the case JAVA_HOME is not
explicitly set. It will also use the detected JAVA_HOME at
make check-java
target.
Also, java versions bigger than 8 don't come anymore with
javah. Instead, javac was incremented to produce headers,
but with a different syntax and more limited features, as
it doesn't allow anymore to generate a single header file
for multiple java sources.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Now that there's an optional feature to parse inverted
images, add a new png file (with is just qr-code.png inverted
via gimp) and a new test, in order to check if inverted parsing
is working.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The ean-2 and ean-5 EAN variants are also disabled by default.
So, the check should explicitly enable it if needed.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The UPC-A is also an EAN-13 variant. As such, it requires
to be explicitly enabled in order to work.
Add support for testing the decoding of this variant.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The ISBN-10 and ISDN-13 are simply variants of EAN-13 code.
Add the needed logic to check them.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Now that the error margin is less than 0.01% for missing
detection and spurious detection, the regress patch passes.
So, add it to the check-local target, in order for Travis CI
to also run it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
As the testset generated by the regression tool may contain
noise, it is possible that some images will cause some
confusion, causing them to not be decoded, or causing
another decoder to think it is a valid image for them.
So, tolerate spurious detections and missing detection, if
is is less than 0.01% of the sample set.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
It helps to print a summary about the number of warnings at
the end. Also, make clear that the wrong symbology warning
is due to a spurious code detection.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The existing argument parsing logic is weird: if parameters
are passed out of an expected order, it may be ignored. Also,
it doesn't provide any help about what parameters are available.
Use argp instead, with simplifies the code and provide a
help about the expected parameters.
As a bonus, the code inside the main() function is now
clearer and easier to understand. It also allows to combine
-n with -s, with could be useful to start a regression test
from a different seed.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Sometimes, the random generated images may be decoded by
multiple decoders. Handle those as warnings, and keep
waiting for the right code, only reporting an error when
either a symbol was missing with the right code or when
it was badly decoded.
With that, "make regress" now produce a more coherent
result:
[28417] SEED=-1466011001: warning: expecting DataBar, got EAN-2
[35442] SEED=-591992353: ERROR: MISSING CODE-39 (YP%CC-.)
[64558] SEED=1906143625: ERROR: MISSING CODE-128 (41714534408557)
[79042] SEED=-1776449378: ERROR: MISSING CODE-39 (Z5EKHI5I6)
[84522] SEED=-966054662: warning: expecting DataBar, got EAN-2
[98350] SEED=1992973531: warning: expecting DataBar, got EAN-2
decoder FAILED (3 errors).
Calling it with one of those seeds will also present a better
result:
test_decode -s -1466011001
[0] SEED=-1466011001
testing data: 58022598404365
[0] SEED=-1466011001: warning: expecting DataBar, got EAN-2
testing alpha: kqw9:'{,sx
decoder PASSED.
On this specific case, it decoded as data=10 (EAN-2) and with
data=58022598404365(DataBar) as expected.
The first one was an expurious decoding.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The check-java seems very useful: it already helped to
detect a regression currently introduced.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The "make tests" target will now run all existing ZBar
tests.
Some notes:
1) The regress image test doesn't make sense, as it depends on
some extra stuff that it is not at Sourceforge anymore;
2) The regress-decoder fails after ~29000 interactions;
3) The other tests will only run fine on a machine with X11,
a video camera device and a functional D-Bus.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This testing tool is too verbose. Add a way to make it run
quietly.
While here, document the other parameters and parse them
using argp. That makes it easier to understand.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
add a makefile target to run this code and make its output
to look similar to the other tests.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Right now, the test targets are spread into 3 different files
and don't produce a coherent result. Also, patches are not
absolute, making harder to be used by travis.
Do some cleanups there in order to make it more consistent.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
On a test script, it is useful to define a maximum time for
it to receive messages from D-BUS. So, add a new argument
for that.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
It is useful to be able to stop D-Bus listening after
receiving an expected number of messages. This way, a CI script
could use it to specify the amount of data it would expect to
receive.
So, add a program argument to implement such logic.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>