git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/incron: added nixos test to ensure expected behaviour
commit24af0bc2b5293697695cb6d878b007130ab8db14 authorAaron Andersen <aaron@fosslib.net> dateSat 10 Nov 2018, 17:37 (8 years ago) parentcf1ce60
2 files changed+53
nixos/release.nix+1 nixos/tests/incron.nix+52
nixos/release.nix+1
@@ -336,6 +336,7 @@ in rec {
336336 tests.plasma5 = callTest tests/plasma5.nix {};
337337 tests.plotinus = callTest tests/plotinus.nix {};
338338 tests.keymap = callSubTests tests/keymap.nix {};
339+ tests.incron = callTest tests/incron.nix {};
339340 tests.initrdNetwork = callTest tests/initrd-network.nix {};
340341 tests.kafka = callSubTests tests/kafka.nix {};
341342 tests.kernel-latest = callTest tests/kernel-latest.nix {};
nixos/tests/incron.nixnew file+52
@@ -0,0 +1,52 @@
1+import ./make-test.nix ({ pkgs, lib, ... }:
2+
3+{
4+ name = "incron";
5+ meta.maintainers = [ lib.maintainers.aanderse ];
6+
7+ machine =
8+ { ... }:
9+ { services.incron.enable = true;
10+ services.incron.extraPackages = [ pkgs.coreutils ];
11+ services.incron.systab = ''
12+ /test IN_CREATE,IN_MODIFY,IN_CLOSE_WRITE,IN_MOVED_FROM,IN_MOVED_TO echo "$@/$# $%" >> /root/incron.log
13+ '';
14+
15+ # ensure the directory to be monitored exists before incron is started
16+ system.activationScripts.incronTest = ''
17+ mkdir /test
18+ '';
19+ };
20+
21+ testScript = ''
22+ startAll;
23+
24+ $machine->waitForUnit("multi-user.target");
25+ $machine->waitForUnit("incron.service");
26+
27+ $machine->succeed("test -d /test");
28+ # create some activity for incron to monitor
29+ $machine->succeed("touch /test/file");
30+ $machine->succeed("echo foo >> /test/file");
31+ $machine->succeed("mv /test/file /root");
32+ $machine->succeed("mv /root/file /test");
33+
34+ $machine->sleep(1);
35+
36+ # touch /test/file
37+ $machine->succeed("grep '/test/file IN_CREATE' /root/incron.log");
38+
39+ # echo foo >> /test/file
40+ $machine->succeed("grep '/test/file IN_MODIFY' /root/incron.log");
41+ $machine->succeed("grep '/test/file IN_CLOSE_WRITE' /root/incron.log");
42+
43+ # mv /test/file /root
44+ $machine->succeed("grep '/test/file IN_MOVED_FROM' /root/incron.log");
45+
46+ # mv /root/file /test
47+ $machine->succeed("grep '/test/file IN_MOVED_TO' /root/incron.log");
48+
49+ # ensure something unexpected is not present
50+ $machine->fail("grep 'IN_OPEN' /root/incron.log");
51+ '';
52+})