Настройка проверки Coverity для кодовой базы ArduinoC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Настройка проверки Coverity для кодовой базы Arduino

Сообщение Anonymous »

У нас есть репозиторий, который мы создаем с помощью Arduino IDE, и мы пытаемся настроить проверки Coverity для этого. Я попытался использовать Arduino-Cli для COV-Build со следующим сценарием: < /p>

Код: Выделить всё

def runMISRA():
configurationComplete = 0
tree = ET.parse(report_config_path)
root = tree.getroot()
excluded_directories = []
for member in root.findall('exclude_directory'):
excluded_directories.append(member.text)

for member in root.findall('module'):
cleanupDirectories('out/')
cleanupDirectories(CoverityWorkspace+'/*')

module_name = member.find('name').text
module_paths = []
exclude_files = []
exclude_dirs = []
for mod_path in member.findall('path'):
module_paths.append(mod_path.text)

for excl_pattern in member.findall('exclude_file'):
exclude_files.append(excl_pattern.text)

for excl_pattern in member.findall('exclude_dir'):
exclude_dirs.append(excl_pattern.text)

# Configure Coverity for all possible Arduino compilers
print("Configuring Coverity for Arduino compilers...")
compiler_configurations = [
(f"{AVR_GCC_PATH}/avr-g++", "g++"),
]

for compiler_path_str, comp_type in compiler_configurations:
if os.path.exists(compiler_path_str):
compiler_exe_name = os.path.basename(compiler_path_str)
print(f"Configuring Coverity for: {compiler_exe_name} (from path {compiler_path_str}) with type {comp_type}")
runCmd_CovConfigure = f'{CoverityPath}/bin/cov-configure --compiler {compiler_exe_name} --comptype {comp_type} --template'
process = subprocess.run(runCmd_CovConfigure, shell=True, capture_output=True, text=True)
if process.returncode != 0:
print(f"Warning/Error during cov-configure for {compiler_exe_name}:")
# print(f"Stdout: {process.stdout}") # Too verbose for normal operation
print(f"Stderr: {process.stderr}")
# else:
#    print(f"Successfully configured {compiler_exe_name}")

# Check if specific known sketch paths exist and compile them
sketch_paths = [
"/home/npyetheendra/arduino/p3751",
"/home/npyetheendra/arduino/p3751/lcd_display.ino",
"/home/npyetheendra/coverity_checker/arduino/p3751",
"/home/npyetheendra/coverity_checker/arduino/p3751/lcd_display.ino"
]

for sketch_path in sketch_paths:
if os.path.exists(sketch_path):
print(f"Found sketch path: {sketch_path}")
if sketch_path.endswith(".ino"):
sketch_dir = os.path.dirname(sketch_path)
else:
sketch_dir = sketch_path

# Use the consistent arduino-cli path
arduino_cli_executable = "/home/npyetheendra/coverity_checker/bin/arduino-cli"
runCmd_CovBuild = (f'${{COVERITY}}/bin/cov-build --dir ${{COV_WORKSPACE}} ' +
f'{arduino_cli_executable} compile ' +
'--fqbn SparkFun:avr:promicro ' +
'--verbose ' +
'--build-path ' + output_dir + ' ' +
'"' + sketch_dir + '"')
print(f"Running: {runCmd_CovBuild}")
subprocess.call(runCmd_CovBuild, shell=True)

# Apply file/directory exclusions if needed
for exclude_pattern in exclude_dirs:
runCmd_exclusion = "${COVERITY}/bin/cov-manage-emit --dir ${COV_WORKSPACE} --tu-pattern \"file('*" + exclude_pattern + "*')\"  delete"
subprocess.call(runCmd_exclusion, shell=True)

# Run MISRA analysis
runCmd_CovAnalysis = '${COVERITY}/bin/cov-analyze --disable-default --ignore-deviated-findings -co MISRA_CAST:non_negative_literals_may_be_unsigned:true --misra-config ${COVERITY}/config/MISRA/MISRA_C2012_SupressAllAdvisory.config --dir ${COV_WORKSPACE} --jobs 8 --max-mem 500'
subprocess.call(runCmd_CovAnalysis, shell=True)

# Generate reports
COVERITY_HTML_OUT_PATH = CoverityResults+today+'/MISRA/'+module_name
runCmd = 'mkdir -p '+COVERITY_HTML_OUT_PATH
subprocess.call(runCmd, shell=True)

# Generate HTML report
exclusionList = ''
for exclude_pattern in exclude_files:
exclusionList += exclude_pattern+'|'
for exclude_pattern in exclude_dirs:
exclusionList += '.*'+exclude_pattern+'.*'+'|'

