A data generation method, device, equipment and readable storage medium

By generating target sequences of specified length and entropy values, the problem of insufficient test data in the development phase of data processors is solved, enabling comprehensive verification of various data processing capabilities of the processor and improving the richness of test data.

CN115935291BActive Publication Date: 2026-06-05DAPUSTOR CORP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DAPUSTOR CORP
Filing Date
2022-12-22
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, data processors cannot fully verify their ability to process various types of data during the development phase due to the limited test data patterns and quantities.

Method used

The process involves generating a specific target sequence of a specified length with an entropy value close to the target entropy value. This includes obtaining the target length and entropy value, generating random and repeating sequences, concatenating them and adjusting the sequence length to achieve the target entropy value, shuffling the sequence to obtain the target sequence, and then outputting the target sequence.

Benefits of technology

It improves the richness and comprehensiveness of test data, enabling a more comprehensive verification of the processor's ability to process various types of data, and assesses the coverage of test data through coverage rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115935291B_ABST
    Figure CN115935291B_ABST
Patent Text Reader

Abstract

The application discloses a data generation method and device, equipment and a readable storage medium in the computer technical field. The application can generate a specific target sequence with a specified length and an entropy value close to a target entropy value according to the target length and the target entropy value, and can output data with a desired entropy value and length. Therefore, the data entropy value and length can be customized, different entropy values and different lengths of data can be obtained, and the richness of the output data can be improved. If the data with different entropy values and different lengths is used as test data of a processor, the richness and comprehensiveness of the test data can be improved, the test data is convenient for verifying the processing capacity of the same processor for various data, and the verification comprehensiveness of the processor can be improved. Correspondingly, the data generation device, equipment and readable storage medium provided by the application also have the above technical effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data generation method, apparatus, device, and readable storage medium. Background Technology

[0002] In practice, data processors need to process data of various types. However, during the processor development phase, due to the limited types and quantities of test data, the processor can only be tested with limited test data. This makes it impossible to verify the processor's ability to process various types of data and makes it difficult to conduct comprehensive testing of the processor.

[0003] Therefore, how to improve the richness of test data to verify the processing capabilities of the same processor for various types of data is a problem that needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a data generation method, apparatus, device, and readable storage medium to enhance the richness of test data and verify the processing capabilities of the same processor for various types of data. The specific solution is as follows:

[0005] Firstly, this application provides a data generation method, including:

[0006] Obtain the target length and target entropy value;

[0007] The first sub-length and the second sub-length are determined based on the target length;

[0008] Generate a random sequence of the first sub-length and a repeating sequence of the second sub-length;

[0009] By concatenating the random sequence and the repeating sequence, a concatenated sequence is obtained;

[0010] If the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy error, then the spliced ​​sequence is broken up to obtain the target sequence, and the target sequence is output.

[0011] Optionally, determining the first sub-length and the second sub-length based on the target length includes:

[0012] The first sub-length is set to half of the target length, and the second sub-length is obtained by subtracting the first sub-length from the target length;

[0013] or

[0014] The first sub-length is set to any value less than the target length, and the second sub-length is obtained by subtracting the first sub-length from the target length.

[0015] Optionally, breaking down the spliced ​​sequence to obtain the target sequence includes:

[0016] The spliced ​​sequence is divided into multiple sub-sequences;

[0017] The target sequence is obtained by adjusting the order of the different subsequences.

[0018] Optionally, dividing the spliced ​​sequence into multiple sub-sequences includes:

[0019] The spliced ​​sequence is divided into multiple subsequences of equal length.

[0020] Optionally, after splicing the random sequence and the repeating sequence to obtain the spliced ​​sequence, the method further includes:

[0021] Determine the current number of retries;

[0022] If the current number of retries is greater than zero, then after the current number of retries is decremented by one, the following steps are executed: if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error, then the spliced ​​sequence is broken up to obtain the target sequence and the target sequence is output.

[0023] If the current number of retries is not greater than zero, a prompt message indicating that the maximum number of retries has been reached is generated, and the current generation process is exited.

[0024] Optionally, it also includes:

[0025] If the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than the preset entropy value error, then the lengths of the random sequence and the repeating sequence are adjusted respectively, and the sum of the lengths of the adjusted random sequence and the adjusted repeating sequence is equal to the target length.

[0026] The steps are as follows: replace the random sequence with the adjusted random sequence, replace the repeated sequence with the adjusted repeated sequence, and perform splicing of the random sequence and the repeated sequence to obtain a spliced ​​sequence; if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error, then break up the spliced ​​sequence to obtain the target sequence and output the target sequence.

[0027] Optionally, adjusting the lengths of the random sequence and the repeating sequence respectively includes:

[0028] Determine whether the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than zero;

[0029] If so, shorten the random sequence and correspondingly lengthen the repeating sequence;

[0030] If not, then the random sequence is extended and the repeating sequence is shortened accordingly.

[0031] Optionally, shortening the random sequence and correspondingly lengthening the repeating sequence includes:

[0032] The adjustment length is determined according to preset rules;

[0033] Delete the adjusted-length data from the random sequence and fill the adjusted-length data into the repeating sequence;

