Commit Graph

564 Commits

Author SHA1 Message Date
90298134a2 tests/fprintd: Add checks for delete enrolled fingers permissions
The test doesn't need any assertion because we're calling DeleteEnrolledFingers
and in case it fails a net.reactivated.Fprint.Error.PermissionDenied error
would be thrown, and thus an exception would be raised at python level, making
the test to fail.
2020-03-27 20:45:59 +01:00
8ff4360750 tests: Add test for STATE_DIRECTORY being multiple paths 2020-03-27 17:05:13 +01:00
fd733e55be file_storage: Handle STATE_DIRECTORY containing multiple paths
As per systemd's documentation:
If multiple directories are set, then in the environment variable the
paths are concatenated with colon (":").

Handle that case by splitting the paths if there's a ":" in the
variable.

Closes: #50
2020-03-27 17:05:06 +01:00
6a1fffae82 tests/fprintd: Fix claim_from_other_client_is_released_when_vanished on CI
test_claim_from_other_client_is_released_when_vanished would fail on
the CI but work on a local system because we wouldn't want long enough
for the "vanished" code path to be taken into account. Add a small
timeout to make sure it works on the CI as well.
2020-03-27 16:57:16 +01:00
47bd3f7fbb tests/fprintd: Fix test_enroll_invalid_storage_dir test
enroll_image() was always waiting for enroll-completed rather than for
what the caller expected as the result.

