at 23.05-pre 1.5 kB view raw
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 nodes.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 import re 27 # sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die 28 strace = machine.succeed('strace scanimage -L 2>&1').split("\n") 29 regexp = 'openat\(.*libsane-brother5.so.1", O_RDONLY|O_CLOEXEC\) = \d\d*$' 30 assert len([x for x in strace if re.match(regexp,x)]) > 0 31 32 # module creates a config 33 cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg') 34 assert 'DEVICE=a , "ADS-1200" , 0x4f9:0x459 , NODENAME=BRW0080927AFBCE' in cfg 35 assert 'DEVICE=b , "ADS-1200" , 0x4f9:0x459 , IP-ADDRESS=192.168.1.2' in cfg 36 37 # scanimage lists the two network scanners 38 scanimage = machine.succeed("scanimage -L") 39 print(scanimage) 40 assert """device `brother5:net1;dev0' is a Brother b ADS-1200""" in scanimage 41 assert """device `brother5:net1;dev1' is a Brother a ADS-1200""" in scanimage 42 ''; 43})