Add a hwloc test

This commit is contained in:
Rodrigo Arias Mallo 2020-12-04 11:18:44 +01:00
parent d70316a25a
commit 90d7c83261
3 changed files with 64 additions and 0 deletions

View File

@ -120,6 +120,10 @@ let
nanos6 = bsc.nanos6Release; nanos6 = bsc.nanos6Release;
nanos6Release = callPackage ./bsc/nanos6/default.nix { }; nanos6Release = callPackage ./bsc/nanos6/default.nix { };
nanos6Git = callPackage ./bsc/nanos6/git.nix { }; nanos6Git = callPackage ./bsc/nanos6/git.nix { };
nanos6Debug = bsc.nanos6.overrideAttrs (old: {
dontStrip = true;
enableDebugging = true;
});
jemalloc = self.jemalloc.overrideAttrs (old: jemalloc = self.jemalloc.overrideAttrs (old:
{ {
@ -546,6 +550,10 @@ let
}; };
}; };
}; };
test = {
hwloc = callPackage ./test/bugs/hwloc.nix { };
};
}; };
}); });

36
test/bugs/hwloc.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include <hwloc.h>
#include <assert.h>
int main(int argc, char *argv[])
{
size_t i, coreCount;
hwloc_topology_t topology;
hwloc_obj_t obj;
if(hwloc_topology_init(&topology))
{
fprintf(stderr, "hwloc_topology_init failed\n");
exit(EXIT_FAILURE);
}
if(hwloc_topology_load(topology))
{
fprintf(stderr, "hwloc_topology_load failed\n");
exit(EXIT_FAILURE);
}
coreCount = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_CORE);
printf("coreCount = %zu\n", coreCount);
for(i = 0; i < coreCount; i++)
{
obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PU, i);
assert(obj != NULL);
assert(obj->parent != NULL);
printf("obj->parent->type = %d, i = %zu\n", obj->parent->type, i);
assert(obj->parent->type == HWLOC_OBJ_CORE);
}
printf("hwloc test OK\n");
}

20
test/bugs/hwloc.nix Normal file
View File

@ -0,0 +1,20 @@
{
stdenv
, hwloc
, strace
}:
stdenv.mkDerivation {
name = "hwloc-test";
src = ./.;
buildInputs = [ hwloc strace ];
buildPhase = ''
ls -l /sys
gcc -lhwloc hwloc.c -o hwloc
strace ./hwloc
'';
}