Commit Graph

112 Commits

Author SHA1 Message Date
ssrlive
c60026ecbe Merge https://github.com/mchehab/zbar.git 2022-09-21 16:23:00 +08:00
Mauro Carvalho Chehab
12748530f7 barcodetest.py: fix error code print logic
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>
2022-05-29 21:00:30 +02:00
ssrlive
cf3d385492 Synchronize with upstream code. 2021-10-07 16:38:06 +08:00
ssrlive
a812a96fad clang-format find . -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format --verbose --style=file -i {} \; 2021-10-07 06:06:52 +00:00
ssrlive
8a030167e4 following upstream changes. 2021-08-15 12:14:00 +08:00
Mauro Carvalho Chehab
4d9a03e716 Improve the coding style on some places
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>
2021-03-14 17:27:36 +01:00
Mauro Carvalho Chehab
5b3c33d5c8 Enforce a coding style
Use clang-format to ensure that a single coding style will
be followed everywhere.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-03-14 17:27:36 +01:00
Mauro Carvalho Chehab
ccfc6078ef use "config.h" instead of <config.h>
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>
2021-02-22 08:53:17 +01:00
Mauro Carvalho Chehab
bd01715671 zbar, test: fix compilation issues with FreeBSD
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>
2021-02-21 17:56:41 +01:00
Mauro Carvalho Chehab
48b47b7226 test: fix decode test
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>
2021-02-16 16:45:04 +01:00
Mauro Carvalho Chehab
8852aff565 tests: disable V4L2 test if /dev/video0 doesn't exist
It doesn't make sense to test V4L2 decoding if the /dev/video0
node doesn't exist.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-04-06 18:49:52 +02:00
Mauro Carvalho Chehab
6424e8df84 test/test_dbus.c: make --log and --log-bin args optional
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>
2020-03-13 10:49:04 +01:00
Matheus Afonso Martins Moreira
13eece07b5 test: verify types of data sent over D-Bus
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.
2020-03-13 10:49:04 +01:00
Matheus Afonso Martins Moreira
0c6eefa72c test: verify binary data received via D-Bus
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>
2020-03-13 10:49:04 +01:00
Matheus Afonso Martins Moreira
284583c237 test: add binary QR code test and example data
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>
2020-03-13 10:49:04 +01:00
Mauro Carvalho Chehab
276180caa8 barcodetest.py: Fix an error condition when called with python3
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>
2020-01-29 14:25:55 +01:00
Mauro Carvalho Chehab
d67faf8ea6 test/test_python.py: make it a little more generic
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>
2019-05-12 09:13:23 -03:00
Mauro Carvalho Chehab
266e420e3b test/test_gi.py: get rid of Gtk3 warnings
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>
2019-05-11 22:46:39 -03:00
Mauro Carvalho Chehab
1ca76bd835 test/Makefile.am.inc: fix a typo
Wrong file name. Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-05-11 15:07:08 -03:00
Mauro Carvalho Chehab
7bf9d3810d test/Makefile.am.inc: add the two extra test files to dist
There are two new scripts added. Add them to EXTRA_DIST.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-05-11 14:48:59 -03:00
Mauro Carvalho Chehab
052546f64f test_python.py: make it run properly with python 3
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>
2019-05-10 17:34:21 -03:00
Mauro Carvalho Chehab
03210cd086 Add a simple python bindings test script
This script checks if the python bindings is working.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-05-10 10:33:20 -03:00
Mauro Carvalho Chehab
5c26c0ea6f test: use the python version that was setup by ./configure
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>
2019-05-10 09:26:34 -03:00
Mauro Carvalho Chehab
2419932e9d test: allow running test-gi.py without installing GIR
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>
2019-05-10 09:13:35 -03:00
Mauro Carvalho Chehab
0616865fd1 test/barcodetest.py: make script compatible with Python3
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>
2019-05-10 08:54:40 -03:00
Mauro Carvalho Chehab
ee991e0e42 add test/test_gi.py to use GObject Instrospection
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>
2019-05-09 23:14:55 -03:00
Mauro Carvalho Chehab
1f204833a3 test/Makefile.am.inc: add a target to check pygtk module
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>
2019-05-08 06:54:33 -03:00
Mauro Carvalho Chehab
b7c045910a Fix Java detection and fix it for newer Java versions
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>
2019-04-26 00:20:43 -03:00
Mauro Carvalho Chehab
21a6d77697 Add test for -Stest-inverted
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>
2019-02-18 09:00:09 -03:00
Mauro Carvalho Chehab
f388a5a877 Add a Databar Expanded example
This one is enabled by default.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-11 13:27:56 -02:00
Mauro Carvalho Chehab
9355e54c88 Add a test for EAN-2 and EAN-5 variants
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>
2019-02-11 12:59:05 -02:00
Mauro Carvalho Chehab
14fe010b77 Add a test for UPC-A EAN-13 variant
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>
2019-02-11 11:25:49 -02:00
Mauro Carvalho Chehab
a5da2f2891 isbn: enable tests
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>
2019-02-11 11:12:20 -02:00
Mauro Carvalho Chehab
23ac956e62 test/test_decode: fix return code for errors
Return !=0 when errors are found.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-09 15:35:34 -02:00
Mauro Carvalho Chehab
e009b9e1a2 check-local: add regression test to this makefile target
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>
2019-02-09 15:25:34 -02:00
Mauro Carvalho Chehab
18d7f686b9 test_decode: add a tolerance margin for errors
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>
2019-02-09 15:23:18 -02:00
Mauro Carvalho Chehab
86a9ef67ca java: fix some wrong dependencies
If one does just "make check-java", it should solve all
needed dependencies.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-09 15:22:20 -02:00
Mauro Carvalho Chehab
0cbedd0f71 test_decode: improve warnings output
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>
2019-02-09 10:43:55 -02:00
Mauro Carvalho Chehab
48335a9c71 test_decode: use argp to decode parameters
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>
2019-02-09 10:35:26 -02:00
Mauro Carvalho Chehab
18b7463e27 test_decode: better handle decoding errors
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>
2019-02-09 09:40:04 -02:00
Mauro Carvalho Chehab
681b0f305f Makefile.am.inc: enable check-java on local tests
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>
2019-02-08 19:24:35 -02:00
Mauro Carvalho Chehab
60010ee3aa configure.ac: autodetect JAVA_HOME and junit location
if javac is present, autodetect the location of the JDK
and junit directories.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-08 16:40:30 -02:00
Mauro Carvalho Chehab
c367dd383d tests: make tests will now run all existing tests
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>
2019-02-08 14:38:43 -02:00
Mauro Carvalho Chehab
bf645d1fad test_jpeg: add a parameter to make it quiet
This testing tool is too verbose. Add a way to make it run
quietly.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-08 14:35:48 -02:00
Mauro Carvalho Chehab
367d71c1bf test_video: add a parameter to make it quiet
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>
2019-02-08 14:25:13 -02:00
Mauro Carvalho Chehab
8711c4142b test_convert: add a checking code for it and improve output
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>
2019-02-08 14:25:13 -02:00
Mauro Carvalho Chehab
e545efcd6f tests: improve test report targets
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>
2019-02-08 13:51:18 -02:00
Mauro Carvalho Chehab
851503d72e Makefile: Add test for D-Bus signaling
It is useful to check if D-Bus is working properly. So, add
a test for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-08 11:43:24 -02:00
Mauro Carvalho Chehab
ca412c20e1 test_dbus: add a timeout argument
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>
2019-02-08 08:50:33 -02:00
Mauro Carvalho Chehab
5077e3d101 test_dbus: add a program argument to stop after receiving #messages
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>
2019-02-08 08:39:19 -02:00