主要内容

使用 Python API 实现服务器上的工作流自动化

R2026b
创建和管理工程、手动或使用脚本运行测试

使用适用于 Polyspace® 的 Python® API 自动化 CI 的测试工作流,然后将结果上传到 Polyspace Access™ 以进行基于 Web 的审查:

import polyspace.project, polyspace.test
import subprocess

proj = polyspace.project.Project("myproject")
proj.Code.Files.add("src/utils.c")
proj.Tests.Files.add("tests/test.c")
res = polyspace.test.run(proj)
res.save("results/ps_test.pstestr")
subprocess.run(["polyspace-access", "-upload", "results/ps_test.pstestr", "-parent-project", "myproject", <SERVER_AND_LOGIN_INFO>])

在开始之前,请确保您的 Python 版本满足与 Polyspace Test Server 结合使用的要求。有关详细信息,请参阅Set Up Python API for Polyspace。

polyspace 包

polyspace.__install_path__(Python) Get Polyspace installation folder
polyspace.ErrorWithLog(Python) Get error logs from actions on a Polyspace project

polyspace.project 模块

全部展开

polyspace.project.Project(Python) Create and manage Polyspace Platform projects
polyspace.project.Workspace(Python) Create and manage Polyspace workspaces
polyspace.project.OwnedBuildConfiguration(Python) Build configurations attached to specific project
polyspace.project.OwnedStaticAnalysisConfiguration(Python) Static analysis configurations attached to specific project
polyspace.project.OwnedTestConfiguration(Python) Testing and profiling configurations attached to specific project
polyspace.project.BuildConfigurationRef(Python) Manage references from project to external build configurations
polyspace.project.StaticAnalysisConfigurationRef(Python) Manage references from project to external static analysis configurations
polyspace.project.TestConfigurationRef(Python) Manage references from project to external testing and profiling configurations
polyspace.project.BuildConfiguration(Python) External build configurations that can be associated with multiple projects
polyspace.project.StaticAnalysisConfiguration(Python) External static analysis configurations that can be associated with multiple projects
polyspace.project.TestConfiguration(Python) External testing and profiling configurations that can be associated with multiple projects
polyspace.project.ExecutionOptions(Python) Options for test execution in a project
polyspace.project.ProjectToolchain(Python) Store toolchain configuration for a build configuration
polyspace.project.Processor(Python) Store processor configuration for a build configuration
polyspace.project.parseCode(Python) Parse C/C++ source code added to project
polyspace.project.CodeInfo(Python) Store information about types, functions, and globals in parsed source code
polyspace.project.Function(Python) Store information about a function in parsed source code
polyspace.project.Global(Python) Store information about a global variable in parsed source code
polyspace.project.Type(Python) Store information about a C/C++ type in parsed source code
polyspace.project.Stubs(Python) Manage external C/C++ stub files
polyspace.project.FunctionStub(Python) Create and update project-specific stub for undefined function
polyspace.project.VariableStub(Python) Create and update project-specific stub for undefined variable
polyspace.project.Mock(Python) Create and update mock for function
polyspace.project.OwnedTestCase(Python) Create and manage owned test cases saved in project
polyspace.project.TestCase(Python) Edit referenced test cases saved in .pstestd file
polyspace.project.TestCaseRef(Python) Manage test cases referenced by project
polyspace.project.ScriptedTestStep(Python) Create and manage scripted test steps
polyspace.project.TabularTestStep(Python) Create and manage tabular test steps
polyspace.project.CallSequenceAssessment(Python) Access and configure function call sequence assessment for test step

polyspace.test 模块

全部展开

polyspace.test.generateTests(Python) Generate C/C++ unit tests automatically
polyspace.test.BoundaryTestOptions(Python) Configure automatic boundary-value test generation
polyspace.test.CoverageTestOptions(Python) Configure automatic test generation to meet coverage objectives
polyspace.test.FunctionTestGenerationConfiguration(Python) Configure function-based automatic test generation
polyspace.test.ScriptedTestGenerationConfiguration(Python) Configure script-based automatic test generation
polyspace.test.build(Python) Build project containing C/C++ sources and tests
polyspace.test.BuildResults(Python) Review build log
polyspace.target(Python) Manage host compilers or manage hardware targets for running C/C++ tests using Polyspace Test
polyspace.test.run(Python) Run test executable for specified project
polyspace.test.TestResults(Python) Review test results
polyspace.test.TestSuiteResult(Python) Review test results for a specific test suite
polyspace.test.TestCaseResult(Python) Review test results for a specific test case in a suite
polyspace.test.AssessmentResult(Python) Review results for a specific assessment in a test
polyspace.test.ProfilingResults(Python) Review code profiling results
polyspace.test.CoverageResults(Python) Review code coverage results
polyspace.test.StatementCoverageInfo(Python) Review statement coverage results
polyspace.test.DecisionCoverageInfo(Python) Review decision coverage results
polyspace.test.ConditionCoverageInfo(Python) Review condition coverage results
polyspace.test.MCDCCoverageInfo(Python) Review MCDC coverage results
polyspace.test.FunctionCoverageInfo(Python) Review function coverage results
polyspace.test.RelationalBoundaryInfo(Python) Review relational boundary coverage results
polyspace.test.CoverageFilters(Python) Create filters for code coverage results
polyspace.test.ProfilingResults(Python) Review code profiling results
polyspace.test.ExecutionProfilingResults(Python) Review execution profiling results
polyspace.test.ProfilingResults(Python) Review code profiling results
polyspace.test.StackProfilingResults(Python) Review stack profiling results
polyspace.test.ProfilingResults(Python) Review code profiling results
polyspace.test.SanitizerProfilingResults(Python) Review code sanitizer profiling results

主题