test: add sigsegv after MPI_Finalize test

The current srun version used in MN4 returns 0 if the program crashes
after MPI_Finalize, as shown by this test.
This commit is contained in:
Rodrigo Arias Mallo 2021-04-06 13:02:45 +02:00
parent 07253c3fa0
commit 604cfd90a3
3 changed files with 58 additions and 2 deletions

View File

@ -214,9 +214,10 @@ let
inherit self super bsc callPackage; inherit self super bsc callPackage;
}; };
# test = { test = {
# hwloc = callPackage ./test/bugs/hwloc.nix { }; # hwloc = callPackage ./test/bugs/hwloc.nix { };
# }; sigsegv = callPackage ./test/reproducers/sigsegv.nix { };
};
}); });
in in

View File

@ -0,0 +1,35 @@
#include <mpi.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
void sigsegv(int rank)
{
if (rank == 2) raise(SIGSEGV);
}
int main(int argc, char *argv[])
{
int rank;
char where;
MPI_Init(&argc, &argv);
if(!argv[1])
{
fprintf(stderr, "missing \"before\" or \"after\" argument\n");
exit(1);
}
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
where = argv[1][0];
if(where == 'b') sigsegv(rank);
MPI_Finalize();
if(where == 'a') sigsegv(rank);
return 0;
}

View File

@ -0,0 +1,20 @@
{
stdenv
, mpi
}:
stdenv.mkDerivation {
name = "sigsegv";
src = ./.;
buildInputs = [ mpi ];
buildPhase = ''
mpicc sigsegv.c -o sigsegv
'';
installPhase = ''
cp sigsegv $out
'';
}