[0034] Accordingly, extending the random sequence and shortening the repeating sequence accordingly includes:

[0035] The adjustment length is determined according to preset rules;

[0036] The adjusted-length data is filled into the random sequence, and the adjusted-length data is deleted from the repeating sequence.

[0037] Optionally, it also includes:

[0038] If the entropy value of the spliced ​​sequence is less than the target entropy value, and the length of the current repeating sequence is recorded in the first array, then the length of the current repeating sequence is incremented by one. When the length obtained by incrementing by one is not recorded in the first array, the length obtained by incrementing by one is taken as the available length of the current repeating sequence. After adjusting the length of the random sequence accordingly, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeating sequence are executed. The first array is used to record the length of the repeating sequence when the entropy value of the spliced ​​sequence is less than the target entropy value.

[0039] If the entropy value of the spliced ​​sequence is greater than the target entropy value, and the length of the current repeating sequence is recorded in the second array, then the length of the current repeating sequence is decremented by one. When the length obtained by decrementing by one is not recorded in the second array, the length obtained by decrementing by one is taken as the available length of the current repeating sequence. After adjusting the length of the random sequence accordingly, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeating sequence are executed. The second array is used to record the length of the repeating sequence when the entropy value of the spliced ​​sequence is greater than the target entropy value.

[0040] Optionally, it also includes:

[0041] After obtaining multiple target sequences, the multiple target sequences are used as test data for testing the target processor, and the entropy value of each target sequence in the test data is summarized to obtain an entropy value set;

[0042] Divide the entropy value range into multiple sub-intervals;

[0043] Traverse each sub-interval. If the current sub-interval can cover at least one entropy value in the entropy value set, then increment the coverage count by one.

[0044] The ratio of the number of coverages at the end of the traversal to the total number of sub-intervals is determined as the test coverage rate of the test data for the target processor.

[0045] Secondly, this application provides a data generation apparatus, comprising:

[0046] The acquisition module is used to obtain the target length and target entropy value;

[0047] The determining module is used to determine a first sub-length and a second sub-length based on the target length;

[0048] A generation module is used to generate a random sequence of the first sub-length and a repeating sequence of the second sub-length;

[0049] A splicing module is used to splice the random sequence and the repeating sequence to obtain a spliced ​​sequence;

[0050] The output module is used to break up the spliced ​​sequence to obtain the target sequence and output the target sequence if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than a preset entropy error.

[0051] Thirdly, this application provides an electronic device, comprising:

[0052] Memory, used to store computer programs;

[0053] A processor for executing the computer program to implement the aforementioned disclosed data generation method.

[0054] Fourthly, this application provides a readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned disclosed data generation method.

[0055] As can be seen from the above scheme, this application provides a data generation method, including: obtaining a target length and a target entropy value; determining a first sub-length and a second sub-length based on the target length; generating a random sequence of the first sub-length and a repeating sequence of the second sub-length; splicing the random sequence and the repeating sequence to obtain a spliced ​​sequence; if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than a preset entropy value error, then shuffling the spliced ​​sequence to obtain a target sequence and outputting the target sequence. It is evident that this application can generate a specific target sequence of a specified length and with an entropy value close to the target entropy value based on the target length and target entropy value. That is, it generates data with a specified information entropy value and a specified length. Therefore, it can be realized that whatever entropy value and length of data is desired to be output, this application can output such data. Thus, the data entropy value and length can be customized to obtain data with different entropy values ​​and different lengths, thereby improving the richness of the output data. If data with different entropy values ​​and different lengths are used as test data for a processor, it can obviously improve the richness and comprehensiveness of the test data. This test data facilitates the verification of the same processor's processing capabilities for various types of data and also improves the comprehensiveness of processor verification.

[0056] Correspondingly, the data generation apparatus, device, and readable storage medium provided in this application also have the above-mentioned technical effects. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in the embodiments of this application 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 embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0058] Figure 1 This is a flowchart of a data generation method disclosed in this application;

[0059] Figure 2 Here is a flowchart of another data generation method disclosed in this application;

[0060] Figure 3 This is a schematic diagram of a data generation device disclosed in this application;

[0061] Figure 4 This is a schematic diagram of an electronic device disclosed in this application. Detailed Implementation

[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0063] Currently, data processors need to process data with diverse patterns in practical applications. However, during the processor development phase, due to the limited patterns and quantity of test data, only a limited amount of test data can be used to test the processor. This makes it impossible to verify the processor's ability to process various types of data and to conduct comprehensive testing of the processor. To address this, this application provides a data generation scheme that can generate a specific target sequence of a specified length with an entropy value close to the target entropy value, based on the target length and target entropy value. This allows for customization of the data entropy value and length, thereby improving the richness of the test data.

[0064] See Figure 1 As shown in the figure, this application discloses a data generation method, including:

[0065] S101. Obtain the target length and target entropy value.

[0066] In this embodiment, the target length and target entropy value are specified by the user. The target length is generally in bytes, so it can be 1024 bytes, 4096 bytes, etc. Specifically, the target length can be specified based on the maximum length of data that the processor can process. For example, if the maximum length that a processor can process is 1048576 (1M bytes), then the target length can be any integer not greater than 1048576 bytes.

