CN103425571A - Source code completeness detecting method and device - Google Patents

Source code completeness detecting method and device Download PDF

Info

Publication number
CN103425571A
CN103425571A CN2012101616651A CN201210161665A CN103425571A CN 103425571 A CN103425571 A CN 103425571A CN 2012101616651 A CN2012101616651 A CN 2012101616651A CN 201210161665 A CN201210161665 A CN 201210161665A CN 103425571 A CN103425571 A CN 103425571A
Authority
CN
China
Prior art keywords
source code
feature coding
code
stake
recorded
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN2012101616651A
Other languages
Chinese (zh)
Other versions
CN103425571B (en
Inventor
彭成锋
罗慧
徐勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201210161665.1A priority Critical patent/CN103425571B/en
Publication of CN103425571A publication Critical patent/CN103425571A/en
Application granted granted Critical
Publication of CN103425571B publication Critical patent/CN103425571B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Electrically Operated Instructional Devices (AREA)

Abstract

The invention discloses a source code completeness detecting method which is applied to instrumentation testing processes of source codes. The source code completeness detecting method includes: generating a feature code of a source code not subjected to instrumentation and recording the feature code in a field, not affecting execution of the source code, in the source code; in the process of removing instrumentation, extracting the feature code recorded in the source code and deleting the feature code from the source code; generating feature code of the source code subjected to instrumentation removing, comparing the feature code of the source code subjected to instrumentation removing with the extracted feature code recorded in the source code, and determining the completeness of the source code according to comparison results. By the aid of the source code completeness detecting method, whether the software source code subjected to instrumentation testing is changed or not can be determined, thereby the changed source code can be replaced, and incorrect source code can be prevented from being published.

Description

A kind of source code integrality detection method and device
Technical field
The present invention relates to field of computer technology, particularly a kind of source code integrality detection method and device.
Background technology
For example, in the process of software being carried out to the pitching pile test (code coverage test), generally need to carry out pitching pile and the operation of going stake to source code, pitching pile adds the stake code in source code, complete the work such as Data Collection by the stake code, going stake is that the stake code is removed from source code, source code by after the execution pitching pile, can reach corresponding test purpose.
After executing the source code after pitching pile and obtaining corresponding test data, with the source code of stake code, be to move in general operating environment, must remove a stake code wherein.Generally the method for employing is, adopts predetermined matching inquiry rule to inquire about a stake code in source code, and the stake code found is deleted.
Yet, inventor's discovery, at least there are the following problems for prior art:
When being gone; according to certain matching inquiry rule, in source code, inquired about; often there will be the code segment that meets the matching inquiry rule found not is the stake code; this will cause deleting the source code content outside the stake code; in addition; also have under certain situation; the position that causes not inquiring a code due to the query script mistake; this will cause a code to be removed; above situation all can cause the mistake of source code; and the flow process of prior art can not find the mistake of source code timely, and wrong source code can be issued.
Summary of the invention
Whether the object of the present invention is to provide a kind of source code integrality detection method and device, change after the pitching pile test to determine software source code, for this reason, the embodiment of the present invention adopts following technical scheme:
A kind of source code integrality detection method, be applied to the pitching pile test process of source code, comprising:
Generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code;
When being gone the stake operation, the feature coding recorded in the extraction source code, and this feature coding is deleted from source code;
The feature coding of the source code after stake is removed in generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.
A kind of source code integrity detection device, be applied to the pitching pile test process of source code, comprising:
Generation module, for generating the feature coding of the source code that does not carry out pitching pile, and be recorded in described feature coding in the field that does not affect the source code execution in source code;
Extraction module, for when being gone the stake operation, the feature coding recorded in the extraction source code, and this feature coding is deleted from source code;
Comparison module, remove the feature coding of the source code after stake for generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.
The above embodiment of the present invention, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code, when being gone the stake operation, the feature coding recorded in the extraction source code, and the described feature coding recorded in source code is deleted, the feature coding of the source code after stake is removed in generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.Thereby, can determine whether software source code is changed after the pitching pile test, and then can be replaced the source code that occurs to change, to prevent wrong source code, be published.
The accompanying drawing explanation
The schematic flow sheet of the source code integrality detection method that Fig. 1 provides for the embodiment of the present invention;
The schematic flow sheet of the source code integrality detection method that Fig. 2 provides for the embodiment of the present invention;
The structural representation of the source code integrity detection device that Fig. 3 provides for the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the present invention, the technical scheme in the present invention is carried out to clear, complete description, obviously, described embodiment is a part of embodiment of the present invention, rather than whole embodiment.Embodiment based in the present invention, all other embodiment that those of ordinary skills obtain under the prerequisite of not making creative work, belong to the scope of protection of the invention.
Embodiment mono-
The embodiment of the present invention provides a kind of source code integrality detection method, is applied to the pitching pile test process of source code.The integrality of detection resources code, whether the detection resources code any change occurred.As shown in Figure 1, be the treatment scheme of the method, can comprise the following steps.
Step 101, generate the feature coding of the source code that does not carry out pitching pile, and this feature coding be recorded in the field that does not affect the source code execution in source code.
Wherein, this feature coding is one section the coding corresponding with this source code that adopts a kind of irreversible coding rule that former code is converted to, feature coding can have default regular length, and feature coding also can be called fingerprint or the summary of source code.According to this coding rule, each different source code has each self-corresponding unique feature coding, so if the feature coding difference can illustrate that corresponding source code exists different.Concrete, this feature coding can be MD5(Message Digest Algorithm 5, Message Digest Algorithm 5) coding, SHA(Secure Hash Algorithm, Secure Hash Algorithm) coding etc.
Concrete, feature coding being recorded in to the process in source code, can before the pitching pile operation, carry out, can also when operating, pitching pile carry out, can certainly after the pitching pile operation, carry out.Preferably, can be when carrying out the pitching pile operation, the generating feature coding, and the feature coding of generation is recorded in source code.On the one hand, the process of generation and recording feature coding carries out can saving corresponding system resource without the cache feature coding simultaneously, on the other hand, the operation of recording feature coding and pitching pile is carried out simultaneously, stake code and feature coding are write to the relevant position in source code simultaneously, can improve the treatment effeciency of this flow process.
The process of source code being carried out to the pitching pile test is: at first, the stake code is written to (being pitching pile) in tested source code, general stake code is written in the forefront of source code; Then, execution writes the source code after a code, first will carry out anterior stake code, then carry out the source code of back, to realize the test purpose to source code; Finally, the stake code is removed to (going stake).Visible, the record position of feature coding in source code, so long as in above-mentioned test process with pitching pile after the irrelevant field of the execution of source code just passable.Preferably, this field can be the field of the annotation information for storing source code, is about to feature coding and is recorded in the annotation information of source code.
Step 102, when being gone the stake operation, the feature coding recorded in the extraction source code, and this feature coding is deleted from source code.
Preferably, can first the feature coding recorded in source code be extracted from source code, then stake code and feature coding in source code be deleted simultaneously, can improve like this treatment effeciency of this flow process.
Step 103, generate the feature coding remove the source code after stake, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted compared, and determine the integrality of source code according to comparative result.
After the stake code and feature coding write, regenerate the feature coding of source code in deleting source code.Here the feature coding generated in step 101 is denoted as to feature coding 1, the feature coding regenerated is denoted as to feature coding 2.The contrast characteristic encodes 1 and feature coding 2, if identical, illustrate that its corresponding source code is also identical, be source code through pitching pile, go not change after the operation of stake, there is integrality, if not identical, illustrate that its corresponding source code is not identical, be source code through pitching pile, go to change after the operation of stake, do not there is integrality.
By the above-mentioned flow process of the embodiment of the present invention, can the integrality of carrying out the source code before and after pitching pile test be detected, if find to go the source code integrality existing problems after stake, can before the source code issue, it be replaced with to correct source code.But, also there is some situation, as script failure etc., cause the stake operation to be carried out unsuccessfully, and the integrity detection result is made mistakes.For this situation, the embodiment of the present invention has also proposed following solution.
When the stake code starts to carry out, judge whether current execution environment is test environment, if so, carry out the stake code, otherwise, skip a code, carry out source code.Specifically can add at the forefront of stake code the judgement statement, to judge current execution environment.If current execution environment is test environment, the execution environment of explanation stake code is correct, can sequentially carry out a code and source code.If current execution environment is operating environment, illustrate that the source code with the stake code is published, because the correct execution environment of stake code should be test environment, so this execution environment mistake, at this moment, if still carry out the stake code may cause program to report an error, can skip a code (not carrying out a code), carry out source code.
The above embodiment of the present invention, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code, when being gone the stake operation, the feature coding recorded in the extraction source code, and the described feature coding recorded in source code is deleted, the feature coding of the source code after stake is removed in generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.Thereby, can determine whether software source code is changed after the pitching pile test, and then can be replaced the source code that occurs to change, to prevent wrong source code, be published.
Embodiment bis-
As shown in Figure 2, the treatment scheme of source code integrality detection method in concrete application scenarios for the embodiment of the present invention provides, can comprise the following steps.
Step 201, the MD5 that generates the source code that does not carry out pitching pile encodes, and is denoted as coding A.
Step 202, by the coding A be written in the annotation information of source code, and by the stake code insertion in source code.General stake code can write on the forefront of source code.
Step 203, the source code after the execution pitching pile, tested source code.
Step 204 is extracted coding A from source code.
Step 205 is deleted stake code and coding A in source code.
Step 206, the MD5 coding of the source code after stake is removed in generation, is denoted as coding B.
Step 207, whether the coding A that judgement is extracted from source code is consistent with the value of removing the rear coding B generated of stake, if so, determines that source code does not change, otherwise, determine that source code changes.
The above embodiment of the present invention, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code, when being gone the stake operation, the feature coding recorded in the extraction source code, and the described feature coding recorded in source code is deleted, the feature coding of the source code after stake is removed in generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.Thereby, can determine whether software source code is changed after the pitching pile test, and then can be replaced the source code that occurs to change, to prevent wrong source code, be published.
Embodiment tri-
Technical conceive based on identical, the embodiment of the present invention also provides a kind of source code integrity detection device, is applied to the pitching pile test process of source code, as shown in Figure 3, comprising:
Generation module 310, for generating the feature coding of the source code that does not carry out pitching pile, and be recorded in described feature coding in the field that does not affect the source code execution in source code;
Extraction module 320, for when being gone the stake operation, the feature coding recorded in the extraction source code, and this feature coding is deleted from source code;
Comparison module 330, remove the feature coding of the source code after stake for generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.
Preferably, described generation module 310, specifically for:
When carrying out the pitching pile operation, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code.
Preferably, described generation module 310, specifically for:
Described feature coding is recorded in the annotation information of source code.
Preferably, described feature coding is specially MD5 coding or SHA coding.
Preferably, also comprise execution module, for:
When the stake code starts to carry out, judge whether current execution environment is test environment, if so, carry out described stake code, otherwise, skip described stake code, carry out source code.
The above embodiment of the present invention, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code, when being gone the stake operation, the feature coding recorded in the extraction source code, and the described feature coding recorded in source code is deleted, the feature coding of the source code after stake is removed in generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.Thereby, can determine whether software source code is changed after the pitching pile test, and then can be replaced the source code that occurs to change, to prevent wrong source code, be published.
It will be appreciated by those skilled in the art that the module in the device in embodiment can be distributed in the device of embodiment according to the embodiment description, also can carry out respective change and be arranged in the one or more devices that are different from the present embodiment.The module of above-described embodiment can be merged into a module, also can further split into a plurality of submodules.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add essential general hardware platform by software and realize, can certainly pass through hardware, but in a lot of situation, the former is better embodiment.Understanding based on such, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in a storage medium, comprise that some instructions are with so that a station terminal equipment (can be mobile phone, personal computer, server, or the network equipment etc.) the described method of execution each embodiment of the present invention.
The above is only the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention; can also make some improvements and modifications, these improvements and modifications also should be looked protection scope of the present invention.

Claims (10)

1. A kind of source code integrality detection method, be applied to the pitching pile test process of source code, it is characterized in that, comprising:
Generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code;
When being gone the stake operation, the feature coding recorded in the extraction source code, and this feature coding is deleted from source code;
The feature coding of the source code after stake is removed in generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.
2. The method of claim 1 is characterized in that the feature coding of the source code of pitching pile is not carried out in described generation, and described feature coding is recorded in the field that does not affect the source code execution in source code, is specially:
When carrying out the pitching pile operation, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code.
3. The method of claim 1, is characterized in that, described described feature coding is recorded in to not affecting in the field that source code carries out in source code, is specially:
Described feature coding is recorded in the annotation information of source code.
4. The method of claim 1, is characterized in that, described feature coding is specially MD5 coding or SHA coding.
5. The method of claim 1, is characterized in that, also comprises:
When the stake code starts to carry out, judge whether current execution environment is test environment, if so, carry out described stake code, otherwise, skip described stake code, carry out source code.
6. A kind of source code integrity detection device, be applied to the pitching pile test process of source code, it is characterized in that, comprising:
Generation module, for generating the feature coding of the source code that does not carry out pitching pile, and be recorded in described feature coding in the field that does not affect the source code execution in source code;
Extraction module, for when being gone the stake operation, the feature coding recorded in the extraction source code, and this feature coding is deleted from source code;
Comparison module, remove the feature coding of the source code after stake for generation, the feature coding recorded in the feature coding that removes the source code after stake and the source code extracted is compared, and determine the integrality of source code according to comparative result.
7. Device as claimed in claim 6, is characterized in that, described generation module, specifically for:
When carrying out the pitching pile operation, generate the feature coding of the source code that does not carry out pitching pile, and described feature coding is recorded in the field that does not affect the source code execution in source code.
8. Device as claimed in claim 6, is characterized in that, described generation module, specifically for:
Described feature coding is recorded in the annotation information of source code.
9. Device as claimed in claim 6, is characterized in that, described feature coding is specially MD5 coding or SHA coding.
10. Device as claimed in claim 6, is characterized in that, also comprises execution module, for:
When the stake code starts to carry out, judge whether current execution environment is test environment, if so, carry out described stake code, otherwise, skip described stake code, carry out source code.
CN201210161665.1A 2012-05-23 2012-05-23 A kind of source code integrality detection method and device Active CN103425571B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210161665.1A CN103425571B (en) 2012-05-23 2012-05-23 A kind of source code integrality detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210161665.1A CN103425571B (en) 2012-05-23 2012-05-23 A kind of source code integrality detection method and device

Publications (2)

Publication Number Publication Date
CN103425571A true CN103425571A (en) 2013-12-04
CN103425571B CN103425571B (en) 2016-04-13

Family

ID=49650356

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210161665.1A Active CN103425571B (en) 2012-05-23 2012-05-23 A kind of source code integrality detection method and device

Country Status (1)

Country Link
CN (1) CN103425571B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114089725A (en) * 2021-11-18 2022-02-25 北京烁科精微电子装备有限公司 Test method and device for CMP (chemical mechanical polishing) equipment control software and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1758585A (en) * 2004-10-10 2006-04-12 北京华旗数码影像技术研究院有限责任公司 Method for recogniting seal by digital watermark
CN102214142A (en) * 2011-07-15 2011-10-12 南京大学 Instrumentation method for traceless manageable source code manually-defined mark
CN102222041A (en) * 2011-06-15 2011-10-19 深圳市运通信息技术有限公司 Test analysis system and method based on embedded software

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1758585A (en) * 2004-10-10 2006-04-12 北京华旗数码影像技术研究院有限责任公司 Method for recogniting seal by digital watermark
CN102222041A (en) * 2011-06-15 2011-10-19 深圳市运通信息技术有限公司 Test analysis system and method based on embedded software
CN102214142A (en) * 2011-07-15 2011-10-12 南京大学 Instrumentation method for traceless manageable source code manually-defined mark

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114089725A (en) * 2021-11-18 2022-02-25 北京烁科精微电子装备有限公司 Test method and device for CMP (chemical mechanical polishing) equipment control software and electronic equipment
CN114089725B (en) * 2021-11-18 2024-03-15 北京晶亦精微科技股份有限公司 Test method and device for control software of chemical mechanical polishing equipment and electronic equipment

Also Published As

Publication number Publication date
CN103425571B (en) 2016-04-13

Similar Documents

Publication Publication Date Title
CN106936441B (en) Data compression method and device
US9612936B2 (en) Correlation of source code with system dump information
AU2012395331B2 (en) Method and apparatus for recovering data
CN110989926B (en) Fault magnetic disc slot positioning method and device and electronic equipment
CN109388556B (en) Method and device for analyzing test process
CN110008129B (en) Reliability test method, device and equipment for storage timing snapshot
CN102135925B (en) Method and device for detecting error check and correcting memory
CN104282342A (en) Flash memory device, memory controller and control method of flash memory
CN111400267B (en) Method and device for recording logs
CN101308471A (en) Method and device for data restoration
CN105446864A (en) Method and device for verifying influence of deletion of cache file and mobile terminal
CN110727597A (en) Method for completing use case based on log troubleshooting invalid codes
CN108874441B (en) Board card configuration method, device, server and storage medium
CN108573172B (en) Data checking and storing method and device
CN108196975B (en) Data verification method and device based on multiple checksums and storage medium
WO2015087509A1 (en) State storage and restoration device, state storage and restoration method, and storage medium
US20110276831A1 (en) Utilizing Input/Output Paths For Failure Detection And Analysis
CN103812719A (en) Failure prediction method and device for cluster system
CN103425571B (en) A kind of source code integrality detection method and device
CN103746868A (en) Methods and apparatuses for sending and receiving testing messages, and testing equipment
CN107357701B (en) SAS signal testing method and device under distributed scene
CN103778114A (en) System and method for file recovery
CN102447589B (en) Method and device for aggregating records
CN114356218A (en) Data error correction method, device and medium for Flash memory
CN112527557A (en) Data recovery method, device and equipment and computer readable storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20190808

Address after: 518000 Nanshan District science and technology zone, Guangdong, Zhejiang Province, science and technology in the Tencent Building on the 1st floor of the 35 layer

Co-patentee after: Tencent cloud computing (Beijing) limited liability company

Patentee after: Tencent Technology (Shenzhen) Co., Ltd.

Address before: Shenzhen Futian District City, Guangdong province 518057 Zhenxing Road, SEG Science Park 2 East Room 403

Patentee before: Tencent Technology (Shenzhen) Co., Ltd.

TR01 Transfer of patent right