diff --git a/Module.mk b/Module.mk index 454e550..b4e72c6 100644 --- a/Module.mk +++ b/Module.mk @@ -147,6 +147,7 @@ include src/test/iidxhook-util/Module.mk include src/test/security/Module.mk include src/test/test/Module.mk include src/test/util/Module.mk +include src/test/iidxhook8/Module.mk # # Distribution build rules @@ -480,6 +481,7 @@ $(BUILDDIR)/tests.zip: \ build/bin/indep-32/security-rp3-test.exe \ build/bin/indep-32/security-util-test.exe \ build/bin/indep-32/util-net-test.exe \ + build/bin/indep-64/iidxhook8-config-cam-test.exe \ dist/test/run-tests.sh \ | $(zipdir)/ $(V)echo ... $@ diff --git a/src/main/camhook/cam.c b/src/main/camhook/cam.c index d8d6feb..76fc7bd 100644 --- a/src/main/camhook/cam.c +++ b/src/main/camhook/cam.c @@ -793,6 +793,7 @@ void camhook_init(struct camhook_config_cam *config_cam) } size_t num_setup = 0; + for (size_t i = 0; i < config_cam->num_devices; ++i) { if (camData[i].setup) { num_setup++; diff --git a/src/main/camhook/config-cam.c b/src/main/camhook/config-cam.c index 04ef74b..e905f0b 100644 --- a/src/main/camhook/config-cam.c +++ b/src/main/camhook/config-cam.c @@ -7,6 +7,8 @@ #define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu" #define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false +// the following two arrays are based on CAMHOOK_CONFIG_CAM_MAX +// please insert more elements if more cams are added const char *camhook_config_device_id_keys[CAMHOOK_CONFIG_CAM_MAX] = { "cam.device_id1", "cam.device_id2", diff --git a/src/test/iidxhook8/Module.mk b/src/test/iidxhook8/Module.mk index 7759e99..57731d5 100644 --- a/src/test/iidxhook8/Module.mk +++ b/src/test/iidxhook8/Module.mk @@ -3,6 +3,7 @@ testexes += iidxhook8-config-cam-test srcdir_iidxhook8-config-cam-test := src/test/iidxhook8 libs_iidxhook8-config-cam-test := \ + camhook \ cconfig \ test \ util \ diff --git a/src/test/iidxhook8/iidxhook8-config-cam-test.c b/src/test/iidxhook8/iidxhook8-config-cam-test.c index 8c2a88d..b7a1a06 100644 --- a/src/test/iidxhook8/iidxhook8-config-cam-test.c +++ b/src/test/iidxhook8/iidxhook8-config-cam-test.c @@ -1,4 +1,4 @@ -#include "iidxhook8/config-cam.h" +#include "camhook/config-cam.h" #include "test/check.h" #include "test/test.h" @@ -9,65 +9,65 @@ static void test_config_cam_defaults() { struct cconfig *config; - struct iidxhook8_config_cam config_cam; + struct camhook_config_cam config_cam; config = cconfig_init(); - iidxhook8_config_cam_init(config); - iidxhook8_config_cam_get(&config_cam, config); + camhook_config_cam_init(config, 2); + camhook_config_cam_get(&config_cam, config, 2); cconfig_finit(config); check_bool_false(config_cam.disable_emu); - check_str_eq(config_cam.device_id1, ""); - check_str_eq(config_cam.device_id2, ""); + check_str_eq(config_cam.device_id[0], ""); + check_str_eq(config_cam.device_id[1], ""); } static void test_config_cam() { struct cconfig *config; - struct iidxhook8_config_cam config_cam; + struct camhook_config_cam config_cam; config = cconfig_init(); - iidxhook8_config_cam_init(config); + camhook_config_cam_init(config, 2); cconfig_set2(config, "cam.disable_emu", "true"); cconfig_set2(config, "cam.device_id1", "asdjkasd"); cconfig_set2(config, "cam.device_id2", "1234"); - iidxhook8_config_cam_get(&config_cam, config); + camhook_config_cam_get(&config_cam, config, 2); cconfig_finit(config); check_bool_true(config_cam.disable_emu); - check_str_eq(config_cam.device_id1, "asdjkasd"); - check_str_eq(config_cam.device_id2, "1234"); + check_str_eq(config_cam.device_id[0], "asdjkasd"); + check_str_eq(config_cam.device_id[1], "1234"); } -static void test_config_invalid_values() +static void test_config_cam_invalid_values() { struct cconfig *config; - struct iidxhook8_config_cam config_cam; + struct camhook_config_cam config_cam; config = cconfig_init(); - iidxhook8_config_cam_init(config); + camhook_config_cam_init(config, 2); cconfig_set2(config, "cam.disable_emu", "123"); cconfig_set2(config, "cam.device_id1", "asdjkasd"); cconfig_set2(config, "cam.device_id2", "1234"); - iidxhook8_config_cam_get(&config_cam, config); + camhook_config_cam_get(&config_cam, config, 2); cconfig_finit(config); - check_bool_fakse(config_cam.disable_emu); - check_str_eq(config_cam.device_id1, "asdjkasd"); - check_str_eq(config_cam.device_id2, "1234"); + check_bool_false(config_cam.disable_emu); + check_str_eq(config_cam.device_id[0], "asdjkasd"); + check_str_eq(config_cam.device_id[1], "1234"); } -TEST_MODULE_BEGIN("iidxhook8-config-cam") +TEST_MODULE_BEGIN("camhook-config-cam") TEST_MODULE_TEST(test_config_cam_defaults) TEST_MODULE_TEST(test_config_cam) TEST_MODULE_TEST(test_config_cam_invalid_values) diff --git a/src/test/iidxhook8/iidxhook8-config-io-test.c b/src/test/iidxhook8/iidxhook8-config-io-test.c index a53ea8e..5524ba6 100644 --- a/src/test/iidxhook8/iidxhook8-config-io-test.c +++ b/src/test/iidxhook8/iidxhook8-config-io-test.c @@ -45,7 +45,7 @@ static void test_config_io() check_bool_true(config_io.disable_poll_limiter); } -static void test_config_invalid_values() +static void test_config_io_invalid_values() { struct cconfig *config; struct iidxhook8_config_io config_io;