at 25.11-pre 1.6 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, lib, ... }: 3 4 { 5 name = "incron"; 6 meta.maintainers = [ lib.maintainers.aanderse ]; 7 8 nodes.machine = 9 { ... }: 10 { 11 services.incron.enable = true; 12 services.incron.extraPackages = [ pkgs.coreutils ]; 13 services.incron.systab = '' 14 /test IN_CREATE,IN_MODIFY,IN_CLOSE_WRITE,IN_MOVED_FROM,IN_MOVED_TO echo "$@/$# $%" >> /root/incron.log 15 ''; 16 17 # ensure the directory to be monitored exists before incron is started 18 systemd.tmpfiles.settings.incron-test = { 19 "/test".d = { }; 20 }; 21 }; 22 23 testScript = '' 24 start_all() 25 26 machine.wait_for_unit("multi-user.target") 27 machine.wait_for_unit("incron.service") 28 29 machine.succeed("test -d /test") 30 # create some activity for incron to monitor 31 machine.succeed("touch /test/file") 32 machine.succeed("echo foo >> /test/file") 33 machine.succeed("mv /test/file /root") 34 machine.succeed("mv /root/file /test") 35 36 machine.sleep(1) 37 38 # touch /test/file 39 machine.succeed("grep '/test/file IN_CREATE' /root/incron.log") 40 41 # echo foo >> /test/file 42 machine.succeed("grep '/test/file IN_MODIFY' /root/incron.log") 43 machine.succeed("grep '/test/file IN_CLOSE_WRITE' /root/incron.log") 44 45 # mv /test/file /root 46 machine.succeed("grep '/test/file IN_MOVED_FROM' /root/incron.log") 47 48 # mv /root/file /test 49 machine.succeed("grep '/test/file IN_MOVED_TO' /root/incron.log") 50 51 # ensure something unexpected is not present 52 machine.fail("grep 'IN_OPEN' /root/incron.log") 53 ''; 54 } 55)