gemba 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/THIRD_PARTY_NOTICES +37 -2
- data/assets/placeholder_boxart.png +0 -0
- data/bin/gemba +2 -2
- data/ext/gemba/extconf.rb +24 -1
- data/ext/gemba/gemba_ext.c +436 -2
- data/ext/gemba/gemba_ext.h +2 -0
- data/gemba.gemspec +5 -3
- data/lib/gemba/achievements/achievement.rb +23 -0
- data/lib/gemba/achievements/backend.rb +186 -0
- data/lib/gemba/achievements/cache.rb +70 -0
- data/lib/gemba/achievements/credentials_presenter.rb +142 -0
- data/lib/gemba/achievements/fake_backend.rb +205 -0
- data/lib/gemba/achievements/null_backend.rb +11 -0
- data/lib/gemba/achievements/offline_backend.rb +168 -0
- data/lib/gemba/achievements/retro_achievements/backend.rb +453 -0
- data/lib/gemba/achievements/retro_achievements/cli_sync_requester.rb +64 -0
- data/lib/gemba/achievements/retro_achievements/ping_worker.rb +27 -0
- data/lib/gemba/achievements.rb +19 -0
- data/lib/gemba/achievements_window.rb +556 -0
- data/lib/gemba/app_controller.rb +1015 -0
- data/lib/gemba/bios.rb +54 -0
- data/lib/gemba/boxart_fetcher/libretro_backend.rb +39 -0
- data/lib/gemba/boxart_fetcher/null_backend.rb +12 -0
- data/lib/gemba/boxart_fetcher.rb +79 -0
- data/lib/gemba/bus_emitter.rb +13 -0
- data/lib/gemba/child_window.rb +24 -1
- data/lib/gemba/cli/commands/config_cmd.rb +83 -0
- data/lib/gemba/cli/commands/decode.rb +154 -0
- data/lib/gemba/cli/commands/patch.rb +78 -0
- data/lib/gemba/cli/commands/play.rb +78 -0
- data/lib/gemba/cli/commands/record.rb +114 -0
- data/lib/gemba/cli/commands/replay.rb +161 -0
- data/lib/gemba/cli/commands/retro_achievements.rb +213 -0
- data/lib/gemba/cli/commands/version.rb +22 -0
- data/lib/gemba/cli.rb +52 -364
- data/lib/gemba/config.rb +135 -1
- data/lib/gemba/data/gb_games.json +1 -0
- data/lib/gemba/data/gb_md5.json +1 -0
- data/lib/gemba/data/gba_games.json +1 -0
- data/lib/gemba/data/gba_md5.json +1 -0
- data/lib/gemba/data/gbc_games.json +1 -0
- data/lib/gemba/data/gbc_md5.json +1 -0
- data/lib/gemba/emulator_frame.rb +1060 -0
- data/lib/gemba/event_bus.rb +48 -0
- data/lib/gemba/frame_stack.rb +60 -0
- data/lib/gemba/game_index.rb +84 -0
- data/lib/gemba/game_picker_frame.rb +268 -0
- data/lib/gemba/gamepad_map.rb +103 -0
- data/lib/gemba/headless.rb +6 -5
- data/lib/gemba/headless_player.rb +33 -3
- data/lib/gemba/help_window.rb +61 -0
- data/lib/gemba/hotkey_map.rb +3 -1
- data/lib/gemba/input_recorder.rb +107 -0
- data/lib/gemba/input_replayer.rb +119 -0
- data/lib/gemba/keyboard_map.rb +90 -0
- data/lib/gemba/locales/en.yml +97 -5
- data/lib/gemba/locales/ja.yml +97 -5
- data/lib/gemba/main_window.rb +56 -0
- data/lib/gemba/modal_stack.rb +81 -0
- data/lib/gemba/patcher_window.rb +223 -0
- data/lib/gemba/platform/gb.rb +21 -0
- data/lib/gemba/platform/gba.rb +21 -0
- data/lib/gemba/platform/gbc.rb +23 -0
- data/lib/gemba/platform.rb +20 -0
- data/lib/gemba/platform_open.rb +19 -0
- data/lib/gemba/recorder.rb +4 -3
- data/lib/gemba/replay_player.rb +691 -0
- data/lib/gemba/rom_info.rb +57 -0
- data/lib/gemba/rom_info_window.rb +16 -3
- data/lib/gemba/rom_library.rb +106 -0
- data/lib/gemba/rom_overrides.rb +47 -0
- data/lib/gemba/rom_patcher/bps.rb +161 -0
- data/lib/gemba/rom_patcher/ips.rb +101 -0
- data/lib/gemba/rom_patcher/ups.rb +118 -0
- data/lib/gemba/rom_patcher.rb +109 -0
- data/lib/gemba/{rom_loader.rb → rom_resolver.rb} +7 -6
- data/lib/gemba/runtime.rb +59 -26
- data/lib/gemba/save_state_manager.rb +4 -7
- data/lib/gemba/save_state_picker.rb +17 -4
- data/lib/gemba/session_logger.rb +64 -0
- data/lib/gemba/settings/audio_tab.rb +77 -0
- data/lib/gemba/settings/gamepad_tab.rb +351 -0
- data/lib/gemba/settings/hotkeys_tab.rb +259 -0
- data/lib/gemba/settings/paths.rb +11 -0
- data/lib/gemba/settings/recording_tab.rb +83 -0
- data/lib/gemba/settings/save_states_tab.rb +91 -0
- data/lib/gemba/settings/system_tab.rb +362 -0
- data/lib/gemba/settings/video_tab.rb +318 -0
- data/lib/gemba/settings_window.rb +162 -1036
- data/lib/gemba/version.rb +1 -1
- data/lib/gemba/virtual_keyboard.rb +19 -0
- data/lib/gemba.rb +2 -12
- data/test/achievements_window/test_bulk_sync.rb +218 -0
- data/test/achievements_window/test_bus_events.rb +125 -0
- data/test/achievements_window/test_close_confirmation.rb +201 -0
- data/test/achievements_window/test_initial_state.rb +164 -0
- data/test/achievements_window/test_sorting.rb +227 -0
- data/test/achievements_window/test_tree_rendering.rb +133 -0
- data/test/fixtures/fake_bios.bin +0 -0
- data/test/fixtures/pong.gba +0 -0
- data/test/fixtures/test.gb +0 -0
- data/test/fixtures/test.gbc +0 -0
- data/test/fixtures/test_quicksave.ss +0 -0
- data/test/screenshots/no_focus.png +0 -0
- data/test/shared/teek_test_worker.rb +17 -1
- data/test/shared/tk_test_helper.rb +91 -4
- data/test/support/achievements_window_helpers.rb +18 -0
- data/test/support/fake_core.rb +25 -0
- data/test/support/fake_ra_runtime.rb +74 -0
- data/test/support/fake_requester.rb +68 -0
- data/test/support/player_helpers.rb +20 -5
- data/test/test_achievement.rb +32 -0
- data/test/{test_player.rb → test_app_controller.rb} +353 -85
- data/test/test_bios.rb +123 -0
- data/test/test_boxart_fetcher.rb +150 -0
- data/test/test_cli.rb +17 -265
- data/test/test_cli_config.rb +64 -0
- data/test/test_cli_decode.rb +97 -0
- data/test/test_cli_patch.rb +58 -0
- data/test/test_cli_play.rb +213 -0
- data/test/test_cli_ra.rb +175 -0
- data/test/test_cli_record.rb +69 -0
- data/test/test_cli_replay.rb +72 -0
- data/test/test_cli_sync_requester.rb +152 -0
- data/test/test_cli_version.rb +27 -0
- data/test/test_config.rb +2 -3
- data/test/test_config_ra.rb +69 -0
- data/test/test_core.rb +62 -1
- data/test/test_credentials_presenter.rb +192 -0
- data/test/test_event_bus.rb +100 -0
- data/test/test_fake_backend_achievements.rb +130 -0
- data/test/test_fake_backend_auth.rb +68 -0
- data/test/test_game_index.rb +77 -0
- data/test/test_game_picker_frame.rb +310 -0
- data/test/test_gamepad_map.rb +1 -3
- data/test/test_headless_player.rb +17 -3
- data/test/test_help_window.rb +82 -0
- data/test/test_hotkey_map.rb +22 -1
- data/test/test_input_recorder.rb +179 -0
- data/test/test_input_replay_determinism.rb +113 -0
- data/test/test_input_replayer.rb +162 -0
- data/test/test_keyboard_map.rb +1 -3
- data/test/test_libretro_backend.rb +41 -0
- data/test/test_locale.rb +1 -1
- data/test/test_logging.rb +123 -0
- data/test/test_null_backend.rb +42 -0
- data/test/test_offline_backend.rb +116 -0
- data/test/test_overlay_renderer.rb +1 -1
- data/test/test_platform.rb +149 -0
- data/test/test_ra_backend.rb +313 -0
- data/test/test_ra_backend_unlock_gate.rb +56 -0
- data/test/test_recorder.rb +0 -3
- data/test/test_replay_player.rb +316 -0
- data/test/test_rom_info.rb +149 -0
- data/test/test_rom_overrides.rb +86 -0
- data/test/test_rom_patcher.rb +382 -0
- data/test/{test_rom_loader.rb → test_rom_resolver.rb} +25 -26
- data/test/test_save_state_manager.rb +2 -4
- data/test/test_settings_audio.rb +107 -0
- data/test/test_settings_hotkeys.rb +83 -66
- data/test/test_settings_recording.rb +49 -0
- data/test/test_settings_save_states.rb +97 -0
- data/test/test_settings_system.rb +133 -0
- data/test/test_settings_video.rb +450 -0
- data/test/test_settings_window.rb +76 -507
- data/test/test_tip_service.rb +6 -6
- data/test/test_toast_overlay.rb +1 -1
- data/test/test_virtual_events.rb +156 -0
- data/test/test_virtual_keyboard.rb +1 -1
- data/vendor/rcheevos/CHANGELOG.md +495 -0
- data/vendor/rcheevos/LICENSE +21 -0
- data/vendor/rcheevos/Package.swift +33 -0
- data/vendor/rcheevos/README.md +67 -0
- data/vendor/rcheevos/include/module.modulemap +70 -0
- data/vendor/rcheevos/include/rc_api_editor.h +296 -0
- data/vendor/rcheevos/include/rc_api_info.h +280 -0
- data/vendor/rcheevos/include/rc_api_request.h +77 -0
- data/vendor/rcheevos/include/rc_api_runtime.h +417 -0
- data/vendor/rcheevos/include/rc_api_user.h +262 -0
- data/vendor/rcheevos/include/rc_client.h +877 -0
- data/vendor/rcheevos/include/rc_client_raintegration.h +101 -0
- data/vendor/rcheevos/include/rc_consoles.h +138 -0
- data/vendor/rcheevos/include/rc_error.h +59 -0
- data/vendor/rcheevos/include/rc_export.h +100 -0
- data/vendor/rcheevos/include/rc_hash.h +200 -0
- data/vendor/rcheevos/include/rc_runtime.h +148 -0
- data/vendor/rcheevos/include/rc_runtime_types.h +452 -0
- data/vendor/rcheevos/include/rc_util.h +51 -0
- data/vendor/rcheevos/include/rcheevos.h +8 -0
- data/vendor/rcheevos/src/rapi/rc_api_common.c +1379 -0
- data/vendor/rcheevos/src/rapi/rc_api_common.h +88 -0
- data/vendor/rcheevos/src/rapi/rc_api_editor.c +625 -0
- data/vendor/rcheevos/src/rapi/rc_api_info.c +587 -0
- data/vendor/rcheevos/src/rapi/rc_api_runtime.c +901 -0
- data/vendor/rcheevos/src/rapi/rc_api_user.c +483 -0
- data/vendor/rcheevos/src/rc_client.c +6941 -0
- data/vendor/rcheevos/src/rc_client_external.c +281 -0
- data/vendor/rcheevos/src/rc_client_external.h +177 -0
- data/vendor/rcheevos/src/rc_client_external_versions.h +171 -0
- data/vendor/rcheevos/src/rc_client_internal.h +409 -0
- data/vendor/rcheevos/src/rc_client_raintegration.c +566 -0
- data/vendor/rcheevos/src/rc_client_raintegration_internal.h +61 -0
- data/vendor/rcheevos/src/rc_client_types.natvis +396 -0
- data/vendor/rcheevos/src/rc_compat.c +251 -0
- data/vendor/rcheevos/src/rc_compat.h +121 -0
- data/vendor/rcheevos/src/rc_libretro.c +915 -0
- data/vendor/rcheevos/src/rc_libretro.h +98 -0
- data/vendor/rcheevos/src/rc_util.c +199 -0
- data/vendor/rcheevos/src/rc_version.c +11 -0
- data/vendor/rcheevos/src/rc_version.h +32 -0
- data/vendor/rcheevos/src/rcheevos/alloc.c +312 -0
- data/vendor/rcheevos/src/rcheevos/condition.c +754 -0
- data/vendor/rcheevos/src/rcheevos/condset.c +777 -0
- data/vendor/rcheevos/src/rcheevos/consoleinfo.c +1215 -0
- data/vendor/rcheevos/src/rcheevos/format.c +330 -0
- data/vendor/rcheevos/src/rcheevos/lboard.c +287 -0
- data/vendor/rcheevos/src/rcheevos/memref.c +805 -0
- data/vendor/rcheevos/src/rcheevos/operand.c +607 -0
- data/vendor/rcheevos/src/rcheevos/rc_internal.h +390 -0
- data/vendor/rcheevos/src/rcheevos/rc_runtime_types.natvis +541 -0
- data/vendor/rcheevos/src/rcheevos/rc_validate.c +1406 -0
- data/vendor/rcheevos/src/rcheevos/rc_validate.h +18 -0
- data/vendor/rcheevos/src/rcheevos/richpresence.c +922 -0
- data/vendor/rcheevos/src/rcheevos/runtime.c +852 -0
- data/vendor/rcheevos/src/rcheevos/runtime_progress.c +1073 -0
- data/vendor/rcheevos/src/rcheevos/trigger.c +344 -0
- data/vendor/rcheevos/src/rcheevos/value.c +935 -0
- data/vendor/rcheevos/src/rhash/aes.c +480 -0
- data/vendor/rcheevos/src/rhash/aes.h +49 -0
- data/vendor/rcheevos/src/rhash/cdreader.c +838 -0
- data/vendor/rcheevos/src/rhash/hash.c +1402 -0
- data/vendor/rcheevos/src/rhash/hash_disc.c +1340 -0
- data/vendor/rcheevos/src/rhash/hash_encrypted.c +566 -0
- data/vendor/rcheevos/src/rhash/hash_rom.c +426 -0
- data/vendor/rcheevos/src/rhash/hash_zip.c +460 -0
- data/vendor/rcheevos/src/rhash/md5.c +382 -0
- data/vendor/rcheevos/src/rhash/md5.h +91 -0
- data/vendor/rcheevos/src/rhash/rc_hash_internal.h +116 -0
- data/vendor/rcheevos/test/libretro.h +205 -0
- data/vendor/rcheevos/test/rapi/test_rc_api_common.c +941 -0
- data/vendor/rcheevos/test/rapi/test_rc_api_editor.c +931 -0
- data/vendor/rcheevos/test/rapi/test_rc_api_info.c +545 -0
- data/vendor/rcheevos/test/rapi/test_rc_api_runtime.c +2213 -0
- data/vendor/rcheevos/test/rapi/test_rc_api_user.c +998 -0
- data/vendor/rcheevos/test/rcheevos/mock_memory.h +32 -0
- data/vendor/rcheevos/test/rcheevos/test_condition.c +570 -0
- data/vendor/rcheevos/test/rcheevos/test_condset.c +5170 -0
- data/vendor/rcheevos/test/rcheevos/test_consoleinfo.c +203 -0
- data/vendor/rcheevos/test/rcheevos/test_format.c +112 -0
- data/vendor/rcheevos/test/rcheevos/test_lboard.c +746 -0
- data/vendor/rcheevos/test/rcheevos/test_memref.c +520 -0
- data/vendor/rcheevos/test/rcheevos/test_operand.c +692 -0
- data/vendor/rcheevos/test/rcheevos/test_rc_validate.c +502 -0
- data/vendor/rcheevos/test/rcheevos/test_richpresence.c +1564 -0
- data/vendor/rcheevos/test/rcheevos/test_runtime.c +1667 -0
- data/vendor/rcheevos/test/rcheevos/test_runtime_progress.c +1821 -0
- data/vendor/rcheevos/test/rcheevos/test_timing.c +166 -0
- data/vendor/rcheevos/test/rcheevos/test_trigger.c +2521 -0
- data/vendor/rcheevos/test/rcheevos/test_value.c +870 -0
- data/vendor/rcheevos/test/rcheevos-test.sln +46 -0
- data/vendor/rcheevos/test/rcheevos-test.vcxproj +239 -0
- data/vendor/rcheevos/test/rcheevos-test.vcxproj.filters +335 -0
- data/vendor/rcheevos/test/rhash/data.c +657 -0
- data/vendor/rcheevos/test/rhash/data.h +32 -0
- data/vendor/rcheevos/test/rhash/mock_filereader.c +236 -0
- data/vendor/rcheevos/test/rhash/mock_filereader.h +31 -0
- data/vendor/rcheevos/test/rhash/test_cdreader.c +920 -0
- data/vendor/rcheevos/test/rhash/test_hash.c +310 -0
- data/vendor/rcheevos/test/rhash/test_hash_disc.c +1450 -0
- data/vendor/rcheevos/test/rhash/test_hash_rom.c +899 -0
- data/vendor/rcheevos/test/rhash/test_hash_zip.c +551 -0
- data/vendor/rcheevos/test/test.c +113 -0
- data/vendor/rcheevos/test/test_framework.h +205 -0
- data/vendor/rcheevos/test/test_rc_client.c +10509 -0
- data/vendor/rcheevos/test/test_rc_client_external.c +2197 -0
- data/vendor/rcheevos/test/test_rc_client_raintegration.c +441 -0
- data/vendor/rcheevos/test/test_rc_libretro.c +952 -0
- data/vendor/rcheevos/test/test_types.natvis +9 -0
- data/vendor/rcheevos/validator/validator.c +658 -0
- data/vendor/rcheevos/validator/validator.vcxproj +152 -0
- data/vendor/rcheevos/validator/validator.vcxproj.filters +82 -0
- metadata +274 -11
- data/lib/gemba/input_mappings.rb +0 -214
- data/lib/gemba/player.rb +0 -1515
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
#include "rc_validate.h"
|
|
2
|
+
|
|
3
|
+
#include "rc_consoles.h"
|
|
4
|
+
|
|
5
|
+
#include "../rc_compat.h"
|
|
6
|
+
#include "../test_framework.h"
|
|
7
|
+
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
#include <string.h>
|
|
10
|
+
|
|
11
|
+
int validate_trigger(const char* trigger, char result[], const size_t result_size, uint32_t max_address) {
|
|
12
|
+
char* buffer;
|
|
13
|
+
rc_trigger_t* compiled;
|
|
14
|
+
int success = 0;
|
|
15
|
+
|
|
16
|
+
int ret = rc_trigger_size(trigger);
|
|
17
|
+
if (ret < 0) {
|
|
18
|
+
snprintf(result, result_size, "%s", rc_error_str(ret));
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
buffer = (char*)malloc(ret + 4);
|
|
23
|
+
if (!buffer) {
|
|
24
|
+
snprintf(result, result_size, "malloc failed");
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
memset(buffer + ret, 0xCD, 4);
|
|
28
|
+
compiled = rc_parse_trigger(buffer, trigger, NULL, 0);
|
|
29
|
+
if (compiled == NULL) {
|
|
30
|
+
snprintf(result, result_size, "parse failed");
|
|
31
|
+
}
|
|
32
|
+
else if (*(uint32_t*)&buffer[ret] != 0xCDCDCDCD) {
|
|
33
|
+
snprintf(result, result_size, "write past end of buffer");
|
|
34
|
+
}
|
|
35
|
+
else if (rc_validate_trigger(compiled, result, result_size, max_address)) {
|
|
36
|
+
success = 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
free(buffer);
|
|
40
|
+
return success;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static void test_validate_trigger_max_address(const char* trigger, const char* expected_error, uint32_t max_address) {
|
|
44
|
+
char buffer[512];
|
|
45
|
+
int valid = validate_trigger(trigger, buffer, sizeof(buffer), max_address);
|
|
46
|
+
|
|
47
|
+
if (*expected_error) {
|
|
48
|
+
ASSERT_STR_EQUALS(buffer, expected_error);
|
|
49
|
+
ASSERT_NUM_EQUALS(valid, 0);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
ASSERT_STR_EQUALS(buffer, "");
|
|
53
|
+
ASSERT_NUM_EQUALS(valid, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void test_validate_trigger(const char* trigger, const char* expected_error) {
|
|
58
|
+
test_validate_trigger_max_address(trigger, expected_error, 0xFFFFFFFF);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static void test_validate_trigger_64k(const char* trigger, const char* expected_error) {
|
|
62
|
+
test_validate_trigger_max_address(trigger, expected_error, 0xFFFF);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static void test_validate_trigger_128k(const char* trigger, const char* expected_error) {
|
|
66
|
+
test_validate_trigger_max_address(trigger, expected_error, 0x1FFFF);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
int validate_trigger_for_console(const char* trigger, char result[], const size_t result_size, uint32_t console_id) {
|
|
70
|
+
char* buffer;
|
|
71
|
+
rc_trigger_t* compiled;
|
|
72
|
+
int success = 0;
|
|
73
|
+
|
|
74
|
+
int ret = rc_trigger_size(trigger);
|
|
75
|
+
if (ret < 0) {
|
|
76
|
+
snprintf(result, result_size, "%s", rc_error_str(ret));
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
buffer = (char*)malloc(ret + 4);
|
|
81
|
+
if (!buffer) {
|
|
82
|
+
snprintf(result, result_size, "malloc failed");
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
memset(buffer + ret, 0xCD, 4);
|
|
86
|
+
compiled = rc_parse_trigger(buffer, trigger, NULL, 0);
|
|
87
|
+
if (compiled == NULL) {
|
|
88
|
+
snprintf(result, result_size, "parse failed");
|
|
89
|
+
}
|
|
90
|
+
else if (*(unsigned*)&buffer[ret] != 0xCDCDCDCD) {
|
|
91
|
+
snprintf(result, result_size, "write past end of buffer");
|
|
92
|
+
}
|
|
93
|
+
else if (rc_validate_trigger_for_console(compiled, result, result_size, console_id)) {
|
|
94
|
+
success = 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
free(buffer);
|
|
98
|
+
return success;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static void test_validate_trigger_console(const char* trigger, const char* expected_error, uint32_t console_id) {
|
|
102
|
+
char buffer[512];
|
|
103
|
+
int valid = validate_trigger_for_console(trigger, buffer, sizeof(buffer), console_id);
|
|
104
|
+
|
|
105
|
+
if (*expected_error) {
|
|
106
|
+
ASSERT_STR_EQUALS(buffer, expected_error);
|
|
107
|
+
ASSERT_NUM_EQUALS(valid, 0);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
ASSERT_STR_EQUALS(buffer, "");
|
|
111
|
+
ASSERT_NUM_EQUALS(valid, 1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static void test_combining_conditions_at_end_of_definition() {
|
|
116
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_A:0xH2345=2", "Condition 2: AddSource condition type expects another condition to follow");
|
|
117
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_B:0xH2345=2", "Condition 2: SubSource condition type expects another condition to follow");
|
|
118
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_C:0xH2345=2", "Condition 2: AddHits condition type expects another condition to follow");
|
|
119
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_D:0xH2345=2", "Condition 2: SubHits condition type expects another condition to follow");
|
|
120
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_N:0xH2345=2", "Condition 2: AndNext condition type expects another condition to follow");
|
|
121
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_O:0xH2345=2", "Condition 2: OrNext condition type expects another condition to follow");
|
|
122
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_Z:0xH2345=2", "Condition 2: ResetNextIf condition type expects another condition to follow");
|
|
123
|
+
|
|
124
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_A:0xH2345=2S0x3456=1", "Core Condition 2: AddSource condition type expects another condition to follow");
|
|
125
|
+
TEST_PARAMS2(test_validate_trigger, "0x3456=1S0xH1234=1_A:0xH2345=2", "Alt1 Condition 2: AddSource condition type expects another condition to follow");
|
|
126
|
+
|
|
127
|
+
/* combining conditions not at end of definition */
|
|
128
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234=1_0xH2345=2", "");
|
|
129
|
+
TEST_PARAMS2(test_validate_trigger, "B:0xH1234=1_0xH2345=2", "");
|
|
130
|
+
TEST_PARAMS2(test_validate_trigger, "N:0xH1234=1_0xH2345=2", "");
|
|
131
|
+
TEST_PARAMS2(test_validate_trigger, "O:0xH1234=1_0xH2345=2", "");
|
|
132
|
+
TEST_PARAMS2(test_validate_trigger, "Z:0xH1234=1_0xH2345=2", "");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static void test_addhits_chain_without_target() {
|
|
136
|
+
TEST_PARAMS2(test_validate_trigger, "C:0xH1234=1_0xH2345=2", "Condition 2: Final condition in AddHits chain must have a hit target");
|
|
137
|
+
TEST_PARAMS2(test_validate_trigger, "D:0xH1234=1_0xH2345=2", "Condition 2: Final condition in AddHits chain must have a hit target");
|
|
138
|
+
TEST_PARAMS2(test_validate_trigger, "C:0xH1234=1_0xH2345=2.1.", "");
|
|
139
|
+
TEST_PARAMS2(test_validate_trigger, "D:0xH1234=1_0xH2345=2.1.", "");
|
|
140
|
+
|
|
141
|
+
/* ResetIf at the end of a hit chain does not require a hit target.
|
|
142
|
+
* It's meant to reset things if some subset of conditions have been true. */
|
|
143
|
+
TEST_PARAMS2(test_validate_trigger, "C:0xH1234=1_C:0xH2345=2_R:0=1.1.", "");
|
|
144
|
+
TEST_PARAMS2(test_validate_trigger, "C:0xH1234=1_C:0xH2345=2_R:0=1", "");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static void test_range_comparisons() {
|
|
148
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>1", "");
|
|
149
|
+
|
|
150
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=255", "");
|
|
151
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234!=255", "");
|
|
152
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>255", "Condition 1: Comparison is never true (max 255)");
|
|
153
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>=255", "");
|
|
154
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234<255", "");
|
|
155
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234<=255", "Condition 1: Comparison is always true (max 255)");
|
|
156
|
+
|
|
157
|
+
/* while a BCD value shouldn't exceed 99, it can reach 165: 0xFF => 15*10+15 */
|
|
158
|
+
TEST_PARAMS2(test_validate_trigger, "b0xH1234<165", "");
|
|
159
|
+
TEST_PARAMS2(test_validate_trigger, "b0xH1234<=165", "Condition 1: Comparison is always true (max 165)");
|
|
160
|
+
|
|
161
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH1234<255_0xH0000=1.1.", "");
|
|
162
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH1234<=255_0xH0000=1.1.", "Condition 1: Comparison is always true (max 255)");
|
|
163
|
+
|
|
164
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=256", "Condition 1: Comparison is never true (max 255)");
|
|
165
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234!=256", "Condition 1: Comparison is always true (max 255)");
|
|
166
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>256", "Condition 1: Comparison is never true (max 255)");
|
|
167
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>=256", "Condition 1: Comparison is never true (max 255)");
|
|
168
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234<256", "Condition 1: Comparison is always true (max 255)");
|
|
169
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234<=256", "Condition 1: Comparison is always true (max 255)");
|
|
170
|
+
|
|
171
|
+
TEST_PARAMS2(test_validate_trigger, "0x 1234>=65535", "");
|
|
172
|
+
TEST_PARAMS2(test_validate_trigger, "0x 1234>=65536", "Condition 1: Comparison is never true (max 65535)");
|
|
173
|
+
|
|
174
|
+
TEST_PARAMS2(test_validate_trigger, "b0x 1234>=16665", "");
|
|
175
|
+
TEST_PARAMS2(test_validate_trigger, "b0x 1234>=16666", "Condition 1: Comparison is never true (max 16665)");
|
|
176
|
+
|
|
177
|
+
TEST_PARAMS2(test_validate_trigger, "0xW1234>=16777215", "");
|
|
178
|
+
TEST_PARAMS2(test_validate_trigger, "0xW1234>=16777216", "Condition 1: Comparison is never true (max 16777215)");
|
|
179
|
+
|
|
180
|
+
TEST_PARAMS2(test_validate_trigger, "b0xW1234>=1666665", "");
|
|
181
|
+
TEST_PARAMS2(test_validate_trigger, "b0xW1234>=1666666", "Condition 1: Comparison is never true (max 1666665)");
|
|
182
|
+
|
|
183
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234>=4294967295", "");
|
|
184
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234>4294967295", "Condition 1: Comparison is never true (max 4294967295)");
|
|
185
|
+
|
|
186
|
+
TEST_PARAMS2(test_validate_trigger, "b0xX1234>=166666665", "");
|
|
187
|
+
TEST_PARAMS2(test_validate_trigger, "b0xX1234>=166666666", "Condition 1: Comparison is never true (max 166666665)");
|
|
188
|
+
|
|
189
|
+
TEST_PARAMS2(test_validate_trigger, "0xT1234>=1", "");
|
|
190
|
+
TEST_PARAMS2(test_validate_trigger, "0xT1234>1", "Condition 1: Comparison is never true (max 1)");
|
|
191
|
+
|
|
192
|
+
/* max for AddSource is the sum of all parts (255+255=510) */
|
|
193
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234_0<255", "");
|
|
194
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234_0<=255", "Condition 2: Comparison is always true (max 255)");
|
|
195
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234_0xH1235<510", "");
|
|
196
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234_0xH1235<=510", "Condition 2: Comparison is always true (max 510)");
|
|
197
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234*10_0xH1235>=2805", "");
|
|
198
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234*10_0xH1235>2805", "Condition 2: Comparison is never true (max 2805)");
|
|
199
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234/10_0xH1235>=280", "");
|
|
200
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234/10_0xH1235>280", "Condition 2: Comparison is never true (max 280)");
|
|
201
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234&10_0xH1235>=265", "");
|
|
202
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234&10_0xH1235>265", "Condition 2: Comparison is never true (max 265)");
|
|
203
|
+
TEST_PARAMS2(test_validate_trigger, "A:b0xH1234*100_b0xH1235>=16665", "");
|
|
204
|
+
TEST_PARAMS2(test_validate_trigger, "A:b0xH1234*100_b0xH1235>16665", "Condition 2: Comparison is never true (max 16665)");
|
|
205
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX1234_0x 1245=123456", ""); /* sum of 32-bit and 16-bit is still 32-bit */
|
|
206
|
+
|
|
207
|
+
/* max for SubSource is always 0xFFFFFFFF */
|
|
208
|
+
TEST_PARAMS2(test_validate_trigger, "B:0xH1234_0xH1235<510", "");
|
|
209
|
+
TEST_PARAMS2(test_validate_trigger, "B:0xH1234_0xH1235<=510", "");
|
|
210
|
+
|
|
211
|
+
/* A - da + 255 > 255 */
|
|
212
|
+
TEST_PARAMS2(test_validate_trigger, "A:255_B:d0xH1234_0xH1234>255", "");
|
|
213
|
+
|
|
214
|
+
/* division by self results in a 0 or 1 */
|
|
215
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234/0xH1234_A:0xH1235/0xH1235_0=2", "");
|
|
216
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234/0xH1234_A:0xH1235/0xH1235_0=3", "Condition 3: Comparison is never true (max 2)");
|
|
217
|
+
TEST_PARAMS2(test_validate_trigger, "B:0xH1241/0xH1241_B:0xH124c/0xH124c_M:2=2", "");
|
|
218
|
+
TEST_PARAMS2(test_validate_trigger, "B:0xH1241/0xH1241_B:0xH124c/0xH124c_M:2>2", "Condition 3: Comparison is never true (max 2)");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
void test_size_comparisons() {
|
|
222
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>0xH1235", "");
|
|
223
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>0x 1235", "Condition 1: Comparing different memory sizes");
|
|
224
|
+
|
|
225
|
+
/* AddSource chain may compare different sizes without warning as the chain changes the
|
|
226
|
+
* size of the final result. */
|
|
227
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234_0xH1235=0xH2345", "");
|
|
228
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH1234_0xH1235=0x 2345", "");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
void test_address_range() {
|
|
232
|
+
/* basic checks for each side */
|
|
233
|
+
TEST_PARAMS2(test_validate_trigger_64k, "0xH1234>0xH1235", "");
|
|
234
|
+
TEST_PARAMS2(test_validate_trigger_64k, "0xH12345>0xH1235", "Condition 1: Address 12345 out of range (max FFFF)");
|
|
235
|
+
TEST_PARAMS2(test_validate_trigger_64k, "0xH1234>0xH12345", "Condition 1: Address 12345 out of range (max FFFF)");
|
|
236
|
+
TEST_PARAMS2(test_validate_trigger_64k, "0xH12345>0xH12345", "Condition 1: Address 12345 out of range (max FFFF)");
|
|
237
|
+
TEST_PARAMS2(test_validate_trigger_64k, "0xX1234>h12345", "");
|
|
238
|
+
TEST_PARAMS2(test_validate_trigger_64k, "K:0xX1234&1073741823_K:0xX2345+{recall}_0=1", "");
|
|
239
|
+
|
|
240
|
+
/* support for multiple memory blocks and edge addresses */
|
|
241
|
+
TEST_PARAMS2(test_validate_trigger_128k, "0xH1234>0xH1235", "");
|
|
242
|
+
TEST_PARAMS2(test_validate_trigger_128k, "0xH12345>0xH1235", "");
|
|
243
|
+
TEST_PARAMS2(test_validate_trigger_128k, "0xH0000>5", "");
|
|
244
|
+
TEST_PARAMS2(test_validate_trigger_128k, "0xH1FFFF>5", "");
|
|
245
|
+
TEST_PARAMS2(test_validate_trigger_128k, "0xH20000>5", "Condition 1: Address 20000 out of range (max 1FFFF)");
|
|
246
|
+
|
|
247
|
+
/* AddAddress can use really big values for negative offsets, don't flag them. */
|
|
248
|
+
TEST_PARAMS2(test_validate_trigger_128k, "I:0xX1234_0xHFFFFFF00>5", "");
|
|
249
|
+
TEST_PARAMS2(test_validate_trigger_128k, "I:0xX1234_0xH1234>5_0xHFFFFFF00>5", "Condition 3: Address FFFFFF00 out of range (max 1FFFF)");
|
|
250
|
+
TEST_PARAMS2(test_validate_trigger_128k, "I:0xX1234_0xHFFFFFF00*2>5", "");
|
|
251
|
+
|
|
252
|
+
/* console-specific warnings */
|
|
253
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH0123>23", "", RC_CONSOLE_NINTENDO);
|
|
254
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH07FF>23", "", RC_CONSOLE_NINTENDO);
|
|
255
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH0800>23", "Condition 1: Mirror RAM may not be exposed by emulator (address 0800)", RC_CONSOLE_NINTENDO);
|
|
256
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH1FFF>23", "Condition 1: Mirror RAM may not be exposed by emulator (address 1FFF)", RC_CONSOLE_NINTENDO);
|
|
257
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH2000>23", "", RC_CONSOLE_NINTENDO);
|
|
258
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH0123>0xH1000", "Condition 1: Mirror RAM may not be exposed by emulator (address 1000)", RC_CONSOLE_NINTENDO);
|
|
259
|
+
|
|
260
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHC123>23", "", RC_CONSOLE_GAMEBOY);
|
|
261
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHDFFF>23", "", RC_CONSOLE_GAMEBOY);
|
|
262
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHE000>23", "Condition 1: Echo RAM may not be exposed by emulator (address E000)", RC_CONSOLE_GAMEBOY);
|
|
263
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHFDFF>23", "Condition 1: Echo RAM may not be exposed by emulator (address FDFF)", RC_CONSOLE_GAMEBOY);
|
|
264
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHFE00>23", "", RC_CONSOLE_GAMEBOY);
|
|
265
|
+
|
|
266
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHC123>23", "", RC_CONSOLE_GAMEBOY_COLOR);
|
|
267
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHDFFF>23", "", RC_CONSOLE_GAMEBOY_COLOR);
|
|
268
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHE000>23", "Condition 1: Echo RAM may not be exposed by emulator (address E000)", RC_CONSOLE_GAMEBOY_COLOR);
|
|
269
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHFDFF>23", "Condition 1: Echo RAM may not be exposed by emulator (address FDFF)", RC_CONSOLE_GAMEBOY_COLOR);
|
|
270
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHFE00>23", "", RC_CONSOLE_GAMEBOY_COLOR);
|
|
271
|
+
|
|
272
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH9E20=68", "Condition 1: Kernel RAM may not be initialized without real BIOS (address 9E20)", RC_CONSOLE_PLAYSTATION);
|
|
273
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHB8BE=68", "Condition 1: Kernel RAM may not be initialized without real BIOS (address B8BE)", RC_CONSOLE_PLAYSTATION);
|
|
274
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xHFFFF=68", "Condition 1: Kernel RAM may not be initialized without real BIOS (address FFFF)", RC_CONSOLE_PLAYSTATION);
|
|
275
|
+
TEST_PARAMS3(test_validate_trigger_console, "0xH10000=68", "", RC_CONSOLE_PLAYSTATION);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void test_delta_pointers() {
|
|
279
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xX1234_0xH0000=1", "");
|
|
280
|
+
TEST_PARAMS2(test_validate_trigger, "I:d0xX1234_0xH0000=1", "Condition 1: Using pointer from previous frame");
|
|
281
|
+
TEST_PARAMS2(test_validate_trigger, "I:p0xX1234_0xH0000=1", "Condition 1: Using pointer from previous frame");
|
|
282
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xX1234_d0xH0000=1", "");
|
|
283
|
+
TEST_PARAMS2(test_validate_trigger, "I:d0xX1234_I:d0xH0010_0xH0000=1", "Condition 1: Using pointer from previous frame");
|
|
284
|
+
TEST_PARAMS2(test_validate_trigger, "I:d0xX1234_I:0xH0010_0xH0000=1", "Condition 1: Using pointer from previous frame");
|
|
285
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xX1234_I:d0xH0010_0xH0000=1", "Condition 2: Using pointer from previous frame");
|
|
286
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xX1234_I:0xH0010_0xH0000=1", "");
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
void test_nonsized_pointers() {
|
|
290
|
+
TEST_PARAMS2(test_validate_trigger, "I:Ff1234_0xH0000=1", "Condition 1: Using non-integer value in AddAddress calculation");
|
|
291
|
+
TEST_PARAMS2(test_validate_trigger, "I:Fb1234_0xH0000=1", "Condition 1: Using non-integer value in AddAddress calculation");
|
|
292
|
+
TEST_PARAMS2(test_validate_trigger, "I:Fm1234_0xH0000=1", "Condition 1: Using non-integer value in AddAddress calculation");
|
|
293
|
+
TEST_PARAMS2(test_validate_trigger, "I:Fh1234_0xH0000=1", "Condition 1: Using non-integer value in AddAddress calculation");
|
|
294
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xH1234*f1.5_0xH0000=1", "Condition 1: Using non-integer value in AddAddress calculation");
|
|
295
|
+
TEST_PARAMS2(test_validate_trigger, "I:b0xH1234_0xH0000=1", "Condition 1: Using transformed value in AddAddress calculation");
|
|
296
|
+
TEST_PARAMS2(test_validate_trigger, "I:~0xH1234_0xH0000=1", "Condition 1: Using transformed value in AddAddress calculation");
|
|
297
|
+
TEST_PARAMS2(test_validate_trigger, "I:~0xH1234*1_0xH0000=1", ""); /* don't report scaled values - assume indexed array */
|
|
298
|
+
TEST_PARAMS2(test_validate_trigger, "I:~0xM1234*4096_0xH0000=1", ""); /* don't report scaled values - assume indexed array */
|
|
299
|
+
TEST_PARAMS2(test_validate_trigger, "I:b0x 1234*8_0xH0000=1", ""); /* don't report scaled values - assume indexed array */
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
void test_float_comparisons() {
|
|
303
|
+
TEST_PARAMS2(test_validate_trigger, "fF1234=f2.3", "");
|
|
304
|
+
TEST_PARAMS2(test_validate_trigger, "fM1234=f2.3", "");
|
|
305
|
+
TEST_PARAMS2(test_validate_trigger, "fF1234=2", "");
|
|
306
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234=2", "");
|
|
307
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234=f2.3", "Condition 1: Comparison is never true (integer can never be 2.3)"); /* non integral comparison */
|
|
308
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234!=f2.3", "Condition 1: Comparison is always true (integer can never be 2.3)"); /* non integral comparison */
|
|
309
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234<f2.3", ""); /* will be converted to < 3 */
|
|
310
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234<=f2.3", ""); /* will be converted to <= 2 */
|
|
311
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234>f2.3", ""); /* will be converted to > 2 */
|
|
312
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234>=f2.3", ""); /* will be converted to >= 3 */
|
|
313
|
+
TEST_PARAMS2(test_validate_trigger, "0xX1234=f2.0", ""); /* float can be converted to int without loss of data*/
|
|
314
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=f2.3", "Condition 1: Comparison is never true (integer can never be 2.3)");
|
|
315
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=f300.0", "Condition 1: Comparison is never true (max 255)"); /* value out of range */
|
|
316
|
+
TEST_PARAMS2(test_validate_trigger, "f2.3=fF1234", "");
|
|
317
|
+
TEST_PARAMS2(test_validate_trigger, "f2.3=0xX1234", "Condition 1: Comparison is never true (integer can never be 2.3)"); /* non integral comparison */
|
|
318
|
+
TEST_PARAMS2(test_validate_trigger, "f2.0=0xX1234", "");
|
|
319
|
+
TEST_PARAMS2(test_validate_trigger, "A:Ff2345_fF1234=f2.3", "");
|
|
320
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX2345_fF1234=f2.3", "");
|
|
321
|
+
TEST_PARAMS2(test_validate_trigger, "A:Ff2345_0x1234=f2.3", "Condition 2: Comparison is never true (integer can never be 2.3)"); /* non integral comparison */
|
|
322
|
+
TEST_PARAMS2(test_validate_trigger, "fM1234>f2.3", "");
|
|
323
|
+
TEST_PARAMS2(test_validate_trigger, "fM1234>f-2.3", "");
|
|
324
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xX2345_fM1234>f1.0", "");
|
|
325
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xX2345_fM1234>f-1.0", "");
|
|
326
|
+
TEST_PARAMS2(test_validate_trigger, "fF1234>=f0.0", ""); /* explicit float comparison can be negative */
|
|
327
|
+
TEST_PARAMS2(test_validate_trigger, "fM1234>=f0.0", "");
|
|
328
|
+
TEST_PARAMS2(test_validate_trigger, "fB1234>=f0.0", "");
|
|
329
|
+
TEST_PARAMS2(test_validate_trigger, "fF1234>=0", ""); /* implicit float comparison can be negative */
|
|
330
|
+
TEST_PARAMS2(test_validate_trigger, "fM1234>=0", "");
|
|
331
|
+
TEST_PARAMS2(test_validate_trigger, "fB1234>=0", "");
|
|
332
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>=f0.1", ""); /* 0 can be less than 0.1 */
|
|
333
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>=f255.1", "Condition 1: Comparison is never true (max 255)"); /* 255 cannot be >= 255.1 */
|
|
334
|
+
TEST_PARAMS2(test_validate_trigger, "f0.1<=0xH1234", ""); /* 0 can be less than 0.1 */
|
|
335
|
+
TEST_PARAMS2(test_validate_trigger, "f255.1<=0xH1234", "Condition 1: Comparison is never true (max 255)"); /* 255 cannot be >= 255.1 */
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
void test_dependent_conditions() {
|
|
339
|
+
TEST_PARAMS2(test_validate_trigger, "M:0xH1234=30_Q:0xH2345!=0", "");
|
|
340
|
+
TEST_PARAMS2(test_validate_trigger, "G:0xH1234=30_Q:0xH2345!=0", "");
|
|
341
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=30_Q:0xH2345!=0", "Condition 2: MeasuredIf without Measured");
|
|
342
|
+
TEST_PARAMS2(test_validate_trigger, "M:0xH1234=30SQ:0xH2345!=0", "Alt1 Condition 1: MeasuredIf without Measured");
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
void test_conflicting_conditions() {
|
|
346
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1_0xH0000=2", "Condition 2: Conflicts with Condition 1");
|
|
347
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_0xH0000>5", "Condition 2: Conflicts with Condition 1");
|
|
348
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_0xH0000=5", "Condition 2: Conflicts with Condition 1");
|
|
349
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_0xH0001=5", ""); /* ignore differing address */
|
|
350
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_0x 0000=5", ""); /* ignore differing size */
|
|
351
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_d0xH0000=5", ""); /* ignore differing type */
|
|
352
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_0xH0000=5.1.", ""); /* ignore anything with a hit target */
|
|
353
|
+
TEST_PARAMS2(test_validate_trigger, "O:0xH0000<5_0xH0000=5", ""); /* ignore combining conditions */
|
|
354
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xH0000<5_0xH0000=5", ""); /* ignore combining conditions */
|
|
355
|
+
TEST_PARAMS2(test_validate_trigger, "N:0xH0000<5_R:0xH0001=8_T:0xH0000=0_0xH0002=1.1.", ""); /* ignore combining conditions */
|
|
356
|
+
TEST_PARAMS2(test_validate_trigger, "T:0xH0000=8_N:d0xH0000=0_R:0xH0000=8_0xH0001=1.1.", ""); /* ignore combining conditions - individually, third conditions is conflicting (second allowed because of delta) */
|
|
357
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0001=58.1._N:0xH0001!=58_N:0xH0001!=4_R:0xH0001!=18", ""); /* ignore combining conditions */
|
|
358
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<=5_0xH0000>=5", "");
|
|
359
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000>1_0xH0000<3", "");
|
|
360
|
+
TEST_PARAMS2(test_validate_trigger, "1=1S0xH0000=1S0xH0000=2", "");
|
|
361
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1S0xH0000=2", "Alt1 Condition 1: Conflicts with Core Condition 1");
|
|
362
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000=1S0xH0000=1_0xH0001=1.1.", "Alt1 Condition 1: Conflicts with Core Condition 1");
|
|
363
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1SR:0xH0000=1_0xH0001=1.1.", "Alt1 Condition 1: Conflicts with Core Condition 1");
|
|
364
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_0xH0000=1", "Condition 2: Conflicts with Condition 1");
|
|
365
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1S0xH0000=1", "");
|
|
366
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1SP:0xH0000!=1", "Alt1 Condition 1: Conflicts with Core Condition 1");
|
|
367
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_P:0xH0000!=1", "Condition 2: Conflicts with Condition 1");
|
|
368
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_R:0xH0000=1_0xH0001=1.1.", "Condition 2: Conflicts with Condition 1");
|
|
369
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1SP:0xH0000=5", "");
|
|
370
|
+
TEST_PARAMS2(test_validate_trigger, "M:0xH0000=5_Q:0xH0000=255", "Condition 2: Conflicts with Condition 1");
|
|
371
|
+
TEST_PARAMS2(test_validate_trigger, "Q:0xH0000=1_Q:0xH0000=2_M:0xH0001=1", "Condition 2: Conflicts with Condition 1");
|
|
372
|
+
TEST_PARAMS2(test_validate_trigger, "Q:0xH0000=1_0xH0000=2_M:0xH0001=1", "Condition 2: Conflicts with Condition 1");
|
|
373
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1_Q:0xH0000=2_M:0xH0001=1", "Condition 2: Conflicts with Condition 1");
|
|
374
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_0xH0000<5_A:0xX0004_0xH0000>5", "Condition 4: Conflicts with Condition 2");
|
|
375
|
+
TEST_PARAMS2(test_validate_trigger, "A:d0xX0004_d0xH0000<5_A:0xX0004_0xH0000>5", "");
|
|
376
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_d0xH0000<5_A:0xX0004_0xH0000>5", "");
|
|
377
|
+
|
|
378
|
+
/* PauseIf prevents hits from incrementing. ResetIf clears all hits. If both exist and are conflicting, the group
|
|
379
|
+
* will only ever be paused or reset, and therefore will never be true */
|
|
380
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_R:0xH0000!=1_0xH0001=1.1.", "Condition 2: Conflicts with Condition 1");
|
|
381
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=1_P:0xH0000=1_0xH0001=1.1.", "Condition 2: Conflicts with Condition 1");
|
|
382
|
+
/* if the PauseIf is less restrictive than the ResetIf, it's just a guard. ignore it*/
|
|
383
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_R:0xH0000!=6_0xH0001=1.1.", "");
|
|
384
|
+
/* PauseIf in alternate group does not affect the ResetIf*/
|
|
385
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1SR:0xH0000!=1_0xH0001=1.1.", "");
|
|
386
|
+
|
|
387
|
+
/* cannot determine OrNext conflicts */
|
|
388
|
+
TEST_PARAMS2(test_validate_trigger, "O:0xH0000=1_0xH0001=1_O:0xH0000=2_0xH0001=2", "");
|
|
389
|
+
TEST_PARAMS2(test_validate_trigger, "O:0xH0000=1_0xH0001=1_O:0xH0000=1_0xH0001=2", "");
|
|
390
|
+
|
|
391
|
+
/* cannot determine AddSource conflicts */
|
|
392
|
+
TEST_PARAMS2(test_validate_trigger, "d0xH1234>0_A:0xH2345_0>d0xH1234", "");
|
|
393
|
+
|
|
394
|
+
/* AndNext conflicts are limited to matching the last condition after exactly matching the others */
|
|
395
|
+
TEST_PARAMS2(test_validate_trigger, "N:0xH0000=1_0xH0001=1_N:0xH0000=2_0xH0001=2", "");
|
|
396
|
+
TEST_PARAMS2(test_validate_trigger, "N:0xH0000=1_0xH0001=1_N:0xH0000=2_0xH0001=1", ""); /* technically conflicting, but hard to detect */
|
|
397
|
+
TEST_PARAMS2(test_validate_trigger, "N:0xH0000=1_0xH0001=1_N:0xH0000=1_0xH0001=2", "Condition 4: Conflicts with Condition 2");
|
|
398
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=0_N:0xH0000!=0_0xH0000=2", "");
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
void test_redundant_conditions() {
|
|
402
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1_0xH0000=1", "Condition 2: Redundant with Condition 1");
|
|
403
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<3_0xH0000<5", "Condition 2: Redundant with Condition 1");
|
|
404
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<5_0xH0000<3", "Condition 1: Redundant with Condition 2");
|
|
405
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1S0xH0000=1", "Alt1 Condition 1: Redundant with Core Condition 1");
|
|
406
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1_0xH0000!=1", "Condition 2: Redundant with Condition 1");
|
|
407
|
+
TEST_PARAMS2(test_validate_trigger, "0x 0001=50.1._0x 0000>=300_R:0x 0000<2", ""); /* ResetIf not redundant if hit target available */
|
|
408
|
+
TEST_PARAMS2(test_validate_trigger, "0x 0001=50.1._R:0x 0000>=300_R:0x 0000<2", "");
|
|
409
|
+
TEST_PARAMS2(test_validate_trigger, "0x 0001=50.1._R:0x 0000<300_R:0x 0000<2", "Condition 2: Redundant with Condition 3");
|
|
410
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1_P:0xH0000!=1", "Condition 2: Redundant with Condition 1");
|
|
411
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000!=1S0xH0000!=1", "Alt1 Condition 1: Redundant with Core Condition 1");
|
|
412
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1S0xH0000=1", "Alt1 Condition 1: Redundant with Core Condition 1");
|
|
413
|
+
TEST_PARAMS2(test_validate_trigger, "P:0xH0000=1SP:0xH0000=1", ""); /* same pauseif can appear in different groups */
|
|
414
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=4.1._0xH0000=5_P:0xH0000<4", "");
|
|
415
|
+
TEST_PARAMS2(test_validate_trigger, "Q:0xH0000=5_Q:0xH0000!=255_M:0xH0001=1", "Condition 2: Redundant with Condition 1");
|
|
416
|
+
TEST_PARAMS2(test_validate_trigger, "M:0xH0000=5_Q:0xH0000!=255", ""); /* measuredif not redundant measured */
|
|
417
|
+
TEST_PARAMS2(test_validate_trigger, "Q:0xH0000=1_0xH0000=1_M:0xH0001=1", "Condition 2: Redundant with Condition 1");
|
|
418
|
+
TEST_PARAMS2(test_validate_trigger, "Q:0xH0000=1_Q:0xH0000=1_M:0xH0001=1", "Condition 2: Redundant with Condition 1");
|
|
419
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_Q:0xH0000=1_A:0xX0004_Q:0xH0000=1_M:0xH0001=1", "Condition 4: Redundant with Condition 2");
|
|
420
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_Q:0xH0000=1_A:0xX0004_0xH0000=1_M:0xH0001=1", "Condition 4: Redundant with Condition 2");
|
|
421
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_0xH0000=1_A:0xX0004_Q:0xH0000=1_M:0xH0001=1", "Condition 2: Redundant with Condition 4");
|
|
422
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_Q:0xH0000=1_A:0xX0005_Q:0xH0000=1_M:0xH0001=1", ""); /* different chains */
|
|
423
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_Q:0xH0000=1_A:0x 0004_Q:0xH0000=1_M:0xH0001=1", ""); /* different sizes */
|
|
424
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_Q:0xH0000=1_A:0xX0004_Q:0xH0000=1_M:0xH0001=1", "Condition 4: Redundant with Condition 2");
|
|
425
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_A:0xX0008_Q:0xH0000=1_A:0xX0004_Q:0xH0000=1_M:0xH0001=1", ""); /* longer first chain */
|
|
426
|
+
TEST_PARAMS2(test_validate_trigger, "A:0xX0004_Q:0xH0000=1_A:0xX0004_A:0xX0008_Q:0xH0000=1_M:0xH0001=1", ""); /* longer second chain */
|
|
427
|
+
TEST_PARAMS2(test_validate_trigger, "Q:0xH0000=1_M:0xH0001=1SQ:0xH0000=1_M:0xH0002=1", ""); /* same measuredif can appear in different groups */
|
|
428
|
+
TEST_PARAMS2(test_validate_trigger, "T:0xH0000!=0_T:0xH0000=6", "Condition 1: Redundant with Condition 2");
|
|
429
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000!=0_T:0xH0000=6", ""); /* trigger more restrictive than non-trigger */
|
|
430
|
+
TEST_PARAMS2(test_validate_trigger, "T:0xH0000!=0_0xH0000=6", "Condition 1: Redundant with Condition 2"); /* trigger less restrictive than non-trigger */
|
|
431
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=6_T:0xH0000=6", "Condition 2: Redundant with Condition 1"); /* trigger same as non-trigger */
|
|
432
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1_Q:0xH0000=1_M:0xH0001=1", "Condition 1: Redundant with Condition 2");
|
|
433
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000=1S0xH0000!=0S0xH0001=2", "Alt1 Condition 1: Redundant with Core Condition 1");
|
|
434
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000!=0S0xH0000=1S0xH0001=2", ""); /* more restrictive alt 1 is not redundant with core */
|
|
435
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000!=0S0xH0000!=0S0xH0001=2", "Alt1 Condition 1: Redundant with Core Condition 1");
|
|
436
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0000<10_N:0xH0001=2_0xH0000<20", ""); /* AndNext should prevent condition 3 being compared directly to condition 1 */
|
|
437
|
+
TEST_PARAMS2(test_validate_trigger, "0xH0001=7.1._R:0xH0000=0_T:0xH0000=1", "");
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
void test_resetif_hittargets() {
|
|
441
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=0", "Condition 1: No captured hits to reset");
|
|
442
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=0_0xH0001=1.1.", "");
|
|
443
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=0_M:0xH0001=1.1.", "");
|
|
444
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=0.1._0xH0001=1.1.", "Condition 1: Hit target of 1 is redundant on ResetIf");
|
|
445
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=0.2._0xH0001=1.1.", "");
|
|
446
|
+
TEST_PARAMS2(test_validate_trigger, "I:0xG1234&536870911_R:0xG0000=4294967294_0xH2222=1.1.", "");
|
|
447
|
+
TEST_PARAMS2(test_validate_trigger, "N:0xH0001=4.1._T:0xH0001=5_R:0xH0001<2", "");
|
|
448
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH0000!=0S0xH0001=1.1.S0xH0002=1", "");
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
void test_variable_operand_errors() {
|
|
452
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{thingy}", "Unknown variable name"); /* variable that does not exist */
|
|
453
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{th$ingy}", "Invalid variable name"); /* separator in name */
|
|
454
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{th*ingy}", "Invalid variable name"); /* invalid character in name */
|
|
455
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{2things}", "Invalid variable name"); /* variable name begins with number*/
|
|
456
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{recall_P:0xH01=18", "Invalid variable name"); /* missing closing curly brace */
|
|
457
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{thisvariablenameistoolong}_P:0xH01=18", "Invalid variable name"); /*too long */
|
|
458
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{}_P:0xH01=18", "Invalid variable name"); /* no name */
|
|
459
|
+
TEST_PARAMS2(test_validate_trigger, "K:4_M:{recall}=4", ""); /* recognized as recall operand */
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
void test_remember_recall_errors() {
|
|
463
|
+
TEST_PARAMS2(test_validate_trigger, "{recall}=5", "Condition 1: Recall used without Remember"); /* No value ever remembered */
|
|
464
|
+
TEST_PARAMS2(test_validate_trigger, "{recall}=5_K:0xH1234&1023_K:{recall}*8_{recall}=100", "Condition 1: Recall used before Remember"); /* First remember is after first recall. */
|
|
465
|
+
TEST_PARAMS2(test_validate_trigger, "K:0xH1234&1023_K:{recall}*8_{recall}=100", ""); /* Recall used after Remember */
|
|
466
|
+
TEST_PARAMS2(test_validate_trigger, "{recall}=5_K:0xH1234*2_P:{recall}>6", ""); /* Remember sets recall in pause - no warning */
|
|
467
|
+
TEST_PARAMS2(test_validate_trigger, "K:0xH1234*2_{recall}=5_P:{recall}>6", "Condition 3: PauseIf cannot use Remembered value not associated to PauseIf chain"); /* Pause evaluated before value is remembered. */
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
void test_error_priorities() {
|
|
471
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH1234=1_0xH2345=500", "Condition 2: Comparison is never true (max 255)"); /* impossible condition more important than unnecessary reset */
|
|
472
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234>5_0xH1234!=0_A:0xH2345", "Condition 3: AddSource condition type expects another condition to follow"); /* impotent condition more important than redundant */
|
|
473
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234!=d0x 1234_I:d0x2345_0=6", "Condition 2: Using pointer from previous frame"); /* pointer math more important that potential logic errors */
|
|
474
|
+
TEST_PARAMS2(test_validate_trigger, "R:0xH1234=1.1.S0xH2345=500", "Alt1 Condition 1: Comparison is never true (max 255)"); /* impossible condition in alt more important than redundant condition in core */
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
void test_rc_validate(void) {
|
|
478
|
+
TEST_SUITE_BEGIN();
|
|
479
|
+
|
|
480
|
+
/* positive baseline test cases */
|
|
481
|
+
TEST_PARAMS2(test_validate_trigger, "", "");
|
|
482
|
+
TEST_PARAMS2(test_validate_trigger, "0xH1234=1_0xH2345=2S0xH3456=1S0xH3456=2", "");
|
|
483
|
+
TEST_PARAMS2(test_validate_trigger, "S0xH3456=1S0xH3456=2", ""); /* empty core */
|
|
484
|
+
|
|
485
|
+
test_combining_conditions_at_end_of_definition();
|
|
486
|
+
test_addhits_chain_without_target();
|
|
487
|
+
test_range_comparisons();
|
|
488
|
+
test_size_comparisons();
|
|
489
|
+
test_address_range();
|
|
490
|
+
test_delta_pointers();
|
|
491
|
+
test_nonsized_pointers();
|
|
492
|
+
test_float_comparisons();
|
|
493
|
+
test_dependent_conditions();
|
|
494
|
+
test_conflicting_conditions();
|
|
495
|
+
test_redundant_conditions();
|
|
496
|
+
test_resetif_hittargets();
|
|
497
|
+
test_variable_operand_errors();
|
|
498
|
+
test_remember_recall_errors();
|
|
499
|
+
test_error_priorities();
|
|
500
|
+
|
|
501
|
+
TEST_SUITE_END();
|
|
502
|
+
}
|