11 stdenv.mkDerivation (finalAttrs: {
13 version = "0.21-unstable-2021-09-01"; # Match the commit used in FreeBSD’s port.
15 src = fetchFromGitHub {
18 rev = "55c21b2c5fb189bbdfccb2b297bfa89236502542";
19 hash = "sha256-u0YBPcoIBvqBVaytaO9feBaRnQygtzEPGJV0ItI1Vco=";
23 # Fixes use after free that causes failures in Kyua’s test suite.
24 # https://github.com/freebsd/atf/pull/57
25 # https://github.com/freebsd/kyua/issues/223
27 name = "fix-use-after-free.patch";
28 url = "https://github.com/freebsd/atf/commit/fb22f3837bcfdce5ce8b3c0e18af131bb6902a02.patch";
29 hash = "sha256-p4L3sxSYfMSzwKrUDlEZpoJydbaK3Hcbvn90KlPHkic=";
34 lib.optionalString finalAttrs.doInstallCheck ''
35 # https://github.com/freebsd/atf/issues/61
36 substituteInPlace atf-c/check_test.c \
37 --replace-fail 'ATF_TP_ADD_TC(tp, build_cpp)' ""
38 substituteInPlace atf-c++/check_test.cpp \
39 --replace-fail 'ATF_ADD_TEST_CASE(tcs, build_cpp);' ""
40 # Can’t find `c_helpers` in the work folder.
41 substituteInPlace test-programs/Kyuafile \
42 --replace-fail 'atf_test_program{name="srcdir_test"}' ""
44 # These tests fail on Darwin.
45 + lib.optionalString (finalAttrs.doInstallCheck && stdenv.hostPlatform.isDarwin) ''
46 substituteInPlace atf-c/detail/process_test.c \
47 --replace-fail 'ATF_TP_ADD_TC(tp, status_coredump);' ""
49 # This test fails on Linux.
50 + lib.optionalString (finalAttrs.doInstallCheck && stdenv.hostPlatform.isLinux) ''
51 substituteInPlace atf-c/detail/fs_test.c \
52 --replace-fail 'ATF_TP_ADD_TC(tp, eaccess);' ""
57 nativeBuildInputs = [ autoreconfHook ];
59 enableParallelBuilding = true;
62 # ATF isn’t compatible with C++17, which is the default on current clang and GCC.
66 doInstallCheck = true;
68 nativeInstallCheckInputs = [ kyua ];
70 installCheckPhase = ''
71 runHook preInstallCheck
72 HOME=$TMPDIR PATH=$out/bin:$PATH kyua test
73 runHook postInstallCheck
76 passthru.updateScript = gitUpdater { rev-prefix = "atf-"; };
78 __structuredAttrs = true;
81 description = "Libraries to write tests in C, C++, and shell";
82 homepage = "https://github.com/freebsd/atf/";
83 license = lib.licenses.bsd3;
84 mainProgram = "atf-sh";
85 maintainers = with lib.maintainers; [ reckenrode ];
86 platforms = lib.platforms.unix;