Merge topic 'instrumentation-snippet-names'

39f365ec3c instrumentation: Unique snippet file names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10491
This commit is contained in:
Brad King 2025-03-19 13:05:25 +00:00 committed by Kitware Robot
commit deb44bdf73
3 changed files with 29 additions and 19 deletions

View File

@ -236,11 +236,11 @@ Example:
}
In this example, after every ``cmake --build`` or ``cmake --install``
invocation, an index file ``index-<hash>.json`` will be generated in
invocation, an index file ``index-<timestamp>.json`` will be generated in
``<build>/.cmake/instrumentation/v1/data`` containing a list of data snippet
files created since the previous indexing. The commands
``/usr/bin/python callback.py index-<hash>.json`` and
``/usr/bin/cmake -P callback.cmake arg index-<hash>.json`` will be executed in
``/usr/bin/python callback.py index-<timestamp>.json`` and
``/usr/bin/cmake -P callback.cmake arg index-<timestamp>.json`` will be executed in
that order. The index file will contain the ``staticSystemInformation`` data and
each snippet file listed in the index will contain the
``dynamicSystemInformation`` data. Once both callbacks have completed, the index
@ -275,7 +275,7 @@ the command executed. Additionally, snippet files are created for the following:
These files remain in the build tree until after `Indexing`_ occurs and any
user-specified `Callbacks`_ are executed.
Snippet files have a filename with the syntax ``<role>-<timestamp>-<hash>.json``
Snippet files have a filename with the syntax ``<role>-<hash>-<timestamp>.json``
and contain the following data:
``version``
@ -285,6 +285,9 @@ and contain the following data:
``command``
The full command executed. Excluded when ``role`` is ``build``.
``workingDir``
The working directory in which the ``command`` was executed.
``result``
The exit-value of the command, an integer.
@ -450,14 +453,14 @@ Example:
"buildDir": "<build>",
"dataDir": "<build>/.cmake/instrumentation/v1/data",
"snippets": [
"configure-<timestamp>-<hash>.json",
"generate-<timestamp>-<hash>.json",
"compile-<timestamp>-<hash>.json",
"compile-<timestamp>-<hash>.json",
"link-<timestamp>-<hash>.json",
"install-<timestamp>-<hash>.json",
"ctest-<timestamp>-<hash>.json",
"test-<timestamp>-<hash>.json",
"test-<timestamp>-<hash>.json",
"configure-<hash>-<timestamp>.json",
"generate-<hash>-<timestamp>.json",
"compile-<hash>-<timestamp>.json",
"compile-<hash>-<timestamp>.json",
"link-<hash>-<timestamp>.json",
"install-<hash>-<timestamp>.json",
"ctest-<hash>-<timestamp>.json",
"test-<hash>-<timestamp>.json",
"test-<hash>-<timestamp>.json",
]
}

View File

@ -409,6 +409,7 @@ std::string cmInstrumentation::InstrumentTest(
root["testName"] = name;
root["result"] = static_cast<Json::Value::Int64>(result);
root["config"] = config;
root["workingDir"] = cmSystemTools::GetLogicalWorkingDirectory();
// Post-Command
this->InsertTimingData(root, steadyStart, systemStart);
@ -417,9 +418,11 @@ std::string cmInstrumentation::InstrumentTest(
this->InsertDynamicSystemInformation(root, "after");
}
std::string file_name =
cmStrCat("test-", this->ComputeSuffixHash(command_str),
this->ComputeSuffixTime(), ".json");
cmsys::SystemInformation info;
std::string file_name = cmStrCat(
"test-",
this->ComputeSuffixHash(cmStrCat(command_str, info.GetProcessId())),
this->ComputeSuffixTime(), ".json");
this->WriteInstrumentationJson(root, "data", file_name);
return file_name;
}
@ -534,11 +537,14 @@ int cmInstrumentation::InstrumentCommand(
}
}
root["role"] = command_type;
root["workingDir"] = cmSystemTools::GetLogicalWorkingDirectory();
// Write Json
std::string const& file_name =
cmStrCat(command_type, "-", this->ComputeSuffixHash(command_str),
this->ComputeSuffixTime(), ".json");
cmsys::SystemInformation info;
std::string const& file_name = cmStrCat(
command_type, "-",
this->ComputeSuffixHash(cmStrCat(command_str, info.GetProcessId())),
this->ComputeSuffixTime(), ".json");
this->WriteInstrumentationJson(root, "data", file_name);
return ret;
}

View File

@ -31,6 +31,7 @@ function(snippet_has_fields snippet contents)
get_filename_component(filename "${snippet}" NAME)
has_key("${snippet}" "${contents}" role)
has_key("${snippet}" "${contents}" result)
has_key("${snippet}" "${contents}" workingDir)
if (NOT filename MATCHES "^build-*")
has_key("${snippet}" "${contents}" command)
endif()