WO2020199789A1 - 一种信息处理方法及装置 - Google Patents

一种信息处理方法及装置 Download PDF

Info

Publication number
WO2020199789A1
WO2020199789A1 PCT/CN2020/076491 CN2020076491W WO2020199789A1 WO 2020199789 A1 WO2020199789 A1 WO 2020199789A1 CN 2020076491 W CN2020076491 W CN 2020076491W WO 2020199789 A1 WO2020199789 A1 WO 2020199789A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
preset
subroutine
information
subroutines
Prior art date
Application number
PCT/CN2020/076491
Other languages
English (en)
French (fr)
Inventor
陈晓丹
殷凇
李宗波
邬秋元
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2020199789A1 publication Critical patent/WO2020199789A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis

Definitions

  • the present invention relates to the field of financial technology (Fintech), in particular to an information processing method and device.
  • the quality of the information can be comprehensively evaluated, thereby providing a basis for users' decision-making.
  • obtaining the coverage information corresponding to the program is a commonly used testing method in the financial technology field.
  • the coverage rate information corresponding to the program refers to the proportion information and degree information of the code executed in the process of executing the program. By determining the coverage rate information corresponding to the program, the quality of the code in the program can be measured.
  • the degree of code coverage in the program is high, the quality of the code in the program can be determined to be better; correspondingly, if the degree of code coverage in the program is low, it can be determined that the quality of the code in the program is poor. Therefore, obtaining accurate coverage information is very important for accurately analyzing the quality of the code in the program.
  • the line-by-line test method is a common method to obtain the coverage information corresponding to the class program.
  • the execution result of each line of bytecode in the program can be recorded.
  • the coverage information obtained can include the line number of each line of bytecode and the word of each line. Section code test result. For example, if the bytecode of line 5 in the class program is not executed, the coverage information can include "5, 0", where "5" can be used to identify the bytecode of line 5, "0" It can be used to identify the test result of this line of bytecode as not executed.
  • the bytecode in the class program is not modified during the test, more accurate coverage information can be obtained; however, if the test process is executed multiple times, and the class is modified during the test Part of the bytecode in the program may be due to changes in the line number of the modified bytecode, which may cause the coverage information corresponding to multiple test processes to be disordered, which makes the merge process of multiple test processes error.
  • the coverage information before modification can include “5 , 0"
  • the modified coverage information can include "5, 1”
  • the bytecode indicated by the "5" in the two coverage information is actually different, in order to achieve the two coverage information
  • Merging may discard the "5, 0" in the coverage information before modification during the merging process, resulting in inaccurate coverage information obtained by the merge.
  • the embodiment of the present invention provides an information processing method and device, which are used to improve the accuracy of the combined coverage information.
  • an information processing method provided by an embodiment of the present invention includes:
  • Acquire first information obtained by using a first program to execute a preset test set at the first moment the first program includes M first subprograms, and the first information includes the corresponding M first subprograms Indicating value, each first subroutine is used to complete the preset function corresponding to each first subroutine, and the instruction value corresponding to each first subroutine is used to instruct the execution of the preset test set.
  • a first subroutine Whether a first subroutine is called; acquiring preset information, the preset information being obtained by executing a preset test set using one or more second programs within a preset time period after the first moment, the The preset information includes the indication values corresponding to the N second subroutines; further, if it is determined that the first program matches the one or more second programs, the M first subroutines corresponding to Update the indication values corresponding to the N second subroutines in the preset information to obtain target information.
  • the indicator value of the subroutine ie the test results of the M first subroutine and N second subroutines
  • the indicator values of the subroutines in the multiple test results are merged according to the subroutine, so as to avoid the subroutines caused by merging the indicator values of different subroutines.
  • the indication values corresponding to the N second subprograms are added to the preset information.
  • the test result corresponding to the new program can be directly added to the preset information; by judging in advance whether the program corresponding to the test result is a new program before combining the predicted results , Can simplify the operation process and improve the efficiency of information processing.
  • the first information further includes an identifier of the first program and a check value of the first program
  • the preset information also includes an identifier of the one or more second programs and The check value of the one or more second programs; if it is determined that the first program matches the one or more second programs, use the indicator values corresponding to the M first subprograms to update
  • the indication values corresponding to the N second subprograms include: if it is determined that the check value of the first program is the same as the check value of the third program in the one or more second programs, then Obtain M second subroutines matching the M first subroutines from the N second subroutines, and update the corresponding M second subroutines according to the indicator values corresponding to the M first subroutines If it is determined that the identifier of the first program is the same as the identifier of the fourth program in the one or more second programs, and the check value of the first program is the same as the one or more second programs If the check values of the programs are not the same, then the T first
  • the identification of the program and the check value of the program are used as the two evaluation criteria of the combined test result, which can make the combined process more perfect; specifically, if the check values of the two programs are the same, then Explain that the bytecodes in the two programs are exactly the same, so the indicator values of the M subprograms included in the two programs can be merged in sequence; if the check values of the two programs are different, and the identifiers of the two programs are the same, you can It shows that there are some bytecode differences in the two programs, so it is possible to merge the indicator values of T subroutines with the same bytecode in the two programs. It can be seen that the above technical solution adopts the method of comparing the program identification and the program check value. On the one hand, it simplifies the operation and makes the process of merging test results easier to achieve. On the other hand, it can improve the accuracy of the target information obtained by the merge. Sex.
  • the updating the indication values corresponding to the M second subprograms according to the indication values corresponding to the M first subprograms includes: if it is determined that the indication value corresponding to the first first subprogram is the first An indicator value, the indicator value corresponding to the first second subroutine is the second indicator value, then the indicator value corresponding to the first second subroutine is updated to the first indicator value; the first indicator value is used
  • the first subroutine or the second subroutine is called when instructing to execute the preset test set; wherein, I ⁇ M.
  • the M first subroutines include a Y-th first subroutine, and the Y-th first subroutine is determined in the following manner: the first subroutine is calculated according to a preset bytecode length. The bytecode in the program is detected.
  • the first position information of the first preset indicating character in the first program is recorded, and the first indicating character is used for Indicate the initial bytecode corresponding to the Y-th first subroutine; detect the bytecode located after the first preset indication character in the first program, and if it is detected that it corresponds to the first preset Assuming that the second preset indicating character corresponds to the indicating character, the second position information of the second preset indicating character in the first program is recorded, and the second indicating character is used to indicate the Y th A termination bytecode corresponding to a subroutine; according to the first position information and the second position information, obtain the first preset indicating character and the second preset indicating character in the first program And use the bytecode as the bytecode of the Y-th first subroutine.
  • the first subroutine can be made the function or method in the first program (ie To complete the program segment of the preset function), the coverage information is updated based on the function or method, which can avoid merging the indicator values of different functions, so as to ensure the integrity of the coverage information and further improve the combined coverage The accuracy of the information.
  • an information processing device provided by an embodiment of the present invention includes:
  • the obtaining module is configured to obtain first information obtained by executing a preset test set using a first program at a first moment, the first program includes M first subprograms, and the first information includes the M first subprograms. Indicating values corresponding to the subroutines respectively, and the indicating value corresponding to each first subroutine is used to indicate whether each of the first subroutines is called when the preset test set is executed; and, obtaining preset information, The preset information is obtained by using one or more second programs to execute a preset test set within a preset time period after the first moment; the preset information includes indication values corresponding to the N second subprograms, respectively ;
  • the update module is configured to, if it is determined that the first program matches the one or more second programs, use the indicator values corresponding to the M first subroutines to update the Nth subroutine in the preset information
  • the indicator value corresponding to the two subroutines obtains the target information.
  • the update module is further configured to: if it is determined that the first program does not match the one or more second programs, add the indication values respectively corresponding to the N second subprograms to all The preset information.
  • the first information further includes an identifier of the first program and a check value of the first program
  • the preset information also includes an identifier of the one or more second programs and The check value of the one or more second programs
  • the update module is configured to: if it is determined that the check value of the first program is the same as the check value of the third program in the one or more second programs, obtain from the N second subprograms M second subprograms matching the M first subprograms, and update the indication values corresponding to the M second subprograms according to the indication values corresponding to the M first subprograms; if it is determined that the The identifier of the first program is the same as the identifier of the fourth program in the one or more second programs, and the check value of the first program is different from the check value of the one or more second programs ,
  • the T first subprograms matching the T second subprograms in the N second subprograms are obtained from the M first subprograms, and corresponding to the T first subprograms Update the corresponding indicator values of the T second subroutines.
  • the update module is configured to: if it is determined that the indicator value corresponding to the first subroutine I is the first indicator value, and the indicator value corresponding to the second subroutine I is the second indicator value, then The indicator value corresponding to the first second subroutine is updated to the first indicator value; the first indicator value is used to indicate that the first subroutine or the second subroutine is called when the preset test set is executed.
  • the M first subroutines include a Y-th first subroutine, and the Y-th first subroutine is determined in the following manner: the first subroutine is calculated according to a preset bytecode length. The bytecode in the program is detected.
  • the first position information of the first preset indicating character in the first program is recorded, and the first indicating character is used for Indicate the initial bytecode corresponding to the Y-th first subroutine; detect the bytecode located after the first preset indication character in the first program, and if it is detected that it corresponds to the first preset Assuming that the second preset indicating character corresponds to the indicating character, the second position information of the second preset indicating character in the first program is recorded, and the second indicating character is used to indicate the Y th A termination bytecode corresponding to a subroutine; according to the first position information and the second position information, obtain the first preset indicating character and the second preset indicating character in the first program And use the bytecode as the bytecode of the Y-th first subroutine.
  • embodiments of the present invention also provide a computer-readable storage medium, including instructions, which when run on a computer, cause the computer to execute the information processing method described in any of the first or second aspects.
  • the embodiments of the present invention also provide a computer program product, which when run on a computer, causes the computer to execute the information processing method described in any of the first or second aspects.
  • FIG. 1 is a schematic diagram of a process for obtaining target coverage information by combining according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of an information processing method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of an array storage of first coverage information provided by an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of an information processing device provided by an embodiment of the present invention.
  • a program may refer to a class program, which may include multiple lines of bytecode
  • a subprogram may refer to a program segment corresponding to a method (or function) in the class program, that is, a subprogram It can include multiple lines of bytecode to complete the function corresponding to the subroutine.
  • the information may refer to coverage information, that is, the call status of the bytecode in the class program when the class program is used to execute the preset test set.
  • coverage information that is, the call status of the bytecode in the class program when the class program is used to execute the preset test set.
  • FIG. 1 is a schematic diagram of a process for obtaining target coverage information by merging according to an embodiment of the present invention. As shown in FIG. 1, the process of obtaining target coverage information by merging may include the following steps:
  • Step d Use the program a 1 to execute the preset test set to obtain the first coverage information.
  • Step e Modify the program a 1 to obtain the program a 2 , and use the program a 2 to execute the preset test set to obtain the second coverage information.
  • Step f Modify the program a 2 to obtain the program a 3 , and use the program a 3 to execute the preset test set to obtain the third coverage information.
  • Step g Combine the first coverage rate information, the second coverage rate information, and the third coverage rate information to obtain target coverage rate information.
  • program a 2 can be obtained by modifying program a 1 , that is, the generation time of program a 2 can be later than the generation time of program a 1 , and program a 3 can be modified to program a 2 obtained, i.e., a program may generate a timing later than the program 3 generates a timing 2.
  • the time when the program a 1 executes the preset test set may be earlier than the time when the program a 2 executes the preset test set, and the time when the program a 2 executes the preset test set may be earlier than the time when the program a 3 executes the preset test set;
  • the generation time of the first coverage rate information may be earlier than the generation time of the second coverage rate information, and the generation time of the second coverage rate information may be earlier than the generation time of the third coverage rate information.
  • the preset test set may be set by those skilled in the art according to actual needs.
  • the preset test set may include one test sample, or may also include at least two test samples, which is not specifically limited.
  • the multiple test samples in are not specifically limited.
  • the preset test set may include test samples w 1 , test samples w 2 , test samples w 3 , test samples w 4 , and test samples w 5
  • the first coverage information may be used
  • Procedure a 1 is obtained by testing test sample w 1 and test sample w 2
  • the second coverage information can be obtained by using procedure a 2 on test sample w 3
  • the third coverage information can be obtained by using procedure a 3 on test Sample w 4 and test sample w 5 are tested.
  • the program a 1, a 2 program and the program is called a 3 byte codes may be different, and therefore, by covering the first program a 1, a 2 and a program corresponding to each program a 3 Rate information, second coverage rate information, and third coverage rate information are combined to determine complete target coverage rate information.
  • FIG. 1 is only an exemplary simple description, and the corresponding relationship among the multiple programs (ie, program a 1 , program a 2, and program a 3 ) listed is only for the convenience of explaining the solution, not It constitutes a restriction on the plan.
  • among the plurality of programs may have a correspondence relationship, or may not have a corresponding relationship, such as a program for the program.
  • 3 a 1 can be obtained by modifying the program, or program a 1, a 2, and program a program 3 can be completely different procedures, and the specifics are not limited.
  • the multiple pieces of coverage information may be combined in a preset order, and the preset order may be set by those skilled in the art based on experience, which is not specifically limited.
  • multiple coverage rate information can be merged in the order of generation time from late to early.
  • the third coverage rate information can be combined with the second coverage rate information to obtain the coverage rate information b 1 , and then the coverage rate information b 1 can be combined with the first coverage rate information to obtain the target coverage rate information;
  • multiple coverage information can be combined in the order of generation time from morning to night.
  • the first coverage information and the second coverage information can be combined first to obtain coverage information b 2 , and then The coverage rate information b 2 can be combined with the third coverage rate information to obtain target coverage rate information.
  • the multiple coverage information can be combined in a random order.
  • the first coverage information and the third coverage information can be combined first to obtain Coverage rate information b 3
  • the second coverage rate information and coverage rate information b 3 may be combined to obtain target coverage rate information, which is not specifically limited.
  • Figure 2 is a schematic flow diagram corresponding to an information processing method provided by an embodiment of the present invention. This method can be used to merge any two coverage information, for example, to the third The coverage rate information is combined with the second coverage rate information, or may also be used to merge the coverage rate information b 1 and the first coverage rate information. If more than two coverage information needs to be merged, the method shown in FIG. 2 can be executed cyclically until the target coverage information is obtained.
  • the method may include:
  • Step 201 Acquire first information obtained by executing a preset test set using the first program at the first moment.
  • the M first subprograms included in the program a 1 can be predetermined, and the program a 1 can be used to execute the preset test set according to the preset periodic monitoring program for a 1 or in the case of each of the first subroutine call. Further, the indicator value corresponding to each first subroutine can be set according to the calling situation of each first subroutine.
  • the indicator value corresponding to the first subroutine can be set as the first indicator value (such as 1); accordingly, if it is determined that none of the first subroutines has been called during the execution of the preset test set, you can set The indicator value corresponding to the first subroutine is set to the second indicator value (for example, 0).
  • the program performs a 1 to a predetermined end position of the test set may be generated in accordance with a first coverage information M first subroutine instruction value corresponding to each program included in a 1.
  • M is a method of determining a first subroutine program comprises a 1
  • the program may be traversed successively in a 1-byte code, when the first detected
  • the bytecode can be stored from the indicator character defined by the first subprogram until the indicator character at the end of the first subprogram closest to the indicator character defined by the first subprogram is detected, and the The bytecode between the indicating character defined by a subprogram and the indicating character at the end of the first subprogram, and the bytecode can be regarded as a first subprogram.
  • the bytecode corresponding to the first subroutine may not include the line number.
  • the bytecode in the process of obtaining the bytecode from the program a 1 and storing it as the first subroutine, if the bytecode indicating the line number (such as LINE NUMBER) is detected, the bytecode can be directly stored without Get the next bytecode. For example, if a certain section of bytecode in program a 1 is "****LINE NUMBER%%%", the bytecode stored in the first subroutine can be "****%%% %”.
  • the foregoing is only an exemplary and simple description, and the method for determining the first subroutine shown in it is only for the convenience of explaining the solution, and does not constitute a limitation on the solution.
  • other methods can also be used to determine the P first subroutines.
  • the above method can be used to detect a certain segment of bytecode in program a 1 and determine the L first subroutines included in the segment of bytecode.
  • manual detection method may be employed to determine a first subprogram pL of a 1-byte code other than the codes included in the field bytes, is not limited particularly.
  • a first subroutine 11 r identifier may be used to uniquely identify a first subroutine r 11, r identifies a first subroutine 11 may be constituted by a first portion and a second portion, the first portion may be a first sub-
  • the second part can be the fully qualified names of multiple parameter types included in the bytecode of the first subroutine r 11 , where one of the fully qualified names of the multiple parameter types
  • the spaces can be separated by preset symbols.
  • the identifier of the first subroutine r 11 is r 11 :i 1 :i 3 :i 4 , it can be determined that the first subroutine r 11 includes parameters of types i 1 , i 3 and i 4 .
  • a first check value r subroutine 11 may be used to uniquely identify a first information bytecode instruction value r subroutine 11 comprises a first check value r subroutine 11 may be a first subroutine r after 11 bytecode information comprises key encryption is obtained, such as may be acquired all bytecode R & lt subroutine 11 includes a first, determining a first encryption algorithm is MD5 routine 11 corresponding to R & lt MD5 value, The MD5 value can be used as the check value of the first subroutine r 11 ; or the redundant cyclic encryption method can be used to determine the CRC value corresponding to the first subroutine r 11 , and the CRC value can be used as the first subroutine The check value of r 11 .
  • Embodiment of the present invention may also be determined program identifier and a program 1, a check value 1.
  • a program can be identified by a unique identification for a program 1
  • a program identifier may be constituted by a first portion and a second portion, the first portion may be a name of a program, the program may be a second portion belongs 1
  • the range of ie the location information of the file where the program a 1 is located); for example, if the identifier of the program a 1 is a 1 :D: ⁇ study, then the name of the program a 1 can be determined as a 1 and the file where the degree a 1 is The location information is D: ⁇ study.
  • the check value of the program a 1 can be used to uniquely identify the bytecode information included in the program a 1.
  • the process of determining the check value of the program a 1 can refer to the calibration of the first subroutine r 11 The process of verification is carried out and will not be repeated.
  • the coverage information may include a first identifying a program 1, a program check value 1, M of first identification subroutine, the subroutine M of first check value and The indicated values corresponding to the M first subroutines.
  • the first coverage information may be stored in the form of a table, or may also be stored in the form of an array, which is not specifically limited.
  • Table 1 is a schematic table in which the first coverage information provided by an embodiment of the present invention is stored in a table form.
  • Table 1 A schematic of storing the first coverage rate information in table form
  • a first coverage information may be a 1 sets a first pair of preset test coverage information obtained using the test procedure, the first coverage information may include a program identifier of a 1 a 1: D: The check value of ⁇ study and program a 1 is 12q345, where the address of the folder where the program a 1 is located can be D: ⁇ study.
  • the program a 1 can include the first subprogram r 11 , the first subprogram r 12 and the first subprogram r 13 , and the identifier of the first subprogram r 11 can be r 11 :i 1 :i 3 :i 4 , that is
  • the first subroutine r 11 can include parameters of type i 1 , i 3 and i 4
  • the identifier of the first subroutine r 12 can be r 12 :i 1 :i 2 :i 7 , that is, the first subroutine r 11 can include parameters of type i 1 , i 2 and i 7
  • the identifier of the first subroutine r 13 can be r 13 :i 1 :i 2 :i 3 , that is, the first subroutine r 11 can include types Are the parameters of i 1 , i 2 and i 3 .
  • the check value of the first subroutine r 11 may be 5452q5, the check value of the first subroutine r 12 may be 32545z, and the check value of the first subroutine r 13 may be P23545. According to the indication values of the first subroutine r 11 , the first subroutine r 12 and the first subroutine r 13 shown in Table 1, the first subroutine r 12 and the first subroutine r 13 can be determined. In the process of using the program a 1 to test the preset test set, the first r. 11 subroutine has not been called bytecode, the bytecode r a first subroutine 12 is not invoked, the first byte code r subroutine 13 is invoked.
  • the content shown in Table 1 is the test result file obtained by using one test program to execute the preset test set.
  • the test program includes multiple (such as program a 1 and program b 1 )
  • the test program is used to It is assumed that the test result file obtained by performing one test of the test set may include the coverage information corresponding to the program a 1 and the program b 1 respectively.
  • the coverage information of each program may be provided with a table correspondingly.
  • the test result file may include the first table and the second table, and the program a 1 may be stored in the first table.
  • the coverage information of the program b 1 can be stored in the second table.
  • the coverage information of multiple programs can be stored in a table.
  • the test file obtained by performing a test on a preset test set can include both the coverage information of program a 1 and the program. b 1 coverage information.
  • FIG. 3 is a schematic diagram of an array storage of the first coverage information provided by an embodiment of the present invention. If the first coverage information is stored in an array, the array corresponding to the first coverage information can be stored There are the identifier of the first program, the check value of the first program, the identifiers of multiple first subroutines, the check value of multiple first subroutines, and each first subroutine can also be stored. The array range of the subroutine. 3, FIG. 3 schematically a first coverage information illustrated in Table 1 corresponds to a first coverage information, wherein, the array may store a program identifier 1, a program check value 1 identifying a first subroutine first subroutine r ⁇ r. 11 and 13 of the first subprogram.
  • the array range of multiple subroutines can also be set by those skilled in the art based on experience. Taking the first subroutine r 11 as an example, the array range of the first subroutine r 11 can be [1, 6], or also It can be [1, 6) or (1, 6], which is not limited.
  • the array shown in Figure 3 is a test result file obtained by using a test program to execute a preset test set.
  • the test program includes multiple (such as program a 1 and program b 1 )
  • the test program pair The test result file obtained by performing one test of the preset test set may include coverage information corresponding to the program a 1 and the program b 1 respectively.
  • the coverage information of each program can be provided with an array correspondingly.
  • the test result file can include the first array and the second array, and the first array can store the program a 1
  • the coverage information of the program b 1 can be stored in the second array.
  • Step 202 Use one or more second programs to execute a preset test set to obtain preset information according to a preset time period after the first moment.
  • the preset information may be the first obtained by executing the preset test set using the program a 2 two coverage information, or may perform a third set of test coverage information preset using the program obtained as a 3.
  • the third set of test coverage information obtained by performing preset may include a program identifier of a 3, the program check value of a 3, the program identified in a 3 M third identification subroutine, a third sub-M The check value of the program and the indicated value corresponding to the M third subroutines.
  • the preset information may be the second obtained by executing the preset test set according to the use program a 2
  • the coverage rate information and the third coverage rate information obtained by using the program a 3 to execute the preset test set are determined.
  • the process of determining the preset information according to the second coverage rate information and the third coverage rate information can be implemented with reference to the process shown in FIG. 2 (ie, step 201 to step 203).
  • the program a 2 can be used to execute the preset test set
  • the obtained second coverage information is used as the first information in step 201
  • the third coverage information obtained by executing the preset test set using program a 3 can be used as the preset information in step 202, and steps 201 to 203 are executed.
  • the determined target coverage information can be the preset information obtained by using multiple second programs to execute the preset test set within the preset time period after the first moment.
  • the following specifically describes the process of merging the first coverage rate information and the second coverage rate information to obtain the target coverage rate information.
  • Table 2a, Table 2b, and Table 2c are respectively schematic tables in which the three types of second coverage information provided by the embodiment of the present invention are stored in table form.
  • Table 2a A schematic of storing the second coverage information in table form
  • the second coverage information may be the second coverage information obtained by using the program a 2 to test the preset test set, and the second coverage information may include the identifier a 1 of the program a 2 :D:
  • the check value of ⁇ study and program a 2 is 12q345, where the address of the folder where the program a 2 is located can be D: ⁇ study.
  • the program a 2 can include the second subprogram r 11 , the second subprogram r 12 and the second subprogram r 13 , and the identifier of the second subprogram r 11 can be r 11 :i 1 :i 3 :i 4 , that is
  • the second subroutine r 11 can include parameters of type i 1 , i 3 and i 4
  • the identifier of the second subroutine r 12 can be r 12 :i 1 :i 2 :i 7 , that is, the second subroutine r 11 can include parameters of type i 1 , i 2 and i 7
  • the identifier of the second subroutine r 13 can be r 13 :i 1 :i 2 :i 3 , that is, the second subroutine r 11 can include types Are the parameters of i 1 , i 2 and i 3 .
  • the check value of the second subroutine r 11 may be 5452q5, the check value of the second subroutine r 12 may be 32545z, and the check value of the second subroutine r 13 may be P23545.
  • the second r. 11 subroutine is called bytecode, the bytecode r a second subroutine 12 is not invoked, the second byte code r subroutine 13 is invoked.
  • Table 2b Another example of storing the second coverage information in table form
  • the second coverage rate information may be the second coverage rate information obtained by using the program a 2 to test the preset test set, and the second coverage rate information may include the identifier a 1 of the program a 2 :D:
  • the check value of ⁇ study and program a 2 is 1563k2, where the address of the folder where the program a 2 is located can be D: ⁇ study.
  • the program a 2 can include the second subroutine r 11 and the second subroutine r 22.
  • the identifier of the second subroutine r 11 can be r 11 :i 1 :i 3 :i 4 , that is, in the second subroutine r 11 It can include parameters of type i 1 , i 3 and i 4.
  • the identifier of the second subroutine r 22 can be r 22 :i 3 :i 6 :i 7 , that is, the second subroutine r 22 can include the type i 3. Parameters of i 6 and i 7 .
  • the check value of the second subroutine r 11 may be 5452q5, and the check value of the second subroutine r 22 may be 32y4i4. According to the indicated values of the second subroutine r 11 and the second subroutine r 22 shown in Table 2b, it can be determined that in the process of using the program a 2 to test the preset test set, the byte of the second subroutine r 11 The code is called, and the bytecode of the second subroutine r 22 is not called.
  • Table 2c Another example of storing the second coverage information in table form
  • the coverage information may be a 2 second pair of preset test set second coverage information obtained using the test procedure
  • the second coverage information may include a program identifier of a 2 a 2: D:
  • the check value of ⁇ study and program a 2 is 553k02, where the address of the folder where the program a 2 is located can be D: ⁇ study.
  • the program a 2 can include the second subroutine r 31 and the second subroutine r 32.
  • the identifier of the second subroutine r 31 can be r 31 :i 1 :i 3 :i 4 , that is, in the second subroutine r 31 It can include parameters of type i 1 , i 3 and i 4.
  • the identifier of the second subroutine r 32 can be r 32 :i 3 :i 6 :i 7 , that is, the second subroutine r 32 can include the type i 3. Parameters of i 6 and i 7 .
  • the check value of the second subroutine r 31 may be 5452q5, and the check value of the second subroutine r 32 may be 32y4i4. According to the indicated values of the second subroutine r 31 and the second subroutine r 32 shown in Table 2c, it can be determined that in the process of using the program a 2 to test the preset test set, the byte of the second subroutine r 31 The code is not called, and the bytecode of the second subroutine r 32 is called.
  • Step 203 According to the first coverage rate information and the preset information, update the preset information to obtain target coverage rate information.
  • a program may be predetermined check value is included in the first coverage information for a program and the check value 1 included in the second coverage information 2 are the same.
  • the check value of program a 1 can be 12q345
  • the check value of program a 2 can be 12q345, that is, the check value of program a 1 a value of the program is the same as the check value 2
  • the program can be described with a bytecode program information of a 2 byte code 1 information are identical, i.e., (i.e., table 1 from the first subprogram is determined in a 1
  • the first subroutine r 11 to the first subroutine r 13 shown in the figure) and the second subroutine determined from the program a 2 that is, the second subroutine r 11 to the second subroutine shown in Table 2
  • the bytecode information of r 13 is exactly the same. Therefore, the indicator values corresponding to the second subroutine r 11 to the
  • Subroutine 13 to update the second value corresponding to the instruction value r according to a first subroutine 13 corresponding to r indicate, for example, a second subroutine r indicates a value of "0" 13, a first subroutine 13 is indicated r "1", you can confirm that the second subroutine r 13 is not called during the testing of the preset test set using program a 2 and the first subroutine is used during the testing of the preset test set using program a 1 r 13 is called, so it can be determined that the second subroutine r 13 has been called during the testing of the preset test set. At this time, the indicator value of the second subroutine r 13 can be updated to "1".
  • the indicator value of the second subroutine r 12 is "0", and the indicator value of the first subroutine r 12 is "0", which can determine the test set using the program a 1 and the program a 2 .
  • the indicator value of the second subroutine r 12 may still be “0".
  • the indicator value of the second subroutine r 11 is "1”, and the indicator value of the first subroutine r 11 is "1", which can determine the first step in the process of using the program a 1 and the program a 2 to test the preset test set.
  • r 11 are two subroutine calls, subroutine thus may not need a second instruction value r 11 is updated, i.e. the second subroutine instruction value r may be 11 remains "1.”
  • Table 3a is a schematic table of target coverage information obtained by updating the second coverage information according to the first coverage information and the second coverage information shown in Table 1 and Table 2a.
  • Table 3a A schematic of storing target coverage information in table form
  • the check value of program a 1 can be 12q345, and the check value of program a 2 can be 1563k2, which is the check of program a 1 a program different from the value of the check value 2, a program can be described in different bytecode program 1 information and a 2 byte code information, i.e., determined from a first subprogram in a program 1 (i.e., table 1
  • the illustrated first subroutine r 11 to the first subroutine r 13 ) and the second subroutine determined from the program a 2 ie, the second subroutine r 11 and the second subroutine r shown in Table 2) 22 )
  • the quantity or bytecode information is different.
  • program a label 1 may be a 1: D: ⁇ study
  • program a identifier 2 may be a 1: ⁇ study, i.e. program a identifying process 1 a same identifier 2 may be described procedure: D a 2 is obtained by modifying the bytecode information in the program a 1 ; at this time, the second subroutine r 11 and the second subroutine r 22 can be obtained from the first subroutine r 11 to the first subroutine r
  • the second subroutine that matches 13 is a second subroutine that has the same identification and check value as any one of the first subroutine r 11 to the first subroutine r 13 .
  • Table 3b is a schematic table of target coverage information obtained by updating the second coverage information according to the first coverage information and the second coverage information shown in Table 1 and Table 2b.
  • Table 3b A schematic of storing target coverage information in table form
  • the check value of program a 1 can be 12q345, and the check value of program a 2 can be 553k02, that is, the check value of program a 1
  • the value is different from the check value of program a 2 , which can indicate that the byte codes of program a 2 and program a 1 are different;
  • the identification of program a 1 can be a 1 :D: ⁇ study, and the identification of program a 2 can be a 2 : D: ⁇ study, i.e., a program identifier and a program in a different identifier 2 may be a description of the process 2 program and a file different from the folder 1.
  • the program a 2 and the program a 1 are different programs.
  • the indicator values corresponding to the first subprogram r 11 to the first subprogram r 13 determined from the program a 1 can be added to the second coverage rate In the information, the target coverage information is obtained.
  • Table 3c is a schematic table of target coverage information obtained by updating the second coverage information according to the first coverage information and the second coverage information shown in Table 1 and Table 2c.
  • Table 3c A schematic of storing target coverage information in table form
  • test result obtained by executing the test on the preset test set can also include the coverage information of multiple programs.
  • coverage information of each program can be combined to obtain the coverage information of each program.
  • Target coverage information can be included in the coverage information of each program.
  • the first information obtained by using the first program to execute the preset test set at the first time is obtained, and the preset time period after the first time is obtained using one or more second programs to execute the preset The preset information obtained from the test set; where the first program includes M first subprograms, and the first information includes indication values corresponding to the M first subprograms. Each first subprogram is used to complete each first subprogram.
  • the preset function corresponding to a subroutine the indicator value corresponding to each first subroutine is used to indicate whether each first subroutine is called when the preset test set is executed, and the preset information includes N second subroutines, respectively Corresponding indication value; further, if it is determined that the first program matches one or more second programs, the indication values corresponding to the M first subprograms included in the first information are used to update the N second programs in the preset information The indicated value corresponding to the subroutine obtains the target information.
  • the solution in the embodiment of the present invention can improve the accuracy of the coverage data obtained by merging.
  • an embodiment of the present invention also provides an information processing device, and the specific content of the device can be implemented with reference to the foregoing method.
  • Fig. 4 is a schematic structural diagram of an information processing device provided by an embodiment of the present invention, including:
  • the acquiring module 401 is configured to acquire first information obtained by using a first program to execute a preset test set at a first moment, the first program includes M first subprograms, and the first information includes the M An indicator value corresponding to a subroutine, and the indicator value corresponding to each first subroutine is used to indicate whether each first subroutine is called when the preset test set is executed; and, the preset information is obtained, so
  • the preset information is obtained by using one or more second programs to execute a preset test set within a preset time period after the first moment; the preset information includes instructions corresponding to the N second subprograms, respectively Value; where M, N>0;
  • the update module 402 is configured to, if it is determined that the first program matches the one or more second programs, use the indicator values corresponding to the M first subprograms to update the N preset information The indicator value corresponding to the second subroutine obtains the target information.
  • the update module 402 is further configured to:
  • the indication values corresponding to the N second subprograms are added to the preset information.
  • the first information further includes an identifier of the first program and a check value of the first program
  • the preset information also includes an identifier of the one or more second programs and The check value of the one or more second programs
  • the update module 402 is used to:
  • the identifier of the first program is the same as the identifier of the fourth program in the one or more second programs, and the check value of the first program is the same as the check value of the one or more second programs Values are not the same, then obtain from the M first subroutines T first subroutines matching the T second subroutines in the N second subroutines, and according to the T th
  • the indicator value corresponding to one subroutine updates the indicator value corresponding to the T second subroutines.
  • the update module 402 is used to:
  • the indicator corresponding to the I first subroutine is the first indicator value
  • the indicator value corresponding to the I second subroutine is the second indicator value
  • the indicator corresponding to the I second subroutine is set The value is updated to the first indicator value; the first indicator value is used to indicate that the first subroutine or the second subroutine is called when the preset test set is executed; where I ⁇ M.
  • the M first subroutines include a Y-th first subroutine, and the Y-th first subroutine is determined in the following manner:
  • the bytecode in the first program is detected according to the preset bytecode length. If a first preset indication character is detected, the first preset indication character in the first program is recorded. A position information; the first indication character is used to indicate the initial bytecode corresponding to the Y-th first subroutine;
  • the first position information and the second position information obtain the byte code between the first preset indication character and the second preset indication character in the first program, and then combine the The byte code is the byte code of the Y-th first subroutine.
  • the first information obtained by executing the preset test set using the first program at the first moment is obtained, and the first information obtained by using the preset test set after the first moment is obtained.
  • the second program executes the preset information obtained by the preset test set; wherein, the first program includes M first subroutines, and the first information includes the indicator values corresponding to the M first subroutines, and each first subroutine
  • the program is used to complete the preset function corresponding to each first subroutine.
  • the indicator value corresponding to each first subroutine is used to indicate whether each first subroutine is called when the preset test set is executed.
  • the preset information includes The indicator values corresponding to the N second subroutines; further, if it is determined that the first program matches one or more second procedures, the indicator values corresponding to the M first subroutines included in the first information are used to update the preset Suppose the indicated values corresponding to the N second subroutines in the information to obtain the target information.
  • the indication value that is, the test result
  • the indicator values of the subroutines in the multiple test results are merged, so as to avoid the technical problem of losing the test results of the subroutines caused by the merging of the indicator values of different subroutines; that is, compared with the prior art
  • the solution in the embodiment of the present invention can improve the accuracy of the coverage data obtained by merging.
  • an embodiment of the present invention also provides a computer-readable storage medium, including instructions, which when run on a computer, cause the computer to execute the information processing method shown in the above-mentioned embodiment of FIG. 2.
  • the embodiment of the present invention also provides a computer program product, which when running on a computer, causes the computer to execute the information processing method shown in the above embodiment in FIG. 2.
  • the embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
  • a computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明实施例公开了一种信息处理方法及装置,其中方法包括:获取第一时刻使用第一程序执行预设测试集得到的第一信息,并获取第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的预设信息,若确定第一程序与一个或多个第二程序匹配,则使用第一信息中包括的M个第一子程序对应的指示值更新预设信息中N个第二子程序对应的指示值,得到目标信息。本发明实施例中,通过以完成预设功能的子程序为单位获取子程序的指示值,可以根据子程序对多个测试结果中的子程序的指示值进行合并,从而可以避免将不同子程序的指示值进行合并所造成的子程序的测试结果丢失的技术问题,从而可以提高合并得到的覆盖率数据的准确性。

