vrclient: Remove unused tests generation code.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon 2023-09-30 10:59:42 +02:00
parent 622e0dbb48
commit 619aa95d93
8 changed files with 0 additions and 71288 deletions

View file

@ -996,8 +996,6 @@ def handle_class(klass):
constructors.write(f" {{\"{klass.version}\", &create_{winclassname}, &destroy_{winclassname}}},\n")
constructors.write(f" {{\"FnTable:{klass.version}\", &create_{winclassname}_FnTable, &destroy_{winclassname}_FnTable}},\n")
generate_c_api_thunk_tests(winclassname, klass.methods)
def canonical_typename(cursor):
if type(cursor) in (Cursor, Struct):
@ -1196,180 +1194,6 @@ extern void call_flat_method_f(void);
f.write("#endif\n")
def generate_c_api_method_test(f, header, thunks_c, class_name, method):
thunk_params = get_capi_thunk_params(method)
f.write("\n init_thunk(t, this_ptr_value, %s_%s, %s);\n" % (class_name, method.name, thunk_params))
f.write(" ")
header.write("\n")
thunks_c.write("\n")
returns_record = method.result_type.get_canonical().kind == TypeKind.RECORD
if returns_record:
f.write("%s *" % strip_ns(method.result_type.spelling))
header.write("%s *" % strip_ns(method.result_type.spelling))
thunks_c.write("%s *" % strip_ns(method.result_type.spelling))
else:
f.write("%s " % strip_ns(method.result_type.spelling))
header.write("%s " % strip_ns(method.result_type.spelling))
thunks_c.write("%s " % strip_ns(method.result_type.spelling))
first_param = True
f.write('(__stdcall *capi_%s_%s)(' % (class_name, method.name))
header.write('__thiscall %s_%s(void *_this' % (class_name, method.name))
thunks_c.write('__thiscall %s_%s(void *_this' % (class_name, method.name))
if returns_record:
f.write("%s *_r" % strip_ns(method.result_type.spelling))
first_param = False
header.write(", %s *_r" % strip_ns(method.result_type.spelling))
thunks_c.write(", %s *_r" % strip_ns(method.result_type.spelling))
for param in method.get_arguments():
if param.type.kind == TypeKind.POINTER \
and param.type.get_pointee().kind == TypeKind.UNEXPOSED:
typename = "void *"
else:
typename = param.type.spelling.split("::")[-1].replace("&", "*");
if not first_param:
f.write(", ")
first_param = False
f.write("%s %s" % (typename, param.spelling))
header.write(", %s %s" % (typename, param.spelling))
thunks_c.write(", %s %s" % (typename, param.spelling))
f.write(") = (void *)t;\n")
header.write(");\n")
thunks_c.write(")\n{\n")
def get_param_typename(param):
param_size = param.type.get_size()
if param.type.kind == TypeKind.POINTER \
or param.type.spelling.endswith("&") \
or param.type.spelling == "vr::glSharedTextureHandle_t":
return "ptr"
elif param.type.spelling == "bool":
return "bool"
elif param.type.spelling == "float":
return "float"
elif param.type.spelling == "vr::HmdRect2_t":
return "HmdRect2"
elif param.type.spelling == "vr::HmdVector2_t":
return "HmdVector2"
elif param.type.spelling == "vr::HmdVector3_t":
return "HmdVector3"
elif param.type.spelling == "vr::HmdColor_t":
return "HmdColor"
elif param_size == 8:
return "uint64"
elif param_size == 4 or param_size == 2:
return "uint32"
else:
return "unknown"
thunks_c.write(" push_ptr_parameter(_this);\n")
if returns_record:
thunks_c.write(" push_ptr_parameter(_r);\n")
for param in method.get_arguments():
typename = get_param_typename(param)
thunks_c.write(" push_%s_parameter(%s);\n" % (typename, param.spelling))
if method.result_type.kind != TypeKind.VOID:
thunks_c.write(" return 0;\n")
thunks_c.write("}\n")
parameter_checks = []
def add_parameter_check(typename, value):
parameter_checks.append("check_%s_parameter(\"%s_%s\", %s)" % (typename, class_name, method.name, value))
add_parameter_check("ptr", "this_ptr_value")
f.write("\n")
f.write(" clear_parameters();\n")
f.write(" capi_%s_%s(" % (class_name, method.name))
first_param = True
if returns_record:
f.write("data_ptr_value")
first_param = False
add_parameter_check("ptr", "data_ptr_value")
for i, param in enumerate(method.get_arguments()):
i += 1
typename = get_param_typename(param)
if typename == "ptr":
v = "(void *)%s" % i
elif typename == "bool":
v = "1"
elif typename == "float":
v = "%s.0f" % i
elif typename == "HmdRect2":
v = "DEFAULT_RECT"
elif typename == "HmdVector2":
v = "DEFAULT_VECTOR2"
elif typename == "HmdVector3":
v = "DEFAULT_VECTOR3"
elif typename == "HmdColor":
v = "DEFAULT_COLOR"
else:
v = str(i)
if not first_param:
f.write(", ")
first_param = False
f.write(v)
add_parameter_check(typename, v)
f.write(");\n")
for c in parameter_checks:
f.write(" %s;\n" % c)
def generate_c_api_thunk_tests(winclassname, methods):
class_name = re.sub(r'^win[A-Za-z]+_', '', winclassname)
filename = "tests/capi_thunks_autogen.h"
file_exists = os.path.isfile(filename)
header = open(filename, "a")
if not file_exists:
header.write("""/* This file is auto-generated, do not edit. */
#include <stdarg.h>
#include <stdint.h>
#include "windef.h"
#include "winbase.h"
#include "cxx.h"
#include "flatapi.h"
#include "vrclient_defs.h"
#include "capi_thunks.h"
""")
header.write("\nvoid test_capi_thunks_%s(void);\n" % class_name)
filename = "tests/capi_thunks_autogen.c"
file_exists = os.path.isfile(filename)
thunks_c = open(filename, "a")
if not file_exists:
thunks_c.write("""/* This file is auto-generated, do not edit. */
#include "capi_thunks_autogen.h"
""")
filename = "tests/capi_thunks_tests_autogen.c"
file_exists = os.path.isfile(filename)
with open(filename, "a") as f:
if not file_exists:
f.write("""/* This file is auto-generated, do not edit. */
#include "capi_thunks_autogen.h"
""")
f.write("\nvoid test_capi_thunks_%s(void)\n{\n" % class_name)
f.write(" struct thunk *t = alloc_thunks(1);\n");
for method in methods:
generate_c_api_method_test(f, header, thunks_c, class_name, method)
f.write(" VirtualFree(t, 0, MEM_RELEASE);\n")
f.write("}\n")
filename = "tests/main_autogen.c"
file_exists = os.path.isfile(filename)
with open(filename, "a") as f:
if not file_exists:
f.write("""/* This file is auto-generated, do not edit. */
#include "capi_thunks_autogen.h"
#include <stdio.h>
int main(void)
{
""")
f.write(" test_capi_thunks_%s();\n" % class_name)
def enumerate_structs(cursor, vr_only=False):
@ -1565,11 +1389,6 @@ for _, klass in sorted(all_classes.items()):
sdkver = klass._sdkver
handle_class(klass)
with open("tests/main_autogen.c", "a") as f:
f.write(" printf(\"All tests executed.\\n\");\n")
f.write("}\n")
generate_flatapi_c()