0

While a binary works with bazel run, when I run a test using bazel test, such as:

$ bazel test //systems/sensors:rgbd_camera_test

I encounter a slew of errors from VTK / OpenGL:

ERROR: In /vtk/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx, line 820
vtkXOpenGLRenderWindow (0x55880715b760): failed to create offscreen window

ERROR: In /vtk/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 816
vtkXOpenGLRenderWindow (0x55880715b760): GLEW could not be initialized.

ERROR: In /vtk/Rendering/OpenGL2/vtkShaderProgram.cxx, line 453
vtkShaderProgram (0x5588071d5aa0): Shader object was not initialized, cannot attach it.

ERROR: In /vtk/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 1858
vtkXOpenGLRenderWindow (0x55880715b760): Hardware does not support the number of textures defined.

May I ask why this happens?

(Note: This post is a means to migrate from http://drake.mit.edu/faq.html to StackOverflow for user-based questions.)

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
eacousineau
  • 3,457
  • 3
  • 34
  • 37

1 Answers1

0

The best workaround at the moment is to first mark the test as as local in the BUILD.bazel file, either with local = 1, or tags = [.., "local"]. Doing so will make the specific target run without sandboxing, such that it has an environment similar to that of bazel run.

As an example, in systems/sensors/BUILD.bazel:

drake_cc_googletest(
    name = "rgbd_camera_test",
    # ...
    local = 1,
    # ...
)

If this does not work, then try running the test in Bazel without sandboxing:

$ bazel test --spawn_strategy=standalone //systems/sensors:rgbd_camera_test

Please note that you can possibly add --spawn_strategy=standalone to your ~/.bazelrc, but be aware that this means your development testing environment may deviate even more from other developer's testing environments.

Eric Cousineau
  • 1,944
  • 14
  • 23