alvr: 20.11.1 -> 20.12.1 (#374869)
[NixPkgs.git] / pkgs / development / libraries / opencv / tests.nix
bloba06d7994794f8a836314e1432cade14a680b9f8c
1 { opencv4
2 , testDataSrc
3 , stdenv
4 , lib
5 , runCommand
6 , gst_all_1
7 , runAccuracyTests
8 , runPerformanceTests
9 , enableGStreamer
10 , enableGtk2
11 , enableGtk3
12 , xvfb-run
14 let
15   testNames = [
16     "calib3d"
17     "core"
18     "features2d"
19     "flann"
20     "imgcodecs"
21     "imgproc"
22     "ml"
23     "objdetect"
24     "photo"
25     "stitching"
26     "video"
27     #"videoio" # - a lot of GStreamer warnings and failed tests
28     #"dnn" #- some caffe tests failed, probably because github workflow also downloads additional models
29   ] ++ lib.optionals (!stdenv.hostPlatform.isAarch64 && enableGStreamer) [ "gapi" ]
30   ++ lib.optionals (enableGtk2 || enableGtk3) [ "highgui" ];
31   perfTestNames = [
32     "calib3d"
33     "core"
34     "features2d"
35     "imgcodecs"
36     "imgproc"
37     "objdetect"
38     "photo"
39     "stitching"
40     "video"
41   ] ++ lib.optionals (!stdenv.hostPlatform.isAarch64 && enableGStreamer) [ "gapi" ];
42   testRunner = lib.optionalString (!stdenv.hostPlatform.isDarwin) "${lib.getExe xvfb-run} -a ";
43   testsPreparation = ''
44     touch $out
45     # several tests want a write access, so we have to copy files
46     tmpPath="$(mktemp -d "/tmp/opencv_extra_XXXXXX")"
47     cp -R ${testDataSrc} $tmpPath/opencv_extra
48     chmod -R +w $tmpPath/opencv_extra
49     export OPENCV_TEST_DATA_PATH="$tmpPath/opencv_extra/testdata"
50     export OPENCV_SAMPLES_DATA_PATH="${opencv4.package_tests}/samples/data"
52     # ignored tests because of gtest error - "Test code is not available due to compilation error with GCC 11"
53     # ignore test due to numerical instability
54     export GTEST_FILTER="-AsyncAPICancelation/cancel*:Photo_CalibrateDebevec.regression"
55   '';
56   accuracyTests = lib.optionalString runAccuracyTests ''
57     ${ builtins.concatStringsSep "\n"
58       (map (test: "${testRunner}${opencv4.package_tests}/opencv_test_${test} --test_threads=$NIX_BUILD_CORES --gtest_filter=$GTEST_FILTER" ) testNames)
59     }
60   '';
61   performanceTests = lib.optionalString runPerformanceTests ''
62     ${ builtins.concatStringsSep "\n"
63       (map (test: "${testRunner}${opencv4.package_tests}/opencv_perf_${test} --perf_impl=plain --perf_min_samples=10 --perf_force_samples=10 --perf_verify_sanity --skip_unstable=1 --gtest_filter=$GTEST_FILTER") perfTestNames)
64     }
65   '';
67 runCommand "opencv4-tests"
69   nativeBuildInputs = lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good ]);
71   (testsPreparation + accuracyTests + performanceTests)