[0067] It's important to note that data entropy reflects the degree of randomness in the data. The more random the data pattern, the higher its information entropy; conversely, the more uniform the data pattern, the lower its information entropy. Therefore, generating data with a specified entropy value results in data with a specified data pattern. For example, if 8 bytes of data D1 exhibits the pattern "ABABAABB", and another 8 bytes of data D2 exhibits the pattern "CDCDCCDD", although the specific content of D1 and D2 is different, their patterns are the same, so their information entropy values ​​are equal. Data with different entropy values ​​must have different patterns.

[0068] S102. Determine the first sub-length and the second sub-length based on the target length.

[0069] In one specific implementation, determining the first sub-length and the second sub-length based on the target length includes: if N is even, setting both the first sub-length and the second sub-length to half the target length; if N is odd, setting the first sub-length to half the target length and subtracting the first sub-length from the target length to obtain the second sub-length; or setting the first sub-length to any value less than the target length and subtracting the first sub-length from the target length to obtain the second sub-length. It is evident that the sum of the lengths of the random sequence and the repeating sequence is always equal to the target length.

[0070] S103. Generate a random sequence of the first sub-length and a repeating sequence of the second sub-length.

[0071] In one example, a random sequence of the first sub-length can be generated based on any random algorithm. The repeating sequence of the second sub-length is a sequence of the second sub-length consisting of the same data. For example, the repeating sequence could be: AAAAAA.

[0072] S104. Concatenate the random sequence and the repeating sequence to obtain the concatenated sequence.

[0073] S105. If the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy error, then break up the spliced ​​sequence to obtain the target sequence and output the target sequence.

[0074] According to this embodiment, after specifying the target length N, the target entropy value E, and preset the entropy error D and the maximum number of retries R, the first sub-length n0 can be set to N / 2, and the second sub-length n1 can be set to N minus n0. Then, n0 random bytes can form a random sequence s0 with a total of n0 bytes, and n1 repeated bytes can form a repeated sequence s1 with a total of n1 bytes. Then, s0 is concatenated with s1 to obtain the concatenated sequence s0+s1. When concatenating s0 and s1, the order of s0 and s1 can be interchanged. If the difference between the entropy value of the concatenated sequence s and the target entropy value E is not greater than the preset entropy error D, then the concatenated sequence s is broken up to obtain the target sequence. After that, the target sequence is output, and thus custom data with a length of N and an entropy value close to E can be obtained. The target entropy value E is in the range of entropy values ​​[0, 8]. The difference between the entropy value of the spliced ​​sequence s and the target entropy value E can be taken as the absolute value of the difference between the entropy value of the spliced ​​sequence s and the target entropy value E.

[0075] To make the data closer to real data, this embodiment breaks down the data in the concatenated sequence before outputting it. In one specific implementation, breaking down the concatenated sequence to obtain the target sequence includes: dividing the concatenated sequence into multiple subsequences; and adjusting the order of the different subsequences to obtain the target sequence. Dividing the concatenated sequence into multiple subsequences includes: dividing the concatenated sequence into multiple subsequences of equal length. Of course, other methods can also be used to make the data in the concatenated sequence irregularly distributed, such as: arranging the random sequence and the repeating sequence in a staggered manner. For example, if the random sequence is sajk and the repeating sequence is mmmm, then the staggered arrangement of the random sequence and the repeating sequence would be smamjmkm or msmamjmk.

[0076] Since not every concatenated sequence meets the requirements, this embodiment sets a maximum number of retries R to avoid infinite repetition. When the algorithm is first executed, the maximum number of retries is set to R. Each time a concatenation operation is performed, the value of R is decremented by one. Once R reaches zero, the process exits to prevent infinite loops. In one specific implementation, after concatenating a random sequence and a repeating sequence to obtain a concatenated sequence, the process further includes: determining the current number of retries; if the current number of retries is greater than zero, then after decrementing the current number of retries by one, executing the step of breaking up the concatenated sequence to obtain the target sequence if the difference between the entropy value of the concatenated sequence and the target entropy value is not greater than a preset entropy error, and outputting the target sequence; if the current number of retries is not greater than zero, then generating a message indicating that the maximum number of retries has been reached, and exiting the current generation process.

[0077] In this embodiment, if the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than the preset entropy error, the current spliced ​​sequence can be adjusted by adjusting the lengths of the random sequence and the repeating sequence to obtain a spliced ​​sequence that meets the output conditions. A spliced ​​sequence that meets the output conditions is a sequence with a length equal to N and an entropy value whose difference from the target entropy value is not greater than the preset entropy error. In one specific implementation, if the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than the preset entropy error, the lengths of the random sequence and the repeating sequence are adjusted respectively, and the sum of the lengths of the adjusted random sequence and the adjusted repeating sequence is made equal to the target length; the adjusted random sequence replaces the random sequence, and the adjusted repeating sequence replaces the repeating sequence, and the splicing of the random sequence and the repeating sequence is performed to obtain the spliced ​​sequence; if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy error, the spliced ​​sequence is broken up to obtain the target sequence, and the target sequence is output.

