From 0f7ccc89def748efa5ef6d5083b245386c125df8 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 11 Dec 2023 12:56:07 +0100 Subject: [PATCH] Add -a flag in ovniemu to enable all models The experimental flag -a is used to ease the transition to the usage of ovni_thread_require(), as it may be posible to have traces in which not all libraries have requested their model. The flag causes all emulation models to be enabled. This flag is considered experimental and it may be removed or renamed in future versions. --- CHANGELOG.md | 1 + src/emu/emu_args.c | 9 +++++++-- src/emu/emu_args.h | 1 + src/emu/model.c | 8 ++++++-- test/emu/nosv/CMakeLists.txt | 4 ++++ test/emu/nosv/flag-enable-all.driver.sh | 4 ++++ 6 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 test/emu/nosv/flag-enable-all.driver.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 8333977..df64be2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Streams are marked as finished when `ovni_thread_free()` is called. A warning is emitted in the emulator for those streams that are not finished properly. - List the emulation models and versions with `ovniemu -h` +- New `-a` ovniemu option to enable all models ### Changed diff --git a/src/emu/emu_args.c b/src/emu/emu_args.c index daecbe9..21fafe5 100644 --- a/src/emu/emu_args.c +++ b/src/emu/emu_args.c @@ -19,13 +19,15 @@ usage(void) { rerr("%s -- version %s\n", progname, version); rerr("\n"); - rerr("Usage: %s [-c offsetfile] [-bdlh] tracedir\n", progname); + rerr("Usage: %s [-c offsetfile] [-abdlh] tracedir\n", progname); rerr("\n"); rerr("Options:\n"); rerr(" -c offsetfile Use the given offset file to correct\n"); rerr(" the clocks among nodes. It can be\n"); rerr(" generated by the ovnisync program\n"); rerr("\n"); + rerr(" -a Enable all models (experimental)\n"); + rerr("\n"); rerr(" -b Enable breakdown model (experimental)\n"); rerr("\n"); rerr(" -d Enable debug output (very verbose)\n"); @@ -51,7 +53,7 @@ emu_args_init(struct emu_args *args, int argc, char *argv[]) memset(args, 0, sizeof(struct emu_args)); int opt; - while ((opt = getopt(argc, argv, "bdc:lh")) != -1) { + while ((opt = getopt(argc, argv, "abdc:lh")) != -1) { switch (opt) { case 'c': args->clock_offset_file = optarg; @@ -59,6 +61,9 @@ emu_args_init(struct emu_args *args, int argc, char *argv[]) case 'l': args->linter_mode = 1; break; + case 'a': + args->enable_all_models = 1; + break; case 'b': args->breakdown = 1; break; diff --git a/src/emu/emu_args.h b/src/emu/emu_args.h index f2267d6..87b43d5 100644 --- a/src/emu/emu_args.h +++ b/src/emu/emu_args.h @@ -7,6 +7,7 @@ struct emu_args { int linter_mode; int breakdown; + int enable_all_models; char *clock_offset_file; char *tracedir; }; diff --git a/src/emu/model.c b/src/emu/model.c index cbff52c..7e053d3 100644 --- a/src/emu/model.c +++ b/src/emu/model.c @@ -6,6 +6,7 @@ #include "common.h" #include "version.h" #include "emu.h" +#include "emu_args.h" #include "thread.h" #include "proc.h" @@ -61,7 +62,7 @@ model_probe(struct model *model, struct emu *emu) } /* Zero is disabled */ - if (ret > 0) { + if (ret > 0 || emu->args.enable_all_models) { model->enabled[i] = 1; nenabled++; } @@ -70,7 +71,10 @@ model_probe(struct model *model, struct emu *emu) if (nenabled == 0) { warn("no models enabled"); } else { - info("the following %d models are enabled: ", nenabled); + if (emu->args.enable_all_models) + info("all %d models are enabled (-a): ", nenabled); + else + info("the following %d models are enabled: ", nenabled); for (int i = 0; i < MAX_MODELS; i++) { if (!model->enabled[i]) continue; diff --git a/test/emu/nosv/CMakeLists.txt b/test/emu/nosv/CMakeLists.txt index 4e39fca..f65bb8b 100644 --- a/test/emu/nosv/CMakeLists.txt +++ b/test/emu/nosv/CMakeLists.txt @@ -13,3 +13,7 @@ test_emu(task-pause-from-submit.c) test_emu(same-subsystem.c) test_emu(require-missing.c SHOULD_FAIL REGEX "model nosv not enabled for event") +test_emu(require-missing.c + NAME flag-enable-all + DRIVER "flag-enable-all.driver.sh" + REGEX "all .* models are enabled") diff --git a/test/emu/nosv/flag-enable-all.driver.sh b/test/emu/nosv/flag-enable-all.driver.sh new file mode 100644 index 0000000..4067238 --- /dev/null +++ b/test/emu/nosv/flag-enable-all.driver.sh @@ -0,0 +1,4 @@ +# Test the -a flag with a program that doesn't enable the required models for +# the events in the stream. +$OVNI_TEST_BIN +ovniemu -a ovni