Reject incomplete thread streams
This commit is contained in:
parent
6a595fff0b
commit
2bf739efed
@ -113,6 +113,26 @@ load_obs(struct stream *stream, const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
check_version(JSON_Object *meta)
|
||||
{
|
||||
JSON_Value *version_val = json_object_get_value(meta, "version");
|
||||
if (version_val == NULL) {
|
||||
err("missing attribute \"version\"");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int version = (int) json_number(version_val);
|
||||
|
||||
if (version != OVNI_METADATA_VERSION) {
|
||||
err("metadata version mismatch %d (expected %d)",
|
||||
version, OVNI_METADATA_VERSION);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static JSON_Object *
|
||||
load_json(const char *path)
|
||||
{
|
||||
@ -129,6 +149,10 @@ load_json(const char *path)
|
||||
}
|
||||
|
||||
/* TODO: Check version */
|
||||
if (check_version(meta) != 0) {
|
||||
err("check_version failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
@ -417,8 +417,10 @@ thread_load_metadata(struct thread *thread, struct stream *s)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (json_object_dotget_number(meta, "ovni.finished") != 1)
|
||||
warn("thread didn't finish properly: %s", thread->id);
|
||||
if (json_object_dotget_number(meta, "ovni.finished") != 1) {
|
||||
err("missing ovni.finished: %s", s->relpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
thread->meta = meta;
|
||||
|
||||
|
@ -18,11 +18,11 @@ test_emu(no-cpus.c SHOULD_FAIL REGEX "loom .* has no physical CPUs")
|
||||
test_emu(sort-cpus-by-loom.c MP)
|
||||
test_emu(sort-cpus-by-rank.c MP)
|
||||
test_emu(tracedir-subdir.c MP DRIVER "tracedir-subdir.driver.sh")
|
||||
test_emu(empty-stream.c SHOULD_FAIL REGEX "model_ovni_finish: thread .* is not dead")
|
||||
test_emu(empty-stream.c SHOULD_FAIL REGEX "missing ovni.finished")
|
||||
test_emu(require-bad-version.c SHOULD_FAIL REGEX "unsupported ovni model version (want 666.66.6, have .*)")
|
||||
test_emu(require-compat.c REGEX "loading trace in compatibility mode")
|
||||
test_emu(require-repeated.c)
|
||||
test_emu(thread-crash.c SHOULD_FAIL REGEX "incomplete stream")
|
||||
test_emu(thread-crash.c SHOULD_FAIL REGEX "missing ovni.finished")
|
||||
test_emu(thread-free-isready.c)
|
||||
test_emu(flush-tmpdir.c MP DRIVER "flush-tmpdir.driver.sh")
|
||||
test_emu(tmpdir-metadata.c MP DRIVER "tmpdir-metadata.driver.sh")
|
||||
|
Loading…
Reference in New Issue
Block a user