Skip to content

Commit

Permalink
adaptivecpp: refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blenderfreaky committed Jan 8, 2025
1 parent 1111098 commit e6635f0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
23 changes: 20 additions & 3 deletions pkgs/by-name/ad/adaptivecpp/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
autoAddDriverRunpath,
callPackage,
symlinkJoin,
runCommand,
nix-update-script,
}:
let
Expand Down Expand Up @@ -99,9 +100,25 @@ stdenv.mkDerivation (finalAttrs: {
# For tests
inherit (finalAttrs) nativeBuildInputs buildInputs;

tests = {
sycl = callPackage ./tests.nix { };
};
tests =
let
runner = callPackage ./tests.nix { };
run = cmd: runCommand cmd { } ''
# the test runner wants to write to $HOME/.acpp, so we need to have it point to a real directory
mkdir home
export HOME=`pwd`/home
${runner}/bin/${cmd} && touch $out
'';
in
{
inherit runner;
sycl = run "sycl_tests";
rt = run "rt_tests";
deviceCompilation = run "device_compilation_tests";
dump = run "dump_tests";
platformApi = run "platform_api";
};

updateScript = nix-update-script { };
};
Expand Down
33 changes: 16 additions & 17 deletions pkgs/by-name/ad/adaptivecpp/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
lib,
stdenv,
adaptivecpp,
# within the nix sandbox, the tests will likely be unable to access the gpu.
# for now we just test omp by default as a sanity check,
# however the bulk of work in acpp focuses on the generic target, so we want to switch to that.
targetsBuild ? "omp",
targetsRun ? "omp",
# Within the nix sandbox, and on the CI especially, the tests will likely be unable to access a gpu.
# While the CI won't be able to test on a GPU, we can do a sanity check with OMP atleast
#
# The bulk of work in acpp focuses on the generic target, so we want to test that first and foremost.
# Not setting an explicit target makes it default to the generic target.
targets ? null,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "${adaptivecpp.pname}-tests";
Expand All @@ -21,25 +22,23 @@ stdenv.mkDerivation (finalAttrs: {

cmakeFlags =
[
# see above
"-DAdaptiveCpp_DIR=${adaptivecpp}/lib/cmake/AdaptiveCpp"
]
++ lib.optionals (targetsBuild != null) [
"-DACCP_TARGETS=\"${targetsBuild}\""
++ lib.optionals (targets!= null) [
"-DACCP_TARGETS=\"${targets}\""
];

doCheck = true;
checkPhase = ''
# the test runner wants to write to $HOME/.acpp, so we need to have it point to a real directory
mkdir home
export HOME=`pwd`/home
doCheck = false;

${lib.strings.optionalString (targetsRun != null) "export ACPP_VISIBILITY_MASK=\"${targetsRun}\""}
./sycl_tests
installPhase = ''
mkdir $out
install -Dm755 sycl_tests -t $out/bin/
install -Dm755 rt_tests -t $out/bin/
install -Dm755 device_compilation_tests -t $out/bin/
install -Dm755 dump_test/dump_test -t $out/bin/
install -Dm755 platform_api/platform_api -t $out/bin/
'';

installPhase = "touch $out";

# currently fails to build
# see https://logs.ofborg.org/?key=nixos/nixpkgs.360893&attempt_id=3b1feb45-0b7d-4cf1-8e38-917afcc12c67
meta.broken = stdenv.isDarwin;
Expand Down

0 comments on commit e6635f0

Please sign in to comment.