[0078] In one specific implementation, adjusting the lengths of the random sequence and the repeating sequence respectively includes: determining whether the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than zero; if so, shortening the random sequence and correspondingly lengthening the repeating sequence; if not, lengthening the random sequence and correspondingly shortening the repeating sequence. Shortening the random sequence and correspondingly lengthening the repeating sequence includes: determining the adjustment length according to a preset rule; deleting data of the adjusted length from the random sequence and filling the repeating sequence with data of the adjusted length; correspondingly, lengthening the random sequence and correspondingly shortening the repeating sequence includes: determining the adjustment length according to a preset rule; filling the random sequence with data of the adjusted length and deleting data of the adjusted length from the repeating sequence. In one specific implementation, determining the adjustment length according to a preset rule includes: if the entropy value of the spliced ​​sequence is greater than the target entropy value, then setting the adjustment length to half of the first sub-length.

[0079] In one example, adjusting the length of the random sequence and the repeating sequence is implemented as follows: If the adjustment length is 1 byte, then the random sequence can be extended by padding with 1 byte of arbitrary data at any position, and the repeating sequence can be shortened by deleting 1 byte of data from any position. For example, if the random sequence is sajk and the repeating sequence is mmmm, then 1 byte of random data q can be padded to the beginning of sajk to get qsajk, and 1 byte of data can be deleted from any position in mmmm to get mmm; in this example, a lowercase letter represents one byte. Correspondingly, the repeating sequence can be extended by padding with 1 byte of the original repeating byte at any position, and the random sequence can be shortened by deleting 1 byte of data from any position in the random sequence. For example, if the random sequence is sajk and the repeating sequence is mmmm, then 1 byte of m can be padded to the end of the repeating sequence to get mmmmmm, and 1 byte of random data q can be padded to the end of sajk to get sajkq; in this example, a lowercase letter represents one byte.

[0080] It is evident that increasing the random sequence by one byte while decreasing the repeating sequence by one byte achieves the adjustment goal. A more efficient approach is to halve the random sequence while increasing the repeating sequence to speed up the adjustment. However, halving the random sequence and allocating the reduced length to the repeating sequence when the entropy value is high may result in an overall low entropy value for the concatenated sequence; conversely, halving the repeating sequence and allocating the reduced length to the random sequence may result in an overall high entropy value for the concatenated sequence. Therefore, directly halving the sequence can easily lead to a convergent infinite loop. To avoid this problem, two arrays can be used: a larger array (the first array) and a smaller array (the second array). Each time a repeating sequence is obtained, if its length is larger, its length is recorded in the larger array; if its length is smaller, its length is recorded in the smaller array. Specifically, if the entropy value of the concatenated sequence is greater than the target entropy value, it indicates that the length of the repeating sequence is too small; conversely, if the entropy value is less than the target entropy value, it indicates that the length of the repeating sequence is too large.

[0081] Therefore, after obtaining the concatenated sequence each time, the length of the repeating sequence at this time is checked. If the entropy value of the concatenated sequence is too high (i.e., the entropy value of the concatenated sequence is greater than the target entropy value) and the length of the repeating sequence is recorded in the smaller array, then the length of the repeating sequence is reduced by one. When the reduced value is not recorded in the smaller array, the reduced value is used as the length of the repeating sequence, and the length of the random sequence is adjusted accordingly. Then, the process is repeated: the adjusted random sequence replaces the random sequence, the adjusted repeating sequence replaces the repeating sequence, and the random sequence and the repeating sequence are concatenated to obtain the concatenated sequence. If the difference between the entropy value of the concatenated sequence and the target entropy value is not greater than the preset entropy value error, then the concatenated sequence is broken up to obtain the target sequence, and the target sequence is output.

[0082] Correspondingly, if the entropy value of the concatenated sequence is low (i.e., the entropy value of the concatenated sequence is less than the target entropy value) and the length of the repeating sequence is recorded in the larger array, then the length of the repeating sequence is incremented by one. When the length obtained by incrementing by one is not recorded in the larger array, the length obtained by incrementing by one is used as the length of the repeating sequence, and the length of the random sequence is adjusted accordingly. Then, the process is repeated: the adjusted random sequence replaces the random sequence, the adjusted repeating sequence replaces the repeating sequence, and the random sequence and repeating sequence are concatenated to obtain the concatenated sequence. If the difference between the entropy value of the concatenated sequence and the target entropy value is not greater than the preset entropy value error, then the concatenated sequence is broken up to obtain the target sequence, and the target sequence is output.

[0083] As can be seen, the preset rule can be a random rule or a fixed-value rule. A random rule is like this: the adjustment length is randomly determined each time. A fixed-value rule is like this: the adjustment length is always set to a fixed numerical value.

