From 518d82c5be13eaefe7f74272d7946026a0a9abf7 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 25 Jan 2026 21:37:36 +0200 Subject: [PATCH] tests.auto-patchelf-structured-log: init This adds a test for the --structured-log feature of auto-patchelf. When auto-patchelf'ing ToneLib-Jam and only making freetype available, we expect: - one "SetInterpreter" line - 3 "Dependency" lines (of which one found) - one SetRpath line (containing freetype) --- .../auto-patchelf-structured-log/default.nix | 53 +++++++++++++++++++ pkgs/test/default.nix | 2 + 2 files changed, 55 insertions(+) create mode 100644 pkgs/test/auto-patchelf-structured-log/default.nix diff --git a/pkgs/test/auto-patchelf-structured-log/default.nix b/pkgs/test/auto-patchelf-structured-log/default.nix new file mode 100644 index 000000000000..b75e5cb58ca1 --- /dev/null +++ b/pkgs/test/auto-patchelf-structured-log/default.nix @@ -0,0 +1,53 @@ +{ + lib, + stdenv, + fetchurl, + + auto-patchelf, + dpkg, + freetype, + jq, +}: + +stdenv.mkDerivation { + name = "auto-patchelf-structured-log-test"; + + src = fetchurl { + url = "https://tonelib.net/download/221222/ToneLib-Jam-amd64.deb"; + sha256 = "sha256-c6At2lRPngQPpE7O+VY/Hsfw+QfIb3COIuHfbqqIEuM="; + }; + + unpackCmd = '' + dpkg -x $curSrc source + ''; + + nativeBuildInputs = [ + dpkg + auto-patchelf + jq + ]; + + installPhase = '' + auto-patchelf \ + --paths ./usr/bin/ToneLib-Jam \ + --libs ${lib.getLib freetype}/lib \ + --structured-logs > log.jsonl || true + + # Expect 1 SetInterpreter line + jq -e -s '[.[] | select(has("SetInterpreter"))] | length == 1' log.jsonl + + # We expect 3 Dependency lines + jq -e -s '[.[] | select(has("Dependency"))] | length == 3' log.jsonl + + # Expect the last line to set the rpath as expected + jq -e -s 'last == { + "SetRpath": { + "file": "usr/bin/ToneLib-Jam", + "rpath": "${lib.getLib freetype}/lib" + } + }' log.jsonl + + cp log.jsonl $out + ''; + +} diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 3823ce88bc80..efcd4963136d 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -227,6 +227,8 @@ in buildFHSEnv = recurseIntoAttrs (callPackages ./buildFHSEnv { }); + auto-patchelf-structured-log = callPackage ./auto-patchelf-structured-log { }; + auto-patchelf-hook = callPackage ./auto-patchelf-hook { }; auto-patchelf-hook-preserve-origin = callPackage ./auto-patchelf-hook-preserve-origin { };