Run Benchmark During CI Test

This commit is contained in:
TheBrokenRail 2022-07-08 13:57:48 -04:00
parent 484d3e7f90
commit 3c1bce876c
5 changed files with 72 additions and 16 deletions

View File

@ -14,6 +14,9 @@ TRUE This Flag Is On By Default
FALSE This Flag Is Off By Default FALSE This Flag Is Off By Default
``` ```
### ``--default`` (Client Mode Only)
If you run MCPI-Reborn with ``--default``, it will skip the startup configuration dialogs and just use the default values.
### ``--only-generate`` (Server Mode Only) ### ``--only-generate`` (Server Mode Only)
If you run MCPI-Reborn with ``--only-generate``, it will immediately exit once world generation has completed. This is mainly used for automatically testing MCPI-Reborn. If you run MCPI-Reborn with ``--only-generate``, it will immediately exit once world generation has completed. This is mainly used for automatically testing MCPI-Reborn.
@ -25,18 +28,18 @@ The world used will always be re-created on start and uses a hard-coded seed.
## Environmental Variables ## Environmental Variables
### ``MCPI_DEBUG`` ### ``MCPI_DEBUG``
This enables debug logging if you set it to any non-zero-length value. This enables debug logging if it is set.
### Client Mode Only ### Client Mode Only
If a value isn't set for any of the following variables, a GUI will open that allows you to select one. If any of the following variables aren't set, one configuration dialog will open on startup for each unset variable.
### ``MCPI_FEATURE_FLAGS`` #### ``MCPI_FEATURE_FLAGS``
This corresponds to ``--print-available-feature-flags``. This is just a list of all enabled feature flags separated by ``|``. This corresponds to ``--print-available-feature-flags``. This is just a list of all enabled feature flags separated by ``|``.
For instance, the string ``Feature A|Feature B`` would enable both ``Feature A`` and ``Feature B`` and *disable every other available feature flag*. For instance, the string ``Feature A|Feature B`` would enable both ``Feature A`` and ``Feature B`` and *disable every other available feature flag*.
### ``MCPI_RENDER_DISTANCE`` #### ``MCPI_RENDER_DISTANCE``
This is the render distance. The possible values are: ``Far``, ``Normal``, ``Short``, and ``Tiny``. This is the render distance. The possible values are: ``Far``, ``Normal``, ``Short``, and ``Tiny``.
### ``MCPI_USERNAME`` #### ``MCPI_USERNAME``
This is the username. This is the username.

View File

