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