From 611ac8ce54bac7626e138e3ad2eab923e20f509a Mon Sep 17 00:00:00 2001 From: Ashley Newson Date: Fri, 17 Jan 2025 22:30:11 +0000 Subject: [PATCH] Add fuzzer for map generator testing Adds a fuzzer that iterates through map generation settings combinations to either discover crashes or measure the frequency of rejected maps. All generated maps are in-memory only and discarded immediately after generation. Running the fuzzer on anything other than a small combination of settings is time expensive. It is added only as a utility for manual invocation and is not integrated into the regular set of tests. --- .../MapGenerator/MapGeneratorSettings.cs | 17 + .../FuzzMapGeneratorCommand.cs | 351 ++++++++++++++++++ 2 files changed, 368 insertions(+) create mode 100644 OpenRA.Mods.Common/UtilityCommands/FuzzMapGeneratorCommand.cs diff --git a/OpenRA.Mods.Common/MapGenerator/MapGeneratorSettings.cs b/OpenRA.Mods.Common/MapGenerator/MapGeneratorSettings.cs index 59f917e464..0f9b06697e 100644 --- a/OpenRA.Mods.Common/MapGenerator/MapGeneratorSettings.cs +++ b/OpenRA.Mods.Common/MapGenerator/MapGeneratorSettings.cs @@ -296,6 +296,23 @@ namespace OpenRA.Mods.Common.MapGenerator return Default; } } + + public bool IsFreeform() + { + switch (Ui) + { + case UiType.Hidden: + case UiType.DropDown: + case UiType.Checkbox: + return false; + case UiType.Integer: + case UiType.Float: + case UiType.String: + return true; + default: + throw new InvalidOperationException("Bad UiType"); + } + } } public readonly IReadOnlyList