Move test inside pkgs/
This commit is contained in:
32
pkgs/test/compilers/asan.nix
Normal file
32
pkgs/test/compilers/asan.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{ stdenv, writeText, which, strace }:
|
||||
|
||||
let
|
||||
hello_c = writeText "hello.c" ''
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "asan-c";
|
||||
buildInputs = [ stdenv which strace ];
|
||||
src = hello_c;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
NIX_DEBUG = 0;
|
||||
buildPhase = ''
|
||||
cp ${hello_c} hello.c
|
||||
$CC -v -fsanitize=address hello.c -o hello
|
||||
./hello
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
20
pkgs/test/compilers/clang-ompss2.nix
Normal file
20
pkgs/test/compilers/clang-ompss2.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{stdenv, clang-ompss2, nanos6}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "test-clang-ompss2";
|
||||
src = ./.;
|
||||
buildInputs = [ clang-ompss2 nanos6 ];
|
||||
NIX_DEBUG = 1;
|
||||
|
||||
buildPhase = ''
|
||||
clang -fompss-2 hello.c -o hello
|
||||
./hello
|
||||
clang++ -fompss-2 hello.cc -o hello
|
||||
./hello
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
'';
|
||||
}
|
||||
46
pkgs/test/compilers/clang-openmp-ld.nix
Normal file
46
pkgs/test/compilers/clang-openmp-ld.nix
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
stdenv
|
||||
, writeText
|
||||
, openmp
|
||||
}:
|
||||
|
||||
let
|
||||
hello_c = writeText "hello.c" ''
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#pragma omp parallel
|
||||
{
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
pname = "openmp-test-ld";
|
||||
version = "1.0.0";
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
|
||||
# nOS-V requires access to /sys/devices to request NUMA information. It will
|
||||
# fail to run otherwise, so we disable the sandbox for this test.
|
||||
__noChroot = true;
|
||||
|
||||
buildInputs = [ openmp ];
|
||||
|
||||
buildPhase = ''
|
||||
set -x
|
||||
|
||||
cp ${hello_c} hello.c
|
||||
clang -fopenmp=libompv ./hello.c -o hello
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
|
||||
}
|
||||
|
||||
60
pkgs/test/compilers/clang-openmp-nosv.nix
Normal file
60
pkgs/test/compilers/clang-openmp-nosv.nix
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
stdenv
|
||||
, nosv
|
||||
, writeText
|
||||
}:
|
||||
|
||||
let
|
||||
hello_c = writeText "hello.c" ''
|
||||
#include <nosv.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int test = 1;
|
||||
#pragma omp parallel
|
||||
#pragma omp single
|
||||
#pragma omp task
|
||||
{
|
||||
if (nosv_self() == NULL) {
|
||||
printf("nosv_self() returned NULL\n");
|
||||
exit(1);
|
||||
} else {
|
||||
printf("nosv_self() INSIDE TASK OK\n");
|
||||
}
|
||||
test = 0;
|
||||
}
|
||||
|
||||
return test;
|
||||
}
|
||||
'';
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
pname = "openmp-test-nosv";
|
||||
version = "1.0.0";
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
|
||||
# nOS-V requires access to /sys/devices to request NUMA information. It will
|
||||
# fail to run otherwise, so we disable the sandbox for this test.
|
||||
__noChroot = true;
|
||||
|
||||
buildInputs = [ nosv ];
|
||||
|
||||
buildPhase = ''
|
||||
set -x
|
||||
|
||||
cp ${hello_c} hello.c
|
||||
clang -fopenmp=libompv ./hello.c -lnosv -o hello
|
||||
./hello | grep "INSIDE TASK OK"
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
|
||||
}
|
||||
|
||||
46
pkgs/test/compilers/clang-openmp.nix
Normal file
46
pkgs/test/compilers/clang-openmp.nix
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
stdenv
|
||||
, writeText
|
||||
}:
|
||||
|
||||
let
|
||||
hello_c = writeText "hello.c" ''
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int test = 1;
|
||||
#pragma omp parallel
|
||||
#pragma omp single
|
||||
#pragma omp task
|
||||
test = 0;
|
||||
|
||||
return test;
|
||||
}
|
||||
'';
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
pname = "openmp-test";
|
||||
version = "1.0.0";
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
|
||||
# nOS-V requires access to /sys/devices to request NUMA information. It will
|
||||
# fail to run otherwise, so we disable the sandbox for this test.
|
||||
__noChroot = true;
|
||||
|
||||
buildPhase = ''
|
||||
set -x
|
||||
|
||||
cp ${hello_c} hello.c
|
||||
clang -fopenmp ./hello.c -o hello
|
||||
./hello
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
|
||||
}
|
||||
|
||||
68
pkgs/test/compilers/hello-c.nix
Normal file
68
pkgs/test/compilers/hello-c.nix
Normal file
@@ -0,0 +1,68 @@
|
||||
{ stdenv, writeText, which, strace }:
|
||||
|
||||
let
|
||||
hello_c = writeText "hello.c" ''
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
shuffle_c = writeText "shuffle.c" ''
|
||||
#include <stdio.h>
|
||||
|
||||
typedef int v4si __attribute__ ((vector_size (16)));
|
||||
|
||||
int main(void) {
|
||||
v4si a = {1,2,3,4};
|
||||
v4si b = {5,6,7,8};
|
||||
v4si mask1 = {0,1,1,3};
|
||||
v4si mask2 = {0,4,2,5};
|
||||
v4si res;
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 7)
|
||||
res = __builtin_shuffle (a, mask1); /* res is {1,2,2,4} */
|
||||
res = __builtin_shuffle (a, b, mask2); /* res is {1,5,3,6} */
|
||||
|
||||
printf("%d %d %d %d\n", res[0], res[1], res[2], res[3]);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "hello-c";
|
||||
buildInputs = [ stdenv which strace ];
|
||||
src = hello_c;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
NIX_DEBUG = 0;
|
||||
buildPhase = ''
|
||||
set -x
|
||||
echo CC=$CC
|
||||
which $CC
|
||||
$CC -v
|
||||
|
||||
cp ${hello_c} hello.c
|
||||
$CC -v hello.c -o hello
|
||||
./hello
|
||||
|
||||
# Only gcc
|
||||
#cp ${shuffle_c} shuffle.c
|
||||
#$CC shuffle.c -o shuffle
|
||||
#./shuffle
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
36
pkgs/test/compilers/hello-cpp.nix
Normal file
36
pkgs/test/compilers/hello-cpp.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ stdenv, writeText, which, strace }:
|
||||
|
||||
let
|
||||
hello_cpp = writeText "hello.cpp" ''
|
||||
#include <cstdio>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "hello-cpp";
|
||||
buildInputs = [ stdenv which strace ];
|
||||
src = hello_cpp;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
NIX_DEBUG = 0;
|
||||
buildPhase = ''
|
||||
cp $src hello.cpp
|
||||
set -x
|
||||
echo CXX=$CXX
|
||||
which $CXX
|
||||
$CXX hello.cpp -o hello
|
||||
./hello
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
35
pkgs/test/compilers/hello-f.nix
Normal file
35
pkgs/test/compilers/hello-f.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{ stdenv, writeText, which, strace }:
|
||||
|
||||
let
|
||||
hello_f90 = writeText "hello.f90" ''
|
||||
program hello
|
||||
print *, 'Hello, World!'
|
||||
end program hello
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "hello-f90";
|
||||
buildInputs = [ stdenv which strace ];
|
||||
src = hello_f90;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
NIX_DEBUG = 0;
|
||||
buildPhase = ''
|
||||
set -x
|
||||
echo FC=$FC
|
||||
which $FC
|
||||
$FC -v
|
||||
|
||||
cp ${hello_f90} hello.f90
|
||||
$FC hello.f90 -o hello
|
||||
./hello
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
7
pkgs/test/compilers/hello.c
Normal file
7
pkgs/test/compilers/hello.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
return 0;
|
||||
}
|
||||
7
pkgs/test/compilers/hello.cc
Normal file
7
pkgs/test/compilers/hello.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
return 0;
|
||||
}
|
||||
25
pkgs/test/compilers/llvm-ompss2-flang.nix
Normal file
25
pkgs/test/compilers/llvm-ompss2-flang.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
stdenv
|
||||
, flangOmpss2Git
|
||||
, runCommand
|
||||
, writeText
|
||||
, strace
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "flang-ompss2-test";
|
||||
buildInputs = [ strace flangOmpss2Git ];
|
||||
file = writeText "hi.f90"
|
||||
''
|
||||
program hello
|
||||
print *, 'Hello, World!'
|
||||
end program hello
|
||||
'';
|
||||
phases = [ "installPhase" ];
|
||||
installPhase = ''
|
||||
set -x
|
||||
flang "$file" -c -o hi.o
|
||||
flang hi.o -o hi
|
||||
install -Dm555 hi "$out"
|
||||
'';
|
||||
}
|
||||
43
pkgs/test/compilers/lto.nix
Normal file
43
pkgs/test/compilers/lto.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{ stdenv, writeText, which, strace }:
|
||||
|
||||
let
|
||||
hello_c = writeText "hello.c" ''
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "lto-c";
|
||||
buildInputs = [ stdenv which strace ];
|
||||
src = hello_c;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
NIX_DEBUG = 0;
|
||||
buildPhase = ''
|
||||
set -x
|
||||
echo CC=$CC
|
||||
echo LD=$LD
|
||||
echo -------------------------------------------
|
||||
env
|
||||
echo -------------------------------------------
|
||||
|
||||
cp ${hello_c} hello.c
|
||||
$CC -v -flto hello.c -o hello
|
||||
./hello
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
52
pkgs/test/compilers/ompss2.nix
Normal file
52
pkgs/test/compilers/ompss2.nix
Normal file
@@ -0,0 +1,52 @@
|
||||
{ stdenv, writeText, which, strace, gdb }:
|
||||
|
||||
let
|
||||
task_c = writeText "task.c" ''
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i < 10; i++) {
|
||||
#pragma oss task
|
||||
printf("Hello world!\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "task_c";
|
||||
src = task_c;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
hardeningDisable = [ "all" ];
|
||||
#NIX_DEBUG = 1;
|
||||
buildInputs = [ ]; #strace gdb;
|
||||
# NODES requires access to /sys/devices to request NUMA information. It will
|
||||
# fail to run otherwise, so we disable the sandbox for this test.
|
||||
__noChroot = true;
|
||||
buildPhase = ''
|
||||
set -x
|
||||
#$CC -v
|
||||
|
||||
cp ${task_c} task.c
|
||||
|
||||
echo CC=$CC
|
||||
echo NANOS6_HOME=$NANOS6_HOME
|
||||
echo NODES_HOME=$NODES_HOME
|
||||
cat task.c
|
||||
$CC -fompss-2 task.c -o task
|
||||
#strace -ff -e trace=open,openat -s9999999 ./task
|
||||
LD_DEBUG=libs ./task
|
||||
#gdb -batch -ex "run" -ex "bt" ./task
|
||||
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
50
pkgs/test/compilers/suffle-c.nix
Normal file
50
pkgs/test/compilers/suffle-c.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
{ stdenv, writeText, which, strace }:
|
||||
|
||||
let
|
||||
shuffle_c = writeText "shuffle.c" ''
|
||||
#include <stdio.h>
|
||||
|
||||
typedef int v4si __attribute__ ((vector_size (16)));
|
||||
|
||||
int main(void) {
|
||||
v4si a = {1,2,3,4};
|
||||
v4si b = {5,6,7,8};
|
||||
v4si mask1 = {0,1,1,3};
|
||||
v4si mask2 = {0,4,2,5};
|
||||
v4si res;
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 7)
|
||||
res = __builtin_shuffle (a, mask1); /* res is {1,2,2,4} */
|
||||
res = __builtin_shuffle (a, b, mask2); /* res is {1,5,3,6} */
|
||||
|
||||
printf("%d %d %d %d\n", res[0], res[1], res[2], res[3]);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.0.1";
|
||||
name = "hello-c";
|
||||
buildInputs = [ stdenv which strace ];
|
||||
src = hello_c;
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
NIX_DEBUG = 0;
|
||||
buildPhase = ''
|
||||
cp $src hello.c
|
||||
set -x
|
||||
echo CC=$CC
|
||||
which $CC
|
||||
#strace -ff -e trace=execve -s99999999 $CC hello.c -o hello
|
||||
$CC hello.c -o hello
|
||||
./hello
|
||||
set +x
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user