[0084] After determining the adjustment length according to the preset rules and adjusting the sequence accordingly to obtain a new spliced ​​sequence; or after obtaining the spliced ​​sequence for the first time, the length of the current repeating sequence can be checked. Specifically, if the entropy value of the concatenated sequence is less than the target entropy value, and the length of the current repeating sequence is recorded in the first array, then the length of the current repeating sequence is incremented by one. When the length obtained by incrementing by one is not recorded in the first array, the length obtained by incrementing by one is taken as the available length of the current repeating sequence, and the length of the random sequence is adjusted accordingly. Then, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeating sequence are executed. The first array is used to record: the length of the repeating sequence when the entropy value of the concatenated sequence is less than the target entropy value. If the entropy value of the concatenated sequence is greater than the target entropy value, and the length of the current repeating sequence is recorded in the second array, then the length of the current repeating sequence is decremented by one. When the length obtained by decrementing by one is not recorded in the second array, the length obtained by decrementing by one is taken as the available length of the current repeating sequence, and the length of the random sequence is adjusted accordingly. Then, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeating sequence are executed. The second array is used to record: the length of the repeating sequence when the entropy value of the concatenated sequence is greater than the target entropy value.

[0085] It should be noted that, according to this embodiment, multiple target sequences can be output. These target sequences can constitute a test dataset for a processor. To ensure that the test dataset composed of these target sequences can cover more data patterns, the test coverage of a batch of target sequences can be calculated. In one specific implementation, the method further includes: after obtaining multiple target sequences, using the multiple target sequences as test data for testing the target processor, and summing the entropy values ​​of each target sequence in the test data to obtain an entropy value set; dividing the entropy value range into multiple sub-intervals; traversing each sub-interval, if the current sub-interval can cover at least one entropy value in the entropy value set, then controlling the coverage count to increment by one; determining the ratio of the coverage count at the end of the traversal to the total number of sub-intervals as the test coverage of the test data for the target processor. The total number of sub-intervals can be flexibly set.

[0086] In one example, the entropy value ranges from [0, 8]. If [0, 8] is divided into 8000 sub-intervals, then for a batch of target sequences, it can be determined whether the entropy value of the target sequence falls into each sub-interval. If so, the coverage count is incremented by one; otherwise, the next sub-interval is checked. After checking all 8000 sub-intervals, the ratio of the coverage count at the end to 8000 is the test coverage rate of this batch of target sequences.

[0087] Furthermore, since this embodiment can generate data with a specified entropy value, if the generated different data are evenly distributed across these 8000 sub-intervals, then ideally a test dataset with 100% test coverage can be obtained. Therefore, when specifying a target entropy value, the user can specify it based on the sub-intervals obtained by dividing the entropy value range, so as to make the algorithm output value as evenly distributed as possible across the sub-intervals obtained by dividing the entropy value range.

[0088] As can be seen, this embodiment can generate a specific target sequence of a specified length with an entropy value close to the target entropy value based on the target length and target entropy value. In other words, it generates data with a specified information entropy value and a specified length. Therefore, it can output data of a desired entropy value and length using this application. This allows for customization of data entropy values ​​and lengths, resulting in data with different entropy values ​​and lengths, thus improving the richness of the output data. If data with different entropy values ​​and lengths are used as test data for the processor, it obviously improves the richness and comprehensiveness of the test data. This test data facilitates the verification of the same processor's processing capabilities for various types of data and also improves the comprehensiveness of processor verification. Furthermore, this embodiment can also quantitatively predict the test coverage of the test dataset based on the entropy distribution of the test data.

[0089] Based on the above embodiments, it should be noted that if a certain test data used to test a certain processor is regarded as a byte array S = {E1,...,En}, and the probability distribution of each byte is P = {p1,...,pn}, then each byte itself can be expressed by the formula: I e =-log 2 p i The logarithm is base 2, and the result is in bits.

[0090] Data patterns can be measured by the probability of each byte appearing. However, since the possible combinations of probabilities for each byte are infinite, how can we quantify the probability of each byte in the data using a unified standard? Referring to the examples D1 and D2 above, measuring the similarity of data patterns in different datasets does not involve the specific byte content, but primarily assesses the similarity in the probability density distribution of characters from a probabilistic perspective. Therefore, information entropy can be used to measure the patterns implied in the data.

[0091] The formula for calculating information entropy is: It represents the average amount of information contained in the data and is also an important indicator of the randomness of the data. Since a byte contains 8 bits, with a value range of [0-255], there are a total of 256 possible values. Assuming the total number of bytes in the input message is N, and the number of times each byte i appears is f(i), i∈[0,255]; then N=∑255 i=0 f(i). Where the probability of byte x appearing is p(i) = f(i) / N, the entropy value H of the entire message can be calculated using the following formula:

[0092]

[0093]

[0094]

[0095] The theoretical range of entropy value H is [0, 8]. Dividing this range into 8000 equal intervals [0.001, 0.002, ..., 7.998, 7.999, 8], we can determine whether the entropy value of each test data point falls within any of these 8000 intervals for a processor's test dataset. The coverage of the test data is measured by counting the total number of test data points falling within these intervals, thus calculating the test coverage rate. For example, if 7000 of the 8000 intervals contain test data, the test coverage rate is 7000 / 8000 = 87.49%. Dividing the entropy interval into 8000 equal parts is merely to demonstrate a feasible implementation; the actual division of the entropy interval can be flexibly adjusted. When the interval division is too fine-grained, more and richer test data is needed to achieve good test coverage; conversely, if the interval division is too coarse-grained, less and less rich test data will be needed to achieve good test coverage. Therefore, the granularity of the entropy interval division should be adjusted according to the actual situation.