if exclusionList:
exclusionList = exclusionList[:-1]
runCmd = '${COVERITY}/bin/cov-format-errors --dir ${COV_WORKSPACE} --exclude-files \''+exclusionList+'\' --html-output '+COVERITY_HTML_OUT_PATH
else:
runCmd = '${COVERITY}/bin/cov-format-errors --dir ${COV_WORKSPACE} --html-output '+COVERITY_HTML_OUT_PATH

subprocess.call(runCmd, shell=True)
< /code>
Но Coverity, похоже, не может захватывать промежуточное состояние файлов во время фазы сборки: < /p>
Used library Version Path
Wire         1.0     /home/npyetheendra/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire

Used platform Version Path
SparkFun:avr  1.1.13  /home/npyetheendra/.arduino15/packages/SparkFun/hardware/avr/1.1.13
arduino:avr   1.8.6   /home/npyetheendra/.arduino15/packages/arduino/hardware/avr/1.8.6
Attempting to detect unconfigured compilers in build
|0----------25-----------50----------75---------100|
****************************************************
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
/home/npyetheendra/coverity_checker/CoverityWorkspace/build-log.txt
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Looking for translation units
No matching translation units.
Coverity Static Analysis version 2024.9.0 on Linux 5.4.0-169-generic x86_64
Internal version numbers: 950e903b4e p-2024.9-push-30

[DEPRECATED] The --misra-config option is deprecated.  Use --coding-standard-config instead.
/home/npyetheendra/p4/tools/Coverity/2024.9.0/Linux64/config/MISRA/MISRA_C2012_SupressAllAdvisory.config:1:3: [WARNING] C/C++ comments are deprecated for coding standard configuration files
/home/npyetheendra/p4/tools/Coverity/2024.9.0/Linux64/config/MISRA/MISRA_C2012_SupressAllAdvisory.config:16:5: [WARNING] Non-string field names are deprecated for coding standard configuration files
/home/npyetheendra/p4/tools/Coverity/2024.9.0/Linux64/config/MISRA/MISRA_C2012_SupressAllAdvisory.config:136:5: [WARNING] Trailing commas in objects are deprecated for coding standard configuration files
[WARNING] Options were specified to the following disabled checkers:
MISRA_CAST
Looking for translation units
Error: intermediate directory contains no translation units.
[ERROR] No results found.
An analysis must have been run before running cov-format-errors.
Generating MISRA report
Generating MISRA report
Generating MISRA report for /home/npyetheendra/coverity_checker/cov_results-2025-05-23_04-36-48/MISRA
Generating MISRA report for /home/npyetheendra/coverity_checker/cov_results-2025-05-23_04-36-48/MISRA/ARDUINO
Consolidating CERT report
Found 0 CSV files
CSV files are: []
Filled NA values with 0
Writing consolidated CERT report to /home/npyetheendra/coverity_checker/cov_results-2025-05-23_04-36-48/CERT_Report_Arduino.csv
Consolidating MISRA report
Found 0 CSV files
CSV files are: []
Filled NA values with 0
Writing consolidated MISRA report to /home/npyetheendra/coverity_checker/cov_results-2025-05-23_04-36-48/MISRA_Report_Arduino.csv
Arduino analysis complete. Results available in /home/npyetheendra/coverity_checker/cov_results-2025-05-23_04-36-48
есть ли способ захватить переводчики при выполнении проверки Coverity с использованием arduino-cli?

Подробнее здесь: https://stackoverflow.com/questions/796 ... o-codebase
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Настройка проверки Coverity для кодовой базы Arduino
    Anonymous » » в форуме C++
    0 Ответы
    3 Просмотры
    Последнее сообщение Anonymous
  • Настройка проверки Coverity для кодовой базы Arduino
    Anonymous » » в форуме C++
    0 Ответы
    3 Просмотры
    Последнее сообщение Anonymous
  • Написание модели Coverity: указатель в структуре ВСЕГДА указывает на испорченные данные
    Anonymous » » в форуме C++
    0 Ответы
    22 Просмотры
    Последнее сообщение Anonymous
  • Clang-Tidy для кода Arduino, как подавить предупреждение об arduino.h
    Anonymous » » в форуме C++
    0 Ответы
    7 Просмотры
    Последнее сообщение Anonymous
  • Clang-Tidy для кода Arduino, как подавить предупреждение об arduino.h
    Anonymous » » в форуме C++
    0 Ответы
    8 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C++»