Description

一种信息处理方法及装置
相关申请的交叉引用
本申请要求在2019年03月29日提交中国专利局、申请号为201910249319.0、申请名称为“一种信息处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及金融科技(Fintech)领域,尤其涉及一种信息处理方法及装置。
背景技术
在金融科技(Fintech)领域中,通过使用智能科技对信息进行处理,可以综合评估信息的质量,从而为用户的决策提供依据。在对程序进行测试的过程中,获取程序对应的覆盖率信息是金融科技领域一种常用的测试方法。程序对应的覆盖率信息是指在执行程序的过程中被执行的代码在全部代码中所占的比例信息和程度信息,通过确定程序对应的覆盖率信息,可以衡量程序中代码的质量。比如,若程序中代码被覆盖的程度较高,则可以确定程序中代码的质量较好;相应地,若程序中代码被覆盖的程度较低,则可以确定程序中代码的质量较差。因此,获取准确的覆盖率信息对于准确分析程序中代码的质量是非常重要的。
以类程序为例,采用逐行测试的方式是获取类程序对应的覆盖率信息的一种常用方法。具体地说,在测试类程序的过程中,可以记录类程序中每行字节码的执行结果,相应地,获取到的覆盖率信息中可以包括每行字节码的行号与每行字节码的测试结果。举例来说,若类程序中第5行字节码未被执行,则覆盖率信息中可以包括“5,0”,其中,“5”可以用于标识第5行字节码,“0”可以用于标识该行字节码的测试结果为未执行。采用上述方式,若 在测试的过程中未修改类程序中的字节码,则可以获取到较为准确的覆盖率信息;然而,若执行了多次测试过程,且在测试的过程中修改了类程序中的部分字节码,则可能由于修改后的字节码的行号发生变化,导致多个测试过程对应的覆盖率信息紊乱,使得多个测试过程的合并过程出错。比如,若在类程序的第5行字节码之前插入一行新的字节码,且在执行类程序时该行新的字节码被调用,则修改前的覆盖率信息中可以包括“5,0”,而修改后的覆盖率信息中可以包括“5,1”;两个覆盖率信息中的“5”所指示的字节码实际是不相同的,为了实现两个覆盖率信息的合并,可能会在合并过程中丢弃修改前的覆盖率信息中的“5,0”,导致合并得到的覆盖率信息不准确。
综上,目前亟需一种信息处理方法,用以提高合并得到的覆盖率信息的准确性。
发明内容
本发明实施例提供一种信息处理方法及装置,用以提高合并得到的覆盖率信息的准确性。
第一方面,本发明实施例提供的一种信息处理方法,包括:
获取第一时刻使用第一程序执行预设测试集得到的第一信息,所述第一程序包括M个第一子程序,所述第一信息中包括所述M个第一子程序分别对应的指示值,每个第一子程序用于完成所述每个第一子程序对应的预设功能,每个第一子程序对应的指示值用于指示执行所述预设测试集时所述每个第一子程序是否被调用;获取预设信息,所述预设信息为所述第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的,所述预设信息中包括N个第二子程序分别对应的指示值;进一步地,若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述预设信息中所述N个第二子程序对应的指示值,得到目标信息。
上述技术方案中,通过以完成预设功能(即函数功能)的子程序为单位,获取子程序的指示值(即M第一子程序、N个第二子程序的测试结果),可以 使得在合并同一个程序对应的多个测试结果的过程中,根据子程序对多个测试结果中的子程序的指示值进行合并,从而可以避免将不同子程序的指示值进行合并所造成的子程序的测试结果丢失的技术问题;也就是说,相比于现有技术采用以一行程序为单位进行合并的方式来说,上述技术方案可以提高合并得到的覆盖率信息的准确性。
可选地,若确定所述第一程序与所述一个或多个第二程序不匹配,则将所述N个第二子程序分别对应的指示值添加到所述预设信息中。
上述技术方案中,若确定测试结果对应的程序为新程序,则可以直接将新程序对应的测试结果添加在预设信息中;通过在合并预测结果之前预先判断测试结果对应的程序是否为新程序,可以简化操作过程,提高信息处理的效率。
可选地,所述第一信息中还包括所述第一程序的标识和所述第一程序的校验值,所述预设信息中还包括所述一个或多个第二程序的标识和所述一个或多个第二程序的校验值;所述若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述N个第二子程序对应的指示值,包括:若确定所述第一程序的校验值与所述一个或多个第二程序中第三程序的校验值相同,则从所述N个第二子程序中获取与所述M个第一子程序匹配的M个第二子程序,并根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值;若确定所述第一程序的标识与所述一个或多个第二程序中第四程序的标识相同,且所述第一程序的校验值与所述一个或多个第二程序的校验值均不相同,则从所述M个第一子程序中获取与所述N个第二子程序中的T个第二子程序匹配的T个第一子程序,并根据所述T个第一子程序对应的指示值更新所述T个第二子程序对应的指示值。
上述技术方案中,通过将程序的标识和程序的校验值作为合并测试结果的两个评判标准,可以使得合并过程更为完善;具体地说,若两个程序的校验值相同,则可以说明两个程序中的字节码完全相同,因此可以依次合并两个程序中所包括的M个子程序的指示值;若两个程序的校验值不同,而两个程 序的标识相同,则可以说明两个程序中存在部分字节码不同,因此可以合并两个程序中字节码相同的T个子程序的指示值。由此可知,上述技术方案采用对比程序的标识和程序的校验值的方式,一方面可以简化操作,使得合并测试结果的过程更加便于实现,另一方面,可以提高合并得到的目标信息的准确性。
可选地,所述根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值,包括:若确定第I个第一子程序对应的指示值为第一指示值,第I个第二子程序对应的指示值为第二指示值,则将所述第I个第二子程序对应的指示值更新为第一指示值;所述第一指示值用于指示执行所述预设测试集时第一子程序或第二子程序被调用;其中,I<M。
可选地,所述M个第一子程序中包括第Y个第一子程序,所述第Y个第一子程序是通过如下方式确定的:按照预设字节码长度对所述第一程序中的字节码进行检测,若检测到第一预设指示字符,则记录所述第一预设指示字符在所述第一程序中的第一位置信息,所述第一指示字符用于指示所述第Y个第一子程序对应的初始字节码;对所述第一程序中位于所述第一预设指示字符后的字节码进行检测,若检测到与所述第一预设指示字符对应的第二预设指示字符,则记录所述第二预设指示字符在所述第一程序中的第二位置信息,所述第二指示字符用于指示所述第Y个第一子程序对应的终止字节码;根据所述第一位置信息和所述第二位置信息,获取所述第一程序中位于所述第一预设指示字符与所述第二预设指示字符之间的字节码,并将所述字节码作为第Y个第一子程序的字节码。
上述技术方案中,通过将第一预设指示字符和第二预设指示字符之间的字节码定义为第一子程序,可以使得第一子程序为第一程序中的函数或方法(即完成预设功能的程序段),采用基于函数或方法来更新覆盖率信息的方式,可以避免将不同函数的指示值进行合并,从而可以保证覆盖率信息的完整,进一步地提高合并得到的覆盖率信息的准确性。
第二方面,本发明实施例提供的一种信息处理装置,所述装置包括:
获取模块,用于获取第一时刻使用第一程序执行预设测试集得到的第一信息,所述第一程序包括M个第一子程序,所述第一信息中包括所述M个第一子程序分别对应的指示值,每个第一子程序对应的指示值用于指示执行所述预设测试集时所述每个第一子程序是否被调用;以及,获取预设信息,所述预设信息为所述第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的;所述预设信息中包括N个第二子程序分别对应的指示值;
更新模块,用于若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述预设信息中所述N个第二子程序对应的指示值,得到目标信息。
可选地,所述更新模块还用于:若确定所述第一程序与所述一个或多个第二程序不匹配,则将所述N个第二子程序分别对应的指示值添加到所述预设信息中。
可选地,所述第一信息中还包括所述第一程序的标识和所述第一程序的校验值,所述预设信息中还包括所述一个或多个第二程序的标识和所述一个或多个第二程序的校验值;
所述更新模块用于:若确定所述第一程序的校验值与所述一个或多个第二程序中第三程序的校验值相同,则从所述N个第二子程序中获取与所述M个第一子程序匹配的M个第二子程序,并根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值;若确定所述第一程序的标识与所述一个或多个第二程序中第四程序的标识相同,且所述第一程序的校验值与所述一个或多个第二程序的校验值均不相同,则从所述M个第一子程序中获取与所述N个第二子程序中的T个第二子程序匹配的T个第一子程序,并根据所述T个第一子程序对应的指示值更新所述T个第二子程序对应的指示值。
可选地,所述更新模块用于:若确定第I个第一子程序对应的指示值为第一指示值,第I个第二子程序对应的指示值为第二指示值,则将所述第I个第二子程序对应的指示值更新为第一指示值;所述第一指示值用于指示执行所述预设测试集时第一子程序或第二子程序被调用。
可选地,所述M个第一子程序中包括第Y个第一子程序,所述第Y个第一子程序是通过如下方式确定的:按照预设字节码长度对所述第一程序中的字节码进行检测,若检测到第一预设指示字符,则记录所述第一预设指示字符在所述第一程序中的第一位置信息,所述第一指示字符用于指示所述第Y个第一子程序对应的初始字节码;对所述第一程序中位于所述第一预设指示字符后的字节码进行检测,若检测到与所述第一预设指示字符对应的第二预设指示字符,则记录所述第二预设指示字符在所述第一程序中的第二位置信息,所述第二指示字符用于指示所述第Y个第一子程序对应的终止字节码;根据所述第一位置信息和所述第二位置信息,获取所述第一程序中位于所述第一预设指示字符与所述第二预设指示字符之间的字节码,并将所述字节码作为第Y个第一子程序的字节码。
第三方面,本发明实施例还提供了一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行如上述第一方面或第二方面任意所述的信息处理方法。
第四方面,本发明实施例还提供了一种计算机程序产品,当其在计算机上运行时,使得计算机执行如上述第一方面或第二方面任意所述的信息处理方法。
本发明的这些方面或其他方面在以下实施例的描述中会更加简明易懂。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种合并得到目标覆盖率信息的流程示意图;
图2为本发明实施例提供的一种信息处理方法对应的流程示意图;
图3为本发明实施例提供的一种第一覆盖率信息的数组存储示意图;
图4为本发明实施例提供的一种信息处理装置的结构示意图。
具体实施方式
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
本发明实施例中,程序可以是指类程序,类程序中可以包括多行字节码,一个子程序可以是指类程序中的一个方法(或者函数)所对应的程序段,即一个子程序可以包括完成该子程序对应的功能的多行字节码。信息可以是指覆盖率信息,即使用类程序执行预设测试集时类程序中的字节码的调用情况。本发明的下列实施例中以确定目标覆盖率信息的过程为例描述本发明实施例中的信息处理方法。
图1为本发明实施例提供的一种合并得到目标覆盖率信息的流程示意图,如图1所示,合并得到目标覆盖率信息的过程可以包括如下步骤:
步骤d,使用程序a 1执行预设测试集得到第一覆盖率信息。
步骤e,对程序a 1进行修改得到程序a 2,并使用程序a 2执行预设测试集得到第二覆盖率信息。
步骤f,对程序a 2进行修改得到程序a 3,并使用程序a 3执行预设测试集得到第三覆盖率信息。
步骤g,对第一覆盖率信息、第二覆盖率信息和第三覆盖率信息进行合并,得到目标覆盖率信息。
在步骤d~步骤g中,程序a 2可以为对程序a 1进行修改得到的,即程序a 2的生成时刻可以晚于程序a 1的生成时刻,程序a 3可以为对程序a 2进行修改得到的,即程序a 3的生成时刻可以晚于程序a 2的生成时刻。因此,程序a 1执行预设测试集的时刻可以早于程序a 2执行预设测试集的时刻,程序a 2执行预设 测试集的时刻可以早于程序a 3执行预设测试集的时刻;相应地,第一覆盖率信息的生成时刻可以早于第二覆盖率信息的生成时刻,第二覆盖率信息的生成时刻可以早于第三覆盖率信息的生成时刻。通过对依次生成的第一覆盖率信息、第二覆盖率信息和第三覆盖率信息进行合并,可以得到目标覆盖率信息,目标覆盖率信息中可以包括执行预设测试集的过程中程序a 1、程序a 2和程序a 3所包括的字节码被调用的信息。
本发明实施例中,预设测试集可以由本领域技术人员根据实际需要进行设置,比如,预设测试集中可以包括一个测试样本,或者也可以包括至少两个测试样本,具体不作限定。以程序a 1执行预设测试集为例,若预设测试集中包括至少两个测试样本,则程序a 1可以执行至少两个测试样本中的一个测试样本,或者也可以执行至少两个测试样本中的多个测试样本(即两个或者两个以上测试样本),具体不作限定。
在一个示例中,如图1所示,预设测试集中可以包括测试样本w 1、测试样本w 2、测试样本w 3、测试样本w 4、测试样本w 5,第一覆盖率信息可以为使用程序a 1对测试样本w 1和测试样本w 2进行测试得到的,第二覆盖率信息可以为使用程序a 2对测试样本w 3得到的,第三覆盖率信息可以为使用程序a 3对测试样本w 4和测试样本w 5进行测试得到的。在测试样本不同的情况下,程序a 1、程序a 2和程序a 3中被调用的字节码可以不同,因此,通过对程序a 1、程序a 2和程序a 3分别对应的第一覆盖率信息、第二覆盖率信息和第三覆盖率信息进行合并,可以确定完整的目标覆盖率信息。
需要说明的是,图1仅是一种示例性的简单说明,其所列举的多个程序(即程序a 1、程序a 2和程序a 3)的对应关系仅是为了便于说明方案,并不构成对方案的限定。在具体实施中,多个程序之间可以具有对应关系,或者也可以不具有对应关系,比如程序a 3可以为对程序a 1进行修改得到的程序,或者程序a 1、程序a 2和程序a 3可以为完全不同的程序,具体不作限定。
在一种可能的实现方式中,获取多个覆盖率信息后,可以按照预设顺序对多个覆盖率信息进行合并,预设顺序可以由本领域技术人员根据经验进行 设置,具体不作限定。以合并第一覆盖率信息、第二覆盖率信息和第三覆盖率信息得到目标覆盖率信息为例,在一个示例中,可以按照生成时刻从晚到早的顺序对多个覆盖率信息进行合并,比如可以首先将第三覆盖率信息与第二覆盖率信息进行合并,得到覆盖率信息b 1,进而可以将覆盖率信息b 1与第一覆盖率信息进行合并,得到目标覆盖率信息;在另一个示例中,可以按照生成时刻从早到晚的顺序对多个覆盖率信息进行合并,比如可以首先将第一覆盖率信息与第二覆盖率信息进行合并,得到覆盖率信息b 2,进而可以将覆盖率信息b 2与第三覆盖率信息进行合并,得到目标覆盖率信息。
在另一种可能的实现方式中,获取多个覆盖率信息后,可以按照随机顺序对多个覆盖率信息进行合并,比如可以首先将第一覆盖率信息与第三覆盖率信息进行合并,得到覆盖率信息b 3,进而可以将第二覆盖率信息与覆盖率信息b 3进行合并,得到目标覆盖率信息,具体不作限定。
基于图1所示意的流程示意图,图2为本发明实施例提供的一种信息处理方法对应的流程示意图,该方法可以用于对任意两个覆盖率信息进行合并,比如可以用于对第三覆盖率信息与第二覆盖率信息进行合并,或者也可以用于对覆盖率信息b 1与第一覆盖率信息进行合并。若需要对两个以上的覆盖率信息进行合并,则可以循环执行图2所示意的方法,直至得到目标覆盖率信息。
如图2所示,该方法可以包括:
步骤201,获取第一时刻使用第一程序执行预设测试集得到的第一信息。
以第一程序为程序a 1为例,具体实施中,可以预先确定程序a 1中包括的M个第一子程序,并可以在使用程序a 1执行预设测试集的过程中,按照预设周期或实时监控程序a 1中每个第一子程序的调用情况。进一步地,可以根据每个第一子程序的调用情况设置每个第一子程序对应的指示值,举例来说,若确定执行预设测试集的过程中某一个第一子程序被调用,则可以将该第一子程序对应的指示值设置为第一指示值(比如1);相应地,若确定在执行预设测试集的过程中某一个第一子程序均未被调用,则可以将该第一子程序对 应的指示值设置为第二指示值(比如0)。当使用程序a 1执行至预设测试集的结束位置时,可以根据程序a 1中包括的M个第一子程序分别对应的指示值生成第一覆盖率信息。
具体实施中,确定程序a 1中包括的M个第一子程序的方法可以有多种,在一种可能的实现方式中,可以依次遍历程序a 1中的字节码,若检测到第一子程序定义的指示字符,则可以从第一子程序定义的指示字符开始存储字节码,直至检测到距离第一子程序定义的指示字符最近的第一子程序结束的指示字符,获取位于第一子程序定义的指示字符与第一子程序结束的指示字符之间的字节码,并可以将该段字节码作为一个第一子程序。在一个示例中,第一子程序对应的字节码中可以不包含行号。具体实施中,在从程序a 1中获取字节码存储为第一子程序的过程中,若检测到指示行号的字节码(比如LINE NUMBER),则可以无需存储该字节码,直接获取下一字节码。举例来说,若程序a 1中的某段字节码为“****LINE NUMBER%%%%”,则第一子程序中存储的字节码可以为“****%%%%”。
需要说明的是,上述仅是一种示例性的简单说明,其所示意的确定第一子程序的方法仅是为了便于说明方案,并不构成对方案的限定。具体实施中,也可采用其它方法确定P个第一子程序,比如,可以采用上述方法检测程序a 1中的某一段字节码,确定该段字节码中包括的L个第一子程序,并可以采用人工检测的方法确定程序a 1中除该段字节码以外的字节码包括的p-L个第一子程序,具体不作限定。
进一步地,在获取到一个第一子程序(比如第一子程序r 11)对应的字节码后,可以设置第一子程序r 11的标识和第一子程序r 11的校验值。在一个示例中,第一子程序r 11的标识可以用于唯一标识第一子程序r 11,第一子程序r 11的标识可以由第一部分和第二部分构成,第一部分可以为第一子程序r 11的名称(即r 11),第二部分可以为第一子程序r 11的字节码中所包括的多个参数类型的全限定名,其中,多个参数类型的全限定名之间可以由预设符号进行分隔。比如,若第一子程序r 11的标识为r 11:i 1:i 3:i 4,则可以确定第一子程序r 11中 包括类型为i 1、i 3和i 4的参数。第一子程序r 11的校验值可以用于唯一标识第一子程序r 11的指示值中包括的字节码信息,第一子程序r 11的校验值可以为对第一子程序r 11中包括的字节码信息进行加密得到的密钥,比如可以在获取到第一子程序r 11包括的全部字节码后,采用MD5加密方法确定第一子程序r 11对应的MD5值,并可以将该MD5值作为第一子程序r 11的校验值;或者也可以采用冗余循环加密方法确定第一子程序r 11对应的CRC值,并可以将该CRC值作为第一子程序r 11的校验值。
本发明实施例中,还可以确定程序a 1的标识和程序a 1的校验值。其中,程序a 1的标识可以用于唯一标识程序a 1,程序a 1的标识可以由第一部分和第二部分构成,第一部分可以为程序a 1的名称,第二部分可以为程序a 1所属的范围(即程序a 1所在的文件的位置信息);比如,若程序a 1的标识为a 1:D:\study,则可以确定程序a 1的名称为a 1,程度a 1所在的文件的位置信息为D:\study。程序a 1的校验值可以用于唯一标识程序a 1中包括的字节码信息,本发明实施例中,确定程序a 1的校验值的过程可以参照确定第一子程序r 11的校验值的过程进行执行,不再赘述。
在一种可能的实现方式中,第一覆盖率信息可以包括程序a 1的标识、程序a 1的校验值、M个第一子程序的标识、M个第一子程序的校验值和M个第一子程序对应的指示值。第一覆盖率信息可以用表格的形式进行存储,或者也可以用数组的形式进行存储,具体不作限定。
示例性地,表1为本发明实施例提供的一种第一覆盖率信息以表格形式存储的示意表。
表1:一种第一覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000001
如表1所示,第一覆盖率信息可以为使用程序a 1对预设测试集进行测试得到的第一覆盖率信息,第一覆盖率信息中可以包括程序a 1的标识a 1:D:\study和程序a 1的校验值12q345,其中,程序a 1所在的文件夹的地址可以为D:\study。程序a 1中可以包括第一子程序r 11、第一子程序r 12和第一子程序r 13,第一子程序r 11的标识可以为r 11:i 1:i 3:i 4,即第一子程序r 11中可以包括类型为i 1、i 3和i 4的参数,第一子程序r 12的标识可以为r 12:i 1:i 2:i 7,即第一子程序r 11中可以包括类型为i 1、i 2和i 7的参数,第一子程序r 13的标识可以为r 13:i 1:i 2:i 3,即第一子程序r 11中可以包括类型为i 1、i 2和i 3的参数。第一子程序r 11的校验值可以为5452q5,第一子程序r 12的校验值可以为32545z,第一子程序r 13的校验值可以为P23545。根据表1所示意的第一子程序r 11、第一子程序r 12和第一子程序r 13的指示值可以确定,在使用程序a 1对预设测试集进行测试的过程中,第一子程序r 11的字节码未被调用,第一子程序r 12的字节码未被调用,第一子程序r 13的字节码被调用。
表1示意的内容为采用一个测试程序执行预设测试集得到的测试结果文件,本发明实施例中,若测试程序包括多个(比如程序a 1和程序b 1),则使用测试程序对预设测试集执行一次测试得到的测试结果文件中可以包括程序a 1和程序b 1分别对应的覆盖率信息。在一种可能的实现方式中,每个程序的覆盖率信息可以对应设置有一个表格,相应地,测试结果文件中可以包括第一表格和第二表格,第一表格中可以存储有程序a 1的覆盖率信息,第二表格中可以存储有程序b 1的覆盖率信息。在另一种可能的实现方式中,多个程序的覆盖率信息可以存储在一个表格内,比如对预设测试集执行一次测试得到的测试文件中可以同时包括程序a 1的覆盖率信息和程序b 1的覆盖率信息。
示例性地,图3为本发明实施例提供的一种第一覆盖率信息的数组存储示意图,若第一覆盖率信息以数组的方式进行存储,则第一覆盖率信息对应的数组中可以存储有第一程序的标识、第一程序的校验值、多个第一子程序的标识、多个第一子程序的校验值,还可以存储有多个第一子程序中每个第一子程序的数组范围。如图3所示,图3所示意的第一覆盖率信息与表1所 示意的第一覆盖率信息相对应,其中,数组中可以存储有程序a 1的标识、程序a 1的校验值、第一子程序r 11~第一子程序r 13的标识和第一子程序r 11~第一子程序r 13的校验值,且,第一子程序r 11占用数组中的第1~第6位,即第一子程序r 11的数组范围可以为[1,6];第一子程序r 12占用数组中的第7~第15位,即第一子程序r 12的数组范围可以为[7,15];第一子程序r 13可以占用数组中的第16~第20位,即第一子程序r 13的数组范围可以为[16,20]。具体实施中,多个子程序的数组范围也可以由本领域技术人员根据经验进行设置,以第一子程序r 11为例,第一子程序r 11的数组范围可以为[1,6],或者也可以为[1,6),或者还可以为(1,6],对此不作限定。
图3所示意的数组为采用一个测试程序执行预设测试集得到的测试结果文件,本发明实施例中,若测试程序包括多个(比如程序a 1和程序b 1),则使用测试程序对预设测试集执行一次测试得到的测试结果文件中可以包括程序a 1和程序b 1分别对应的覆盖率信息。在一种可能的实现方式中,每个程序的覆盖率信息可以对应设置有一个数组,相应地,测试结果文件中可以包括第一数组和第二数组,第一数组中可以存储有程序a 1的覆盖率信息,第二数组中可以存储有程序b 1的覆盖率信息。
步骤202,根据第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到预设信息。
此处,若预设信息为根据第一时刻之后的预设时间段内使用一个第二程序执行预设测试集得到的,则预设信息可以为使用程序a 2执行预设测试集得到的第二覆盖率信息,或者可以为使用程序a 3执行预设测试集得到的第三覆盖率信息。其中,获取第二覆盖率信息或第三覆盖率信息的过程参照步骤201进行实施,相应地,使用程序a 2执行预设测试集得到的第二覆盖率信息中可以包括程序a 2的标识、程序a 2的校验值、从程序a 2中确定的M个第二子程序的标识、M个第二子程序的校验值和M个第二子程序对应的指示值;使用程序a 3执行预设测试集得到的第三覆盖率信息中可以包括程序a 3的标识、程序a 3的校验值、从程序a 3中确定的M个第三子程序的标识、M个第三子程序 的校验值和M个第三子程序对应的指示值。
若预设信息为根据第一时刻之后的预设时间段内使用多个第二程序执行预设测试集得到的,则预设信息可以为根据使用程序a 2执行预设测试集得到的第二覆盖率信息以及使用程序a 3执行预设测试集得到的第三覆盖率信息确定的。根据第二覆盖率信息和第三覆盖率信息确定预设信息的过程可以参照图2所示意的过程(即步骤201~步骤203)进行实现,比如,可以将使用程序a 2执行预设测试集得到的第二覆盖率信息作为步骤201中的第一信息,并可以将使用程序a 3执行预设测试集得到的第三覆盖率信息作为步骤202中的预设信息,执行步骤201~步骤203,确定得到的目标覆盖率信息即可为根据第一时刻之后的预设时间段内使用多个第二程序执行预设测试集得到的预设信息。
下面具体描述根据第一覆盖率信息和第二覆盖率信息合并得到目标覆盖率信息的过程。
表2a、表2b和表2c分别为本发明实施例提供的三种第二覆盖率信息以表格形式存储的示意表。
表2a:一种第二覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000002
如表2a所示,第二覆盖率信息可以为使用程序a 2对预设测试集进行测试得到的第二覆盖率信息,第二覆盖率信息中可以包括程序a 2的标识a 1:D:\study和程序a 2的校验值12q345,其中,程序a 2所在的文件夹的地址可以为D:\study。程序a 2中可以包括第二子程序r 11、第二子程序r 12和第二子程序r 13,第二子程序r 11的标识可以为r 11:i 1:i 3:i 4,即第二子程序r 11中可以包括类型为i 1、i 3和i 4的参数,第二子程序r 12的标识可以为r 12:i 1:i 2:i 7,即第二子程序r 11中可以包 括类型为i 1、i 2和i 7的参数,第二子程序r 13的标识可以为r 13:i 1:i 2:i 3,即第二子程序r 11中可以包括类型为i 1、i 2和i 3的参数。第二子程序r 11的校验值可以为5452q5,第二子程序r 12的校验值可以为32545z,第二子程序r 13的校验值可以为P23545。根据表2a所示意的第二子程序r 11、第二子程序r 12和第二子程序r 13的指示值可以确定,在使用程序a 2对预设测试集进行测试的过程中,第二子程序r 11的字节码被调用,第二子程序r 12的字节码未被调用,第二子程序r 13的字节码被调用。
表2b:另一种第二覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000003
如表2b所示,第二覆盖率信息可以为使用程序a 2对预设测试集进行测试得到的第二覆盖率信息,第二覆盖率信息中可以包括程序a 2的标识a 1:D:\study和程序a 2的校验值1563k2,其中,程序a 2所在的文件夹的地址可以为D:\study。程序a 2中可以包括第二子程序r 11和第二子程序r 22,第二子程序r 11的标识可以为r 11:i 1:i 3:i 4,即第二子程序r 11中可以包括类型为i 1、i 3和i 4的参数,第二子程序r 22的标识可以为r 22:i 3:i 6:i 7,即第二子程序r 22中可以包括类型为i 3、i 6和i 7的参数。第二子程序r 11的校验值可以为5452q5,第二子程序r 22的校验值可以为32y4i4。根据表2b所示意的第二子程序r 11和第二子程序r 22的指示值可以确定,在使用程序a 2对预设测试集进行测试的过程中,第二子程序r 11的字节码被调用,第二子程序r 22的字节码未被调用。
表2c:又一种第二覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000004
如表2c所示,第二覆盖率信息可以为使用程序a 2对预设测试集进行测试得到的第二覆盖率信息,第二覆盖率信息中可以包括程序a 2的标识a 2:D:\study和程序a 2的校验值553k02,其中,程序a 2所在的文件夹的地址可以为D:\study。程序a 2中可以包括第二子程序r 31和第二子程序r 32,第二子程序r 31的标识可以为r 31:i 1:i 3:i 4,即第二子程序r 31中可以包括类型为i 1、i 3和i 4的参数,第二子程序r 32的标识可以为r 32:i 3:i 6:i 7,即第二子程序r 32中可以包括类型为i 3、i 6和i 7的参数。第二子程序r 31的校验值可以为5452q5,第二子程序r 32的校验值可以为32y4i4。根据表2c所示意的第二子程序r 31和第二子程序r 32的指示值可以确定,在使用程序a 2对预设测试集进行测试的过程中,第二子程序r 31的字节码未被调用,第二子程序r 32的字节码被调用。
步骤203,根据第一覆盖率信息和预设信息,更新预设信息得到目标覆盖率信息。
具体实施中,可以预先确定第一覆盖率信息中包括的程序a 1的校验值和第二覆盖率信息中包括的程序a 2的校验值是否相同。参照表1和表2a所示意的第一覆盖率信息和第二覆盖率信息,程序a 1的校验值可以为12q345,程序a 2的校验值可以为12q345,即程序a 1的校验值与程序a 2的校验值相同,可以说明程序a 1的字节码信息与程序a 2的字节码信息完全相同,即从程序a 1中确定出的第一子程序(即表1所示意出的第一子程序r 11~第一子程序r 13)与从程序a 2中确定出的第二子程序(即表2所示意出的第二子程序r 11~第二子程序r 13)的字节码信息完全相同。因此,可以根据第一子程序r 11~第一子程序r 13对应的指示值更新第二子程序r 11~第二子程序r 13对应的指示值。
以根据第一子程序r 13对应的指示值更新第二子程序r 13对应的指示值为例,第二子程序r 13的指示值为“0”,第一子程序r 13的指示值为“1”,即可以确定使用程序a 2对预设测试集进行测试的过程中第二子程序r 13未被调用,而使用程序a 1对预设测试集进行测试的过程中第一子程序r 13被调用,因此可以确定在对预设测试集进行测试的过程中第二子程序r 13被调用过,此时,可以将第二子程序r 13的指示值更新为“1”。相应地,第二子程序r 12的指示值为“0”, 第一子程序r 12的指示值为“0”,即可以确定使用程序a 1和程序a 2对预设测试集进行测试的过程中第二子程序r 12均未被调用,因此可以无需对第二子程序r 12的指示值进行更新,即第二子程序r 12的指示值可以仍为“0”。第二子程序r 11的指示值为“1”,第一子程序r 11的指示值为“1”,即可以确定使用程序a 1和程序a 2对预设测试集进行测试的过程中第二子程序r 11均被调用,因此可以无需对第二子程序r 11的指示值进行更新,即第二子程序r 11的指示值可以仍为“1”。
表3a为根据表1和表2a所示意的第一覆盖信息和第二覆盖信息,更新第二覆盖信息得到的目标覆盖率信息的一种示意表。
表3a:一种目标覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000005
参照表1和表2b所示意的第一覆盖率信息和第二覆盖率信息,程序a 1的校验值可以为12q345,程序a 2的校验值可以为1563k2,即程序a 1的校验值与程序a 2的校验值不同,可以说明程序a 1的字节码信息与程序a 2的字节码信息不同,即从程序a 1中确定出的第一子程序(即表1所示意出的第一子程序r 11~第一子程序r 13)与从程序a 2中确定出的第二子程序(即表2所示意出的第二子程序r 11和第二子程序r 22)的数量或字节码信息不同。进一步地,程序a 1的标识可以为a 1:D:\study,程序a 2的标识可以为a 1:D:\study,即程序a 1的标识与程序a 2的标识相同,可以说明程序a 2为对程序a 1中的字节码信息进行修改得到的;此时,可以获取第二子程序r 11和第二子程序r 22中与第一子程序r 11~第一子程序r 13相匹配的第二子程序,即获取与第一子程序r 11~第一子程序r 13中的某一个第一子程序的标识和校验值均相同的第二子程序。根据表1和表2b可以确定,第二子程序r 11与第一子程序r 11相匹配,此时可以根据第一子 程序r 11对应的指示值更新第二子程序r 11对应的指示值。更新的过程可以参照上述内容进行实现,具体不再赘述。
表3b为根据表1和表2b所示意的第一覆盖信息和第二覆盖信息,更新第二覆盖信息得到的目标覆盖率信息的一种示意表。
表3b:一种目标覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000006
参照表1和表2c所示意的第一覆盖率信息和第二覆盖率信息,程序a 1的校验值可以为12q345,程序a 2的校验值可以为553k02,即程序a 1的校验值与程序a 2的校验值不同,可以说明程序a 2和程序a 1的字节码不同;程序a 1的标识可以为a 1:D:\study,程序a 2的标识可以为a 2:D:\study,即程序a 1的标识与程序a 2的标识不同,可以说明程序a 2和程序a 1所在的文件夹不同。因此,可以确定程序a 2和程序a 1是不同的程序,此时可以将从程序a 1中确定的第一子程序r 11~第一子程序r 13对应的指示值添加到第二覆盖率信息中,得到目标覆盖率信息。
表3c为根据表1和表2c所示意的第一覆盖信息和第二覆盖信息,更新第二覆盖信息得到的目标覆盖率信息的一种示意表。
表3c:一种目标覆盖率信息以表格形式存储的示意
Figure PCTCN2020076491-appb-000007
需要说明的是,表1~表3c仅是一种示例性的简单说明,并不构成对方案的限定。在具体实施中,对预设测试集执行测试得到的一次测试结果中也可以包括多个程序的覆盖率信息,此时,可以针对于每个程序的覆盖率信息进行合并,得到每个程序的目标覆盖率信息。
本发明的上述实施例中,获取第一时刻使用第一程序执行预设测试集得到的第一信息,并获取第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的预设信息;其中,第一程序包括M个第一子程序,第一信息中包括M个第一子程序分别对应的指示值,每个第一子程序用于完成每个第一子程序对应的预设功能,每个第一子程序对应的指示值用于指示执行预设测试集时每个第一子程序是否被调用,预设信息中包括N个第二子程序分别对应的指示值;进一步地,若确定第一程序与一个或多个第二程序匹配,则使用第一信息中包括的M个第一子程序对应的指示值更新预设信息中N个第二子程序对应的指示值,得到目标信息。本发明实施例中,通过以完成预设功能的子程序为单位获取子程序的指示值(即测试结果),可以使得在合并同一个程序对应的多个测试结果的过程中,根据子程序对多个测试结果中的子程序的指示值进行合并,从而可以避免将不同子程序的指示值进行合并所造成的子程序的测试结果丢失的技术问题;也就是说,相比于现有技术采用以一行程序为单位进行合并的方式来说,本发明实施例中的方案可以提高合并得到的覆盖率数据的准确性。
针对上述方法流程,本发明实施例还提供一种信息处理装置,该装置的具体内容可以参照上述方法实施。
图4为本发明实施例提供的一种信息处理装置的结构示意图,包括:
获取模块401,用于获取第一时刻使用第一程序执行预设测试集得到的第一信息,所述第一程序包括M个第一子程序,所述第一信息中包括所述M个第一子程序分别对应的指示值,每个第一子程序对应的指示值用于指示执行所述预设测试集时所述每个第一子程序是否被调用;以及,获取预设信息,所 述预设信息为所述第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的;所述预设信息中包括N个第二子程序分别对应的指示值;其中,M,N>0;
更新模块402,用于若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述预设信息中所述N个第二子程序对应的指示值,得到目标信息。
可选地,所述更新模块402还用于:
若确定所述第一程序与所述一个或多个第二程序不匹配,则将所述N个第二子程序分别对应的指示值添加到所述预设信息中。
可选地,所述第一信息中还包括所述第一程序的标识和所述第一程序的校验值,所述预设信息中还包括所述一个或多个第二程序的标识和所述一个或多个第二程序的校验值;
所述更新模块402用于:
若确定所述第一程序的校验值与所述一个或多个第二程序中第三程序的校验值相同,则从所述N个第二子程序中获取与所述M个第一子程序匹配的M个第二子程序,并根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值;
若确定所述第一程序的标识与所述一个或多个第二程序中第四程序的标识相同,且所述第一程序的校验值与所述一个或多个第二程序的校验值均不相同,则从所述M个第一子程序中获取与所述N个第二子程序中的T个第二子程序匹配的T个第一子程序,并根据所述T个第一子程序对应的指示值更新所述T个第二子程序对应的指示值。
可选地,所述更新模块402用于:
若确定第I个第一子程序对应的指示值为第一指示值,第I个第二子程序对应的指示值为第二指示值,则将所述第I个第二子程序对应的指示值更新为第一指示值;所述第一指示值用于指示执行所述预设测试集时第一子程序或第二子程序被调用;其中,I<M。
可选地,所述M个第一子程序中包括第Y个第一子程序,所述第Y个第一子程序是通过如下方式确定的:
按照预设字节码长度对所述第一程序中的字节码进行检测,若检测到第一预设指示字符,则记录所述第一预设指示字符在所述第一程序中的第一位置信息;所述第一指示字符用于指示所述第Y个第一子程序对应的初始字节码;
对所述第一程序中位于所述第一预设指示字符后的字节码进行检测,若检测到与所述第一预设指示字符对应的第二预设指示字符,则记录所述第二预设指示字符在所述第一程序中的第二位置信息;所述第二指示字符用于指示所述第Y个第一子程序对应的终止字节码;
根据所述第一位置信息和所述第二位置信息,获取所述第一程序中位于所述第一预设指示字符与所述第二预设指示字符之间的字节码,并将所述字节码作为第Y个第一子程序的字节码。
从上述内容可以看出:本发明的上述实施例中,获取第一时刻使用第一程序执行预设测试集得到的第一信息,并获取第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的预设信息;其中,第一程序包括M个第一子程序,第一信息中包括M个第一子程序分别对应的指示值,每个第一子程序用于完成每个第一子程序对应的预设功能,每个第一子程序对应的指示值用于指示执行预设测试集时每个第一子程序是否被调用,预设信息中包括N个第二子程序分别对应的指示值;进一步地,若确定第一程序与一个或多个第二程序匹配,则使用第一信息中包括的M个第一子程序对应的指示值更新预设信息中N个第二子程序对应的指示值,得到目标信息。本发明实施例中,通过以完成预设功能的子程序为单位获取子程序的指示值(即测试结果),可以使得在合并同一个程序对应的多个测试结果的过程中,根据子程序对多个测试结果中的子程序的指示值进行合并,从而可以避免将不同子程序的指示值进行合并所造成的子程序的测试结果丢失的技术问题;也就是说,相比于现有技术采用以一行程序为单位进行合并的方式来说,本发明实施例中的方案可以提高合并得到的覆盖率数据的准确性。
基于同一发明构思,本发明实施例还提供了一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行如上述图2实施例所示的信息处理方法。
基于同一发明构思,本发明实施例还提供了一种计算机程序产品,当其在计算机上运行时,使得计算机执行如上述图2实施例所示的信息处理方法。
本领域内的技术人员应明白,本发明的实施例可提供为方法、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了 基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (12)

  1. 一种信息处理方法,其特征在于,所述方法包括:
    获取第一时刻使用第一程序执行预设测试集得到的第一信息,所述第一程序包括M个第一子程序,所述第一信息包括所述M个第一子程序分别对应的指示值;每个第一子程序用于完成所述每个第一子程序对应的预设功能,所述每个第一子程序对应的指示值用于指示执行所述预设测试集时所述每个第一子程序是否被调用;
    获取预设信息,所述预设信息为所述第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的;所述预设信息中包括N个第二子程序分别对应的指示值;其中,M,N>0;
    若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述预设信息中所述N个第二子程序对应的指示值,得到目标信息。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    若确定所述第一程序与所述一个或多个第二程序不匹配,则将所述N个第二子程序分别对应的指示值添加到所述预设信息中。
  3. 根据权利要求1所述的方法,其特征在于,所述第一信息还包括所述第一程序的标识和所述第一程序的校验值,所述预设信息还包括所述一个或多个第二程序的标识和所述一个或多个第二程序的校验值;
    所述若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述N个第二子程序对应的指示值,包括:
    若确定所述第一程序的校验值与所述一个或多个第二程序中第三程序的校验值相同,则从所述N个第二子程序中获取与所述M个第一子程序匹配的M个第二子程序,并根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值;
    若确定所述第一程序的标识与所述一个或多个第二程序中第四程序的标 识相同,且所述第一程序的校验值与所述一个或多个第二程序的校验值均不相同,则从所述M个第一子程序中获取与所述N个第二子程序中的T个第二子程序匹配的T个第一子程序,并根据所述T个第一子程序对应的指示值更新所述T个第二子程序对应的指示值。
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值,包括:
    若确定第I个第一子程序对应的指示值为第一指示值,第I个第二子程序对应的指示值为第二指示值,则将所述第I个第二子程序对应的指示值更新为第一指示值;所述第一指示值用于指示执行所述预设测试集时第一子程序或第二子程序被调用;其中,I<M。
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述M个第一子程序中包括第Y个第一子程序,所述第Y个第一子程序是通过如下方式确定的:
    按照预设字节码长度对所述第一程序中的字节码进行检测,若检测到第一预设指示字符,则记录所述第一预设指示字符在所述第一程序中的第一位置信息;所述第一指示字符用于指示所述第Y个第一子程序对应的初始字节码;
    对所述第一程序中位于所述第一预设指示字符后的字节码进行检测,若检测到与所述第一预设指示字符对应的第二预设指示字符,则记录所述第二预设指示字符在所述第一程序中的第二位置信息;所述第二指示字符用于指示所述第Y个第一子程序对应的终止字节码;
    根据所述第一位置信息和所述第二位置信息,获取所述第一程序中位于所述第一预设指示字符与所述第二预设指示字符之间的字节码,并将所述字节码作为第Y个第一子程序的字节码。
  6. 一种信息处理装置,其特征在于,所述装置包括:
    获取模块,用于获取第一时刻使用第一程序执行预设测试集得到的第一信息,所述第一程序包括M个第一子程序,所述第一信息中包括所述M个第一子程序分别对应的指示值,每个第一子程序用于完成所述每个第一子程序对 应的预设功能,每个第一子程序对应的指示值用于指示执行所述预设测试集时所述每个第一子程序是否被调用;以及,获取预设信息,所述预设信息为所述第一时刻之后的预设时间段内使用一个或多个第二程序执行预设测试集得到的;所述预设信息中包括N个第二子程序分别对应的指示值;其中,M,N>0;
    更新模块,用于若确定所述第一程序与所述一个或多个第二程序匹配,则使用所述M个第一子程序对应的指示值更新所述预设信息中所述N个第二子程序对应的指示值,得到目标信息。
  7. 根据权利要求6所述的装置,其特征在于,所述更新模块还用于:
    若确定所述第一程序与所述一个或多个第二程序不匹配,则将所述N个第二子程序分别对应的指示值添加到所述预设信息中。
  8. 根据权利要求6所述的装置,其特征在于,所述第一信息还包括所述第一程序的标识和所述第一程序的校验值,所述预设信息还包括所述一个或多个第二程序的标识和所述一个或多个第二程序的校验值;
    所述更新模块用于:若确定所述第一程序的校验值与所述一个或多个第二程序中第三程序的校验值相同,则从所述N个第二子程序中获取与所述M个第一子程序匹配的M个第二子程序,并根据所述M个第一子程序对应的指示值更新所述M个第二子程序对应的指示值;以及,若确定所述第一程序的标识与所述一个或多个第二程序中第四程序的标识相同,且所述第一程序的校验值与所述一个或多个第二程序的校验值均不相同,则从所述M个第一子程序中获取与所述N个第二子程序中的T个第二子程序匹配的T个第一子程序,并根据所述T个第一子程序对应的指示值更新所述T个第二子程序对应的指示值。
  9. 根据权利要求8所述的装置,其特征在于,所述更新模块用于:
    若确定第I个第一子程序对应的指示值为第一指示值,第I个第二子程序对应的指示值为第二指示值,则将所述第I个第二子程序对应的指示值更新为第一指示值;所述第一指示值用于指示执行所述预设测试集时第一子程序或第二子程序被调用;其中,I<M。
  10. 根据权利要求6至9中任一项所述的装置,其特征在于,所述M个第一子程序中包括第Y个第一子程序,所述第Y个第一子程序是通过如下方式确定的:
    按照预设字节码长度对所述第一程序中的字节码进行检测,若检测到第一预设指示字符,则记录所述第一预设指示字符在所述第一程序中的第一位置信息;所述第一指示字符用于指示所述第Y个第一子程序对应的初始字节码;
    对所述第一程序中位于所述第一预设指示字符后的字节码进行检测,若检测到与所述第一预设指示字符对应的第二预设指示字符,则记录所述第二预设指示字符在所述第一程序中的第二位置信息;所述第二指示字符用于指示所述第Y个第一子程序对应的终止字节码;
    根据所述第一位置信息和所述第二位置信息,获取所述第一程序中位于所述第一预设指示字符与所述第二预设指示字符之间的字节码,并将所述字节码作为第Y个第一子程序的字节码。
  11. 一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得计算机执行如权利要求1至5任一项所述的方法。
  12. 一种计算机程序产品,其特征在于,当其在计算机上运行时,使得计算机执行如权利要求1至5任一项所述的方法。
