...
 
Commits (6)
variables:
UPSTREAM_REPO: monado/monado
DEBIAN_VERSION: buster
DEBIAN_TAG: '2019-03-19.0'
DEBIAN_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG
DEBIAN_DEBS: build-essential git cmake meson ninja-build doxygen graphviz libeigen3-dev curl patch python3 pkg-config libx11-dev libxxf86vm-dev libxrandr-dev libxcb-randr0-dev libhidapi-dev libwayland-dev libvulkan-dev glslang-dev glslang-tools libglvnd-dev libgl1-mesa-dev ca-certificates
DEBIAN_EXEC: 'bash .gitlab-ci/build-openxr-openhmd.sh'
ARCH_TAG: '2019-04-09.0'
ARCH_PKGS: 'git gcc cmake meson ninja pkgconfig python3 diffutils patch doxygen graphviz eigen hidapi libxrandr mesa glslang vulkan-headers vulkan-icd-loader check glfw-x11'
ARCH_EXEC: 'bash .gitlab-ci/build-openxr-openhmd.sh'
ARCH_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/archlinux/rolling:$ARCH_TAG
include:
- project: 'wayland/ci-templates'
ref: c73dae8b84697ef18e2dbbf4fed7386d9652b0cd
file: '/templates/debian.yml'
- project: 'wayland/ci-templates'
ref: 96912c7331cbc6da41fbf22c4217aa541176f063
file: '/templates/arch.yml'
stages:
- container_prep
- build
container_prep:
debian:container_prep:
extends: .debian@container-ifnot-exists
stage: container_prep
build-cmake:
arch:container_prep:
extends: .arch@container-ifnot-exists
stage: container_prep
debian:build-cmake:
stage: build
image: $DEBIAN_CONTAINER_IMAGE
script:
- mkdir build
- pushd build
- cmake -GNinja ..
- ninja
arch:build-cmake:
stage: build
image: $DEBIAN_CONTAINER_IMAGE
script:
......
......@@ -24,7 +24,8 @@ find_package(Vulkan REQUIRED)
find_package(OpenGL REQUIRED COMPONENTS GLX)
find_package(HIDAPI)
find_package(OpenHMD)
find_package(Libcheck)
find_package(glfw3)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(X11)
......@@ -37,6 +38,7 @@ cmake_dependent_option(BUILD_WITH_HIDAPI "Enable HIDAPI-based OSVR HDK driver" O
cmake_dependent_option(BUILD_WITH_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_XLIB "Enable xlib support" ON "X11_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_OPENGL "Enable OpenGL Graphics API support?" ON "OPENGL_FOUND" OFF)
cmake_dependent_option(BUILD_TESTING "Enable building of the test suite?" ON "LIBCHECK_FOUND AND glfw3_FOUND AND OPENGL_FOUND" OFF)
if(NOT BUILD_WITH_OPENHMD AND NOT BUILD_WITH_HIDAPI)
message(FATAL_ERROR "You must enable at least one driver: either provide OpenHMD and enable BUILD_WITH_OPENHMD (for a variety of devices via OpenHMD), or provide HIDAPI and enable BUILD_WITH_HIDAPI (for the HDK driver)")
......@@ -57,3 +59,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")
add_subdirectory(src)
add_subdirectory(doc)
if(BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
endif()
# Copyright 2018-2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
add_executable(tests
tests_common.c
tests_main.c
tests_unit.c
tests_system.c)
target_include_directories(tests PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/external"
"${PROJECT_SOURCE_DIR}/src/xrt/include"
"${PROJECT_SOURCE_DIR}/src/xrt/state_trackers"
"${PROJECT_SOURCE_DIR}/src/xrt/auxiliary"
)
target_link_libraries(tests ${RUNTIME_TARGET} libcheck::check OpenGL::GL glfw X11)
# TODO: adjust the runner so we can individually run test cases here.
add_test(NAME monado_tests COMMAND tests)
// Copyright 2018-2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Functions used in several tests.
* @author Christoph Haag <christop.haag@collabora.com>
*/
#include <glad/gl.c>
#include <glad/gl.h>
#define GLFW_EXPOSE_NATIVE_GLX
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#define X11_INCLUDES
#include "tests_common.h"
void error_callback(int error, const char *description) {
fprintf(stderr, "Error: %s\n", description);
}
GLFWwindow *window;
void init_glx(Display **display, GLXDrawable *w, GLXContext *ctx) {
if (!glfwInit()) {
printf("GLFW: Failed to init!\n");
exit(-1);
}
glfwSetErrorCallback(error_callback);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
window = glfwCreateWindow(640, 480, "Window Used for Tests", NULL, NULL);
if (!window) {
printf("GLFW: Failed to create window!\n");
exit(-1);
}
glfwHideWindow(window);
glfwMakeContextCurrent(window);
if (!gladLoadGL(glfwGetProcAddress)) {
printf("GLAD: Failed to load GL function pointers!\n");
exit(-1);
}
// hope glfw uses GLX
*display = glfwGetX11Display();
*w = glfwGetGLXWindow(window);
*ctx = glfwGetGLXContext(window);
}
void destroy_glx() {
glfwDestroyWindow(window);
glfwTerminate();
}
// Copyright 2018-2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Functions used in several tests.
* @author Christoph Haag <christop.haag@collabora.com>
*/
#pragma once
#include <check.h>
/* Several internal xrt headers use a void* definition of GLX types, so we have
* to do it too. */
#ifdef X11_INCLUDES
#include <X11/Xlib.h>
#include <GL/glx.h>
#else
typedef void *Display;
typedef void *GLXFBConfig;
typedef void *GLXDrawable;
typedef void *GLXContext;
#endif
#include <vulkan/vulkan.h>
#define XR_USE_GRAPHICS_API_OPENGL
#define XR_USE_GRAPHICS_API_VULKAN
#define XR_USE_PLATFORM_XLIB
#include "openxr_includes/openxr.h"
#include "openxr_includes/openxr_platform.h"
#include "openxr_includes/loader_interfaces.h"
#include <xrt/xrt_defines.h>
#include <oxr/oxr_logger.h>
#include <oxr/oxr_api_funcs.h>
#include <oxr/oxr_api_verify.h>
void init_glx(Display **display, GLXDrawable *w, GLXContext *ctx);
void destroy_glx();
#include <check.h>
#include <stdlib.h>
Suite *system_test_suite(void);
Suite *unit_test_suite(void);
int main(void) {
Suite *systemtest_suite = system_test_suite();
SRunner *sr = srunner_create(systemtest_suite);
Suite *unittest_suite = unit_test_suite();
srunner_add_suite(sr, unittest_suite);
srunner_run_all(sr, CK_NORMAL);
int number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
// Copyright 2018-2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief System test.
* @author Christoph Haag <christop.haag@collabora.com>
*/
#include "tests_common.h"
START_TEST(system_test) {
XrInstance instance = XR_NULL_HANDLE;
{
const char *extensions[] = {XR_KHR_OPENGL_ENABLE_EXTENSION_NAME};
XrInstanceCreateInfo ici = {0};
ici.type = XR_TYPE_INSTANCE_CREATE_INFO;
ici.enabledExtensionCount = sizeof(extensions) / sizeof(extensions[0]);
ici.enabledExtensionNames = extensions;
ck_assert(XR_SUCCESS == oxr_xrCreateInstance(&ici, &instance));
ck_assert(XR_NULL_HANDLE != instance);
}
XrInstanceProperties instance_props = {0};
instance_props.type = XR_TYPE_INSTANCE_PROPERTIES;
ck_assert(XR_SUCCESS ==
oxr_xrGetInstanceProperties(instance, &instance_props));
XrSystemId system_id;
{
XrSystemGetInfo sgi = {0};
sgi.type = XR_TYPE_SYSTEM_GET_INFO;
sgi.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
ck_assert(XR_SUCCESS == oxr_xrGetSystem(instance, &sgi, &system_id));
}
XrSystemProperties system_props = {0};
system_props.type = XR_TYPE_SYSTEM_PROPERTIES;
ck_assert(XR_SUCCESS ==
oxr_xrGetSystemProperties(instance, system_id, &system_props));
ck_assert(system_props.systemName[0] != '\0');
ck_assert(system_props.systemId != XR_NULL_SYSTEM_ID);
ck_assert(system_props.vendorId != 0);
ck_assert_int_gt(system_props.graphicsProperties.maxSwapchainImageHeight, 0);
ck_assert_int_gt(system_props.graphicsProperties.maxSwapchainImageWidth, 0);
ck_assert_int_gt(system_props.graphicsProperties.maxLayerCount, 0);
ck_assert_int_gt(system_props.graphicsProperties.maxViewCount, 0);
uint32_t view_config_type_count = 0;
{
ck_assert(XR_SUCCESS ==
oxr_xrEnumerateViewConfigurations(instance, system_id, 0,
&view_config_type_count, NULL));
ck_assert_int_gt(view_config_type_count, 0);
}
XrViewConfigurationType view_configuration_types[view_config_type_count];
{
ck_assert(XR_SUCCESS == oxr_xrEnumerateViewConfigurations(
instance, system_id, view_config_type_count,
&view_config_type_count,
view_configuration_types));
ck_assert_int_gt(view_config_type_count, 0);
}
XrViewConfigurationType view_type_stereo =
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
bool stereo_supported = false;
for (uint32_t i = 0; i < view_config_type_count; ++i) {
XrViewConfigurationProperties view_configuration_props = {0};
view_configuration_props.type = XR_TYPE_VIEW_CONFIGURATION_PROPERTIES;
ck_assert(XR_SUCCESS ==
oxr_xrGetViewConfigurationProperties(instance, system_id,
view_configuration_types[i],
&view_configuration_props));
if (view_configuration_types[i] == view_type_stereo) {
stereo_supported = true;
ck_assert_int_eq(view_configuration_props.viewConfigurationType,
view_type_stereo);
}
}
ck_assert(stereo_supported);
uint32_t view_config_count = 0;
ck_assert(XR_SUCCESS == oxr_xrEnumerateViewConfigurationViews(
instance, system_id, view_type_stereo, 0,
&view_config_count, NULL));
ck_assert_int_eq(view_config_count, 2);
XrViewConfigurationView view_configurations[view_config_count];
ck_assert(XR_SUCCESS == oxr_xrEnumerateViewConfigurationViews(
instance, system_id, view_type_stereo,
view_config_count, &view_config_count,
view_configurations));
ck_assert_int_eq(view_config_count, 2);
for (int i = 0; i < 2; i++) {
ck_assert_int_gt(view_configurations[i].recommendedImageRectHeight, 0);
ck_assert_int_gt(view_configurations[i].recommendedImageRectWidth, 0);
ck_assert_int_gt(view_configurations[i].maxImageRectHeight, 0);
ck_assert_int_gt(view_configurations[i].maxImageRectWidth, 0);
ck_assert_int_gt(view_configurations[i].recommendedSwapchainSampleCount, 0);
ck_assert_int_gt(view_configurations[i].maxSwapchainSampleCount, 0);
}
XrGraphicsBindingOpenGLXlibKHR graphics_binding_gl = {0};
graphics_binding_gl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR;
init_glx(&graphics_binding_gl.xDisplay, &graphics_binding_gl.glxDrawable,
&graphics_binding_gl.glxContext);
XrSessionCreateInfo sci = {0};
sci.type = XR_TYPE_SESSION_CREATE_INFO;
sci.next = &graphics_binding_gl;
sci.systemId = system_id;
XrSession session;
ck_assert(XR_SUCCESS == oxr_xrCreateSession(instance, &sci, &session));
ck_assert(XR_SUCCESS == oxr_xrDestroySession(session));
ck_assert(XR_SUCCESS == oxr_xrDestroyInstance(instance));
destroy_glx();
}
END_TEST
Suite *system_test_suite(void) {
Suite *s = suite_create("Monado System Test Suite");
TCase *system_test_case = tcase_create("System Test");
tcase_add_test(system_test_case, system_test);
suite_add_tcase(s, system_test_case);
return s;
}
This diff is collapsed.