libtorch-bin: cleanup passthru test

- Make passthru.tests an attrset.
- Remove CMake VERBOSE option.
- Remove spurious `cat CMakeLists.txt`.
- Run the test as well.
- Actually test some functionality.

+18 -9
+1 -1
pkgs/development/libraries/science/math/libtorch/bin.nix
··· 100 101 outputs = [ "out" "dev" ]; 102 103 - passthru.tests = callPackage ./test { }; 104 105 meta = with stdenv.lib; { 106 description = "C++ API of the PyTorch machine learning framework";
··· 100 101 outputs = [ "out" "dev" ]; 102 103 + passthru.tests.cmake = callPackage ./test { }; 104 105 meta = with stdenv.lib; { 106 description = "C++ API of the PyTorch machine learning framework";
+2 -6
pkgs/development/libraries/science/math/libtorch/test/default.nix
··· 6 7 src = ./.; 8 9 - postPatch = '' 10 - cat CMakeLists.txt 11 - ''; 12 - 13 - makeFlags = [ "VERBOSE=1" ]; 14 - 15 nativeBuildInputs = [ cmake ]; 16 17 buildInputs = [ libtorch-bin ]; 18 19 installPhase = '' 20 touch $out
··· 6 7 src = ./.; 8 9 nativeBuildInputs = [ cmake ]; 10 11 buildInputs = [ libtorch-bin ]; 12 + 13 + doCheck = true; 14 15 installPhase = '' 16 touch $out
+15 -2
pkgs/development/libraries/science/math/libtorch/test/test.cpp
··· 1 #include <torch/torch.h> 2 - #include <iostream> 3 4 int main() { 5 torch::Tensor tensor = torch::eye(3); 6 - std::cout << tensor << std::endl; 7 }
··· 1 + #undef NDEBUG 2 + #include <cassert> 3 + 4 + #include <iostream> 5 + 6 #include <torch/torch.h> 7 8 int main() { 9 torch::Tensor tensor = torch::eye(3); 10 + 11 + float checkData[] = { 12 + 1, 0, 0, 13 + 0, 1, 0, 14 + 0, 0, 1 15 + }; 16 + 17 + torch::Tensor check = torch::from_blob(checkData, {3, 3}); 18 + 19 + assert(tensor.allclose(check)); 20 }