fix brscan5 config generation

before this, the config utility was unable to locate the models folder
update tests to use a compatible model
This commit is contained in:
Matt Christ 2021-05-23 08:03:19 -05:00
parent a9b7300f6f
commit 14bf8f109b
2 changed files with 16 additions and 8 deletions

View File

@ -21,8 +21,8 @@ nix-build -E 'let pkgs = import ./. {};
brscan5-etc-files = pkgs.callPackage (import ./nixos/modules/services/hardware/sane_extra_backends/brscan5_etc_files.nix) {}; brscan5-etc-files = pkgs.callPackage (import ./nixos/modules/services/hardware/sane_extra_backends/brscan5_etc_files.nix) {};
in brscan5-etc-files.override { in brscan5-etc-files.override {
netDevices = [ netDevices = [
{name="a"; model="MFC-7860DW"; nodename="BRW0080927AFBCE";} {name="a"; model="ADS-1200"; nodename="BRW0080927AFBCE";}
{name="b"; model="MFC-7860DW"; ip="192.168.1.2";} {name="b"; model="ADS-1200"; ip="192.168.1.2";}
]; ];
}' }'
~~~ ~~~
@ -58,7 +58,7 @@ stdenv.mkDerivation {
cp -rp "./brscan5.ini" "$TARGET_DIR" cp -rp "./brscan5.ini" "$TARGET_DIR"
cp -rp "./brsanenetdevice.cfg" "$TARGET_DIR" cp -rp "./brsanenetdevice.cfg" "$TARGET_DIR"
export NIX_REDIRECTS="/etc/opt/brother/scanner/brscan5//brsanenetdevice.cfg=$TARGET_DIR/brsanenetdevice.cfg" export NIX_REDIRECTS="/etc/opt/brother/scanner/brscan5/=$TARGET_DIR/"
printf '${addAllNetDev netDevices}\n' printf '${addAllNetDev netDevices}\n'

View File

@ -15,8 +15,8 @@ import ./make-test-python.nix ({ pkgs, ...} : {
brscan5 = { brscan5 = {
enable = true; enable = true;
netDevices = { netDevices = {
"a" = { model="MFC-7860DW"; nodename="BRW0080927AFBCE"; }; "a" = { model="ADS-1200"; nodename="BRW0080927AFBCE"; };
"b" = { model="MFC-7860DW"; ip="192.168.1.2"; }; "b" = { model="ADS-1200"; ip="192.168.1.2"; };
}; };
}; };
}; };
@ -24,11 +24,19 @@ import ./make-test-python.nix ({ pkgs, ...} : {
testScript = '' testScript = ''
# sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die # sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die
assert 'libsane-brother5.so.1", O_RDONLY|O_CLOEXEC) = 10' in machine.succeed('strace scanimage -L 2>&1') strace = machine.succeed('strace scanimage -L 2>&1').split("\n")
regexp = 'openat\(.*libsane-brother5.so.1", O_RDONLY|O_CLOEXEC\) = \d\d*$'
assert len([x for x in strace if re.match(regexp,x)]) > 0
# module creates a config # module creates a config
cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg') cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg')
assert 'DEVICE=a , "MFC-7860DW" , Unknown , NODENAME=BRW0080927AFBCE' in cfg assert 'DEVICE=a , "ADS-1200" , 0x4f9:0x459 , NODENAME=BRW0080927AFBCE' in cfg
assert 'DEVICE=b , "MFC-7860DW" , Unknown , IP-ADDRESS=192.168.1.2' in cfg assert 'DEVICE=b , "ADS-1200" , 0x4f9:0x459 , IP-ADDRESS=192.168.1.2' in cfg
# scanimage lists the two network scanners
scanimage = machine.succeed("scanimage -L")
print(scanimage)
assert """device `brother5:net1;dev0' is a Brother b ADS-1200""" in scanimage
assert """device `brother5:net1;dev1' is a Brother a ADS-1200""" in scanimage
''; '';
}) })