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