1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
autoreconfHook,
kyua,
gitUpdater,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "atf";
version = "0.21-unstable-2021-09-01"; # Match the commit used in FreeBSD’s port.
src = fetchFromGitHub {
owner = "freebsd";
repo = "atf";
rev = "55c21b2c5fb189bbdfccb2b297bfa89236502542";
hash = "sha256-u0YBPcoIBvqBVaytaO9feBaRnQygtzEPGJV0ItI1Vco=";
};
patches = [
# Fixes use after free that causes failures in Kyua’s test suite.
# https://github.com/freebsd/atf/pull/57
# https://github.com/freebsd/kyua/issues/223
(fetchpatch {
name = "fix-use-after-free.patch";
url = "https://github.com/freebsd/atf/commit/fb22f3837bcfdce5ce8b3c0e18af131bb6902a02.patch";
hash = "sha256-p4L3sxSYfMSzwKrUDlEZpoJydbaK3Hcbvn90KlPHkic=";
})
];
postPatch =
lib.optionalString finalAttrs.doInstallCheck ''
# https://github.com/freebsd/atf/issues/61
substituteInPlace atf-c/check_test.c \
--replace-fail 'ATF_TP_ADD_TC(tp, build_cpp)' ""
substituteInPlace atf-c++/check_test.cpp \
--replace-fail 'ATF_ADD_TEST_CASE(tcs, build_cpp);' ""
# Can’t find `c_helpers` in the work folder.
substituteInPlace test-programs/Kyuafile \
--replace-fail 'atf_test_program{name="srcdir_test"}' ""
''
# These tests fail on Darwin.
+ lib.optionalString (finalAttrs.doInstallCheck && stdenv.hostPlatform.isDarwin) ''
substituteInPlace atf-c/detail/process_test.c \
--replace-fail 'ATF_TP_ADD_TC(tp, status_coredump);' ""
''
# This test fails on Linux.
+ lib.optionalString (finalAttrs.doInstallCheck && stdenv.hostPlatform.isLinux) ''
substituteInPlace atf-c/detail/fs_test.c \
--replace-fail 'ATF_TP_ADD_TC(tp, eaccess);' ""
'';
strictDeps = true;
nativeBuildInputs = [ autoreconfHook ];
enableParallelBuilding = true;
makeFlags = [
# ATF isn’t compatible with C++17, which is the default on current clang and GCC.
"CXXFLAGS=-std=c++11"
];
doInstallCheck = true;
nativeInstallCheckInputs = [ kyua ];
installCheckPhase = ''
runHook preInstallCheck
HOME=$TMPDIR PATH=$out/bin:$PATH kyua test
runHook postInstallCheck
'';
passthru.updateScript = gitUpdater { rev-prefix = "atf-"; };
__structuredAttrs = true;
meta = {
description = "Libraries to write tests in C, C++, and shell";
homepage = "https://github.com/freebsd/atf/";
license = lib.licenses.bsd3;
mainProgram = "atf-sh";
maintainers = with lib.maintainers; [ reckenrode ];
platforms = lib.platforms.unix;
};
})
|