Automobile software test case generation method and system based on dynamic semantic desensitization

By using dynamic semantic desensitization methods, a sensitive entity type library and semantic context graph are constructed, which solves the problems of semantic loss and data leakage in static desensitization, generates accurate and usable automotive software test case code, and improves development efficiency and security.

CN121524082APending Publication Date: 2026-02-13ANHUI XIANGYU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511878291.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-12
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

In automotive software testing, existing static desensitization methods result in semantic loss, fail to generate usable test case code, and pose a risk of data leakage.

Method used

By employing a dynamic semantic desensitization method, and through the construction of a sensitive entity type library, named entity recognition, and semantic context graph, test code for security symbols is generated and restored to ensure that the AI ​​model understands the core semantics and protects data security.

Benefits of technology

It enables the generation of accurate and usable test code while protecting data security, improving development efficiency and security, and preventing data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121524082A_ABST
    Figure CN121524082A_ABST
Patent Text Reader

Abstract

The invention discloses an automobile software test case generation method and system based on dynamic semantic desensitization, and the method comprises the steps: S1, constructing a sensitive entity type library, and defining a unified safety symbol generation rule for each type; s2, acquiring an original test text, identifying all sensitive entities belonging to the sensitive entity type library in the text, performing replacement according to a security symbol generation rule, generating a mapping query table, and constructing a semantic context graph; s3, generating a test code containing the security symbol according to the desensitized text replaced with the security symbol and the semantic context graph; and S4, replacing the security symbol of the test code according to the mapping query table, and restoring the test code into an executable test text. According to the invention, the test code is not exposed to the AI model in an original form, so that data leakage is fundamentally avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of automotive software testing and artificial intelligence security technology, and in particular to a method and system for generating automotive software test cases based on dynamic semantic desensitization. Background Technology

[0002] In the automotive manufacturing industry, using AI to automatically generate test case code has become a key technology for improving software development efficiency. The typical process involves engineers inputting natural language text describing test requirements into an AI model, which then outputs the corresponding test code.

[0003] However, testing requirements themselves are among the most valuable trade secrets. A requirement such as "testing the arbitration mechanism and error frame handling logic of the vehicle gateway ECU_ID_0x718 for CAN FD messages [0x1A0]" directly includes: 1. Core system identifier: The specific ECU model (gateway ECU_ID_0x718).

[0004] 2. Communication protocol details: CAN FD protocol used, specific message ID (0x1A0).

[0005] 3. Functional safety mechanisms: The "arbitration mechanism" and "error frame handling" reveal the fault-tolerant design of the system.

[0006] Sending this request directly to AI services (especially cloud services) would be tantamount to exposing core intellectual property to the public. Existing technologies typically employ simple keyword replacement (e.g., replacing "ECU_ID_0x718" with "ECU_A"), but this "static desensitization" has serious flaws: Semantic loss: The AI ​​model cannot understand the logical relationship between "ECU_A" and "gateway" and "CAN FD", resulting in the generated code being logically confused or completely wrong.

[0007] Context breakage: The replaced symbols lose their original meaning, and when the test requirements involve multiple related components, the AI ​​cannot build the correct system context model.

[0008] Unusable generated code: Ultimately, the generated test case code fails to compile or cannot effectively test the target function due to semantic distortion, rendering the AI ​​generation process useless.

[0009] Therefore, there is an urgent need to provide a solution for generating automotive software test cases based on dynamic semantic desensitization. Summary of the Invention

[0010] To address the above issues, the present invention provides a method and system for generating automotive software test cases based on dynamic semantic desensitization, resolving the contradiction of "strictly protecting sensitive data in test requirements while ensuring that AI can accurately understand its core semantics."

[0011] According to a first aspect of the present invention, a method for generating automotive software test cases based on dynamic semantic desensitization is provided, comprising: S1. Construct a sensitive entity type library and define unified security symbol generation rules for each type; S2. Obtain the original test text, identify all sensitive entities in the text that belong to the sensitive entity type library, replace them according to the security symbol generation rules, generate a mapping query table, and construct a semantic context graph. S3. Generate test code containing security symbols based on the desensitized text replaced with security symbols and the semantic context graph; S4. Replace the security symbols in the test code according to the mapping lookup table, and restore the test code to executable test text.

