about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2024-06-23 20:38:41 -0300
committerThiago Kenji Okada <thiagokokada@gmail.com>2024-06-24 19:01:16 -0300
commitb8cd02c34f1f64660c7a5a5f22fb2825574f0c23 (patch)
tree07156cdb6970431c75189f66e9e33bc3f4918ee1
parent33f1e2ece3861c0bdd032d370e6d0b841728c372 (diff)
nixos/rtorrent: add NixOS tests
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/rtorrent.nix25
-rw-r--r--pkgs/applications/networking/p2p/rakshasa-rtorrent/default.nix7
3 files changed, 32 insertions, 1 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 1db9f702e2416..d9551c33d8f6a 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -824,6 +824,7 @@ in {
   rstudio-server = handleTest ./rstudio-server.nix {};
   rsyncd = handleTest ./rsyncd.nix {};
   rsyslogd = handleTest ./rsyslogd.nix {};
+  rtorrent = handleTest ./rtorrent.nix {};
   rxe = handleTest ./rxe.nix {};
   sabnzbd = handleTest ./sabnzbd.nix {};
   samba = handleTest ./samba.nix {};
diff --git a/nixos/tests/rtorrent.nix b/nixos/tests/rtorrent.nix
new file mode 100644
index 0000000000000..77e78b549a96f
--- /dev/null
+++ b/nixos/tests/rtorrent.nix
@@ -0,0 +1,25 @@
+import ./make-test-python.nix ({ pkgs, ... }:
+let
+  port = 50001;
+in
+{
+  name = "rtorrent";
+  meta = {
+    maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
+  };
+
+  nodes.machine = { pkgs, ... }: {
+    services.rtorrent = {
+      inherit port;
+      enable = true;
+    };
+  };
+
+  testScript = /* python */ ''
+    machine.start()
+    machine.wait_for_unit("rtorrent.service")
+    machine.wait_for_open_port(${toString port})
+
+    machine.succeed("nc -z localhost ${toString port}")
+  '';
+})
diff --git a/pkgs/applications/networking/p2p/rakshasa-rtorrent/default.nix b/pkgs/applications/networking/p2p/rakshasa-rtorrent/default.nix
index bc3989f1ee67c..52ef3f7350015 100644
--- a/pkgs/applications/networking/p2p/rakshasa-rtorrent/default.nix
+++ b/pkgs/applications/networking/p2p/rakshasa-rtorrent/default.nix
@@ -13,9 +13,10 @@
 , pkg-config
 , xmlrpc_c
 , zlib
+, nixosTests
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   pname = "rakshasa-rtorrent";
   version = "0.9.8+date=2022-06-20";
 
@@ -53,6 +54,10 @@ stdenv.mkDerivation rec {
     "--with-posix-fallocate"
   ];
 
+  passthru.tests = {
+    inherit (nixosTests) rtorrent;
+  };
+
   enableParallelBuilding = true;
 
   postInstall = ''