PCT/CN2020/076491 2019-03-29 2020-02-24 一种信息处理方法及装置 WO2020199789A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910249319.0A CN110008124A (zh) 2019-03-29 2019-03-29 一种信息处理方法及装置
CN201910249319.0 2019-03-29

Publications (1)

Publication Number Publication Date
WO2020199789A1 true WO2020199789A1 (zh) 2020-10-08

Family

ID=67168786

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/076491 WO2020199789A1 (zh) 2019-03-29 2020-02-24 一种信息处理方法及装置

Country Status (2)

Country Link
CN (1) CN110008124A (zh)
WO (1) WO2020199789A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008124A (zh) * 2019-03-29 2019-07-12 深圳前海微众银行股份有限公司 一种信息处理方法及装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020066077A1 (en) * 2000-05-19 2002-05-30 Leung Wu-Hon Francis Methods and apparatus for preventing software modifications from invalidating previously passed integration tests
CN105988926A (zh) * 2015-02-13 2016-10-05 腾讯科技(深圳)有限公司 多版本测试数据的处理方法和装置
CN106547680A (zh) * 2015-09-17 2017-03-29 腾讯科技(深圳)有限公司 覆盖率测试中的数据处理方法和装置
CN108829580A (zh) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 多版本测试数据处理方法、装置、设备及存储介质
CN108959059A (zh) * 2017-05-19 2018-12-07 腾讯科技(深圳)有限公司 一种测试方法以及测试平台
CN110008124A (zh) * 2019-03-29 2019-07-12 深圳前海微众银行股份有限公司 一种信息处理方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007249696A (ja) * 2006-03-16 2007-09-27 Hows:Kk 情報処理システム、情報処理装置、サーバ装置、およびプログラム
CN101661425B (zh) * 2008-08-26 2012-03-21 国际商业机器公司 测试覆盖分析方法和装置
CN103902606B (zh) * 2012-12-28 2018-07-06 腾讯科技(深圳)有限公司 一种数据库的数据处理方法和系统
CN106502901A (zh) * 2016-10-24 2017-03-15 网易(杭州)网络有限公司 覆盖率检测方法、装置和设备
CN107977309B (zh) * 2016-10-25 2021-02-12 腾讯科技(北京)有限公司 一种数据处理方法及其装置、系统
CN109388566B (zh) * 2018-09-27 2022-07-29 北京城市网邻信息技术有限公司 一种代码覆盖率分析方法、装置、设备及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020066077A1 (en) * 2000-05-19 2002-05-30 Leung Wu-Hon Francis Methods and apparatus for preventing software modifications from invalidating previously passed integration tests
CN105988926A (zh) * 2015-02-13 2016-10-05 腾讯科技(深圳)有限公司 多版本测试数据的处理方法和装置
CN106547680A (zh) * 2015-09-17 2017-03-29 腾讯科技(深圳)有限公司 覆盖率测试中的数据处理方法和装置
CN108959059A (zh) * 2017-05-19 2018-12-07 腾讯科技(深圳)有限公司 一种测试方法以及测试平台
CN108829580A (zh) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 多版本测试数据处理方法、装置、设备及存储介质
CN110008124A (zh) * 2019-03-29 2019-07-12 深圳前海微众银行股份有限公司 一种信息处理方法及装置