[0012] In the above scheme, step S2 includes: S2.1 Use named entity recognition technology to identify sensitive entities in the original test text; S2.2 Generate a corresponding security symbol for each identified sensitive entity and record the mapping relationship between the original value and the security symbol in the mapping lookup table; S2.3 Construct a semantic context graph to record the semantic relationships between security symbols and non-sensitive context information.

[0013] In the above scheme, the named entity recognition technology is a hybrid method based on a pre-trained language model and combined with domain rule post-processing. The pre-trained language model is fine-tuned using corpus from the automotive software testing domain.

[0014] In the above scheme, the semantic context graph is a directed attribute graph, including nodes and edges. Each node corresponds to a sensitive entity that has been identified and replaced with a security symbol. Each edge connects two nodes and is used to represent the semantic relationship between the two nodes. The semantic relationship includes at least one of communication relationship, functional relationship and structural relationship.

[0015] In the above scheme, step S3 includes: S3.1 Input the desensitized test text and semantic context graph into the AI ​​model; S3.2 The AI ​​model generates test code containing security symbols based on the anonymized text and graph.

[0016] In the above scheme, the AI ​​model is a general large model, including Qwen and Deepseek, and a non-sensitive common sense knowledge base in the field of automotive software testing is added to the input to assist in reasoning.

[0017] In the above scheme, step S4 includes: S4.1 Restore the security symbols in the test code according to the mapping lookup table; S4.2 The restored test code is compiled and verified, and then output as an executable test text.

[0018] In the above scheme, the mapping lookup table is stored in volatile memory during a single session and destroyed immediately after the session ends.

[0019] In the above scheme, step S1: The sensitive entity type library includes one or more of the following: ECU_ID, Message_ID, Signal_Name, HW_Address, Service_ID, and Function_Name; The security symbol generation rule is to generate symbols based on a combination of entity type and session-unique sequence number, with the format: entity type_descriptor_sequence number.

[0020] According to a second aspect of the present invention, a system for generating automotive software test cases based on dynamic semantic desensitization is provided. The system is used to implement the method described in any one of the above solutions, and the system includes: The building module is used to build a library of sensitive entity types and define unified rules for generating security symbols for each type; The replacement module is used to obtain the original test text, identify all sensitive entities in the text that belong to the sensitive entity type library, replace them according to the security symbol generation rules, generate a mapping query table, and construct a semantic context graph. The code generation module is used to generate test code containing security symbols based on the de-identified text replaced with security symbols and the semantic context graph; The code restoration module is used to replace the safety symbols in the test code according to the mapping lookup table, and restore the test code into executable test text.

[0021] The beneficial effects of this invention are: Root cause data protection: It ensures from the source that the highest value test requirement intellectual property (such as ECU logic and communication matrix) will never be exposed to the AI ​​model in its original form, whether it is a local or cloud model, thus fundamentally preventing data leakage.

[0022] Ensuring the accuracy and usability of generated code: The "semantic context graph" preserves the inherent logic of the requirements, enabling AI to make "correct" judgments even in an "unknowing" state. The generated test code can be used directly after restoration, resolving the contradiction between security and utility.

[0023] Achieve fine-grained access control: Different engineers or project teams can use different de-identification strategies and mapping rules to achieve fine-grained control of data access permissions at the requirement input layer.

[0024] Improved process automation: Automation completes the entire process from de-identification to restoration, eliminating the need for engineers to manually write two sets of requirements (one for AI and one for their own use), greatly improving development efficiency and security. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0026] Figure 1 This is a flowchart of the automotive software test case generation method based on dynamic semantic desensitization in this invention; Figure 2 This is a diagram illustrating the overall architecture and data flow of the present invention. Figure 3 This is a flowchart of step S2 in the present invention; Figure 4 This is a flowchart of step S4 in the present invention.

[0027] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0028] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0029] The terms "first," "second," etc., used in this disclosure are for distinguishing similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented, for example, in orders other than those illustrated or described herein.

[0030] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.

[0031] Multiple, including two or more.

[0032] And / or, it should be understood that, for the purposes of this disclosure, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0033] like Figure 1 and Figure 2 As shown, one embodiment of the technical solution of the present invention provides a method for generating automotive software test cases based on dynamic semantic desensitization, including: S1. Construct a sensitive entity type library and define unified security symbol generation rules for each type; S2. Obtain the original test text, identify all sensitive entities in the text that belong to the sensitive entity type library, replace them according to the security symbol generation rules, generate a mapping query table, and construct a semantic context graph. S3. Generate test code containing security symbols based on the desensitized text replaced with security symbols and the semantic context graph; S4. Replace the security symbols in the test code according to the mapping lookup table, and restore the test code to executable test text.

