commit d05a776200b0395bc87c2eccbda785ab4ec7c2fd
parent 7009c94a9329fd69f089a787e1bcfc574217fefd
Author: Guillaume Bouchard <guillaume.bouchard@tweag.io>
Date: Mon, 27 Apr 2020 10:12:44 +0200
Tests:
- Add failure test (to test on nixos, we ensure that it fails with
another libc implementation).
Diffstat:
| M | Test.hs | | | 38 | +++++++++++++++++++++++++------------- |
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/Test.hs b/Test.hs
@@ -8,36 +8,48 @@ import Data.Text (Text)
import Control.Monad.IO.Class (liftIO)
import Data.List (find)
+currentChannel = "channel:nixos-19.03-small"
+
-- | Utils function: run a command and returns its output.
processOutput p args = Text.strip . Text.pack <$> readProcess (Text.unpack p) (Text.unpack <$> args) ""
-- | Returns the path to the nixGLXXX binary.
-nixGLBin version = (<>("/bin/"<>version)) <$> processOutput "nix-build" ["./", "-A", version]
+getNixGLBin version = (<>("/bin/"<>version)) <$> processOutput "nix-build" ["./", "-A", version, "--arg", "pkgs", "import (fetchTarball " <> currentChannel <> ")"]
-- | Returns the vendor string associated with a glxinfo wrapped by a nixGL.
-getVendorString nixGL glxinfo = do
- output <- Text.lines <$> processOutput nixGL [glxinfo]
+getVendorString io = do
+ output <- Text.lines <$> io
pure $ Text.unpack <$> find ("OpenGL version string"`Text.isPrefixOf`) output
-- | Checks that a nixGL wrapper works with glxinfo 32 & 64 bits.
checkOpenGL_32_64 glxinfo32 glxinfo64 vendorName nixGLName = do
- nixGLBin <- runIO $ (<>("/bin/"<>nixGLName)) <$> processOutput "nix-build" ["./", "-A", nixGLName]
-
- it "32 bits" $ do
- Just vendorString <- getVendorString nixGLBin glxinfo32
- vendorString `shouldContain` vendorName
+ beforeAll (getNixGLBin nixGLName) $ do
+ it "32 bits" $ \nixGLBin -> do
+ Just vendorString <- getVendorString (processOutput nixGLBin [glxinfo32, "-B"])
+ vendorString `shouldContain` vendorName
- it "64 bits" $ do
- Just vendorString <- getVendorString nixGLBin glxinfo64
- vendorString `shouldContain` vendorName
+ it "64 bits" $ \nixGLBin -> do
+ Just vendorString <- getVendorString (processOutput nixGLBin [glxinfo64, "-B"])
+ vendorString `shouldContain` vendorName
main = do
- glxinfo64 <- (<>"/bin/glxinfo") <$> processOutput "nix-build" ["<nixpkgs>", "-A", "glxinfo"]
- glxinfo32 <- (<>"/bin/glxinfo") <$> processOutput "nix-build" ["<nixpkgs>", "-A", "pkgsi686Linux.glxinfo"]
+ -- nixos-18-03 is used so hopefully it will have a different libc
+ -- than the one used in current nixOS system, so it will trigger the
+ -- driver failure.
+ glxinfo64 <- (<>"/bin/glxinfo") <$> processOutput "nix-build" [currentChannel, "-A", "glxinfo"]
+ glxinfo32 <- (<>"/bin/glxinfo") <$> processOutput "nix-build" [currentChannel, "-A", "pkgsi686Linux.glxinfo"]
let checkOpenGL = checkOpenGL_32_64 glxinfo32 glxinfo64
hspec $ do
+ describe "Must fail" $ do
+ it "fails with unwrapped glxinfo64" $ do
+ vendorString <- getVendorString (processOutput glxinfo64 [])
+ vendorString `shouldBe` Nothing
+
+ it "fails with unwrapped glxinfo32" $ do
+ vendorString <- getVendorString (processOutput glxinfo32 [])
+ vendorString `shouldBe` Nothing
describe "Mesa" $ do
checkOpenGL "Mesa" "nixGLIntel"
describe "Nvidia - Bumblebee" $ do