parent
e6c304a5d9
commit
0bc7ec6e28
@ -62,7 +62,6 @@ in rec {
|
||||
(all nixos.tests.printing)
|
||||
(all nixos.tests.proxy)
|
||||
(all nixos.tests.simple)
|
||||
(all nixos.tests.udisks)
|
||||
(all nixos.tests.udisks2)
|
||||
(all nixos.tests.xfce)
|
||||
|
||||
|
@ -241,7 +241,6 @@ in rec {
|
||||
tests.runInMachine = callTest tests/run-in-machine.nix {};
|
||||
tests.simple = callTest tests/simple.nix {};
|
||||
tests.tomcat = callTest tests/tomcat.nix {};
|
||||
tests.udisks = callTest tests/udisks.nix {};
|
||||
tests.udisks2 = callTest tests/udisks2.nix {};
|
||||
tests.xfce = callTest tests/xfce.nix {};
|
||||
|
||||
|
@ -1,56 +0,0 @@
|
||||
import ./make-test.nix ({ pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
stick = pkgs.fetchurl {
|
||||
url = http://nixos.org/~eelco/nix/udisks-test.img.xz;
|
||||
sha256 = "0was1xgjkjad91nipzclaz5biv3m4b2nk029ga6nk7iklwi19l8b";
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
machine =
|
||||
{ config, pkgs, ... }:
|
||||
{ services.udisks.enable = true;
|
||||
imports = [ ./common/user-account.nix ];
|
||||
|
||||
security.polkit.extraConfig =
|
||||
''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (subject.user == "alice") return "yes";
|
||||
});
|
||||
'';
|
||||
};
|
||||
|
||||
testScript =
|
||||
''
|
||||
my $stick = $machine->stateDir . "/usbstick.img";
|
||||
system("xz -d < ${stick} > $stick") == 0 or die;
|
||||
|
||||
$machine->succeed("udisks --enumerate | grep /org/freedesktop/UDisks/devices/vda");
|
||||
$machine->fail("udisks --enumerate | grep /org/freedesktop/UDisks/devices/sda1");
|
||||
|
||||
# Attach a USB stick and wait for it to show up.
|
||||
$machine->sendMonitorCommand("usb_add disk:$stick");
|
||||
$machine->waitUntilSucceeds("udisks --enumerate | grep /org/freedesktop/UDisks/devices/sda1");
|
||||
$machine->succeed("udisks --show-info /dev/sda1 | grep 'label:.*USBSTICK'");
|
||||
|
||||
# Mount the stick as a non-root user and do some stuff with it.
|
||||
$machine->succeed("su - alice -c 'udisks --enumerate | grep /org/freedesktop/UDisks/devices/sda1'");
|
||||
$machine->succeed("su - alice -c 'udisks --mount /dev/sda1'");
|
||||
$machine->succeed("su - alice -c 'cat /media/USBSTICK/test.txt'") =~ /Hello World/ or die;
|
||||
$machine->succeed("su - alice -c 'echo foo > /media/USBSTICK/bar.txt'");
|
||||
|
||||
# Unmounting the stick should make the mountpoint disappear.
|
||||
$machine->succeed("su - alice -c 'udisks --unmount /dev/sda1'");
|
||||
$machine->fail("[ -d /media/USBSTICK ]");
|
||||
|
||||
# Remove the USB stick.
|
||||
$machine->sendMonitorCommand("usb_del 0.3"); # FIXME
|
||||
$machine->waitUntilFails("udisks --enumerate | grep /org/freedesktop/UDisks/devices/sda1");
|
||||
$machine->fail("[ -e /dev/sda ]");
|
||||
'';
|
||||
|
||||
})
|
Loading…
Reference in New Issue
Block a user