[0034] Specifically, in step S1: For the automotive software testing field, a knowledge base containing various sensitive entity types is pre-built. Sensitive entity types include: ECU_ID (Electronic Control Unit Identifier), Message_ID (Message Identifier), Signal_Name (Signal Name), HW_Address (Hardware Address), Service_ID (Service Identifier), Function_Name (Function Name), etc.

[0035] The security symbol generation rule is to generate symbols based on a combination of entity type and a unique sequence number within the session, in the format: entity type_descriptor_sequence number. For example: ECU_Gateway_01 represents a gateway-type ECU with an in-session number of 01.

[0036] MSG_PowerManagement_01 indicates a power management related message, numbered 01.

[0037] The descriptor can be extracted from the non-sensitive context of the original text (such as "gateway" or "power management") and used to help understand the general role of the symbol later; the serial number is assigned sequentially within a single session to ensure uniqueness.

[0038] This invention standardizes the desensitization process through a predefined type library and generation rules, making it easy to extend to new entity types. Descriptors are incorporated into the rules, enabling the generated secure symbols to carry some semantic information, laying the foundation for subsequent AI model understanding and overcoming the drawback of complete semantic loss in static desensitization.

[0039] like Figure 3 As shown, step S2 includes: S2.1 Use named entity recognition technology to identify sensitive entities in the original test text; S2.2 Generate a corresponding security symbol for each identified sensitive entity and record the mapping relationship between the original value and the security symbol in the mapping lookup table; S2.3 Construct a semantic context graph to record the semantic relationships between security symbols and non-sensitive context information.

[0040] Furthermore, Named Entity Recognition (NER) technology is a hybrid method based on pre-trained language models and combined with domain rule post-processing. The specific implementation scheme of Named Entity Recognition technology is as follows: I. Core Technology Selection: Based on Pre-trained Deep Learning Models and Domain Fine-tuning 1) Basic model architecture: The system prioritizes using pre-trained language models based on the Transformer architecture (such as BERT, RoBERTa, or their variants) as the foundational engine for NER tasks. These models are trained on large-scale general corpora, possessing powerful semantic understanding and contextual representation capabilities, effectively addressing polysemy and long-distance dependency issues. They are able to understand context. For example, they can accurately distinguish whether the word "gateway" is a general noun or specifically refers to part of a sensitive entity like "gateway ECU_ID_0x718"; they can also determine whether "0x1A0" is a "Message_ID" or a regular hexadecimal number (such as a memory address).

[0041] 2) Domain Adaptation (Fine-tuning): Specialized pre-training or fine-tuning for the automotive software testing field is crucial for achieving high-precision recognition.

[0042] Fine-tuning the corpus: The model was fine-tuned using a domain-annotated corpus containing a large amount of text such as automotive testing requirements, design documents, communication matrices, and diagnostic specifications. These corpora have been pre-annotated with sensitive entity types defined in this invention, such as "ECU_ID", "Message_ID", and "Signal_Name".

[0043] Through fine-tuning, the model's general language understanding capabilities are specifically adapted to the automotive testing domain. This enables the model to accurately identify complex, specialized, and even enterprise-defined entity identifiers such as "GW_CEM_2024", "VCU_Main", and "APP_SIG_VehicleSpeed", and to be more sensitive to common domain-specific expressions.

[0044] II. Assistance and Enhancement Techniques: Domain-Based Rule-Based Post-Processing To achieve the extremely high accuracy required for industrial applications and to handle potential boundary cases encountered by the model, the system introduces a rule-based post-processing layer as an enhancement and safeguard: 1) Rule base definition: In the "semantic desensitization knowledge base", a structural pattern (regular expression) and context keywords are predefined for each sensitive entity type.

[0045] Structure patterns: For example, ECU_ID may conform to the pattern "ECU_" + suffix or "controller"; Message_ID is usually a hexadecimal number starting with "0x"; HW_Address conforms to the IP address format.

[0046] Contextual keywords: For example, words such as "address" and "port" often appear near "HW_Address"; verbs such as "verify", "process", and "mechanism" often appear near "Function_Name".

[0047] 2) Hybrid Workflow: Preliminary model recognition: The input test requirement text is first processed by a fine-tuned deep learning NER model to generate preliminary entity recognition results and their confidence levels.