======================================================================
FAIL: test_enroll_invalid_storage_dir (__main__.FPrintdVirtualDeviceClaimedTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/hadess/Projects/jhbuild/fprintd/tests/fprintd.py", line 661, in test_enroll_invalid_storage_dir
    self.enroll_image('whorl', expected_result='enroll-failed')
  File "/home/hadess/Projects/jhbuild/fprintd/tests/fprintd.py", line 384, in enroll_image
    self.wait_for_result('enroll-completed')
  File "/home/hadess/Projects/jhbuild/fprintd/tests/fprintd.py", line 373, in wait_for_result
    self.assertEqual(self._last_result, expected)
AssertionError: 'enroll-failed' != 'enroll-completed'
- enroll-failed
+ enroll-completed
2020-03-27 16:26:28 +01:00
4f3589c0dc build: List single unit python tests allowing to run them separately
We run a certain number of tests right now, without being able to easily
run them separated or to check which one failed.

So add a script to inspect all the available unittests per each python
script and use it to figure out the tests we can run in meson.

As per this, define a global 'python_tests' variable in meson that allows
to register new python tests easily without having to repeat the settings
for all the tests.

For each test we have, we check if we can fetch a list of unit tests, and
if possible we create a meson test for each one.
Otherwise we just fallback to normal behavior.

This is something that can be hopefully implemented into upstream meson [1].

[1] https://github.com/mesonbuild/meson/issues/6851
2020-03-27 02:29:57 +01:00
eccd790df7 tests/fprintd: Add missing implementation of list_tests
Use unittest_inspector that we provide for meson tests inspection as well
2020-03-27 02:01:14 +01:00
bc29114a2c tests: Add a tool to inspect the single python unit tests
The unit tests files are provided as python files, adding a tool that
allows to list them in order to be able to run them easily via

  python3 -m unittest module.Class.test_method
2020-03-27 01:57:22 +01:00
cf95187268 ci: Update CI after the fdo template changes
The CI definition needs to be updated to work with the new fdo
templates.

Adapted from bd4f118b5e
2020-03-24 15:50:57 +01:00
23c37cd9b5 Revert "ci: Fix CI syntax error"
This reverts commit 01ea517a97.
2020-03-24 15:49:30 +01:00
967e4f24ed Revert "ci: Fix unknown keys in CI"
This reverts commit 10a3e75937.
2020-03-24 15:49:22 +01:00
d7fec03f24 tests/fprintd: Increase allowed timeout
On my laptop it takes 48 seconds to run.
2020-03-23 12:22:53 -04:00
4a3ae5ccaf tests/fprintd: Allow tests to run even when virtual device is not available
The test file calls self.daemon_start() in order to start fprintd and
locate the virtual image device that's needed for the test to run.
However, since the virtual image driver is not available on all
libfprint installations, the test should be skipped if the driver is not
available.

The skipping mechanism used to work, by checking if self.device is None.
This is based on the assumption that self.device would be set to None in
cases where the driver is not available. However, even in the past
self.device is only set to None in the tearDown method and not in setUp,
so presumably in edge cases it didn't entirely work.

However, since 0fb4f3b021 which
consistently removes the self.device attribute rather than setting it to
None, the "self.device is None" check no longer works. In particular,
the following error message is shown:

    test_manager_get_default_device (__main__.FPrintdManagerTests) ...
    Did not find virtual device! Probably libfprint was build without
    the corresponding driver!
    ERROR

After this patch, the following is shown:

    test_manager_get_default_device (__main__.FPrintdManagerTests) ...
    Did not find virtual device! Probably libfprint was build without
    the corresponding driver!
    skipped 'Need virtual_image device to run the test'

We fix this bug by consistently setting self.device to None, in both the
setUp method before daemon_start gets called, and in tearDown. We also
make the same change to self.manager for consistency.

The issue was not caught on CI, as the CI configuration always installs
a libfprint version that has the virtual_image device explicitly enabled
in the preparation phase.
2020-03-23 12:22:20 -04:00
e828ea3b2d main: Add missing locale.h include
The include is present in all other binaries in utils/.
2020-03-19 23:33:58 -04:00
d27872ff86 test_fprintd_utils: Don't use hard-coded sleep time
Make sleep time on verification dependent on the environment, so that it's
different when under valgrind
2020-03-17 17:14:35 +01:00
cfbded36e1 test_fprintd_utils: Use a non-blocking pipe to read output
Avoid using a temporary file for reading the utilities output, so we can
read it as it comes, ignoring the previous one, and avoiding open/closing
the file.

To keep the output printing on cleanup working, adding an utility function
that reads the output and save it for later printing
2020-03-17 17:14:35 +01:00
072fbc2b46 tests_fprintd_utils: Print the process output when done
This is particularly useful when using valgrind or address sanitizer to read
the output log
2020-03-17 17:14:35 +01:00
7846359b65 test_fprintd_utils: De-duplicate utilities launching
Avoid repeating the same operation to launch the utilities all the times,
but provide instead a function that allows to start a process and saves its
output without having to handle this in every test.

Simplify the operation when we just want the final output, still reusing
the same code.
2020-03-17 17:14:35 +01:00
08339a0648 tests/fprintd: Skip some tests in CI depending on permissions 2020-03-17 17:14:35 +01:00
3dd10b4b37 tests/fprind: Check that device is released when Caller operation is done
Add support to run fprintd-utils to test fprint daemon, and ensure that a
device is released and its operation cancelled once a caller goes away.

Related to https://gitlab.freedesktop.org/libfprint/fprintd/issues/37
2020-03-17 17:14:35 +01:00
bee2e154b1 tests/fprintd: Ensure that other clients can't interfere with claimer 2020-03-17 17:14:35 +01:00
27f0b64d03 tests/fprintd: Add tests for verification through finger id 2020-03-17 17:14:35 +01:00
f4ee2f86a3 device: Throw NoEnrolledPrints on missing finger in gallery
Throw a NoEnrolledPrints error if the requested finger isn't present
in the gallery.
2020-03-17 17:14:35 +01:00
04829ed39f tests/fprintd: Check that we can't mix Enroll and Verify operations 2020-03-17 17:14:35 +01:00
756a80a63e tests/fprintd: Ensure we throw NoActionInProgress on *Stop() 2020-03-17 17:14:35 +01:00
b861500a9f device: Throw AlreadyInUse error if stopping an enroll during verification
When starting an enroll when verification is in progress (and vice-versa) we
emit an AlreadyInUse error, however when calling VerifyStop() during an
enrollment (and vice-versa) we just return a NoActionInProgress error, which
is not the case.

So let's be consistent and change the error type.
2020-03-17 17:14:33 +01:00
154d0c0373 device: Use proper function name in debug 2020-03-17 17:10:17 +01:00
b2cdc1ed1e tests/fprint: Check current API user permissions 2020-03-17 17:10:17 +01:00
ab47e03f05 tests/fprintd: Ensure device open is correctly handled 2020-03-17 17:10:17 +01:00
f92801a15c tests/fprintd: Ensure that verify fails on storage read failure 2020-03-17 17:10:17 +01:00
086ceb98ab tests/fprintd: Ensure enroll fails on storage save failure 2020-03-17 17:10:17 +01:00
8bdbc7e2b0 tests/fprintd: Ensure that we can't verify without enrolled fingers 2020-03-17 17:10:17 +01:00
1f8bb1abd4 tests/fprintd: Ensure that devices are available on name appeared
Given we don't support adding devices after we created the manager (yet) we
must ensure that once the name appeared we have them all
2020-03-17 17:10:17 +01:00
47d55a97c4 tests/fprintd: Add tests for Manager methods 2020-03-17 17:10:17 +01:00
657b90a066 tests/fprintd: Move assertFprintError to FPrintdTest
This may be used by any class inheriting FPrintdTest, so let's move it at
lower level.
2020-03-17 17:10:17 +01:00
3821b96ca5 tests/fprintd: Only enable 'virtual_image' driver
When we run tests in a system with real devices, we may try to initialize
the real ones, while we can just ignore them all in tests.

We do it in setUp instead of setUpClass to allow tests to change this if
they need to, but just for temporary.
2020-03-17 17:10:17 +01:00
22ad9b5ae8 tests/fprintd: Check all the error types during verify/enroll
Ensure that we properly handle all the errors that a driver may return us
2020-03-17 17:10:17 +01:00
2ddc8a86a2 tests/fprind: Add verify retry tests for all the cases
The tests are repeated for both verify and identify actions
2020-03-17 17:10:17 +01:00
930cae4647 tests/fprind: Add enroll retry tests for all the cases 2020-03-17 17:10:17 +01:00
5e9624bef5 device: Fix verify-disconnected state name
Respect protocol, and use proper name
2020-03-17 17:10:17 +01:00
efac52d94f device: Fix retry enroll error names
Use proper names for enroll retry errors, fixing a copy/paste error from the
verify code.
2020-03-17 17:10:17 +01:00
af18aa35e5 tests/fprintd: Add tests to verify permissions on prints management 2020-03-17 17:10:16 +01:00
0d7a703200 tests/fprintd: Split claimed device tests to a single class
Avoid doing fo reach test the Claim/Release procedure manually if it is just
a prerequisite for the test.
2020-03-17 17:09:19 +01:00
ad19c49e2e tests/fprintd: Move tests which need a claimed device 2020-03-17 17:09:19 +01:00
a8de1003a4 tests/fprintd: Use addCleanup to always terminate daemons
Ensure that the daemons are always terminated after each test, even on
failure, so that we don't have to do hacks such as always trying to stop
them
2020-03-17 17:09:19 +01:00
cefe939141 tests/fprintd: Use addCleanup to ensure we remove the test dir 2020-03-17 17:09:19 +01:00
24cd986476 tests/fprintd: Use GTestDBus unset to undefine envs
Unset the dbus environment that may affect the dbus tests using GTestDBus
utility, instead of doing it manually.
2020-03-17 17:09:19 +01:00
06480c7994 tests/fprintd: Use a new bus for each test unit
When creating a new unit we used to get the system bus via Gio.bus_get_sync,
however this has a singleton implementation, and so would always return the
same connection, creating issues in tests when a new test suite is added
because the newly got connection would be already closed.

So, just manually create a new bus connection, also close the bus and
cleanup the test bus in dbus.
2020-03-17 17:09:19 +01:00
b2ad590891 tests/fprintd: Call the super class on setup 2020-03-17 17:09:19 +01:00
85aad7bb01 tests/fprintd: Remove usage of never-used self.client variable 2020-03-17 17:09:19 +01:00