@@ -23,6 +23,7 @@ SRC_URI = "\
file://cpp-example.service \
file://cpp-example.init \
file://.clang-format \
+ file://.clang-tidy \
file://run-ptest \
"
new file mode 100644
@@ -0,0 +1,33 @@
+---
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+Checks: >
+ -*,
+ bugprone-*,
+ -bugprone-easily-swappable-parameters,
+ clang-analyzer-*,
+ modernize-*,
+ -modernize-use-trailing-return-type,
+ performance-*,
+ -performance-avoid-endl,
+ readability-*,
+ -readability-magic-numbers,
+ -readability-identifier-length,
+ -readability-implicit-bool-conversion,
+ -readability-convert-member-functions-to-static,
+ -readability-isolate-declaration
+
+WarningsAsErrors: ''
+HeaderFilterRegex: '.*'
+FormatStyle: file
+
+CheckOptions:
+ - key: readability-identifier-naming.VariableCase
+ value: lower_case
+ - key: readability-identifier-naming.FunctionCase
+ value: lower_case
+ - key: readability-identifier-naming.StructCase
+ value: CamelCase
+ - key: readability-identifier-naming.ClassCase
+ value: CamelCase
@@ -12,13 +12,14 @@
struct CppExample
{
+ // NOLINTNEXTLINE(bugprone-throwing-static-initialization) -- exercises debugger handling of a lazy-init static member, see devtool ide-sdk tests
inline static const std::string test_string = "cpp-example-lib Magic: 123456789";
/* Header-only function, to exercise breakpoint resolution against
* header-only debug info. volatile prevents compiler optimization from
* eliminating the function body, ensuring a concrete code location exists
* for debugger breakpoints. */
- inline static int scale_number(int n)
+ static int scale_number(int n)
{
volatile int scaled = n * 7;
std::cout << "scale_number(" << n << ") = " << scaled << std::endl;
@@ -113,6 +113,7 @@ int main(int argc, char *argv[])
log_info(std::string("Linking json-c version ") + cpp_example.get_json_c_version());
cpp_example.print_json();
+ // NOLINTNEXTLINE(bugprone-infinite-loop) -- intentionally endless when requested; stopped externally (e.g. systemd stop/SIGTERM)
do {
// Read and print message from config file
std::string config_message = cpp_example.read_config_message();
@@ -17,7 +17,7 @@ int main()
{
auto cpp_example = CppExample();
auto ret_string = cpp_example.get_string();
- if (0 == ret_string.compare(CppExample::test_string + FAIL_COMPARISON_STR)) {
+ if (ret_string == CppExample::test_string + FAIL_COMPARISON_STR) {
std::cout << "PASS: " << ret_string << " = " << CppExample::test_string << std::endl;
} else {
std::cout << "FAIL: " << ret_string << " != " << CppExample::test_string << std::endl;
@@ -3312,8 +3312,8 @@ class DevtoolIdeSdkTests(DevtoolBase):
cpp_code = file.read()
cpp_code = cpp_code.replace(DevtoolIdeSdkTests.MAGIC_STRING_ORIG, MAGIC_STRING_NEW)
cpp_code = cpp_code.replace(
- " inline static int scale_number(int n)",
- extra_lines + " inline static int scale_number(int n)")
+ " static int scale_number(int n)",
+ extra_lines + " static int scale_number(int n)")
with open(cpp_example_lib_hpp, 'w') as file:
file.write(cpp_code)
@@ -3362,8 +3362,8 @@ class DevtoolIdeSdkTests(DevtoolBase):
# the first _gdb_cross_debugging_multi call above.
self._gdb_cross_debugging_multi(
qemu, recipe_name, example_exe, MAGIC_STRING_NEW,
- exe_break_line=136 + LINE_SHIFT, exe_list_line=128 + LINE_SHIFT,
- hpp_break_line=21 + LINE_SHIFT, lib_break_line=31 + LINE_SHIFT)
+ exe_break_line=136 + LINE_SHIFT, exe_list_line=129 + LINE_SHIFT,
+ hpp_break_line=24 + LINE_SHIFT, lib_break_line=31 + LINE_SHIFT)
def _verify_cmake_preset(self, tempdir):
"""Verify the generated cmake preset works as expected
@@ -3532,14 +3532,14 @@ class DevtoolIdeSdkGccTests(DevtoolIdeSdkTests):
self.assertIn("GNU gdb", r.output)
def _gdb_debug_cpp_example(self, magic_string, gdb_start_cmd="run",
- exe_break_line=136, exe_list_line=128, hpp_break_line=21,
+ exe_break_line=136, exe_list_line=129, hpp_break_line=24,
lib_break_line=31):
"""Get a series of gdb commands to debug the cpp-example-lib example"""
gdb_batch_cmd = " -ex 'break main' -ex '%s'" % gdb_start_cmd
gdb_batch_cmd += " -ex 'break CppExample::print_json()' -ex 'continue'"
gdb_batch_cmd += " -ex 'print CppExample::test_string.compare(\"cpp-example-lib %s\")'" % magic_string
gdb_batch_cmd += " -ex 'print CppExample::test_string.compare(\"cpp-example-lib %saaa\")'" % magic_string
- gdb_batch_cmd += " -ex 'list cpp-example-lib.hpp:15,15'"
+ gdb_batch_cmd += " -ex 'list cpp-example-lib.hpp:16,16'"
# Break inside the library's own .cpp file by file:line (not by
# symbol), while still inside the print_json() call reached above.
@@ -3578,7 +3578,7 @@ class DevtoolIdeSdkGccTests(DevtoolIdeSdkTests):
gdb_batch_cmd += " -ex 'continue'"
return gdb_batch_cmd
- def _gdb_debug_cpp_example_check(self, gdb_output, magic_string, exe_list_line=128, lib_break_line=31):
+ def _gdb_debug_cpp_example_check(self, gdb_output, magic_string, exe_list_line=129, lib_break_line=31):
self.assertIn("Breakpoint 1, main", gdb_output)
self.assertIn("$1 = 0", gdb_output) # test.string.compare equal
self.assertIn("$2 = -3", gdb_output) # test.string.compare longer
@@ -3606,7 +3606,7 @@ class DevtoolIdeSdkGccTests(DevtoolIdeSdkTests):
self.assertIn("exited normally", gdb_output)
def _gdb_cross_debugging_multi(self, qemu, recipe_name, example_exe, magic_string,
- exe_break_line=136, exe_list_line=128, hpp_break_line=21,
+ exe_break_line=136, exe_list_line=129, hpp_break_line=24,
lib_break_line=31):
"""Verify gdb-cross is working
@@ -4814,8 +4814,8 @@ class DevtoolIdeSdkClangTests(DevtoolIdeSdkTests):
cpp_code = file.read()
cpp_code = cpp_code.replace(DevtoolIdeSdkTests.MAGIC_STRING_ORIG, magic_string_new)
cpp_code = cpp_code.replace(
- " inline static int scale_number(int n)",
- extra_lines + " inline static int scale_number(int n)")
+ " static int scale_number(int n)",
+ extra_lines + " static int scale_number(int n)")
with open(cpp_example_lib_hpp, 'w') as file:
file.write(cpp_code)