[0048] Rule validation and completion: High confidence result: Adopt directly.

[0049] Low confidence or controversial results: The rule engine will be activated for verification. For example, if a string identified by the model as "plain text" matches the pattern "MSG_XXX" and its context contains keywords such as "message" or "send", the rule engine will correct or supplement it to identify it as "Message_ID".

[0050] Recall and completion: Using high-precision regular expressions and other rules, it is ensured that 100% of entities that conform to the predefined hard format can be recalled (such as all strings in the format 0x[0-9A-Fa-f]{1,8} will be initially judged as candidate Message_IDs). The model then combines the context for final confirmation to avoid omissions.

[0051] The semantic context graph is a directed attribute graph, including nodes and edges, as follows: Each node corresponds to an identified sensitive entity, which has been replaced with a security symbol (e.g., ECU_Gateway_01). Each node is a collection of key-value pair attributes that describe the entity's detailed information. Typical attributes include: safe_symbol: The primary key of the node, i.e. the generated security symbol (such as ECU_Gateway_01).

[0052] original_value: The original value before anonymization (e.g., ECU_ID_0x718). (This is highly sensitive data; it only exists in session memory and is destroyed immediately after the session ends.) entity_type: Entity type (e.g., ECU_ID, Message_ID).

[0053] contextual_descriptor: A general role that uses descriptive information (such as "gateway") extracted or inferred from a non-sensitive context to help AI understand the symbol.

[0054] Each edge connects two nodes and represents the semantic relationship between them. Each edge is also a set of attributes used to precisely describe the nature of the relationship.

[0055] relationship_type: The abstract type of the relationship.

[0056] interaction_verb: Specific verbs extracted from the original text (such as "send", "receive", "process"), which provide the most direct logical clues for AI-generated code.

[0057] protocol_or_interface: The protocol or interface through which the relationship occurs (e.g., "CAN FD", "SOME / IP").

[0058] The map uses the following storage strategy: Storage medium: During system operation, the graph is stored entirely in server memory (e.g., using a high-performance in-memory database such as Redis). This is because the graph needs to be frequently and rapidly queried and updated during the code generation and reconstruction phases, and in-memory storage provides the necessary extremely low latency.

[0059] Session isolation: Each independent user request or conversation session generates a unique session_id. All graph data is strictly isolated by namespace using this session_id, ensuring that data from different users and different tasks will never be mixed up or leaked.

[0060] Lifecycle and Secure Destruction: The lifecycle of the graph is completely tied to a single AI code generation session. When a session successfully ends (i.e., after the test code is securely restored and delivered to the user), the system immediately triggers a cleanup process, clearing or destroying all graph data and mapping tables in memory for that session. This mechanism ensures that sensitive raw data is never persistently stored on the server, achieving fundamental data protection with a "use and discard" approach.

[0061] Semantic relations are a predefined system based on knowledge in the field of automotive software testing, mainly divided into the following categories: Communication relationship: describes the direction of data flow between entities.

[0062] a) SENDS_TO (Sent to): Indicates that one ECU or component sends a message or signal to another.

[0063] b) RECEIVES_FROM: Indicates that an ECU or component receives a message or signal from another.

[0064] c) PROVIDES_SERVICE (Provide services): Indicates that one component provides a certain service to another (such as SOME / IP service).

[0065] Functional relationship: describes the control or processing logic between entities.

[0066] a) HANDLES: Indicates that an ECU is responsible for handling specific messages, signals, or events (such as "arbitration" or "error frame handling"). This is one of the most common relationships.

[0067] b) CONFIGURES: This indicates that one entity configures parameters for another entity.

[0068] c) DEPENDS_ON (depends on): This indicates that the proper functioning of a component depends on another component.

[0069] Structural relationships: describe the composition of the system.

[0070] CONTAINS: Indicates that a large system component contains another sub-component.

[0071] Unlike static replacement, this invention dynamically records the semantic relationships between entities through a graph, upgrading desensitization from a simple string operation to a semantic structure preservation process. Employing a hybrid NER scheme of pre-trained model fine-tuning and rule enhancement, it achieves industrial-grade accuracy while maintaining high recall, effectively identifying complex, custom identifiers defined within an enterprise. The graph and mapping table are isolated and stored in memory using session_id, implementing "use-and-burn" functionality and fundamentally eliminating the risk of persistent leakage of sensitive data.