[0096] Therefore, this embodiment can use information entropy values ​​to measure the test coverage of the test dataset. Furthermore, this embodiment can also generate data sequences with specified information entropy values ​​and lengths; please refer to [link to documentation] for details. Figure 2 .

[0097] Figure 2 The implemented algorithm flow specifically includes the following steps:

[0098] Step 1: Set the target data bytes N, target entropy value E, maximum tolerable entropy error D (take a positive number), and maximum number of retries R.

[0099] Step 2: Set n0 to N divided by 2, and n1 to N minus n0.

[0100] Step 3: Use a general random number generation algorithm to generate a sequence containing n0 random bytes, recorded as s0; generate a sequence containing n1 repeating bytes (e.g., with a value of 0), recorded as s1.

[0101] Step 4: Concatenate s0 and s1 together and record it as s.

[0102] Step 5: If the current value of R is greater than 0, proceed to step 6; otherwise, the process ends and the generation of target data fails.

[0103] Step 6: Decrement the value of R by 1.

[0104] Step 7: Calculate the entropy e of sequence s using a general entropy calculation method.

[0105] Step 8: Calculate the entropy error d = eE.

[0106] Step 9: If the absolute value of d is less than or equal to D, it means that s has met the length and target entropy value set in Step 1. Therefore, s is divided into blocks of 5 bytes each, and then random position transformations are performed on each block. After that, the sequence after the block position transformations is output, and the process ends. If the absolute value of d is greater than D, it means that s has not yet reached the target entropy value set in Step 1, so proceed to Step 10.

[0107] Step 10: If d > 0, it means that the entropy value of the current s is too high, so proceed to step 11 to adjust the sequence; otherwise, it means that the entropy value of the current s is too low, so proceed to step 12 to adjust the sequence.

[0108] Step 11: Reduce the random byte sequence s0 by one byte (e.g., delete the last byte), and increase the repeated byte sequence s1 by one byte, then return to step 4 to continue execution.

[0109] Step 12: Add one byte to the random byte sequence s0 (for example, append a random byte to the end), and reduce the repeating byte sequence s1 by one byte, then return to step 4 to continue execution.

[0110] As shown in steps 11 and 12 above, when the entropy value of the current byte sequence s is too high or too low, the entropy value of s in the next round is changed accordingly by adjusting the content of s0 and s1 byte by byte. Byte-by-byte adjustment may be inefficient; therefore, in practice, multiple bytes can be adjusted at once to improve efficiency. Specifically, when the entropy value of s is higher than the target entropy value, the length of s0 can be halved, while the length of s1 can be increased accordingly to accelerate the convergence of the entropy value.

[0111] Based on the above, multiple pattern-rich sequences can be generated as test data for any processor. At the same time, the coverage of a batch of generated test data can be quantitatively evaluated using the aforementioned coverage calculation method, so that the processor's test dataset achieves approximately 100% coverage of data patterns.

[0112] In summary, this application can quantitatively evaluate the coverage of test data based on the pattern richness of the test data, and can generate test vectors with specified information entropy and length, realizing the customization of test vectors, thereby improving the richness of test data.

[0113] The following describes a data generation apparatus provided in an embodiment of this application. The data generation apparatus described below and the data generation method described above can be referred to each other.

[0114] See Figure 3 As shown in the figure, this application discloses a data generation apparatus, including:

[0115] Module 301 is used to obtain the target length and target entropy value;

[0116] The determining module 302 is used to determine the first sub-length and the second sub-length based on the target length;

[0117] The generation module 303 is used to generate a random sequence of the first sub-length and a repeating sequence of the second sub-length;

[0118] The splicing module 304 is used to splice random sequences and repeating sequences to obtain a spliced ​​sequence;

[0119] The output module 305 is used to break up the spliced ​​sequence to obtain the target sequence and output the target sequence if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error.

[0120] In one specific implementation, the determining module is specifically used for:

[0121] The first sub-length is set to half the target length, and the second sub-length is obtained by subtracting the first sub-length from the target length.

[0122] or

[0123] The first sub-length is set to any value less than the target length, and the second sub-length is obtained by subtracting the first sub-length from the target length.

[0124] In one specific implementation, the output module is specifically used for:

[0125] Divide the spliced ​​sequence into multiple subsequences;

[0126] The target sequence is obtained by adjusting the order of different subsequences.

[0127] In one specific implementation, the output module is specifically used for:

[0128] The concatenated sequence is divided into multiple subsequences of equal length.

[0129] In one specific implementation, it further includes:

[0130] The retry count update module is used to determine the current retry count. If the current retry count is greater than zero, the current retry count is decremented by one, and then the following steps are executed: if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error, the spliced ​​sequence is broken up to obtain the target sequence, and the target sequence is output. If the current retry count is not greater than zero, a prompt message indicating that the maximum number of retry counts has been reached is generated, and the current generation process is exited.

[0131] In one specific implementation, it further includes:

