fix brscan5 config generation

before this, the config utility was unable to locate the models folder
update tests to use a compatible model

Changed files
+16 -8
nixos
modules
services
hardware
sane_extra_backends
tests
+3 -3
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 {
netDevices = [
-
{name="a"; model="MFC-7860DW"; nodename="BRW0080927AFBCE";}
-
{name="b"; model="MFC-7860DW"; ip="192.168.1.2";}
];
}'
~~~
···
cp -rp "./brscan5.ini" "$TARGET_DIR"
cp -rp "./brsanenetdevice.cfg" "$TARGET_DIR"
-
export NIX_REDIRECTS="/etc/opt/brother/scanner/brscan5//brsanenetdevice.cfg=$TARGET_DIR/brsanenetdevice.cfg"
printf '${addAllNetDev netDevices}\n'
···
brscan5-etc-files = pkgs.callPackage (import ./nixos/modules/services/hardware/sane_extra_backends/brscan5_etc_files.nix) {};
in brscan5-etc-files.override {
netDevices = [
+
{name="a"; model="ADS-1200"; nodename="BRW0080927AFBCE";}
+
{name="b"; model="ADS-1200"; ip="192.168.1.2";}
];
}'
~~~
···
cp -rp "./brscan5.ini" "$TARGET_DIR"
cp -rp "./brsanenetdevice.cfg" "$TARGET_DIR"
+
export NIX_REDIRECTS="/etc/opt/brother/scanner/brscan5/=$TARGET_DIR/"
printf '${addAllNetDev netDevices}\n'
+13 -5
nixos/tests/brscan5.nix
···
brscan5 = {
enable = true;
netDevices = {
-
"a" = { model="MFC-7860DW"; nodename="BRW0080927AFBCE"; };
-
"b" = { model="MFC-7860DW"; ip="192.168.1.2"; };
};
};
};
···
testScript = ''
# 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')
# module creates a config
cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg')
-
assert 'DEVICE=a , "MFC-7860DW" , Unknown , NODENAME=BRW0080927AFBCE' in cfg
-
assert 'DEVICE=b , "MFC-7860DW" , Unknown , IP-ADDRESS=192.168.1.2' in cfg
'';
})
···
brscan5 = {
enable = true;
netDevices = {
+
"a" = { model="ADS-1200"; nodename="BRW0080927AFBCE"; };
+
"b" = { model="ADS-1200"; ip="192.168.1.2"; };
};
};
};
···
testScript = ''
# sane loads libsane-brother5.so.1 successfully, and scanimage doesn't die
+
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
cfg = machine.succeed('cat /etc/opt/brother/scanner/brscan5/brsanenetdevice.cfg')
+
assert 'DEVICE=a , "ADS-1200" , 0x4f9:0x459 , NODENAME=BRW0080927AFBCE' 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
'';
})