[0072] Step S3 includes: S3.1 Input the desensitized test text and semantic context graph into the AI ​​model; S3.2 The AI ​​model generates test code containing security symbols based on the anonymized text and graph.

[0073] The AI ​​model is a general-purpose large model, including Qwen and Deepseek, and can embed core concepts and rules from fields such as automotive network communication (e.g., CAN, LIN, SOME / IP), diagnostic protocols (UDS), and functional safety standards (ISO 26262) into the system in the form of a knowledge base. When generating desensitized requirements, these non-sensitive domain common sense can be selectively added to assist the AI ​​model in making correct reasoning.

[0074] Furthermore, if undefined or ambiguous symbols appear in the code generated by the AI, the handling mechanism is as follows: Undefined symbol handling: Any symbol not found in the mapping table is marked as "undefined symbol". The system will not attempt to restore these symbols. Although true referential ambiguity is rare due to the uniqueness of symbols within a session, the system still checks for polysemous word disambiguation. This primarily targets non-sensitive logical verbs retained from the original requirements.

[0075] Disambiguation strategy: The system uses a pre-constructed context graph to resolve ambiguities. For example, the AI ​​might confuse the specific meaning of the word "process" (is it "parse message" or "error handling"?). The system will examine the entity types and relationships associated with the verb in the graph to determine its most likely accurate meaning and add clear comments to the generated code if necessary, without changing the core logic.

[0076] When automated processes fail to resolve issues, the system needs a safe and controllable exit strategy, such as a tiered rollback mechanism. 1) Level 1 Rollback: Request AI Regeneration: In cases where undefined symbols or serious logical contradictions are detected, the system can automatically construct a more detailed hint and feed the problem back to the AI ​​model, requesting it to regenerate the code based on the correct symbol set. A maximum number of retries can be set for this process (e.g., 2 times).

[0077] 2) Secondary rollback: Marking and isolation: If the problem persists after retrying, or if an unrecoverable fatal error is encountered during the restoration process (such as unexpected corruption of the mapping table), the system will immediately stop the automated process.

[0078] The system will mark this session as "restore failed".

[0079] All generated code containing security symbols, raw mapping table data (encrypted), and error logs will be fully packaged and stored in an audit queue.

[0080] 3) Manual review process: Notification mechanism: The system automatically notifies relevant personnel (such as the test engineer who submitted the requirement).

[0081] Furthermore, to ensure code security, the AI ​​model used in this invention also has isolation and security mechanisms, as detailed below: Isolation mechanisms for AI models: 1) Network and physical isolation Option 1: Local Deployment. Deploy the entire system (including the semantic desensitization engine, knowledge base, AI model, etc.) on a private server or isolated domain within the enterprise. This is the highest level of security measure, fundamentally cutting off any possibility of data flowing to the external environment.

[0082] Option 2: Virtual Private Cloud Isolation. If cloud computing power must be used, the AI ​​model must be deployed in a virtual private cloud environment dedicated to the enterprise, with strict security groups and network access control policies configured to ensure that only the "AI code generation interface" of this system can access it, and to prevent access from the public network or other tenants.

[0083] 2) Logic and process isolation Dedicated API Gateway and Authentication: The "AI Code Generation Interface" acts as a dedicated API gateway, enforcing authentication and authorization for all requests sent to the AI ​​model. It uses technologies such as API keys and two-way TLS certificates to ensure that only trusted system components can invoke the AI ​​service.

[0084] Request cleanup and auditing: Before forwarding a request, this interface performs a final verification of the request content to ensure that it does not contain any original sensitive data not registered in the "semantic masking mapping table". All requests and responses to AI are logged (only metadata such as session ID and timestamp are recorded, not the masked request content) for security auditing and troubleshooting.

[0085] Security mechanisms: Outer layer defense: By using network / physical isolation and API gateways, the AI ​​model is kept within a security boundary.

[0086] Mid-layer defense: By minimizing data and using unidirectional data flow, ensure that data flowing into the security boundary is completely de-identified.

[0087] Inner layer defense: Through instant session destruction and symbol irreversibility, it ensures that even if unforeseen vulnerabilities occur, attackers cannot obtain valuable sensitive information.

[0088] This invention's AI model can perform accurate reasoning even without seeing real sensitive data, thanks to the logical relationships conveyed by a graph, thus overcoming the traditional dilemma of sacrificing both security and utility. It eliminates the need to train dedicated models for specific enterprises, reducing deployment costs. By injecting graph information, a general-purpose model acquires precise domain-specific understanding capabilities.

