1# integration tests for brscan5 sane driver
2#
3
4import ./make-test-python.nix ({ pkgs, ...} : {
5 name = "brscan5";
6 meta = with pkgs.lib.maintainers; {
7 maintainers = [ mattchrist ];
8 };
9
10 machine = { pkgs, ... }:
11 {
12 nixpkgs.config.allowUnfree = true;
13 hardware.sane = {
14 enable = true;
15 brscan5 = {
16 enable = true;
17 netDevices = {
18 "a" = { model="ADS-1200"; nodename="BRW0080927AFBCE"; };
19 "b" = { model="ADS-1200"; ip="192.168.1.2"; };
20 };
21 };
22 };
23 };
24
25 testScript = ''
26 # sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die
27 strace = machine.succeed('strace scanimage -L 2>&1').split("\n")
28 regexp = 'openat\(.*libsane-brother5.so.1", O_RDONLY|O_CLOEXEC\) = \d\d*$'
29 assert len([x for x in strace if re.match(regexp,x)]) > 0
30
31 # module creates a config
32 cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg')
33 assert 'DEVICE=a , "ADS-1200" , 0x4f9:0x459 , NODENAME=BRW0080927AFBCE' in cfg
34 assert 'DEVICE=b , "ADS-1200" , 0x4f9:0x459 , IP-ADDRESS=192.168.1.2' in cfg
35
36 # scanimage lists the two network scanners
37 scanimage = machine.succeed("scanimage -L")
38 print(scanimage)
39 assert """device `brother5:net1;dev0' is a Brother b ADS-1200""" in scanimage
40 assert """device `brother5:net1;dev1' is a Brother a ADS-1200""" in scanimage
41 '';
42})