Also Published As

Publication number Publication date
CN110008124A (zh) 2019-07-12

Similar Documents

Publication Publication Date Title
US20140380279A1 (en) Prioritizing test cases using multiple variables
US20150370685A1 (en) Defect localization in software integration tests
US7698690B2 (en) Identifying code that wastes time performing redundant computation
WO2019019647A1 (zh) 应用程序测试范围确定方法、系统、服务器和存储介质
WO2018195795A1 (zh) 测试方法、测试服务器及系统
US8793224B2 (en) Linear sweep filesystem checking
CN112363937B (zh) 差异覆盖率测试方法、装置、计算机设备和存储介质
CN108710571A (zh) 一种生成自动化测试代码的方法和装置
WO2020199789A1 (zh) 一种信息处理方法及装置
CN112363936A (zh) 差异覆盖率测试方法、装置、计算机设备和存储介质
CN107943646B (zh) 一种程序监控方法及装置
CN111221721B (zh) 一种单元测试案例自动化录制和执行方法及装置
WO2016029441A1 (zh) 一种文件扫描方法及装置
CN106776348B (zh) 测试用例管理方法和装置
KR20070079030A (ko) 데이터 포맷 방법 및 장치
CN116432190B (zh) 接口未授权访问检测方法、装置、计算机设备及存储介质
CN111124894A (zh) 代码覆盖率的处理方法、装置和计算机设备
CN111382052A (zh) 代码质量评价方法、装置及电子设备
CN107451063B (zh) 一种脚本测试方法及装置
CN114416410A (zh) 一种异常分析方法、设备和计算机可读存储介质
CN114077545A (zh) 验证数据的获取方法、装置、设备及可读存储介质
CN111078549B (zh) 代码覆盖率的处理方法、装置和计算机设备
CN113342651A (zh) 一种用于测试用例缺陷与用例模糊关联关系的恢复方法
CN113742208A (zh) 一种软件检测方法、装置、设备及计算机可读存储介质
CN110532174B (zh) 计算增量代码覆盖率的方法、装置、计算机设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20782187

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 24.01.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20782187

Country of ref document: EP

Kind code of ref document: A1