[0089] like Figure 4 As shown, step S4 includes: S4.1 Restore the security symbols in the test code according to the mapping lookup table; S4.2 The restored test code is compiled and verified, and then output as an executable test text.

[0090] This invention defines the following multi-dimensional, quantifiable evaluation index system for verifying and continuously optimizing system output: 1) Grammatical accuracy: Metrics: Whether the generated test code passes the syntax check of the target language compiler or interpreter without compilation errors.

[0091] Measurement method: Automated compilation / static syntax checking.

[0092] 2) Functional logic accuracy: Metrics: Does the generated test code accurately reflect the core test intent and logical flow described in the anonymized requirements (e.g., whether timeouts are correctly simulated, expected messages are sent, and correct responses are checked)?

[0093] Measurement method: a) Automated verification: Run the restored code in a simulation environment or test bench to check whether its execution path meets expectations.

[0094] b) Expert review: Test engineers score the logic of the generated code (e.g., using a 1-5 scale) to assess whether it covers key test points.

[0095] 3) Semantic fidelity: Metrics: This is the core evaluation metric of this invention, used to measure the degree of matching between the real identifiers used in the code and the original requirements after the entire process of "de-sensitization-generation-restoration".

[0096] Measurement method: Automated comparison to see if the restored code is completely consistent with the hardware address, message ID, signal name, etc. used in a "golden reference code" (written by experts based on the original requirements).

[0097] 4) Test validity: Metrics: When the final restored test code runs on the real target ECU, can it effectively trigger the expected behavior (such as passing normally, failing, or reporting an error) and correctly verify the function of the tested object?

[0098] This invention achieves a fully automated closed loop from data anonymization and generation to data restoration, eliminating the need for engineers to manually handle two sets of code and significantly improving efficiency. Through quantitative indicators such as semantic restoration fidelity, the entire process can be objectively evaluated to ensure data security without distortion, something static data anonymization methods cannot achieve.

[0099] According to a second aspect of the present invention, a system for generating automotive software test cases based on dynamic semantic desensitization is provided. The system is used to implement the method described in any one of the above solutions, and the system includes: The building module is used to build a library of sensitive entity types and define unified rules for generating security symbols for each type; The replacement module is used to obtain the original test text, identify all sensitive entities in the text that belong to the sensitive entity type library, replace them according to the security symbol generation rules, generate a mapping query table, and construct a semantic context graph. The code generation module is used to generate test code containing security symbols based on the de-identified text replaced with security symbols and the semantic context graph; The code restoration module is used to replace the safety symbols in the test code according to the mapping lookup table, and restore the test code into executable test text.

[0100] Example This embodiment provides an original test requirement: "Verify the communication timeout handling mechanism of the intelligent cockpit domain controller (HW_Addr:10.0.0.1) sending the vehicle speed signal (Signal: VehicleSpeed) to the instrument panel ECU (ECU_ID: IC_01) via the SOME / IP service (Service ID: 0x4001). 1. Dynamic desensitization: Entity identification: HW_Addr: 10.0.0.1 -> Type: HW_Address Entity Identification: Service ID: 0x4001 -> Type: Service_ID Entity Identification: ECU_ID: IC_01 -> Type: ECU_ID Entity identification: Signal: VehicleSpeed ​​-> Type: Signal_Name Generate secure symbols and establish relationships: HW_Node_01 (representing 10.0.0.1) Srv_Display_01 (representing 0x4001) ECU_Display_01 (representing IC_01) Sig_Speed_01 (represents VehicleSpeed) Recorded in the context graph: HW_Node_01 [via] Srv_Display_01 [to] ECU_Display_01 [sent] Sig_Speed_01.

[0101] After anonymization, the requirement becomes: "Verify the communication timeout handling mechanism for the intelligent cockpit domain controller (HW_Node_01) sending the vehicle speed signal (Sig_Speed_01) to the instrument panel ECU (ECU_Display_01) via the SOME / IP service (Srv_Display_01). AI code generation and reconstruction: The AI ​​code generation interface sends the anonymized text and the constructed semantic context graph data to the AI ​​model. Based on its training knowledge, the AI ​​model understands publicly available domain concepts such as "intelligent cockpit domain controller," "SOME / IP protocol," and "communication timeout test."