@ -126,6 +126,20 @@ static void run_zenity_and_set_env(const char *env_name, std::vector<std::string
run_command_and_set_env(env_name, full_command_array); run_command_and_set_env(env_name, full_command_array);
} }
// Set Variable If Not Already Set
static void set_env_if_unset(const char *env_name, std::function<std::string()> callback) {
if (getenv(env_name) == NULL) {
char *value = strdup(callback().c_str());
ALLOC_CHECK(value);
set_and_print_env(env_name, value);
free(value);
}
}
// Defaults
#define DEFAULT_USERNAME "StevePi"
#define DEFAULT_RENDER_DISTANCE "Short"
// Launch // Launch
#define LIST_DIALOG_SIZE "400" #define LIST_DIALOG_SIZE "400"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -149,6 +163,37 @@ int main(int argc, char *argv[]) {
} }
} }
// --default
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--default") == 0) {
// Use Default Feature Flags
set_env_if_unset("MCPI_FEATURE_FLAGS", []() {
std::string feature_flags = "";
load_available_feature_flags([&feature_flags](std::string flag) {
bool default_value;
// Strip Default Value
std::string stripped_flag = strip_feature_flag_default(flag, &default_value);
// Specify Default Value
if (default_value) {
// Enabled By Default
feature_flags += stripped_flag + '|';
}
});
if (feature_flags.length() > 0 && feature_flags[feature_flags.length() - 1] == '|') {
feature_flags.pop_back();
}
return feature_flags;
});
set_env_if_unset("MCPI_RENDER_DISTANCE", []() {
return DEFAULT_RENDER_DISTANCE;
});
set_env_if_unset("MCPI_USERNAME", []() {
return DEFAULT_USERNAME;
});
break;
}
}
// Create ~/.minecraft-pi If Needed // Create ~/.minecraft-pi If Needed
// Minecraft Folder // Minecraft Folder
{ {
@ -215,14 +260,11 @@ int main(int argc, char *argv[]) {
command.push_back("Selected"); command.push_back("Selected");
command.push_back("--column"); command.push_back("--column");
command.push_back("Name"); command.push_back("Name");
command.push_back("FALSE"); std::string render_distances[] = {"Far", "Normal", "Short", "Tiny"};
command.push_back("Far"); for (std::string &render_distance : render_distances) {
command.push_back("FALSE"); command.push_back(render_distance.compare(DEFAULT_RENDER_DISTANCE) == 0 ? "TRUE" : "FALSE");
command.push_back("Normal"); command.push_back(render_distance);
command.push_back("TRUE"); }
command.push_back("Short");
command.push_back("FALSE");
command.push_back("Tiny");
// Run // Run
run_zenity_and_set_env("MCPI_RENDER_DISTANCE", command); run_zenity_and_set_env("MCPI_RENDER_DISTANCE", command);
} }
@ -233,7 +275,7 @@ int main(int argc, char *argv[]) {
command.push_back("--text"); command.push_back("--text");
command.push_back("Enter Minecraft Username:"); command.push_back("Enter Minecraft Username:");
command.push_back("--entry-text"); command.push_back("--entry-text");
command.push_back("StevePi"); command.push_back(DEFAULT_USERNAME);
// Run // Run
run_zenity_and_set_env("MCPI_USERNAME", command); run_zenity_and_set_env("MCPI_USERNAME", command);
} }

View File

@ -6,6 +6,6 @@
// Logging // Logging
#define INFO(format, ...) { fprintf(stderr, "[INFO]: " format "\n", ##__VA_ARGS__); } #define INFO(format, ...) { fprintf(stderr, "[INFO]: " format "\n", ##__VA_ARGS__); }
#define WARN(format, ...) { fprintf(stderr, "[WARN]: " format "\n", ##__VA_ARGS__); } #define WARN(format, ...) { fprintf(stderr, "[WARN]: " format "\n", ##__VA_ARGS__); }
#define DEBUG(format, ...) { const char *debug = getenv("MCPI_DEBUG"); if (debug != NULL && strlen(debug) > 0) { fprintf(stderr, "[DEBUG]: " format "\n", ##__VA_ARGS__); } } #define DEBUG(format, ...) { const char *debug = getenv("MCPI_DEBUG"); if (debug != NULL) { fprintf(stderr, "[DEBUG]: " format "\n", ##__VA_ARGS__); } }
#define ERR(format, ...) { fprintf(stderr, "[ERR]: (%s:%i): " format "\n", __FILE__, __LINE__, ##__VA_ARGS__); exit(EXIT_FAILURE); } #define ERR(format, ...) { fprintf(stderr, "[ERR]: (%s:%i): " format "\n", __FILE__, __LINE__, ##__VA_ARGS__); exit(EXIT_FAILURE); }
#define IMPOSSIBLE() ERR("This Should Never Be Called") #define IMPOSSIBLE() ERR("This Should Never Be Called")

@ -1 +1 @@
Subproject commit da6713cd096a40a4512f468b34c189017e73f987 Subproject commit 84e165ef64ce117c5f1fa99b607f5bd143973e65

View File

@ -17,3 +17,14 @@ mkdir -p build/test
# Run Test # Run Test
cd build/test cd build/test
minecraft-pi-reborn-server --only-generate minecraft-pi-reborn-server --only-generate
cd ../../
# Build Benchmark
./scripts/setup.sh client "${ARCH}" -DMCPI_HEADLESS_MODE=ON
./scripts/build.sh client "${ARCH}"
# Add minecraft-pi-reborn-server To PATH
export PATH="$(pwd)/out/client-$(dpkg-architecture -qDEB_BUILD_ARCH)/usr/bin:${PATH}"
# Run Benchmark
minecraft-pi-reborn-client --default --benchmark