2016-09-21 03:57:24 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Józef Kucia for CodeWeavers
|
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2016-09-21 03:57:24 -07:00
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2016-09-21 03:57:24 -07:00
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2016-09-21 03:57:24 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VKD3D_TEST_H
|
|
|
|
#define __VKD3D_TEST_H
|
|
|
|
|
2017-12-14 02:45:54 -08:00
|
|
|
#include "vkd3d_common.h"
|
2016-11-09 05:46:37 -08:00
|
|
|
#include <assert.h>
|
2016-10-10 02:22:50 -07:00
|
|
|
#include <inttypes.h>
|
2016-09-21 03:57:24 -07:00
|
|
|
#include <stdarg.h>
|
2016-10-24 04:20:09 -07:00
|
|
|
#include <stdbool.h>
|
2016-09-21 03:57:24 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2022-01-26 17:40:27 -08:00
|
|
|
extern const char *vkd3d_test_name;
|
|
|
|
extern const char *vkd3d_test_platform;
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2018-12-03 02:31:27 -08:00
|
|
|
static void vkd3d_test_start_todo(bool is_todo);
|
|
|
|
static int vkd3d_test_loop_todo(void);
|
|
|
|
static void vkd3d_test_end_todo(void);
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
#define START_TEST(name) \
|
2022-01-26 17:40:27 -08:00
|
|
|
const char *vkd3d_test_name = #name; \
|
2016-11-09 05:46:37 -08:00
|
|
|
static void vkd3d_test_main(int argc, char **argv)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-03-11 04:19:20 -07:00
|
|
|
/*
|
|
|
|
* Use assert_that() for conditions that should always be true.
|
|
|
|
* todo_if() and bug_if() do not influence assert_that().
|
|
|
|
*/
|
|
|
|
#define assert_that assert_that_(__LINE__)
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#define ok ok_(__LINE__)
|
2019-03-11 04:19:20 -07:00
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#define skip skip_(__LINE__)
|
2019-03-11 04:19:20 -07:00
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#define trace trace_(__LINE__)
|
|
|
|
|
2019-03-11 04:19:20 -07:00
|
|
|
#define assert_that_(line) \
|
|
|
|
do { \
|
|
|
|
unsigned int vkd3d_line = line; \
|
|
|
|
VKD3D_TEST_ASSERT_THAT
|
|
|
|
|
2019-10-01 03:33:44 -07:00
|
|
|
#define VKD3D_TEST_ASSERT_THAT(...) \
|
|
|
|
vkd3d_test_assert_that(vkd3d_line, __VA_ARGS__); } while (0)
|
2019-03-11 04:19:20 -07:00
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#define ok_(line) \
|
2016-10-17 05:24:22 -07:00
|
|
|
do { \
|
|
|
|
unsigned int vkd3d_line = line; \
|
|
|
|
VKD3D_TEST_OK
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-10-01 03:33:44 -07:00
|
|
|
#define VKD3D_TEST_OK(...) \
|
|
|
|
vkd3d_test_ok(vkd3d_line, __VA_ARGS__); } while (0)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2016-09-28 00:42:49 -07:00
|
|
|
#define todo_(line) \
|
2016-10-17 05:24:22 -07:00
|
|
|
do { \
|
|
|
|
unsigned int vkd3d_line = line; \
|
|
|
|
VKD3D_TEST_TODO
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2019-10-01 03:33:44 -07:00
|
|
|
#define VKD3D_TEST_TODO(...) \
|
|
|
|
vkd3d_test_todo(vkd3d_line, __VA_ARGS__); } while (0)
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#define skip_(line) \
|
2016-10-17 05:24:22 -07:00
|
|
|
do { \
|
|
|
|
unsigned int vkd3d_line = line; \
|
|
|
|
VKD3D_TEST_SKIP
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-10-01 03:33:44 -07:00
|
|
|
#define VKD3D_TEST_SKIP(...) \
|
|
|
|
vkd3d_test_skip(vkd3d_line, __VA_ARGS__); } while (0)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
|
|
|
#define trace_(line) \
|
2016-10-17 05:24:22 -07:00
|
|
|
do { \
|
|
|
|
unsigned int vkd3d_line = line; \
|
|
|
|
VKD3D_TEST_TRACE
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-10-01 03:33:44 -07:00
|
|
|
#define VKD3D_TEST_TRACE(...) \
|
|
|
|
vkd3d_test_trace(vkd3d_line, __VA_ARGS__); } while (0)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2018-12-03 02:31:27 -08:00
|
|
|
#define todo_if(is_todo) \
|
|
|
|
for (vkd3d_test_start_todo(is_todo); vkd3d_test_loop_todo(); vkd3d_test_end_todo())
|
|
|
|
|
2019-03-04 04:15:20 -08:00
|
|
|
#define bug_if(is_bug) \
|
|
|
|
for (vkd3d_test_start_bug(is_bug); vkd3d_test_loop_bug(); vkd3d_test_end_bug())
|
|
|
|
|
2018-12-03 02:31:27 -08:00
|
|
|
#define todo todo_if(true)
|
|
|
|
|
2022-01-26 17:40:27 -08:00
|
|
|
struct vkd3d_test_state
|
2016-09-21 03:57:24 -07:00
|
|
|
{
|
2024-01-30 03:54:54 -08:00
|
|
|
unsigned int success_count;
|
|
|
|
unsigned int failure_count;
|
|
|
|
unsigned int skip_count;
|
|
|
|
unsigned int todo_count;
|
|
|
|
unsigned int todo_success_count;
|
|
|
|
unsigned int bug_count;
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
unsigned int debug_level;
|
2018-12-03 02:31:27 -08:00
|
|
|
|
|
|
|
unsigned int todo_level;
|
|
|
|
bool todo_do_loop;
|
2018-12-11 06:47:57 -08:00
|
|
|
|
2019-03-04 04:15:20 -08:00
|
|
|
unsigned int bug_level;
|
|
|
|
bool bug_do_loop;
|
2019-05-07 06:37:06 -07:00
|
|
|
bool bug_enabled;
|
2019-03-04 04:15:20 -08:00
|
|
|
|
2019-07-17 04:17:35 -07:00
|
|
|
const char *test_name_filter;
|
2023-02-23 14:20:40 -08:00
|
|
|
char context[8][128];
|
|
|
|
unsigned int context_count;
|
2022-01-26 17:40:27 -08:00
|
|
|
};
|
|
|
|
extern struct vkd3d_test_state vkd3d_test_state;
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2017-12-14 02:45:57 -08:00
|
|
|
static bool
|
|
|
|
vkd3d_test_platform_is_windows(void)
|
|
|
|
{
|
|
|
|
return !strcmp(vkd3d_test_platform, "windows");
|
|
|
|
}
|
|
|
|
|
2018-10-01 04:57:12 -07:00
|
|
|
static inline bool
|
|
|
|
broken(bool condition)
|
|
|
|
{
|
|
|
|
return condition && vkd3d_test_platform_is_windows();
|
|
|
|
}
|
|
|
|
|
2023-02-23 13:42:18 -08:00
|
|
|
static void vkd3d_test_printf(unsigned int line, const char *msg)
|
|
|
|
{
|
2023-02-23 14:20:40 -08:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
printf("%s:%u: ", vkd3d_test_name, line);
|
|
|
|
for (i = 0; i < vkd3d_test_state.context_count; ++i)
|
|
|
|
printf("%s: ", vkd3d_test_state.context[i]);
|
|
|
|
printf("%s", msg);
|
2023-02-23 13:42:18 -08:00
|
|
|
}
|
|
|
|
|
2019-03-11 04:19:20 -07:00
|
|
|
static void
|
|
|
|
vkd3d_test_check_assert_that(unsigned int line, bool result, const char *fmt, va_list args)
|
|
|
|
{
|
|
|
|
if (result)
|
|
|
|
{
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_atomic_increment_u32(&vkd3d_test_state.success_count);
|
2019-03-11 04:19:20 -07:00
|
|
|
if (vkd3d_test_state.debug_level > 1)
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Test succeeded.\n");
|
2019-03-11 04:19:20 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_atomic_increment_u32(&vkd3d_test_state.failure_count);
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Test failed: ");
|
2019-03-11 04:19:20 -07:00
|
|
|
vprintf(fmt, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED
|
|
|
|
vkd3d_test_assert_that(unsigned int line, bool result, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
vkd3d_test_check_assert_that(line, result, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2017-12-14 02:45:57 -08:00
|
|
|
static void
|
|
|
|
vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list args)
|
2016-09-21 03:57:24 -07:00
|
|
|
{
|
2018-12-03 02:31:27 -08:00
|
|
|
bool is_todo = vkd3d_test_state.todo_level && !vkd3d_test_platform_is_windows();
|
2019-03-04 04:15:20 -08:00
|
|
|
bool is_bug = vkd3d_test_state.bug_level && !vkd3d_test_platform_is_windows();
|
2018-12-03 02:31:27 -08:00
|
|
|
|
2019-05-07 06:37:06 -07:00
|
|
|
if (is_bug && vkd3d_test_state.bug_enabled)
|
2019-03-04 04:15:20 -08:00
|
|
|
{
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_atomic_increment_u32(&vkd3d_test_state.bug_count);
|
2019-03-04 04:15:20 -08:00
|
|
|
if (is_todo)
|
|
|
|
result = !result;
|
|
|
|
if (result)
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Fixed bug: ");
|
2019-03-04 04:15:20 -08:00
|
|
|
else
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Bug: ");
|
2019-03-04 04:15:20 -08:00
|
|
|
vprintf(fmt, args);
|
|
|
|
}
|
|
|
|
else if (is_todo)
|
2018-12-03 02:31:27 -08:00
|
|
|
{
|
|
|
|
if (result)
|
|
|
|
{
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_atomic_increment_u32(&vkd3d_test_state.todo_success_count);
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Todo succeeded: ");
|
2018-12-03 02:31:27 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_atomic_increment_u32(&vkd3d_test_state.todo_count);
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Todo: ");
|
2018-12-03 02:31:27 -08:00
|
|
|
}
|
2019-03-04 04:15:20 -08:00
|
|
|
vprintf(fmt, args);
|
2018-12-03 02:31:27 -08:00
|
|
|
}
|
2016-09-21 03:57:24 -07:00
|
|
|
else
|
|
|
|
{
|
2019-03-11 04:19:20 -07:00
|
|
|
vkd3d_test_check_assert_that(line, result, fmt, args);
|
2016-09-21 03:57:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-14 02:45:57 -08:00
|
|
|
static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED
|
|
|
|
vkd3d_test_ok(unsigned int line, bool result, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
vkd3d_test_check_ok(line, result, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2016-10-17 05:24:22 -07:00
|
|
|
static void VKD3D_PRINTF_FUNC(2, 3) VKD3D_UNUSED
|
|
|
|
vkd3d_test_skip(unsigned int line, const char *fmt, ...)
|
2016-09-21 03:57:24 -07:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "Test skipped: ");
|
2016-09-21 03:57:24 -07:00
|
|
|
vprintf(fmt, args);
|
|
|
|
va_end(args);
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_atomic_increment_u32(&vkd3d_test_state.skip_count);
|
2016-09-21 03:57:24 -07:00
|
|
|
}
|
|
|
|
|
2016-10-17 05:24:22 -07:00
|
|
|
static void VKD3D_PRINTF_FUNC(2, 3) VKD3D_UNUSED
|
|
|
|
vkd3d_test_trace(unsigned int line, const char *fmt, ...)
|
2016-09-21 03:57:24 -07:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
2023-02-23 13:42:18 -08:00
|
|
|
vkd3d_test_printf(line, "");
|
2016-09-21 03:57:24 -07:00
|
|
|
vprintf(fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
static void VKD3D_PRINTF_FUNC(1, 2) VKD3D_UNUSED
|
|
|
|
vkd3d_test_debug(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char buffer[512];
|
|
|
|
va_list args;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
size = snprintf(buffer, sizeof(buffer), "%s: ", vkd3d_test_name);
|
|
|
|
if (0 < size && size < sizeof(buffer))
|
|
|
|
{
|
|
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(buffer + size, sizeof(buffer) - size, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
buffer[sizeof(buffer) - 1] = '\0';
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
OutputDebugStringA(buffer);
|
|
|
|
#endif
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
if (vkd3d_test_state.debug_level > 0)
|
2016-11-09 05:46:37 -08:00
|
|
|
printf("%s\n", buffer);
|
|
|
|
}
|
|
|
|
|
2022-01-26 17:40:27 -08:00
|
|
|
#ifndef VKD3D_TEST_NO_DEFS
|
|
|
|
const char *vkd3d_test_platform = "other";
|
|
|
|
struct vkd3d_test_state vkd3d_test_state;
|
|
|
|
|
|
|
|
static void vkd3d_test_main(int argc, char **argv);
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
int main(int argc, char **argv)
|
2016-09-21 03:57:24 -07:00
|
|
|
{
|
2019-07-17 04:17:35 -07:00
|
|
|
const char *test_filter = getenv("VKD3D_TEST_FILTER");
|
2016-11-09 05:46:37 -08:00
|
|
|
const char *debug_level = getenv("VKD3D_TEST_DEBUG");
|
2017-12-14 02:45:57 -08:00
|
|
|
char *test_platform = getenv("VKD3D_TEST_PLATFORM");
|
2019-05-07 06:37:06 -07:00
|
|
|
const char *bug = getenv("VKD3D_TEST_BUG");
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2024-02-15 05:51:42 -08:00
|
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
2016-09-21 03:57:24 -07:00
|
|
|
memset(&vkd3d_test_state, 0, sizeof(vkd3d_test_state));
|
2019-05-07 06:37:06 -07:00
|
|
|
vkd3d_test_state.debug_level = debug_level ? atoi(debug_level) : 0;
|
|
|
|
vkd3d_test_state.bug_enabled = bug ? atoi(bug) : true;
|
2019-07-17 04:17:35 -07:00
|
|
|
vkd3d_test_state.test_name_filter = test_filter;
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2017-12-14 02:45:57 -08:00
|
|
|
if (test_platform)
|
|
|
|
{
|
|
|
|
test_platform = strdup(test_platform);
|
|
|
|
vkd3d_test_platform = test_platform;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vkd3d_test_state.debug_level > 1)
|
|
|
|
printf("Test platform: '%s'.\n", vkd3d_test_platform);
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
vkd3d_test_main(argc, argv);
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2024-01-30 03:54:54 -08:00
|
|
|
printf("%s: %u tests executed (%u failures, %u skipped, %u todo, %u bugs).\n",
|
2016-09-21 03:57:24 -07:00
|
|
|
vkd3d_test_name,
|
2024-01-30 03:54:54 -08:00
|
|
|
vkd3d_test_state.success_count + vkd3d_test_state.failure_count
|
|
|
|
+ vkd3d_test_state.todo_count + vkd3d_test_state.todo_success_count,
|
|
|
|
vkd3d_test_state.failure_count + vkd3d_test_state.todo_success_count,
|
|
|
|
vkd3d_test_state.skip_count,
|
|
|
|
vkd3d_test_state.todo_count,
|
|
|
|
vkd3d_test_state.bug_count);
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2017-12-14 02:45:57 -08:00
|
|
|
if (test_platform)
|
|
|
|
free(test_platform);
|
|
|
|
|
2016-09-28 00:42:49 -07:00
|
|
|
return vkd3d_test_state.failure_count || vkd3d_test_state.todo_success_count;
|
2016-09-21 03:57:24 -07:00
|
|
|
}
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
static char *vkd3d_test_strdupWtoA(WCHAR *str)
|
|
|
|
{
|
|
|
|
char *out;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!(len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL)))
|
|
|
|
return NULL;
|
|
|
|
if (!(out = malloc(len)))
|
|
|
|
return NULL;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, str, -1, out, len, NULL, NULL);
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2017-12-14 02:45:58 -08:00
|
|
|
static bool running_under_wine(void)
|
|
|
|
{
|
|
|
|
HMODULE module = GetModuleHandleA("ntdll.dll");
|
|
|
|
return module && GetProcAddress(module, "wine_server_call");
|
|
|
|
}
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
int wmain(int argc, WCHAR **wargv)
|
|
|
|
{
|
|
|
|
char **argv;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
argv = malloc(argc * sizeof(*argv));
|
|
|
|
assert(argv);
|
|
|
|
for (i = 0; i < argc; ++i)
|
|
|
|
{
|
|
|
|
if (!(argv[i] = vkd3d_test_strdupWtoA(wargv[i])))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert(i == argc);
|
|
|
|
|
2017-12-14 02:45:58 -08:00
|
|
|
vkd3d_test_platform = running_under_wine() ? "wine" : "windows";
|
2017-12-14 02:45:57 -08:00
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
ret = main(argc, argv);
|
|
|
|
|
|
|
|
for (i = 0; i < argc; ++i)
|
|
|
|
free(argv[i]);
|
|
|
|
free(argv);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* _WIN32 */
|
2022-01-26 17:40:27 -08:00
|
|
|
#endif /* VKD3D_TEST_NO_DEFS */
|
2016-11-09 05:46:37 -08:00
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
typedef void (*vkd3d_test_pfn)(void);
|
|
|
|
|
|
|
|
static inline void vkd3d_run_test(const char *name, vkd3d_test_pfn test_pfn)
|
|
|
|
{
|
2019-07-17 04:17:35 -07:00
|
|
|
if (vkd3d_test_state.test_name_filter && !strstr(name, vkd3d_test_state.test_name_filter))
|
|
|
|
return;
|
|
|
|
|
2018-01-17 03:48:12 -08:00
|
|
|
vkd3d_test_debug("%s", name);
|
2016-11-09 05:46:37 -08:00
|
|
|
test_pfn();
|
|
|
|
}
|
|
|
|
|
2018-12-03 02:31:27 -08:00
|
|
|
static inline void vkd3d_test_start_todo(bool is_todo)
|
|
|
|
{
|
|
|
|
vkd3d_test_state.todo_level = (vkd3d_test_state.todo_level << 1) | is_todo;
|
|
|
|
vkd3d_test_state.todo_do_loop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int vkd3d_test_loop_todo(void)
|
|
|
|
{
|
|
|
|
bool do_loop = vkd3d_test_state.todo_do_loop;
|
|
|
|
vkd3d_test_state.todo_do_loop = false;
|
|
|
|
return do_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void vkd3d_test_end_todo(void)
|
|
|
|
{
|
|
|
|
vkd3d_test_state.todo_level >>= 1;
|
|
|
|
}
|
|
|
|
|
2019-03-04 04:15:20 -08:00
|
|
|
static inline void vkd3d_test_start_bug(bool is_bug)
|
|
|
|
{
|
|
|
|
vkd3d_test_state.bug_level = (vkd3d_test_state.bug_level << 1) | is_bug;
|
|
|
|
vkd3d_test_state.bug_do_loop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int vkd3d_test_loop_bug(void)
|
|
|
|
{
|
|
|
|
bool do_loop = vkd3d_test_state.bug_do_loop;
|
|
|
|
vkd3d_test_state.bug_do_loop = false;
|
|
|
|
return do_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void vkd3d_test_end_bug(void)
|
|
|
|
{
|
|
|
|
vkd3d_test_state.bug_level >>= 1;
|
|
|
|
}
|
|
|
|
|
2023-02-23 14:20:40 -08:00
|
|
|
static inline void vkd3d_test_push_context(const char *fmt, ...)
|
2018-12-11 06:47:57 -08:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
2023-02-23 14:20:40 -08:00
|
|
|
if (vkd3d_test_state.context_count < ARRAY_SIZE(vkd3d_test_state.context))
|
2018-12-11 06:47:57 -08:00
|
|
|
{
|
2023-02-23 14:20:40 -08:00
|
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(vkd3d_test_state.context[vkd3d_test_state.context_count],
|
|
|
|
sizeof(vkd3d_test_state.context), fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
vkd3d_test_state.context[vkd3d_test_state.context_count][sizeof(vkd3d_test_state.context[0]) - 1] = '\0';
|
2018-12-11 06:47:57 -08:00
|
|
|
}
|
2023-02-23 14:20:40 -08:00
|
|
|
++vkd3d_test_state.context_count;
|
|
|
|
}
|
2018-12-11 06:47:57 -08:00
|
|
|
|
2023-02-23 14:20:40 -08:00
|
|
|
static inline void vkd3d_test_pop_context(void)
|
|
|
|
{
|
|
|
|
if (vkd3d_test_state.context_count)
|
|
|
|
--vkd3d_test_state.context_count;
|
2018-12-11 06:47:57 -08:00
|
|
|
}
|
|
|
|
|
2016-11-09 05:46:37 -08:00
|
|
|
#define run_test(test_pfn) \
|
|
|
|
vkd3d_run_test(#test_pfn, test_pfn)
|
|
|
|
|
2016-10-24 04:20:09 -07:00
|
|
|
#endif /* __VKD3D_TEST_H */
|