[0132] The adjustment module is used to adjust the lengths of the random sequence and the repeating sequence respectively if the difference between the entropy value of the concatenated sequence and the target entropy value is greater than the preset entropy error, so that the sum of the lengths of the adjusted random sequence and the adjusted repeating sequence is equal to the target length; replace the random sequence with the adjusted random sequence, replace the repeating sequence with the adjusted repeating sequence, and perform concatenation of the random sequence and the repeating sequence to obtain the concatenated sequence; if the difference between the entropy value of the concatenated sequence and the target entropy value is not greater than the preset entropy error, then break up the concatenated sequence to obtain the target sequence and output the target sequence.

[0133] In one specific implementation, the adjustment module is specifically used for:

[0134] Determine whether the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than zero;

[0135] If so, shorten the random sequence and correspondingly lengthen the repeating sequence;

[0136] If not, then extend the random sequence and shorten the repeating sequence accordingly.

[0137] In one specific implementation, the adjustment module is specifically used for:

[0138] The adjustment length is determined according to preset rules;

[0139] Remove data of adjusted length from the random sequence and fill the repeating sequence with data of adjusted length;

[0140] Accordingly, the adjustment module is specifically used for:

[0141] The adjustment length is determined according to preset rules;

[0142] Fill random sequences with data of adjusted length and remove data of adjusted length from repeating sequences.

[0143] In one specific implementation, the adjustment module is specifically used for:

[0144] If the entropy value of the spliced ​​sequence is greater than the target entropy value, the length will be adjusted to half the length of the first sub-sequence.

[0145] In one specific implementation, it further includes:

[0146] The coverage evaluation module is used to take multiple target sequences as test data for testing the target processor after obtaining multiple target sequences, and to summarize the entropy value of each target sequence in the test data to obtain an entropy value set; divide the entropy value range into multiple sub-intervals; traverse each sub-interval, and if the current sub-interval can cover at least one entropy value in the entropy value set, the coverage count is incremented by one; the ratio of the coverage count at the end of the traversal to the total number of sub-intervals is determined as the test coverage of the test data for the target processor.

[0147] In one specific implementation, it further includes:

[0148] The inspection module is used to: if the entropy value of the concatenated sequence is less than the target entropy value, and the length of the current repeating sequence is recorded in the first array, then control the length of the current repeating sequence to be incremented by one. When the length obtained by incrementing by one is not recorded in the first array, the length obtained by incrementing by one is used as the available length of the current repeating sequence, and the length of the random sequence is adjusted accordingly. Then, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeated sequence are executed. The first array is used to record: the length of the repeating sequence when the entropy value of the concatenated sequence is less than the target entropy value; if the entropy value of the concatenated sequence is greater than the target entropy value, and the length of the current repeating sequence is recorded in the second array, then control the length of the current repeating sequence to be decremented by one. When the length obtained by decrementing by one is not recorded in the second array, the length obtained by decrementing by one is used as the available length of the current repeating sequence, and the length of the random sequence is adjusted accordingly. Then, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeated sequence are executed. The second array is used to record: the length of the repeating sequence when the entropy value of the concatenated sequence is greater than the target entropy value.

[0149] For more detailed information on the working process of each module and unit in this embodiment, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.

[0150] As can be seen, this embodiment provides a data generation device that can quantitatively evaluate the coverage of test data based on the pattern richness of test data, and can generate test vectors with specified information entropy and specified length, realizing the customization of test vectors, thereby improving the richness of test data.

[0151] The following describes an electronic device provided by an embodiment of this application. The electronic device described below can be referred to in conjunction with the data generation method and apparatus described above.

[0152] See Figure 4 As shown in the figure, an embodiment of this application discloses an electronic device, including:

[0153] Memory 401 is used to store computer programs;

[0154] Processor 402 is configured to execute the computer program to implement the method disclosed in any of the above embodiments.

[0155] The following describes a readable storage medium provided in an embodiment of this application. The readable storage medium described below can be referred to in conjunction with the data generation method, apparatus and device described above.

[0156] A readable storage medium is provided for storing a computer program, wherein the computer program, when executed by a processor, implements the data generation method disclosed in the foregoing embodiments. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0157] The terms “first,” “second,” “third,” “fourth,” etc., used in this application (if applicable) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, or apparatus that includes a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, or apparatus.

[0158] It should be noted that the use of terms such as "first" and "second" in this application is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed in this application.

[0159] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0160] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of readable storage medium known in the art.

[0161] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A processor testing method, characterized in that, include: Obtain the target length and the target entropy value that reflects the randomness of the data; the target length is any integer not greater than the maximum data length that the target processor can process; The first sub-length and the second sub-length are determined based on the target length; Generate a random sequence of the first sub-length and a repeating sequence of the second sub-length; By concatenating the random sequence and the repeating sequence, a concatenated sequence is obtained; If the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error, then the spliced ​​sequence is broken up to obtain the target sequence, and the target sequence is output. After obtaining multiple target sequences, the multiple target sequences are used as test data for testing the target processor, and the entropy value of each target sequence in the test data is summarized to obtain an entropy value set; Divide the entropy value range into multiple sub-intervals; Traverse each sub-interval. If the current sub-interval can cover at least one entropy value in the entropy value set, then increment the coverage count by one. The ratio of the number of coverages at the end of the traversal to the total number of sub-intervals is determined as the test coverage rate of the test data for the target processor.