[0102] The AI ​​model reads the map data and establishes cognition: HW_Node_01 (a domain controller) uses (USES) Srv_Display_01 (a certain SOME / IP service), the function of which is to send (SENDS_TO) a data named Sig_Speed_01 (vehicle speed signal) to ECU_Display_01 (an instrument panel ECU).

[0103] Based on the test objective of "communication timeout handling mechanism," the generated code should include the following logical steps: establishing a SOME / IP client-server connection, periodically sending signals, simulating timeout failures, and capturing and verifying timeout responses. In the generated code, all addresses and IDs will use secure symbols (such as HW_Node_01, Srv_Display_01).

[0104] The security restore module retrieves the corresponding mapping table from memory based on the current session_id. Then, it performs a batch search and replace to restore all security symbols (such as HW_Node_01) in the code to their original real identifiers (such as 10.0.0.1).

[0105] After the restoration process is complete, the system immediately destroys the session's memory mapping table and graph data. The test engineers are delivered a ready-to-use test code containing real network addresses, ECU identifiers, and service IDs; the syntax is correct and accurately reflects the original test intent.

[0106] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0107] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0108] Through the above description of the embodiments, those skilled in the art can clearly understand that the above implementation methods can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0109] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.

Claims

1. A method for generating automotive software test cases based on dynamic semantic desensitization, characterized in that, include: S1. Construct a sensitive entity type library and define unified security symbol generation rules for each type; S2. Obtain the original test text, identify all sensitive entities in the text that belong to the sensitive entity type library, replace them according to the security symbol generation rules, generate a mapping query table, and construct a semantic context graph. S3. Generate test code containing security symbols based on the desensitized text replaced with security symbols and the semantic context graph; S4. Replace the security symbols in the test code according to the mapping lookup table, and restore the test code to executable test text.

2. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 1, characterized in that, Step S2 includes: S2.1 Use named entity recognition technology to identify sensitive entities in the original test text; S2.2 Generate a corresponding security symbol for each identified sensitive entity and record the mapping relationship between the original value and the security symbol in the mapping lookup table; S2.3 Construct a semantic context graph to record the semantic relationships between security symbols and non-sensitive context information.

3. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 2, characterized in that, Named entity recognition technology is a hybrid approach based on a pre-trained language model and combined with domain rule post-processing. The pre-trained language model is fine-tuned using corpus from the automotive software testing domain.

4. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 2, characterized in that, The semantic context graph is a directed attribute graph, which includes nodes and edges. Each node corresponds to a sensitive entity that has been identified and replaced with a security symbol. Each edge connects two nodes and is used to represent the semantic relationship between the two nodes. The semantic relationship includes at least one of communication relationship, functional relationship and structural relationship.

5. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 4, characterized in that, Step S3 includes: S3.1 Input the desensitized test text and semantic context graph into the AI ​​model; S3.2 The AI ​​model generates test code containing security symbols based on the anonymized text and graph.

6. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 5, characterized in that, The AI ​​models are general-purpose large models, including Qwen and Deepseek, and a non-sensitive common-sense knowledge base in the field of automotive software testing is added to the input to assist in reasoning.

7. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 1, characterized in that, Step S4 includes: S4.1 Restore the security symbols in the test code according to the mapping lookup table; S4.2 The restored test code is compiled and verified, and then output as an executable test text.

8. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 1, characterized in that, The mapping lookup table is stored in volatile memory during a single session and destroyed immediately after the session ends.

9. The method for generating automotive software test cases based on dynamic semantic desensitization according to claim 1, characterized in that, In step S1: The sensitive entity type library includes one or more of the following: ECU_ID, Message_ID, Signal_Name, HW_Address, Service_ID, and Function_Name; The security symbol generation rule is to generate symbols based on a combination of entity type and session-unique sequence number, with the format: entity type_descriptor_sequence number.

10. A test case generation system for automotive software based on dynamic semantic desensitization, characterized in that, The system is used to implement the method as described in any one of claims 1-9, the system comprising: The building module is used to build a library of sensitive entity types and define unified rules for generating security symbols for each type; The replacement module is used to obtain the original test text, identify all sensitive entities in the text that belong to the sensitive entity type library, replace them according to the security symbol generation rules, generate a mapping query table, and construct a semantic context graph. The code generation module is used to generate test code containing security symbols based on the de-identified text replaced with security symbols and the semantic context graph; The code restoration module is used to replace the safety symbols in the test code according to the mapping lookup table, and restore the test code into executable test text.