Apply clang-format code style to all source files
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#include "cconfig/cmd.h"
|
||||
#include "cconfig/cconfig-util.h"
|
||||
#include "cconfig/cmd.h"
|
||||
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
static void test_cmd()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
int argc = 6;
|
||||
char* argv[] = {"-P", "test=aaa", "-C", "asdf", "-P", "test2=123"};
|
||||
char *argv[] = {"-P", "test=aaa", "-C", "asdf", "-P", "test2=123"};
|
||||
char str[32];
|
||||
int32_t val;
|
||||
|
||||
@@ -21,7 +21,8 @@ static void test_cmd()
|
||||
|
||||
check_int_eq(config->nentries, 2);
|
||||
|
||||
check_bool_true(cconfig_util_get_str(config, "test", str, sizeof(str), "1"));
|
||||
check_bool_true(
|
||||
cconfig_util_get_str(config, "test", str, sizeof(str), "1"));
|
||||
check_str_eq(str, "aaa");
|
||||
|
||||
check_bool_true(cconfig_util_get_int(config, "test2", &val, 0));
|
||||
@@ -32,9 +33,9 @@ static void test_cmd()
|
||||
|
||||
static void test_cmd_absent_entries()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
int argc = 6;
|
||||
char* argv[] = {"-P", "test=aaa", "-C", "asdf", "-P", "test2=123"};
|
||||
char *argv[] = {"-P", "test=aaa", "-C", "asdf", "-P", "test2=123"};
|
||||
char str[32];
|
||||
int32_t val;
|
||||
|
||||
@@ -49,7 +50,8 @@ static void test_cmd_absent_entries()
|
||||
|
||||
check_int_eq(config->nentries, 1);
|
||||
|
||||
check_bool_true(cconfig_util_get_str(config, "test", str, sizeof(str), "1"));
|
||||
check_bool_true(
|
||||
cconfig_util_get_str(config, "test", str, sizeof(str), "1"));
|
||||
check_str_eq(str, "aaa");
|
||||
|
||||
check_bool_false(cconfig_util_get_int(config, "test2", &val, 0));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -17,7 +17,7 @@ static void test_init()
|
||||
|
||||
static void test_get_empty()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -31,8 +31,8 @@ static void test_get_empty()
|
||||
|
||||
static void test_set_get_one_elem()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig *config;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -50,15 +50,15 @@ static void test_set_get_one_elem()
|
||||
|
||||
check_str_eq(entry->key, "test");
|
||||
check_str_eq(entry->value, "123");
|
||||
check_str_eq(entry->desc, "desc");
|
||||
check_str_eq(entry->desc, "desc");
|
||||
|
||||
cconfig_finit(config);
|
||||
}
|
||||
|
||||
static void test_set_get_one_elem2()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig *config;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -76,15 +76,15 @@ static void test_set_get_one_elem2()
|
||||
|
||||
check_str_eq(entry->key, "test");
|
||||
check_str_eq(entry->value, "123");
|
||||
check_str_eq(entry->desc, "");
|
||||
check_str_eq(entry->desc, "");
|
||||
|
||||
cconfig_finit(config);
|
||||
}
|
||||
|
||||
static void test_set_get_same_elem()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig *config;
|
||||
struct cconfig_entry *entry;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -104,15 +104,15 @@ static void test_set_get_same_elem()
|
||||
|
||||
check_str_eq(entry->key, "test");
|
||||
check_str_eq(entry->value, "12345");
|
||||
check_str_eq(entry->desc, "aaa");
|
||||
check_str_eq(entry->desc, "aaa");
|
||||
|
||||
cconfig_finit(config);
|
||||
}
|
||||
|
||||
static void test_set_get_many_elem()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig_entry* entry;
|
||||
struct cconfig *config;
|
||||
struct cconfig_entry *entry;
|
||||
char key[16];
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -140,7 +140,7 @@ static void test_set_get_many_elem()
|
||||
|
||||
check_str_eq(entry->key, key);
|
||||
check_str_eq(entry->value, "123");
|
||||
check_str_eq(entry->desc, "desc");
|
||||
check_str_eq(entry->desc, "desc");
|
||||
}
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
static void test_set_get_int()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
int32_t value;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -29,7 +29,7 @@ static void test_set_get_int()
|
||||
|
||||
static void test_get_int_na()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
int32_t value;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -45,7 +45,7 @@ static void test_get_int_na()
|
||||
|
||||
static void test_set_get_float()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
float value;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -67,7 +67,7 @@ static void test_set_get_float()
|
||||
|
||||
static void test_get_float_na()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
float value;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -83,7 +83,7 @@ static void test_get_float_na()
|
||||
|
||||
static void test_set_get_bool()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
bool value;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -105,7 +105,7 @@ static void test_set_get_bool()
|
||||
|
||||
static void test_get_bool_na()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
bool value;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -121,7 +121,7 @@ static void test_get_bool_na()
|
||||
|
||||
static void test_set_get_str()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
char value[1024];
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -135,8 +135,8 @@ static void test_set_get_str()
|
||||
check_str_eq(config->entries[0].key, "test");
|
||||
check_str_eq(config->entries[0].desc, "desc");
|
||||
|
||||
check_bool_true(cconfig_util_get_str(config, "test", value, sizeof(value),
|
||||
"world hello"));
|
||||
check_bool_true(cconfig_util_get_str(
|
||||
config, "test", value, sizeof(value), "world hello"));
|
||||
check_str_eq(value, "hello world");
|
||||
|
||||
cconfig_finit(config);
|
||||
@@ -144,7 +144,7 @@ static void test_set_get_str()
|
||||
|
||||
static void test_get_str_na()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
char value[1024];
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -152,8 +152,8 @@ static void test_get_str_na()
|
||||
check_int_eq(config->nentries, 0);
|
||||
check_null(config->entries);
|
||||
|
||||
check_bool_false(cconfig_util_get_str(config, "test", value, sizeof(value),
|
||||
"world hello"));
|
||||
check_bool_false(cconfig_util_get_str(
|
||||
config, "test", value, sizeof(value), "world hello"));
|
||||
check_str_eq(value, "world hello");
|
||||
|
||||
cconfig_finit(config);
|
||||
@@ -161,7 +161,7 @@ static void test_get_str_na()
|
||||
|
||||
static void test_set_get_data()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
uint8_t value[1024];
|
||||
uint8_t value2[1024];
|
||||
uint8_t value_default[] = {0x00};
|
||||
@@ -181,8 +181,8 @@ static void test_set_get_data()
|
||||
check_str_eq(config->entries[0].key, "test");
|
||||
check_str_eq(config->entries[0].desc, "desc");
|
||||
|
||||
check_bool_true(cconfig_util_get_data(config, "test", value2, sizeof(value2),
|
||||
value_default));
|
||||
check_bool_true(cconfig_util_get_data(
|
||||
config, "test", value2, sizeof(value2), value_default));
|
||||
check_data_eq(value2, sizeof(value2), value, sizeof(value));
|
||||
|
||||
cconfig_finit(config);
|
||||
@@ -190,7 +190,7 @@ static void test_set_get_data()
|
||||
|
||||
static void test_get_data_na()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
uint8_t value[1024];
|
||||
uint8_t value_default[] = {0x01};
|
||||
|
||||
@@ -199,8 +199,8 @@ static void test_get_data_na()
|
||||
check_int_eq(config->nentries, 0);
|
||||
check_null(config->entries);
|
||||
|
||||
check_bool_false(cconfig_util_get_data(config, "test", value, sizeof(value),
|
||||
value_default));
|
||||
check_bool_false(cconfig_util_get_data(
|
||||
config, "test", value, sizeof(value), value_default));
|
||||
check_data_eq(value, 1, value_default, sizeof(value_default));
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
+54
-35
@@ -10,33 +10,32 @@
|
||||
|
||||
#define debug_print(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp);
|
||||
static HRESULT my_d3d9_handler(struct hook_d3d9_irp *irp);
|
||||
|
||||
static const hook_d3d9_irp_handler_t d3d9_handlers[] = {
|
||||
my_d3d9_handler
|
||||
};
|
||||
static const hook_d3d9_irp_handler_t d3d9_handlers[] = {my_d3d9_handler};
|
||||
|
||||
static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
static HRESULT my_d3d9_handler(struct hook_d3d9_irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
enum hook_d3d9_irp_op pre_op;
|
||||
|
||||
debug_print("my_d3d9_handler dispatch: %d\n", irp->op);
|
||||
|
||||
// Important: All parameter checks must align with the parameters from the test executable
|
||||
// Important: All parameter checks must align with the parameters from the
|
||||
// test executable
|
||||
|
||||
// Pre-real invoke checks
|
||||
switch (irp->op) {
|
||||
case HOOK_D3D9_IRP_OP_INVALID:
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
|
||||
|
||||
case HOOK_D3D9_IRP_OP_CTX_CREATE:
|
||||
debug_print("Pre HOOK_D3D9_IRP_OP_CTX_CREATE\n");
|
||||
|
||||
|
||||
check_int_eq(irp->args.ctx_create.sdk_ver, D3D_SDK_VERSION);
|
||||
check_null(irp->args.ctx_create.ctx);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case HOOK_D3D9_IRP_OP_ENUM_DISPLAY_DEVICES:
|
||||
@@ -45,20 +44,22 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
check_null(irp->args.enum_display_devices.dev_name);
|
||||
check_int_eq(irp->args.enum_display_devices.dev_num, 0);
|
||||
check_non_null(irp->args.enum_display_devices.info);
|
||||
check_int_eq(irp->args.enum_display_devices.flags, EDD_GET_DEVICE_INTERFACE_NAME);
|
||||
check_int_eq(
|
||||
irp->args.enum_display_devices.flags,
|
||||
EDD_GET_DEVICE_INTERFACE_NAME);
|
||||
|
||||
break;
|
||||
|
||||
case HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX:
|
||||
debug_print("Pre HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX\n");
|
||||
|
||||
// Cannot test because wine is also using this call causing the tests to fail
|
||||
// check_int_eq(irp->args.create_window_ex.ex_style, 0);
|
||||
// check_str_eq(irp->args.create_window_ex.class_name, "d3d9hook");
|
||||
// check_str_eq(irp->args.create_window_ex.window_name, "d3d9hook test");
|
||||
// check_int_eq(irp->args.create_window_ex.style, WS_OVERLAPPEDWINDOW);
|
||||
// check_int_eq(irp->args.create_window_ex.x, 0);
|
||||
// check_int_eq(irp->args.create_window_ex.y, 0);
|
||||
// Cannot test because wine is also using this call causing the
|
||||
// tests to fail check_int_eq(irp->args.create_window_ex.ex_style,
|
||||
// 0); check_str_eq(irp->args.create_window_ex.class_name,
|
||||
// "d3d9hook"); check_str_eq(irp->args.create_window_ex.window_name,
|
||||
// "d3d9hook test"); check_int_eq(irp->args.create_window_ex.style,
|
||||
// WS_OVERLAPPEDWINDOW); check_int_eq(irp->args.create_window_ex.x,
|
||||
// 0); check_int_eq(irp->args.create_window_ex.y, 0);
|
||||
// check_int_eq(irp->args.create_window_ex.width, 640);
|
||||
// check_int_eq(irp->args.create_window_ex.height, 480);
|
||||
// check_null(irp->args.create_window_ex.wnd_parent);
|
||||
@@ -72,7 +73,8 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
case HOOK_D3D9_IRP_OP_GET_CLIENT_RECT:
|
||||
debug_print("Pre HOOK_D3D9_IRP_OP_GET_CLIENT_RECT\n");
|
||||
|
||||
// Cannot test because wine is also using this call causing the tests to fail
|
||||
// Cannot test because wine is also using this call causing the
|
||||
// tests to fail
|
||||
|
||||
break;
|
||||
|
||||
@@ -80,10 +82,13 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
debug_print("Pre HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE\n");
|
||||
|
||||
check_non_null(irp->args.ctx_create_device.self);
|
||||
check_int_eq(irp->args.ctx_create_device.adapter, D3DADAPTER_DEFAULT);
|
||||
check_int_eq(
|
||||
irp->args.ctx_create_device.adapter, D3DADAPTER_DEFAULT);
|
||||
check_int_eq(irp->args.ctx_create_device.type, D3DDEVTYPE_HAL);
|
||||
check_non_null(irp->args.ctx_create_device.hwnd);
|
||||
check_int_eq(irp->args.ctx_create_device.flags, D3DCREATE_HARDWARE_VERTEXPROCESSING);
|
||||
check_int_eq(
|
||||
irp->args.ctx_create_device.flags,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING);
|
||||
check_non_null(irp->args.ctx_create_device.pp);
|
||||
check_non_null(irp->args.ctx_create_device.pdev);
|
||||
|
||||
@@ -158,13 +163,13 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
case HOOK_D3D9_IRP_OP_INVALID:
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
|
||||
|
||||
case HOOK_D3D9_IRP_OP_CTX_CREATE:
|
||||
debug_print("Post HOOK_D3D9_IRP_OP_CTX_CREATE\n");
|
||||
|
||||
|
||||
check_int_eq(irp->args.ctx_create.sdk_ver, D3D_SDK_VERSION);
|
||||
check_non_null(irp->args.ctx_create.ctx);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case HOOK_D3D9_IRP_OP_ENUM_DISPLAY_DEVICES:
|
||||
@@ -173,18 +178,24 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
check_null(irp->args.enum_display_devices.dev_name);
|
||||
check_int_eq(irp->args.enum_display_devices.dev_num, 0);
|
||||
check_non_null(irp->args.enum_display_devices.info);
|
||||
check_int_eq(irp->args.enum_display_devices.flags, EDD_GET_DEVICE_INTERFACE_NAME);
|
||||
check_int_eq(
|
||||
irp->args.enum_display_devices.flags,
|
||||
EDD_GET_DEVICE_INTERFACE_NAME);
|
||||
|
||||
break;
|
||||
|
||||
case HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX:
|
||||
debug_print("Post HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX\n");
|
||||
|
||||
// Cannot test because wine is also using this call causing the tests to fail
|
||||
// Cannot test because wine is also using this call causing the
|
||||
// tests to fail
|
||||
// check_int_eq(irp->args.create_window_ex.ex_style, 0);
|
||||
// check_str_eq(irp->args.create_window_ex.class_name, "d3d9hook");
|
||||
// check_str_eq(irp->args.create_window_ex.window_name, "d3d9hook test");
|
||||
// check_int_eq(irp->args.create_window_ex.style, WS_OVERLAPPEDWINDOW);
|
||||
// check_str_eq(irp->args.create_window_ex.class_name,
|
||||
// "d3d9hook");
|
||||
// check_str_eq(irp->args.create_window_ex.window_name,
|
||||
// "d3d9hook test");
|
||||
// check_int_eq(irp->args.create_window_ex.style,
|
||||
// WS_OVERLAPPEDWINDOW);
|
||||
// check_int_eq(irp->args.create_window_ex.x, 0);
|
||||
// check_int_eq(irp->args.create_window_ex.y, 0);
|
||||
// check_int_eq(irp->args.create_window_ex.width, 640);
|
||||
@@ -200,7 +211,8 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
case HOOK_D3D9_IRP_OP_GET_CLIENT_RECT:
|
||||
debug_print("Post HOOK_D3D9_IRP_OP_GET_CLIENT_RECT\n");
|
||||
|
||||
// Cannot test because wine is also using this call causing the tests to fail
|
||||
// Cannot test because wine is also using this call causing the
|
||||
// tests to fail
|
||||
|
||||
break;
|
||||
|
||||
@@ -208,10 +220,13 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
debug_print("Post HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE\n");
|
||||
|
||||
check_non_null(irp->args.ctx_create_device.self);
|
||||
check_int_eq(irp->args.ctx_create_device.adapter, D3DADAPTER_DEFAULT);
|
||||
check_int_eq(
|
||||
irp->args.ctx_create_device.adapter, D3DADAPTER_DEFAULT);
|
||||
check_int_eq(irp->args.ctx_create_device.type, D3DDEVTYPE_HAL);
|
||||
check_non_null(irp->args.ctx_create_device.hwnd);
|
||||
check_int_eq(irp->args.ctx_create_device.flags, D3DCREATE_HARDWARE_VERTEXPROCESSING);
|
||||
check_int_eq(
|
||||
irp->args.ctx_create_device.flags,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING);
|
||||
check_non_null(irp->args.ctx_create_device.pp);
|
||||
check_non_null(irp->args.ctx_create_device.pdev);
|
||||
|
||||
@@ -225,8 +240,10 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
check_int_eq(irp->args.dev_create_texture.height, 240);
|
||||
check_int_eq(irp->args.dev_create_texture.levels, 0);
|
||||
check_int_eq(irp->args.dev_create_texture.usage, 0);
|
||||
check_int_eq(irp->args.dev_create_texture.format, D3DFMT_A8R8G8B8);
|
||||
check_int_eq(irp->args.dev_create_texture.pool, D3DPOOL_DEFAULT);
|
||||
check_int_eq(
|
||||
irp->args.dev_create_texture.format, D3DFMT_A8R8G8B8);
|
||||
check_int_eq(
|
||||
irp->args.dev_create_texture.pool, D3DPOOL_DEFAULT);
|
||||
check_non_null(irp->args.dev_create_texture.texture);
|
||||
check_null(irp->args.dev_create_texture.shared_handle);
|
||||
|
||||
@@ -261,8 +278,10 @@ static HRESULT my_d3d9_handler(struct hook_d3d9_irp* irp)
|
||||
debug_print("Post HOOK_D3D9_IRP_OP_DEV_SET_RENDER_STATE\n");
|
||||
|
||||
check_non_null(irp->args.dev_set_render_state.self);
|
||||
check_int_eq(irp->args.dev_set_render_state.state, D3DRS_FILLMODE);
|
||||
check_int_eq(irp->args.dev_set_render_state.value, D3DFILL_POINT);
|
||||
check_int_eq(
|
||||
irp->args.dev_set_render_state.state, D3DRS_FILLMODE);
|
||||
check_int_eq(
|
||||
irp->args.dev_set_render_state.value, D3DFILL_POINT);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
+96
-74
@@ -9,85 +9,99 @@
|
||||
|
||||
static const int render_loop_iterations = 100;
|
||||
|
||||
static LRESULT CALLBACK wnd_proc(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param);
|
||||
static LRESULT CALLBACK
|
||||
wnd_proc(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param);
|
||||
|
||||
static HWND create_window()
|
||||
{
|
||||
WNDCLASS wc;
|
||||
WNDCLASS wc;
|
||||
HRESULT hr;
|
||||
|
||||
memset(&wc, 0, sizeof(WNDCLASS));
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.lpfnWndProc = (WNDPROC) wnd_proc;
|
||||
wc.hInstance = NULL;
|
||||
wc.lpszClassName = "d3d9hook";
|
||||
memset(&wc, 0, sizeof(WNDCLASS));
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.lpfnWndProc = (WNDPROC) wnd_proc;
|
||||
wc.hInstance = NULL;
|
||||
wc.lpszClassName = "d3d9hook";
|
||||
|
||||
hr = RegisterClass(&wc);
|
||||
check_int_neq(hr, 0);
|
||||
|
||||
return CreateWindow("d3d9hook", "d3d9hook test", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, NULL, NULL, NULL, 0);
|
||||
return CreateWindow(
|
||||
"d3d9hook",
|
||||
"d3d9hook test",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0,
|
||||
0,
|
||||
640,
|
||||
480,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
}
|
||||
|
||||
static D3DPRESENT_PARAMETERS create_presenter_params(HWND window)
|
||||
{
|
||||
D3DPRESENT_PARAMETERS pp;
|
||||
|
||||
memset(&pp, 0, sizeof(D3DPRESENT_PARAMETERS));
|
||||
memset(&pp, 0, sizeof(D3DPRESENT_PARAMETERS));
|
||||
|
||||
pp.BackBufferWidth = 640;
|
||||
pp.BackBufferHeight = 480;
|
||||
pp.BackBufferFormat = D3DFMT_A8R8G8B8;
|
||||
pp.BackBufferCount = 1;
|
||||
pp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
pp.MultiSampleQuality = 0;
|
||||
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
pp.hDeviceWindow = window;
|
||||
pp.Windowed = TRUE;
|
||||
pp.EnableAutoDepthStencil = TRUE;
|
||||
pp.AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
pp.Flags = 0;
|
||||
pp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
pp.BackBufferWidth = 640;
|
||||
pp.BackBufferHeight = 480;
|
||||
pp.BackBufferFormat = D3DFMT_A8R8G8B8;
|
||||
pp.BackBufferCount = 1;
|
||||
pp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
pp.MultiSampleQuality = 0;
|
||||
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
pp.hDeviceWindow = window;
|
||||
pp.Windowed = TRUE;
|
||||
pp.EnableAutoDepthStencil = TRUE;
|
||||
pp.AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
pp.Flags = 0;
|
||||
pp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
return pp;
|
||||
return pp;
|
||||
}
|
||||
|
||||
static IDirect3DTexture9* create_texture(IDirect3DDevice9* dev)
|
||||
static IDirect3DTexture9 *create_texture(IDirect3DDevice9 *dev)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirect3DTexture9* texture;
|
||||
HRESULT hr;
|
||||
IDirect3DTexture9 *texture;
|
||||
|
||||
hr = IDirect3DDevice9_CreateTexture(dev, 320, 240, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
|
||||
check_int_eq(hr, S_OK);
|
||||
hr = IDirect3DDevice9_CreateTexture(
|
||||
dev, 320, 240, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
|
||||
check_int_eq(hr, S_OK);
|
||||
|
||||
return texture;
|
||||
return texture;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
DISPLAY_DEVICEA display_device;
|
||||
BOOL res;
|
||||
HWND window;
|
||||
RECT rect;
|
||||
DISPLAY_DEVICEA display_device;
|
||||
BOOL res;
|
||||
HWND window;
|
||||
RECT rect;
|
||||
MSG msg;
|
||||
IDirect3D9* d3d9;
|
||||
IDirect3D9 *d3d9;
|
||||
HRESULT hr;
|
||||
D3DPRESENT_PARAMETERS pp;
|
||||
IDirect3DDevice9* dev;
|
||||
IDirect3DDevice9 *dev;
|
||||
int loop_count;
|
||||
IDirect3DTexture9* texture;
|
||||
|
||||
res = EnumDisplayDevicesA(NULL, 0, &display_device, EDD_GET_DEVICE_INTERFACE_NAME);
|
||||
check_int_eq(res, TRUE);
|
||||
IDirect3DTexture9 *texture;
|
||||
|
||||
res = EnumDisplayDevicesA(
|
||||
NULL, 0, &display_device, EDD_GET_DEVICE_INTERFACE_NAME);
|
||||
check_int_eq(res, TRUE);
|
||||
|
||||
window = create_window();
|
||||
check_non_null(window);
|
||||
check_non_null(window);
|
||||
|
||||
res = GetClientRect(window, &rect);
|
||||
check_int_eq(res, TRUE);
|
||||
res = GetClientRect(window, &rect);
|
||||
check_int_eq(res, TRUE);
|
||||
|
||||
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
check_non_null(d3d9);
|
||||
@@ -97,37 +111,45 @@ int main(int argc, char** argv)
|
||||
hr = IDirect3D9_CreateDevice(
|
||||
d3d9,
|
||||
D3DADAPTER_DEFAULT,
|
||||
D3DDEVTYPE_HAL,
|
||||
window,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||
&pp,
|
||||
&dev);
|
||||
D3DDEVTYPE_HAL,
|
||||
window,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||
&pp,
|
||||
&dev);
|
||||
check_int_eq(hr, S_OK);
|
||||
|
||||
IDirect3DDevice9_Release(d3d9);
|
||||
d3d9 = NULL;
|
||||
|
||||
texture = create_texture(dev);
|
||||
texture = create_texture(dev);
|
||||
|
||||
ShowWindow(window, SW_SHOW);
|
||||
UpdateWindow(window);
|
||||
ShowWindow(window, SW_SHOW);
|
||||
UpdateWindow(window);
|
||||
|
||||
memset(&msg, 0, sizeof(MSG));
|
||||
memset(&msg, 0, sizeof(MSG));
|
||||
|
||||
loop_count = 0;
|
||||
|
||||
// TODO create vertex buffer, upload and render
|
||||
// TODO create vertex buffer, upload and render
|
||||
|
||||
while (msg.message != WM_QUIT) {
|
||||
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
} else {
|
||||
hr = IDirect3DDevice9_Clear(dev, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
|
||||
while (msg.message != WM_QUIT) {
|
||||
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
} else {
|
||||
hr = IDirect3DDevice9_Clear(
|
||||
dev,
|
||||
0,
|
||||
NULL,
|
||||
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||
0xff0000ff,
|
||||
1.0f,
|
||||
0);
|
||||
check_int_eq(hr, S_OK);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(dev, D3DRS_FILLMODE, D3DFILL_POINT);
|
||||
check_int_eq(hr, S_OK);
|
||||
hr = IDirect3DDevice9_SetRenderState(
|
||||
dev, D3DRS_FILLMODE, D3DFILL_POINT);
|
||||
check_int_eq(hr, S_OK);
|
||||
|
||||
hr = IDirect3DDevice9_BeginScene(dev);
|
||||
check_int_eq(hr, S_OK);
|
||||
@@ -143,25 +165,25 @@ int main(int argc, char** argv)
|
||||
if (loop_count > render_loop_iterations) {
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
IDirect3DDevice9_Release(dev);
|
||||
|
||||
return 0;
|
||||
IDirect3DTexture9_Release(texture);
|
||||
IDirect3DDevice9_Release(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK wnd_proc(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param)
|
||||
{
|
||||
switch(msg) {
|
||||
switch (msg) {
|
||||
case WM_CREATE:
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(wnd, msg, w_param, l_param);
|
||||
return DefWindowProc(wnd, msg, w_param, l_param);
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
static void test_config_eamuse_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_util_config_eamuse config_eamuse;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -20,15 +20,17 @@ static void test_config_eamuse_defaults()
|
||||
|
||||
check_str_eq(config_eamuse.card_type, "C02");
|
||||
check_str_eq(net_addr_to_str(&config_eamuse.server), "localhost:80");
|
||||
check_str_eq(security_id_to_str(&config_eamuse.pcbid, false),
|
||||
check_str_eq(
|
||||
security_id_to_str(&config_eamuse.pcbid, false),
|
||||
"0101020304050607086F");
|
||||
check_str_eq(security_id_to_str(&config_eamuse.eamid, false),
|
||||
check_str_eq(
|
||||
security_id_to_str(&config_eamuse.eamid, false),
|
||||
"0101020304050607086F");
|
||||
}
|
||||
|
||||
static void test_config_eamuse()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_util_config_eamuse config_eamuse;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -45,17 +47,19 @@ static void test_config_eamuse()
|
||||
cconfig_finit(config);
|
||||
|
||||
check_str_eq(config_eamuse.card_type, "D01");
|
||||
check_str_eq(net_addr_to_str(&config_eamuse.server),
|
||||
"http://myServer.com/legacy");
|
||||
check_str_eq(security_id_to_str(&config_eamuse.pcbid, false),
|
||||
check_str_eq(
|
||||
net_addr_to_str(&config_eamuse.server), "http://myServer.com/legacy");
|
||||
check_str_eq(
|
||||
security_id_to_str(&config_eamuse.pcbid, false),
|
||||
"0101020304050607086F");
|
||||
check_str_eq(security_id_to_str(&config_eamuse.eamid, false),
|
||||
check_str_eq(
|
||||
security_id_to_str(&config_eamuse.eamid, false),
|
||||
"0101020304050607086F");
|
||||
}
|
||||
|
||||
static void test_config_eamuse_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_util_config_eamuse config_eamuse;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -73,9 +77,11 @@ static void test_config_eamuse_invalid_values()
|
||||
|
||||
check_str_eq(config_eamuse.card_type, "C02");
|
||||
check_str_eq(net_addr_to_str(&config_eamuse.server), "asdf");
|
||||
check_str_eq(security_id_to_str(&config_eamuse.pcbid, false),
|
||||
check_str_eq(
|
||||
security_id_to_str(&config_eamuse.pcbid, false),
|
||||
"00000000000000000000");
|
||||
check_str_eq(security_id_to_str(&config_eamuse.eamid, false),
|
||||
check_str_eq(
|
||||
security_id_to_str(&config_eamuse.eamid, false),
|
||||
"00000000000000000000");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering
|
||||
the tests */
|
||||
|
||||
static void test_config_gfx_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -27,12 +27,14 @@ static void test_config_gfx_defaults()
|
||||
check_bool_false(config_gfx.windowed);
|
||||
check_int_eq(config_gfx.scale_back_buffer_width, 0);
|
||||
check_int_eq(config_gfx.scale_back_buffer_height, 0);
|
||||
check_int_eq(config_gfx.scale_back_buffer_width, IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE);
|
||||
check_int_eq(
|
||||
config_gfx.scale_back_buffer_width,
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE);
|
||||
}
|
||||
|
||||
static void test_config_gfx()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -62,12 +64,14 @@ static void test_config_gfx()
|
||||
check_bool_true(config_gfx.windowed);
|
||||
check_int_eq(config_gfx.scale_back_buffer_width, 1920);
|
||||
check_int_eq(config_gfx.scale_back_buffer_height, 1080);
|
||||
check_int_eq(config_gfx.scale_back_buffer_filter, IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_LINEAR);
|
||||
check_int_eq(
|
||||
config_gfx.scale_back_buffer_filter,
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_LINEAR);
|
||||
}
|
||||
|
||||
static void test_config_gfx_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -97,7 +101,9 @@ static void test_config_gfx_invalid_values()
|
||||
check_bool_false(config_gfx.windowed);
|
||||
check_int_eq(config_gfx.scale_back_buffer_width, 0);
|
||||
check_int_eq(config_gfx.scale_back_buffer_height, 0);
|
||||
check_int_eq(config_gfx.scale_back_buffer_width, IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE);
|
||||
check_int_eq(
|
||||
config_gfx.scale_back_buffer_width,
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE);
|
||||
}
|
||||
|
||||
TEST_MODULE_BEGIN("iidxhook-config-gfx")
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the tests */
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the
|
||||
* tests */
|
||||
|
||||
static void test_config_misc_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -23,7 +24,7 @@ static void test_config_misc_defaults()
|
||||
|
||||
static void test_config_misc()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -43,7 +44,7 @@ static void test_config_misc()
|
||||
|
||||
static void test_config_misc_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_misc config_misc;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the tests */
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the
|
||||
* tests */
|
||||
|
||||
static void test_config_sec_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_sec config_sec;
|
||||
const uint32_t boot_seeds[3] = {0, 0, 0};
|
||||
|
||||
@@ -19,15 +20,18 @@ static void test_config_sec_defaults()
|
||||
cconfig_finit(config);
|
||||
|
||||
check_str_eq(security_mcode_to_str(&config_sec.boot_version), "GEC02 ");
|
||||
check_data_eq(config_sec.boot_seeds, sizeof(config_sec.boot_seeds),
|
||||
(void*) boot_seeds, sizeof(boot_seeds));
|
||||
check_str_eq(security_mcode_to_str(&config_sec.black_plug_mcode),
|
||||
"GQC02JAA");
|
||||
check_data_eq(
|
||||
config_sec.boot_seeds,
|
||||
sizeof(config_sec.boot_seeds),
|
||||
(void *) boot_seeds,
|
||||
sizeof(boot_seeds));
|
||||
check_str_eq(
|
||||
security_mcode_to_str(&config_sec.black_plug_mcode), "GQC02JAA");
|
||||
}
|
||||
|
||||
static void test_config_sec()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_sec config_sec;
|
||||
const uint32_t boot_seeds[3] = {1, 1, 1};
|
||||
|
||||
@@ -44,15 +48,18 @@ static void test_config_sec()
|
||||
cconfig_finit(config);
|
||||
|
||||
check_str_eq(security_mcode_to_str(&config_sec.boot_version), "ASDFG ");
|
||||
check_data_eq(config_sec.boot_seeds, sizeof(config_sec.boot_seeds),
|
||||
(void*) boot_seeds, sizeof(boot_seeds));
|
||||
check_str_eq(security_mcode_to_str(&config_sec.black_plug_mcode),
|
||||
"GQD01JAB");
|
||||
check_data_eq(
|
||||
config_sec.boot_seeds,
|
||||
sizeof(config_sec.boot_seeds),
|
||||
(void *) boot_seeds,
|
||||
sizeof(boot_seeds));
|
||||
check_str_eq(
|
||||
security_mcode_to_str(&config_sec.black_plug_mcode), "GQD01JAB");
|
||||
}
|
||||
|
||||
static void test_config_sec_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_sec config_sec;
|
||||
const uint32_t boot_seeds[3] = {0, 0, 0};
|
||||
|
||||
@@ -69,10 +76,13 @@ static void test_config_sec_invalid_values()
|
||||
cconfig_finit(config);
|
||||
|
||||
check_str_eq(security_mcode_to_str(&config_sec.boot_version), "GEC02 ");
|
||||
check_data_eq(config_sec.boot_seeds, sizeof(config_sec.boot_seeds),
|
||||
(void*) boot_seeds, sizeof(boot_seeds));
|
||||
check_str_eq(security_mcode_to_str(&config_sec.black_plug_mcode),
|
||||
"GQC02JAA");
|
||||
check_data_eq(
|
||||
config_sec.boot_seeds,
|
||||
sizeof(config_sec.boot_seeds),
|
||||
(void *) boot_seeds,
|
||||
sizeof(boot_seeds));
|
||||
check_str_eq(
|
||||
security_mcode_to_str(&config_sec.black_plug_mcode), "GQC02JAA");
|
||||
}
|
||||
|
||||
TEST_MODULE_BEGIN("iidxhook-config-sec")
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the tests */
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the
|
||||
* tests */
|
||||
|
||||
static void test_config_iidxhook1_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_iidxhook1 config_iidxhook1;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -22,7 +23,7 @@ static void test_config_iidxhook1_defaults()
|
||||
|
||||
static void test_config_iidxhook1()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_iidxhook1 config_iidxhook1;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -40,7 +41,7 @@ static void test_config_iidxhook1()
|
||||
|
||||
static void test_config_iidxhook1_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_iidxhook1 config_iidxhook1;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the tests */
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the
|
||||
* tests */
|
||||
|
||||
static void test_config_iidxhook2_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_iidxhook2 config_iidxhook2;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -22,7 +23,7 @@ static void test_config_iidxhook2_defaults()
|
||||
|
||||
static void test_config_iidxhook2()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_iidxhook2 config_iidxhook2;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -40,7 +41,7 @@ static void test_config_iidxhook2()
|
||||
|
||||
static void test_config_iidxhook2_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook_config_iidxhook2 config_iidxhook2;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the tests */
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the
|
||||
* tests */
|
||||
|
||||
static void test_config_cam_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook8_config_cam config_cam;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -24,7 +25,7 @@ static void test_config_cam_defaults()
|
||||
|
||||
static void test_config_cam()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook8_config_cam config_cam;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -46,7 +47,7 @@ static void test_config_cam()
|
||||
|
||||
static void test_config_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook8_config_cam config_cam;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the tests */
|
||||
/* We don't care about cleaning up some of the memory to avoid cluttering the
|
||||
* tests */
|
||||
|
||||
static void test_config_io_defaults()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook8_config_io config_io;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -24,7 +25,7 @@ static void test_config_io_defaults()
|
||||
|
||||
static void test_config_io()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook8_config_io config_io;
|
||||
|
||||
config = cconfig_init();
|
||||
@@ -46,7 +47,7 @@ static void test_config_io()
|
||||
|
||||
static void test_config_invalid_values()
|
||||
{
|
||||
struct cconfig* config;
|
||||
struct cconfig *config;
|
||||
struct iidxhook8_config_io config_io;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
static void test_to_str()
|
||||
{
|
||||
check_str_eq(security_id_to_str(&security_id_default, false),
|
||||
check_str_eq(
|
||||
security_id_to_str(&security_id_default, false),
|
||||
"0101020304050607086F");
|
||||
check_str_eq(security_id_to_str(&security_id_default, true),
|
||||
"0102030405060708");
|
||||
check_str_eq(
|
||||
security_id_to_str(&security_id_default, true), "0102030405060708");
|
||||
}
|
||||
|
||||
static void test_parse_valid()
|
||||
|
||||
@@ -93,12 +93,17 @@ static void test_encode_iidx_09_black_dongle()
|
||||
{
|
||||
struct security_rp_eeprom result;
|
||||
|
||||
security_rp_generate_signed_eeprom_data(&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_09, &black_plug_mcode_iidx_09, &security_id_default,
|
||||
security_rp_generate_signed_eeprom_data(
|
||||
&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_09,
|
||||
&black_plug_mcode_iidx_09,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_iidx_09_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_iidx_09_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp_eeprom));
|
||||
}
|
||||
|
||||
@@ -106,12 +111,17 @@ static void test_encode_iidx_10_black_dongle()
|
||||
{
|
||||
struct security_rp_eeprom result;
|
||||
|
||||
security_rp_generate_signed_eeprom_data(&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_10, &black_plug_mcode_iidx_10, &security_id_default,
|
||||
security_rp_generate_signed_eeprom_data(
|
||||
&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_10,
|
||||
&black_plug_mcode_iidx_10,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_iidx_10_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_iidx_10_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp_eeprom));
|
||||
}
|
||||
|
||||
@@ -119,12 +129,17 @@ static void test_encode_iidx_11_black_dongle()
|
||||
{
|
||||
struct security_rp_eeprom result;
|
||||
|
||||
security_rp_generate_signed_eeprom_data(&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_11, &black_plug_mcode_iidx_11, &security_id_default,
|
||||
security_rp_generate_signed_eeprom_data(
|
||||
&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_11,
|
||||
&black_plug_mcode_iidx_11,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_iidx_11_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_iidx_11_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp_eeprom));
|
||||
}
|
||||
|
||||
@@ -132,12 +147,17 @@ static void test_encode_iidx_12_black_dongle()
|
||||
{
|
||||
struct security_rp_eeprom result;
|
||||
|
||||
security_rp_generate_signed_eeprom_data(&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_12, &black_plug_mcode_iidx_12, &security_id_default,
|
||||
security_rp_generate_signed_eeprom_data(
|
||||
&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_12,
|
||||
&black_plug_mcode_iidx_12,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_iidx_12_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_iidx_12_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp_eeprom));
|
||||
}
|
||||
|
||||
@@ -145,12 +165,17 @@ static void test_encode_iidx_13_black_dongle()
|
||||
{
|
||||
struct security_rp_eeprom result;
|
||||
|
||||
security_rp_generate_signed_eeprom_data(&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_13, &black_plug_mcode_iidx_13, &security_id_default,
|
||||
security_rp_generate_signed_eeprom_data(
|
||||
&boot_version_iidx_09_to_13,
|
||||
boot_seeds_iidx_13,
|
||||
&black_plug_mcode_iidx_13,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_iidx_13_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_iidx_13_black_eeprom,
|
||||
sizeof(struct security_rp_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp_eeprom));
|
||||
}
|
||||
|
||||
|
||||
@@ -120,96 +120,144 @@ static void test_encode_iidx_14_black_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_14, &black_plug_mcode_iidx_14, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_14,
|
||||
&black_plug_mcode_iidx_14,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_14_black_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_14_black_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_14_white_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_14, &security_mcode_eamuse, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_14,
|
||||
&security_mcode_eamuse,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_14_white_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_14_white_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_15_black_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_15, &black_plug_mcode_iidx_15, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_15,
|
||||
&black_plug_mcode_iidx_15,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_15_black_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_15_black_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_15_white_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_15, &security_mcode_eamuse, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_15,
|
||||
&security_mcode_eamuse,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_15_white_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_15_white_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_16_black_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_16, &black_plug_mcode_iidx_16, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_16,
|
||||
&black_plug_mcode_iidx_16,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_16_black_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_16_black_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_16_white_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_16, &security_mcode_eamuse, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_16,
|
||||
&security_mcode_eamuse,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_16_white_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_16_white_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_17_black_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_17, &black_plug_mcode_iidx_17, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&boot_version_iidx_17,
|
||||
&black_plug_mcode_iidx_17,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_17_black_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_17_black_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
static void test_encode_iidx_17_white_dongle()
|
||||
{
|
||||
struct security_rp2_eeprom result;
|
||||
|
||||
security_rp2_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_17, &security_mcode_eamuse, &security_id_default,
|
||||
security_rp2_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&boot_version_iidx_17,
|
||||
&security_mcode_eamuse,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &result, sizeof(struct security_rp2_eeprom),
|
||||
(void*) &exp_iidx_17_white_eeprom, sizeof(struct security_rp2_eeprom));
|
||||
check_data_eq(
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp2_eeprom),
|
||||
(void *) &exp_iidx_17_white_eeprom,
|
||||
sizeof(struct security_rp2_eeprom));
|
||||
}
|
||||
|
||||
TEST_MODULE_BEGIN("security-rp2")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "security/rp3.h"
|
||||
#include "security/rp-sign-key.h"
|
||||
#include "security/rp3.h"
|
||||
|
||||
#include "test/check.h"
|
||||
#include "test/test.h"
|
||||
@@ -16,16 +16,50 @@ static const struct security_mcode black_plug_mcode_jubeat = {
|
||||
static const struct security_rp3_eeprom exp_jubeat_black_eeprom = {
|
||||
.signature = {0x73, 0x66, 0xBA, 0xBD, 0xDE, 0x36},
|
||||
.packed_payload = {0xE7, 0x88, 0x52, 0x94, 0x1A, 0x8A},
|
||||
.zeros = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
.zeros = {0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00},
|
||||
.crc = 0xA3,
|
||||
};
|
||||
|
||||
static const struct security_rp3_eeprom exp_jubeat_white_eeprom = {
|
||||
.signature = {0x43, 0x17, 0xB4, 0x2A, 0x3E, 0x87},
|
||||
.packed_payload = {0x20, 0x08, 0x82, 0x20, 0x08, 0x82},
|
||||
.zeros = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
.zeros = {0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00},
|
||||
.crc = 0x94,
|
||||
};
|
||||
|
||||
@@ -33,12 +67,17 @@ static void test_mcode_encode_black_dongle_jubeat()
|
||||
{
|
||||
struct security_rp3_eeprom result;
|
||||
|
||||
security_rp3_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&security_rp_sign_key_black_gfdmv4, &black_plug_mcode_jubeat,
|
||||
&security_id_default, &result);
|
||||
security_rp3_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_BLACK,
|
||||
&security_rp_sign_key_black_gfdmv4,
|
||||
&black_plug_mcode_jubeat,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_jubeat_black_eeprom,
|
||||
sizeof(struct security_rp3_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_jubeat_black_eeprom,
|
||||
sizeof(struct security_rp3_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp3_eeprom));
|
||||
}
|
||||
|
||||
@@ -46,12 +85,17 @@ static void test_mcode_encode_white_dongle_jubeat()
|
||||
{
|
||||
struct security_rp3_eeprom result;
|
||||
|
||||
security_rp3_generate_signed_eeprom_data(SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&security_rp_sign_key_white_eamuse, &security_mcode_eamuse,
|
||||
&security_id_default, &result);
|
||||
security_rp3_generate_signed_eeprom_data(
|
||||
SECURITY_RP_UTIL_RP_TYPE_WHITE,
|
||||
&security_rp_sign_key_white_eamuse,
|
||||
&security_mcode_eamuse,
|
||||
&security_id_default,
|
||||
&result);
|
||||
|
||||
check_data_eq((void*) &exp_jubeat_white_eeprom,
|
||||
sizeof(struct security_rp3_eeprom), (void*) &result,
|
||||
check_data_eq(
|
||||
(void *) &exp_jubeat_white_eeprom,
|
||||
sizeof(struct security_rp3_eeprom),
|
||||
(void *) &result,
|
||||
sizeof(struct security_rp3_eeprom));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,14 @@ static void test_mcode_encode_decode_eamuse()
|
||||
uint8_t buffer[8];
|
||||
uint8_t result[8];
|
||||
|
||||
security_util_8_to_6_encode((const uint8_t*) &security_mcode_eamuse, buffer);
|
||||
security_util_8_to_6_encode(
|
||||
(const uint8_t *) &security_mcode_eamuse, buffer);
|
||||
security_util_6_to_8_decode(buffer, result);
|
||||
|
||||
check_data_eq(result, sizeof(result), &security_mcode_eamuse,
|
||||
check_data_eq(
|
||||
result,
|
||||
sizeof(result),
|
||||
&security_mcode_eamuse,
|
||||
sizeof(security_mcode_eamuse));
|
||||
}
|
||||
|
||||
@@ -30,11 +34,14 @@ static void test_mcode_encode_decode_jubeat()
|
||||
uint8_t buffer[8];
|
||||
uint8_t result[8];
|
||||
|
||||
security_util_8_to_6_encode((const uint8_t*) &black_plug_mcode_jubeat,
|
||||
buffer);
|
||||
security_util_8_to_6_encode(
|
||||
(const uint8_t *) &black_plug_mcode_jubeat, buffer);
|
||||
security_util_6_to_8_decode(buffer, result);
|
||||
|
||||
check_data_eq(result, sizeof(result), &black_plug_mcode_jubeat,
|
||||
check_data_eq(
|
||||
result,
|
||||
sizeof(result),
|
||||
&black_plug_mcode_jubeat,
|
||||
sizeof(black_plug_mcode_jubeat));
|
||||
}
|
||||
|
||||
@@ -43,11 +50,14 @@ static void test_mcode_encode_decode_reverse_eamuse()
|
||||
uint8_t buffer[8];
|
||||
uint8_t result[8];
|
||||
|
||||
security_util_8_to_6_encode_reverse((const uint8_t*) &security_mcode_eamuse,
|
||||
buffer);
|
||||
security_util_8_to_6_encode_reverse(
|
||||
(const uint8_t *) &security_mcode_eamuse, buffer);
|
||||
security_util_6_to_8_decode_reverse(buffer, result);
|
||||
|
||||
check_data_eq(result, sizeof(result), &security_mcode_eamuse,
|
||||
check_data_eq(
|
||||
result,
|
||||
sizeof(result),
|
||||
&security_mcode_eamuse,
|
||||
sizeof(security_mcode_eamuse));
|
||||
}
|
||||
|
||||
@@ -57,10 +67,13 @@ static void test_mcode_encode_decode_reverse_jubeat()
|
||||
uint8_t result[8];
|
||||
|
||||
security_util_8_to_6_encode_reverse(
|
||||
(const uint8_t*) &black_plug_mcode_jubeat, buffer);
|
||||
(const uint8_t *) &black_plug_mcode_jubeat, buffer);
|
||||
security_util_6_to_8_decode_reverse(buffer, result);
|
||||
|
||||
check_data_eq(result, sizeof(result), &black_plug_mcode_jubeat,
|
||||
check_data_eq(
|
||||
result,
|
||||
sizeof(result),
|
||||
&black_plug_mcode_jubeat,
|
||||
sizeof(black_plug_mcode_jubeat));
|
||||
}
|
||||
|
||||
|
||||
+187
-87
@@ -8,8 +8,8 @@
|
||||
|
||||
#include "util/hex.h"
|
||||
|
||||
static void _Noreturn __attribute__((format (printf, 4, 5))) fail(
|
||||
const char *file, int line, const char *func, const char *fmt, ...)
|
||||
static void _Noreturn __attribute__((format(printf, 4, 5)))
|
||||
fail(const char *file, int line, const char *func, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -21,128 +21,228 @@ static void _Noreturn __attribute__((format (printf, 4, 5))) fail(
|
||||
abort();
|
||||
}
|
||||
|
||||
void _Noreturn check_char_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, char result, char expected)
|
||||
void _Noreturn check_char_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
char result,
|
||||
char expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %c\n"
|
||||
"\tExpected %c\n\n",
|
||||
expr, result, expected);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %c\n"
|
||||
"\tExpected %c\n\n",
|
||||
expr,
|
||||
result,
|
||||
expected);
|
||||
}
|
||||
|
||||
void _Noreturn check_char_neq_failed(const char *file, int line,
|
||||
const char *func, char *expr, char result, char expected)
|
||||
void _Noreturn check_char_neq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
char result,
|
||||
char expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %c\n"
|
||||
"\tNot expected %c\n\n",
|
||||
expr, result, expected);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %c\n"
|
||||
"\tNot expected %c\n\n",
|
||||
expr,
|
||||
result,
|
||||
expected);
|
||||
}
|
||||
|
||||
void _Noreturn check_int_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, int result, int expected)
|
||||
void _Noreturn check_int_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
int result,
|
||||
int expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %i\n"
|
||||
"\tExpected %i\n\n",
|
||||
expr, result, expected);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %i\n"
|
||||
"\tExpected %i\n\n",
|
||||
expr,
|
||||
result,
|
||||
expected);
|
||||
}
|
||||
|
||||
void _Noreturn check_int_neq_failed(const char *file, int line,
|
||||
const char *func, char *expr, int result, int expected)
|
||||
void _Noreturn check_int_neq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
int result,
|
||||
int expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %i\n"
|
||||
"\tNot expected %i\n\n",
|
||||
expr, result, expected);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %i\n"
|
||||
"\tNot expected %i\n\n",
|
||||
expr,
|
||||
result,
|
||||
expected);
|
||||
}
|
||||
|
||||
void _Noreturn check_bool_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, bool result, bool expected)
|
||||
void _Noreturn check_bool_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
bool result,
|
||||
bool expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %s\n"
|
||||
"\tExpected %s\n\n",
|
||||
expr, result ? "true" : "false", expected ? "true" : "false");
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %s\n"
|
||||
"\tExpected %s\n\n",
|
||||
expr,
|
||||
result ? "true" : "false",
|
||||
expected ? "true" : "false");
|
||||
}
|
||||
|
||||
void _Noreturn check_bool_neq_failed(const char *file, int line,
|
||||
const char *func, char *expr, bool result, bool expected)
|
||||
void _Noreturn check_bool_neq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
bool result,
|
||||
bool expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %s\n"
|
||||
"\tNot expected %s\n\n",
|
||||
expr, result ? "true" : "false", expected ? "true" : "false");
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %s\n"
|
||||
"\tNot expected %s\n\n",
|
||||
expr,
|
||||
result ? "true" : "false",
|
||||
expected ? "true" : "false");
|
||||
}
|
||||
|
||||
void _Noreturn check_float_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, float result, float expected, float delta)
|
||||
void _Noreturn check_float_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
float result,
|
||||
float expected,
|
||||
float delta)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %f\n"
|
||||
"\tDelta value %f\n"
|
||||
"\tExpected %f\n\n",
|
||||
expr, result, delta, expected);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was %f\n"
|
||||
"\tDelta value %f\n"
|
||||
"\tExpected %f\n\n",
|
||||
expr,
|
||||
result,
|
||||
delta,
|
||||
expected);
|
||||
}
|
||||
|
||||
void _Noreturn check_str_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, const char *result,
|
||||
const char *expected)
|
||||
void _Noreturn check_str_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
const char *result,
|
||||
const char *expected)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was \"%s\"\n"
|
||||
"\tExpected \"%s\"\n\n",
|
||||
expr, result, expected);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn value was \"%s\"\n"
|
||||
"\tExpected \"%s\"\n\n",
|
||||
expr,
|
||||
result,
|
||||
expected);
|
||||
}
|
||||
|
||||
void _Noreturn check_data_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, const void *result, const void *expected,
|
||||
size_t result_size, size_t expected_size)
|
||||
void _Noreturn check_data_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
const void *result,
|
||||
const void *expected,
|
||||
size_t result_size,
|
||||
size_t expected_size)
|
||||
{
|
||||
char result_data[result_size * 2 + 1];
|
||||
char expected_data[expected_size * 2 + 1];
|
||||
|
||||
hex_encode_uc(result, result_size, result_data, sizeof(result_data));
|
||||
hex_encode_uc(expected, expected_size, expected_data,
|
||||
sizeof(expected_data));
|
||||
hex_encode_uc(
|
||||
expected, expected_size, expected_data, sizeof(expected_data));
|
||||
|
||||
fail(file, line, func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn size was: %d\n"
|
||||
"\tExected size: %d\n"
|
||||
"\tReturn value was \"%s\"\n"
|
||||
"\tExpected \"%s\"\n\n",
|
||||
expr, result_size, expected_size, result_data, expected_data);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tIncorrect result: %s\n"
|
||||
"\tReturn size was: %d\n"
|
||||
"\tExected size: %d\n"
|
||||
"\tReturn value was \"%s\"\n"
|
||||
"\tExpected \"%s\"\n\n",
|
||||
expr,
|
||||
result_size,
|
||||
expected_size,
|
||||
result_data,
|
||||
expected_data);
|
||||
}
|
||||
|
||||
void _Noreturn check_non_null_failed(const char *file, int line, const char *func,
|
||||
char *expr)
|
||||
void _Noreturn check_non_null_failed(
|
||||
const char *file, int line, const char *func, char *expr)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tValue is not non-null: %s\n"
|
||||
"\tExpected non-null value\n\n",
|
||||
expr);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tValue is not non-null: %s\n"
|
||||
"\tExpected non-null value\n\n",
|
||||
expr);
|
||||
}
|
||||
|
||||
void _Noreturn check_null_failed(const char *file, int line, const char *func,
|
||||
char *expr)
|
||||
void _Noreturn check_null_failed(
|
||||
const char *file, int line, const char *func, char *expr)
|
||||
{
|
||||
fail(file, line, func,
|
||||
"\tValue is not null: %s\n"
|
||||
"\tExpected null value\n\n",
|
||||
expr);
|
||||
fail(
|
||||
file,
|
||||
line,
|
||||
func,
|
||||
"\tValue is not null: %s\n"
|
||||
"\tExpected null value\n\n",
|
||||
expr);
|
||||
}
|
||||
|
||||
void _Noreturn check_failed(const char *file, int line,
|
||||
const char *func, char *expr)
|
||||
void _Noreturn check_failed(
|
||||
const char *file, int line, const char *func, char *expr)
|
||||
{
|
||||
fail(file, line, func, "\t%s\n", expr);
|
||||
fail(file, line, func, "\t%s\n", expr);
|
||||
}
|
||||
+174
-121
@@ -4,145 +4,198 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#define check_char_eq(expr, expected) \
|
||||
{ \
|
||||
char _result = expr; \
|
||||
\
|
||||
if (_result != expected) { \
|
||||
check_char_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected); \
|
||||
} \
|
||||
} \
|
||||
#define check_char_eq(expr, expected) \
|
||||
{ \
|
||||
char _result = expr; \
|
||||
\
|
||||
if (_result != expected) { \
|
||||
check_char_eq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, expected); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_char_neq(expr, expected) \
|
||||
{ \
|
||||
char _result = expr; \
|
||||
\
|
||||
if (_result == expected) { \
|
||||
check_char_neq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected); \
|
||||
} \
|
||||
} \
|
||||
#define check_char_neq(expr, expected) \
|
||||
{ \
|
||||
char _result = expr; \
|
||||
\
|
||||
if (_result == expected) { \
|
||||
check_char_neq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, expected); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_int_eq(expr, expected) \
|
||||
{ \
|
||||
int _result = expr; \
|
||||
\
|
||||
if (_result != expected) { \
|
||||
check_int_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected); \
|
||||
} \
|
||||
} \
|
||||
#define check_int_eq(expr, expected) \
|
||||
{ \
|
||||
int _result = expr; \
|
||||
\
|
||||
if (_result != expected) { \
|
||||
check_int_eq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, expected); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_int_neq(expr, expected) \
|
||||
{ \
|
||||
int _result = expr; \
|
||||
\
|
||||
if (_result == expected) { \
|
||||
check_int_neq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected); \
|
||||
} \
|
||||
} \
|
||||
#define check_int_neq(expr, expected) \
|
||||
{ \
|
||||
int _result = expr; \
|
||||
\
|
||||
if (_result == expected) { \
|
||||
check_int_neq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, expected); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_float_eq(expr, expected, delta) \
|
||||
{ \
|
||||
float _result = expr; \
|
||||
\
|
||||
if (_result - expected > delta) { \
|
||||
check_float_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected, delta); \
|
||||
} \
|
||||
} \
|
||||
{ \
|
||||
float _result = expr; \
|
||||
\
|
||||
if (_result - expected > delta) { \
|
||||
check_float_eq_failed( \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
__func__, \
|
||||
#expr, \
|
||||
_result, \
|
||||
expected, \
|
||||
delta); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_bool_true(expr) \
|
||||
{ \
|
||||
bool _result = expr; \
|
||||
\
|
||||
if (!_result) { \
|
||||
check_bool_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, true); \
|
||||
} \
|
||||
} \
|
||||
#define check_bool_true(expr) \
|
||||
{ \
|
||||
bool _result = expr; \
|
||||
\
|
||||
if (!_result) { \
|
||||
check_bool_eq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, true); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_bool_false(expr) \
|
||||
{ \
|
||||
bool _result = expr; \
|
||||
\
|
||||
if (_result) { \
|
||||
check_bool_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, false); \
|
||||
} \
|
||||
} \
|
||||
#define check_bool_false(expr) \
|
||||
{ \
|
||||
bool _result = expr; \
|
||||
\
|
||||
if (_result) { \
|
||||
check_bool_eq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, false); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_str_eq(expr, expected) \
|
||||
{ \
|
||||
const char *_result = expr; \
|
||||
\
|
||||
if (strcmp(_result, expected) != 0) { \
|
||||
check_str_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected); \
|
||||
} \
|
||||
} \
|
||||
#define check_str_eq(expr, expected) \
|
||||
{ \
|
||||
const char *_result = expr; \
|
||||
\
|
||||
if (strcmp(_result, expected) != 0) { \
|
||||
check_str_eq_failed( \
|
||||
__FILE__, __LINE__, __func__, #expr, _result, expected); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_data_eq(expr, result_size, expected, expected_size) \
|
||||
{ \
|
||||
const void *_result = expr; \
|
||||
\
|
||||
if (result_size != expected_size || memcmp(expr, expected, \
|
||||
expected_size)) { \
|
||||
check_data_eq_failed(__FILE__, __LINE__, __func__, #expr, \
|
||||
_result, expected, result_size, expected_size); \
|
||||
} \
|
||||
} \
|
||||
{ \
|
||||
const void *_result = expr; \
|
||||
\
|
||||
if (result_size != expected_size || \
|
||||
memcmp(expr, expected, expected_size)) { \
|
||||
check_data_eq_failed( \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
__func__, \
|
||||
#expr, \
|
||||
_result, \
|
||||
expected, \
|
||||
result_size, \
|
||||
expected_size); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_non_null(expr) \
|
||||
{ \
|
||||
if (!expr) { \
|
||||
#define check_non_null(expr) \
|
||||
{ \
|
||||
if (!expr) { \
|
||||
check_non_null_failed(__FILE__, __LINE__, __func__, #expr); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_null(expr) \
|
||||
{ \
|
||||
if (expr) { \
|
||||
#define check_null(expr) \
|
||||
{ \
|
||||
if (expr) { \
|
||||
check_null_failed(__FILE__, __LINE__, __func__, #expr); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_fail() \
|
||||
{ \
|
||||
#define check_fail() \
|
||||
{ \
|
||||
check_failed(__FILE__, __LINE__, __func__, ""); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define check_fail_msg(expr) \
|
||||
{ \
|
||||
#define check_fail_msg(expr) \
|
||||
{ \
|
||||
check_failed(__FILE__, __LINE__, __func__, expr); \
|
||||
} \
|
||||
}
|
||||
|
||||
void _Noreturn check_char_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, char result, char expected);
|
||||
void _Noreturn check_char_neq_failed(const char *file, int line,
|
||||
const char *func, char *expr, char result, char expected);
|
||||
void _Noreturn check_int_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, int result, int expected);
|
||||
void _Noreturn check_int_neq_failed(const char *file, int line,
|
||||
const char *func, char *expr, int result, int expected);
|
||||
void _Noreturn check_bool_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, bool result, bool expected);
|
||||
void _Noreturn check_float_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, float result, float expected,
|
||||
float delta);
|
||||
void _Noreturn check_str_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, const char *result,
|
||||
const char *expected);
|
||||
void _Noreturn check_data_eq_failed(const char *file, int line,
|
||||
const char *func, char *expr, const void *result, const void *expected,
|
||||
size_t expr_size, size_t expected_size);
|
||||
void _Noreturn check_non_null_failed(const char *file, int line, const char *func,
|
||||
char *expr);
|
||||
void _Noreturn check_null_failed(const char *file, int line, const char *func,
|
||||
char *expr);
|
||||
void _Noreturn check_failed(const char *file, int line,
|
||||
const char *func, char *expr);
|
||||
void _Noreturn check_char_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
char result,
|
||||
char expected);
|
||||
void _Noreturn check_char_neq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
char result,
|
||||
char expected);
|
||||
void _Noreturn check_int_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
int result,
|
||||
int expected);
|
||||
void _Noreturn check_int_neq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
int result,
|
||||
int expected);
|
||||
void _Noreturn check_bool_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
bool result,
|
||||
bool expected);
|
||||
void _Noreturn check_float_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
float result,
|
||||
float expected,
|
||||
float delta);
|
||||
void _Noreturn check_str_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
const char *result,
|
||||
const char *expected);
|
||||
void _Noreturn check_data_eq_failed(
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *expr,
|
||||
const void *result,
|
||||
const void *expected,
|
||||
size_t expr_size,
|
||||
size_t expected_size);
|
||||
void _Noreturn check_non_null_failed(
|
||||
const char *file, int line, const char *func, char *expr);
|
||||
void _Noreturn check_null_failed(
|
||||
const char *file, int line, const char *func, char *expr);
|
||||
void _Noreturn check_failed(
|
||||
const char *file, int line, const char *func, char *expr);
|
||||
|
||||
#endif
|
||||
+12
-12
@@ -5,21 +5,21 @@
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#define TEST_MODULE_BEGIN(name) \
|
||||
int main(int argc, char** argv) \
|
||||
{ \
|
||||
#define TEST_MODULE_BEGIN(name) \
|
||||
int main(int argc, char **argv) \
|
||||
{ \
|
||||
log_to_writer(log_writer_stderr, NULL); \
|
||||
fprintf(stderr, "Executing test module '%s'...\n", #name); \
|
||||
fprintf(stderr, "Executing test module '%s'...\n", #name);
|
||||
|
||||
#define TEST_MODULE_TEST(func) \
|
||||
{ \
|
||||
#define TEST_MODULE_TEST(func) \
|
||||
{ \
|
||||
fprintf(stderr, "\tRunning test '%s'...\n", #func); \
|
||||
func(); \
|
||||
} \
|
||||
func(); \
|
||||
}
|
||||
|
||||
#define TEST_MODULE_END() \
|
||||
fprintf(stderr, "Finished execution of test module\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
#define TEST_MODULE_END() \
|
||||
fprintf(stderr, "Finished execution of test module\n"); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "util/net.h"
|
||||
|
||||
/* Note: Don't care about cleaning up of returned strings to avoid code
|
||||
* clutter
|
||||
* clutter
|
||||
*/
|
||||
|
||||
static void test_parse_invalid()
|
||||
@@ -183,7 +183,8 @@ static void test_parse_url_https_hostname()
|
||||
check_int_eq(addr.url.hostname.port, NET_INVALID_PORT);
|
||||
check_str_eq(addr.url.path, "somewhere");
|
||||
|
||||
check_bool_true(net_str_parse("https://www.google.com:22/somewhere", &addr));
|
||||
check_bool_true(
|
||||
net_str_parse("https://www.google.com:22/somewhere", &addr));
|
||||
check_int_eq(addr.type, NET_ADDR_TYPE_URL);
|
||||
check_bool_true(addr.url.is_https);
|
||||
check_int_eq(addr.url.type, NET_ADDR_TYPE_HOSTNAME);
|
||||
@@ -346,7 +347,8 @@ static void test_net_addr_to_str_url_http_hostname()
|
||||
addr.url.hostname.port = 1234;
|
||||
strcpy(addr.url.path, "somewhere");
|
||||
|
||||
check_str_eq(net_addr_to_str(&addr), "http://www.google.com:1234/somewhere");
|
||||
check_str_eq(
|
||||
net_addr_to_str(&addr), "http://www.google.com:1234/somewhere");
|
||||
}
|
||||
|
||||
static void test_net_addr_to_str_url_https_hostname()
|
||||
@@ -387,7 +389,8 @@ static void test_net_addr_to_str_url_https_hostname()
|
||||
addr.url.hostname.port = 1234;
|
||||
strcpy(addr.url.path, "somewhere");
|
||||
|
||||
check_str_eq(net_addr_to_str(&addr), "https://www.google.com:1234/somewhere");
|
||||
check_str_eq(
|
||||
net_addr_to_str(&addr), "https://www.google.com:1234/somewhere");
|
||||
}
|
||||
|
||||
static void test_resolve_hostname_str()
|
||||
|
||||
Reference in New Issue
Block a user