2. The method according to claim 1, characterized in that, Determining the first sub-length and the second sub-length based on the target length includes: The first sub-length is set to half of the target length, and the second sub-length is obtained by subtracting the first sub-length from the target length; or The first sub-length is set to any value less than the target length, and the second sub-length is obtained by subtracting the first sub-length from the target length.

3. The method according to claim 1, characterized in that, The process of breaking down the spliced ​​sequence to obtain the target sequence includes: The spliced ​​sequence is divided into multiple sub-sequences; The target sequence is obtained by adjusting the order of the different subsequences.

4. The method according to claim 3, characterized in that, The step of dividing the spliced ​​sequence into multiple sub-sequences includes: The spliced ​​sequence is divided into multiple subsequences of equal length.

5. The method according to claim 1, characterized in that, After splicing the random sequence and the repeating sequence to obtain the spliced ​​sequence, the method further includes: Determine the current number of retries; If the current number of retries is greater than zero, then after the current number of retries is decremented by one, the following steps are executed: if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error, then the spliced ​​sequence is broken up to obtain the target sequence and the target sequence is output. If the current number of retries is not greater than zero, a prompt message indicating that the maximum number of retries has been reached is generated, and the current generation process is exited.

6. The method according to claim 1, characterized in that, Also includes: If the difference is greater than the preset entropy error, then the lengths of the random sequence and the repeating sequence are adjusted respectively, and the sum of the lengths of the adjusted random sequence and the adjusted repeating sequence is equal to the target length. The steps are as follows: replace the random sequence with the adjusted random sequence, replace the repeated sequence with the adjusted repeated sequence, and perform splicing of the random sequence and the repeated sequence to obtain a spliced ​​sequence; if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than the preset entropy value error, then break up the spliced ​​sequence to obtain the target sequence and output the target sequence.

7. The method according to claim 6, characterized in that, The steps of adjusting the lengths of the random sequence and the repeating sequence respectively include: Determine whether the difference between the entropy value of the spliced ​​sequence and the target entropy value is greater than zero; If so, shorten the random sequence and correspondingly lengthen the repeating sequence; If not, then the random sequence is extended and the repeating sequence is shortened accordingly.

8. The method according to claim 7, characterized in that, The shortening of the random sequence and the corresponding lengthening of the repeating sequence include: The adjustment length is determined according to preset rules; Delete the adjusted-length data from the random sequence and fill the adjusted-length data into the repeating sequence; Accordingly, extending the random sequence and shortening the repeating sequence accordingly includes: The adjustment length is determined according to preset rules; The adjusted-length data is filled into the random sequence, and the adjusted-length data is deleted from the repeating sequence.

9. The method according to claim 6, characterized in that, Also includes: If the entropy value of the spliced ​​sequence is less than the target entropy value, and the length of the current repeating sequence is recorded in the first array, then the length of the current repeating sequence is incremented by one. When the length obtained by incrementing by one is not recorded in the first array, the length obtained by incrementing by one is taken as the available length of the current repeating sequence. After adjusting the length of the random sequence accordingly, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeating sequence are executed. The first array is used to record the length of the repeating sequence when the entropy value of the spliced ​​sequence is less than the target entropy value. If the entropy value of the spliced ​​sequence is greater than the target entropy value, and the length of the current repeating sequence is recorded in the second array, then the length of the current repeating sequence is decremented by one. When the length obtained by decrementing by one is not recorded in the second array, the length obtained by decrementing by one is taken as the available length of the current repeating sequence. After adjusting the length of the random sequence accordingly, the steps of replacing the random sequence with the adjusted random sequence and replacing the repeating sequence with the adjusted repeating sequence are executed. The second array is used to record the length of the repeating sequence when the entropy value of the spliced ​​sequence is greater than the target entropy value.

10. A processor testing apparatus, characterized in that, include: The acquisition module is used to acquire the target length and the target entropy value, which reflects the randomness of the data; the target length is any integer not greater than the maximum data length that the target processor can process. The determining module is used to determine a first sub-length and a second sub-length based on the target length; A generation module is used to generate a random sequence of the first sub-length and a repeating sequence of the second sub-length; A splicing module is used to splice the random sequence and the repeating sequence to obtain a spliced ​​sequence; The output module is used to break up the spliced ​​sequence to obtain the target sequence and output the target sequence if the difference between the entropy value of the spliced ​​sequence and the target entropy value is not greater than a preset entropy value error. The coverage evaluation module is used to, after obtaining multiple target sequences, use the multiple target sequences as test data for testing the target processor, and summarize the entropy value of each target sequence in the test data to obtain an entropy value set; divide the entropy value range into multiple sub-intervals; traverse each sub-interval, and if the current sub-interval can cover at least one entropy value in the entropy value set, control the coverage count to increment by one; and determine the ratio of the coverage count at the end of the traversal to the total number of sub-intervals as the test coverage rate of the test data for the target processor.

11. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method as claimed in any one of claims 1 to 9.

12. A readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the method as described in any one of claims 1 to 9.