#!/usr/bin/env python3 import sys try: import gi import re import os from gi.repository import GLib, Gio import unittest import socket import struct import subprocess import shutil import glob import tempfile except Exception as e: print("Missing dependencies: %s" % str(e)) sys.exit(77) FPrint = None # Re-run the test with the passed wrapper if set wrapper = os.getenv('LIBFPRINT_TEST_WRAPPER') if wrapper: wrap_cmd = wrapper.split(' ') + [sys.executable, os.path.abspath(__file__)] + \ sys.argv[1:] os.unsetenv('LIBFPRINT_TEST_WRAPPER') sys.exit(subprocess.check_call(wrap_cmd)) ctx = GLib.main_context_default() class Connection: def __init__(self, addr): self.addr = addr def __enter__(self): self.con = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.con.connect(self.addr) return self.con def __exit__(self, exc_type, exc_val, exc_tb): self.con.close() del self.con class VirtualDevice(unittest.TestCase): @classmethod def setUpClass(cls): unittest.TestCase.setUpClass() cls.tmpdir = tempfile.mkdtemp(prefix='libfprint-') driver_name = cls.driver_name if hasattr(cls, 'driver_name') else None if not driver_name: driver_name = re.compile(r'(?