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.
This commit is contained in:
Rodrigo Arias 2023-12-11 12:56:07 +01:00
parent 998200d507
commit 0f7ccc89de
6 changed files with 23 additions and 4 deletions

View File

@ -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 - 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. is emitted in the emulator for those streams that are not finished properly.
- List the emulation models and versions with `ovniemu -h` - List the emulation models and versions with `ovniemu -h`
- New `-a` ovniemu option to enable all models
### Changed ### Changed

View File

@ -19,13 +19,15 @@ usage(void)
{ {
rerr("%s -- version %s\n", progname, version); rerr("%s -- version %s\n", progname, version);
rerr("\n"); rerr("\n");
rerr("Usage: %s [-c offsetfile] [-bdlh] tracedir\n", progname); rerr("Usage: %s [-c offsetfile] [-abdlh] tracedir\n", progname);
rerr("\n"); rerr("\n");
rerr("Options:\n"); rerr("Options:\n");
rerr(" -c offsetfile Use the given offset file to correct\n"); rerr(" -c offsetfile Use the given offset file to correct\n");
rerr(" the clocks among nodes. It can be\n"); rerr(" the clocks among nodes. It can be\n");
rerr(" generated by the ovnisync program\n"); rerr(" generated by the ovnisync program\n");
rerr("\n"); rerr("\n");
rerr(" -a Enable all models (experimental)\n");
rerr("\n");
rerr(" -b Enable breakdown model (experimental)\n"); rerr(" -b Enable breakdown model (experimental)\n");
rerr("\n"); rerr("\n");
rerr(" -d Enable debug output (very verbose)\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)); memset(args, 0, sizeof(struct emu_args));
int opt; int opt;
while ((opt = getopt(argc, argv, "bdc:lh")) != -1) { while ((opt = getopt(argc, argv, "abdc:lh")) != -1) {
switch (opt) { switch (opt) {
case 'c': case 'c':
args->clock_offset_file = optarg; args->clock_offset_file = optarg;
@ -59,6 +61,9 @@ emu_args_init(struct emu_args *args, int argc, char *argv[])
case 'l': case 'l':
args->linter_mode = 1; args->linter_mode = 1;
break; break;
case 'a':
args->enable_all_models = 1;
break;
case 'b': case 'b':
args->breakdown = 1; args->breakdown = 1;
break; break;

View File

@ -7,6 +7,7 @@
struct emu_args { struct emu_args {
int linter_mode; int linter_mode;
int breakdown; int breakdown;
int enable_all_models;
char *clock_offset_file; char *clock_offset_file;
char *tracedir; char *tracedir;
}; };

View File

@ -6,6 +6,7 @@
#include "common.h" #include "common.h"
#include "version.h" #include "version.h"
#include "emu.h" #include "emu.h"
#include "emu_args.h"
#include "thread.h" #include "thread.h"
#include "proc.h" #include "proc.h"
@ -61,7 +62,7 @@ model_probe(struct model *model, struct emu *emu)
} }
/* Zero is disabled */ /* Zero is disabled */
if (ret > 0) { if (ret > 0 || emu->args.enable_all_models) {
model->enabled[i] = 1; model->enabled[i] = 1;
nenabled++; nenabled++;
} }
@ -70,7 +71,10 @@ model_probe(struct model *model, struct emu *emu)
if (nenabled == 0) { if (nenabled == 0) {
warn("no models enabled"); warn("no models enabled");
} else { } 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++) { for (int i = 0; i < MAX_MODELS; i++) {
if (!model->enabled[i]) if (!model->enabled[i])
continue; continue;

View File

@ -13,3 +13,7 @@ test_emu(task-pause-from-submit.c)
test_emu(same-subsystem.c) test_emu(same-subsystem.c)
test_emu(require-missing.c SHOULD_FAIL test_emu(require-missing.c SHOULD_FAIL
REGEX "model nosv not enabled for event") 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")

View File

@ -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