CN106776293A - A kind of method and device of program segment detection - Google Patents
A kind of method and device of program segment detection Download PDFInfo
- Publication number
- CN106776293A CN106776293A CN201611076158.2A CN201611076158A CN106776293A CN 106776293 A CN106776293 A CN 106776293A CN 201611076158 A CN201611076158 A CN 201611076158A CN 106776293 A CN106776293 A CN 106776293A
- Authority
- CN
- China
- Prior art keywords
- printf
- information
- running
- positional information
- present
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
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
The invention discloses a kind of method and device of program segment detection, it is used to realize detect the purpose whether certain section of code runs succeeded exactly.Methods described includes:Operation printf;By the printf call macro;It is described grand by running, obtain current location information;The positional information is exported by printf.
Description
Technical field
The present invention relates to field of computer technology, more particularly to a kind of method and device of program segment detection.
Background technology
Detect whether certain section of code runs succeeded in process of application development, a printing letter can be write in code
Number, the parameter value of printf is the passage that programming personnel writes.If code runs succeeded, printf can be performed,
The word that output is finished writing., it is necessary to the point of test is especially more for an application program (app), then printf can be held
Row is multiple.If the word difference that the parameter value of printf, i.e. programming personnel are write is little, it is difficult to determine that output character is directed to
Which functional test, once go wrong, it is also difficult to the position of error codes is determined according to output character.It would therefore be highly desirable to solve
Certainly this problem.
The content of the invention
The present invention provides a kind of method and device of program segment detection, is used to realize detect whether certain section of code is held exactly
The successful purpose of row.
The present invention provides a kind of method of program segment detection, including:
Operation printf;
By the printf call macro;
It is described grand by running, obtain current location information;
The positional information is exported by printf.
In an embodiment of the present invention, the positional information at least includes one of following:Filename, class name, function name and
Code line number.
In an embodiment of the present invention, it is described described grand by running, current location information is obtained, including:
It is described grand by running, obtain the system information of compiling system;
Current location information is obtained from system information.
In an embodiment of the present invention, it is described that the positional information is exported by printf, including:
By the field name and the corresponding positional information of printf output position information.
The present invention also provides a kind of device of program segment detection, including:
Operation module, for running printf;
Calling module, for by the printf call macro;
Acquisition module, for described grand by running, obtains current location information;
Output module, for exporting the positional information by printf.
In an embodiment of the present invention, the positional information at least includes one of following:Filename, class name, function name and
Code line number.
In an embodiment of the present invention, the acquisition module is additionally operable to:
It is described grand by running, obtain the system information of compiling system;
In an embodiment of the present invention, the output module is additionally operable to:
By the field name and the corresponding positional information of printf output position information.
In embodiments of the present invention, printf is run;By the printf call macro;It is described grand by running,
Obtain current location information;The positional information is exported by printf.As can be seen here, the embodiment of the present invention can realize standard
Really detect the purpose whether certain section of code runs succeeded.
Other features and advantages of the present invention will be illustrated in the following description, also, the partly change from specification
Obtain it is clear that or being understood by implementing the present invention.The purpose of the present invention and other advantages can be by the explanations write
Specifically noted structure is realized and obtained in book, claims and accompanying drawing.
Below by drawings and Examples, technical scheme is described in further detail.
Brief description of the drawings
Accompanying drawing is used for providing a further understanding of the present invention, and constitutes a part for specification, with reality of the invention
Applying example is used to explain the present invention together, is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 show the flow chart of the method for one embodiment of the invention Program section detection;
Fig. 2 show the flow chart of the method for another embodiment of the present invention Program section detection;And
Fig. 3 show the structural representation of the device of one embodiment of the invention Program section detection.
Specific embodiment
The preferred embodiments of the present invention are illustrated below in conjunction with accompanying drawing, it will be appreciated that preferred reality described herein
Apply example to be merely to illustrate and explain the present invention, be not intended to limit the present invention.
As shown in Figure 1 for one embodiment of the invention Program section detection method flow chart, the method can include with
Lower step S11-S14.
Step S11, runs printf.
Step S12, by the printf call macro.
Step S13, it is described grand by running, obtain current location information.
In this step, the positional information of acquisition can at least include one of following:Filename, class name, function name and generation
Code line number.
Step S14, the positional information is exported by printf.
It is in this step, described that to export the positional information by printf can be by printf outgoing position
The field name of information and the corresponding positional information.
In embodiments of the present invention, printf is run;By the printf call macro;It is described grand by running,
Obtain current location information;The positional information is exported by printf.As can be seen here, embodiment of the present invention modification printing letter
Number, makes printf read the information such as code line number, class name, and when performing printf, in addition to output character, also
Output code line number and class name etc., so conveniently determine the module of the module or error being successfully tested, thus the embodiment of the present invention
Can realize detecting the purpose whether certain section of code runs succeeded exactly.
Can be logical by running the grand acquisition current location information in step S13 in an optional embodiment
Cross and run described grand, the system information of acquisition compiling system.
The method implementation process of program segment detection of the invention is discussed in detail below by a specific embodiment.Such as Fig. 2
The flow chart of the method for another embodiment of the present invention Program section detection is shown, the method may comprise steps of S21-
S24。
Step S21, runs printf.
Step S22, by the printf call macro.
Step S23, it is described grand by running, obtain the system information of compiling system.
Step S24, by the field name and the corresponding positional information of printf output position information.
In this step, the positional information at least includes one of following:Filename, class name, function name and code line number.
, it is necessary to this output information is added in the place of test printing in specific code, content information can be defined with oneself,
Which viewcontroller the inside such as output is currently at, inside which method of this viewcontroller,
Whole file which, can oneself definition:
#define log(fmt…)
NSlog ((@" [filenames:%s] n " " [function name:%s] n " " line number:%d " n fmt), _ file_,
_function_,_line_)
#define log(…)
The embodiment of the present invention changes printf, printf is read the information such as code line number, class name, and perform
During printf, in addition to output character, output code line number and class name etc. are gone back, so conveniently determine the module being successfully tested
Or error module, thus the embodiment of the present invention can realize detecting the purpose whether certain section of code runs succeeded exactly.
It should be noted that in actual applications, above-mentioned all optional embodiments can be any by the way of combining
Combination, forms alternative embodiment of the invention, and this is no longer going to repeat them.
Corresponding to the method for the program segment detection in above-described embodiment, the present invention also provides a kind of dress of program segment detection
Put.The structural representation of the device of one embodiment of the invention Program section detection is illustrated in figure 3, including:
Operation module 31, for running printf;
Calling module 32, for by the printf call macro;
Acquisition module 33, for described grand by running, obtains current location information;
Output module 34, for exporting the positional information by printf.
In an embodiment of the present invention, the positional information at least includes one of following:Filename, class name, function name and
Code line number.
In an embodiment of the present invention, the acquisition module 33, is additionally operable to by running described grand, obtains compiling system
System information.
In an embodiment of the present invention, the output module 34, is additionally operable to the word by printf output position information
Name section and the corresponding positional information.
The said apparatus of the embodiment of the present invention:Operation printf;By the printf call macro;By running
State grand, acquisition current location information;The positional information is exported by printf.As can be seen here, the embodiment of the present invention can
Realization detects the purpose whether certain section of code runs succeeded exactly.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer program
Product.Therefore, the present invention can be using the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Apply the form of example.And, the present invention can be used and wherein include the computer of computer usable program code at one or more
The shape of the computer program product implemented in usable storage medium (including but not limited to magnetic disk storage and optical memory etc.)
Formula.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program product
Figure and/or block diagram are described.It should be understood that every first-class during flow chart and/or block diagram can be realized by computer program instructions
The combination of flow and/or square frame in journey and/or square frame and flow chart and/or block diagram.These computer programs can be provided
The processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce
A raw machine so that produced for reality by the instruction of computer or the computing device of other programmable data processing devices
The device of the function of being specified in present one flow of flow chart or multiple one square frame of flow and/or block diagram or multiple square frames.
These computer program instructions may be alternatively stored in can guide computer or other programmable data processing devices with spy
In determining the computer-readable memory that mode works so that instruction of the storage in the computer-readable memory is produced and include finger
Make the manufacture of device, the command device realize in one flow of flow chart or multiple one square frame of flow and/or block diagram or
The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that in meter
Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented treatment, so as in computer or
The instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in individual square frame or multiple square frames.
Obviously, those skilled in the art can carry out various changes and modification without deviating from essence of the invention to the present invention
God and scope.So, if these modifications of the invention and modification belong to the scope of the claims in the present invention and its equivalent technologies
Within, then the present invention is also intended to comprising these changes and modification.
Claims (8)
1. a kind of method that program segment is detected, it is characterised in that including:
Operation printf;
By the printf call macro;
It is described grand by running, obtain current location information;
The positional information is exported by printf.
2. program segment detection method according to claim 1, it is characterised in that the positional information at least include it is following it
One:Filename, class name, function name and code line number.
3. program segment detection method according to claim 1, it is characterised in that described described grand by running, obtains and works as
Front position information, including:
It is described grand by running, obtain the system information of compiling system;
Current location information is obtained from system information.
4. program segment detection method according to claim 1, it is characterised in that described that institute's rheme is exported by printf
Confidence ceases, including:
By the field name and the corresponding positional information of printf output position information.
5. the device that a kind of program segment is detected, it is characterised in that including:
Operation module, for running printf;
Calling module, for by the printf call macro;
Acquisition module, for described grand by running, obtains current location information;
Output module, for exporting the positional information by printf.
6. device according to claim 5, it is characterised in that the positional information at least includes one of following:Filename,
Class name, function name and code line number.
7. device according to claim 5, it is characterised in that the acquisition module is additionally operable to:
It is described grand by running, obtain the system information of compiling system.
8. device according to claim 5, it is characterised in that the output module is additionally operable to:
By the field name and the corresponding positional information of printf output position information.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611076158.2A CN106776293A (en) | 2016-11-29 | 2016-11-29 | A kind of method and device of program segment detection |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611076158.2A CN106776293A (en) | 2016-11-29 | 2016-11-29 | A kind of method and device of program segment detection |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106776293A true CN106776293A (en) | 2017-05-31 |
Family
ID=58900935
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611076158.2A Pending CN106776293A (en) | 2016-11-29 | 2016-11-29 | A kind of method and device of program segment detection |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106776293A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101122880A (en) * | 2007-09-17 | 2008-02-13 | 福建星网锐捷网络有限公司 | Embedded type system of embed type debugging device and embedded type system debugging method |
CN101916223A (en) * | 2010-08-11 | 2010-12-15 | 无锡中星微电子有限公司 | Program debugging method and system |
US20130055216A1 (en) * | 2010-03-04 | 2013-02-28 | Nec Corporation | Application modification portion searching device and application modification portion searching method |
CN103645985A (en) * | 2013-11-28 | 2014-03-19 | 广州视源电子科技股份有限公司 | Source code macro-pairing detection method |
-
2016
- 2016-11-29 CN CN201611076158.2A patent/CN106776293A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101122880A (en) * | 2007-09-17 | 2008-02-13 | 福建星网锐捷网络有限公司 | Embedded type system of embed type debugging device and embedded type system debugging method |
US20130055216A1 (en) * | 2010-03-04 | 2013-02-28 | Nec Corporation | Application modification portion searching device and application modification portion searching method |
CN101916223A (en) * | 2010-08-11 | 2010-12-15 | 无锡中星微电子有限公司 | Program debugging method and system |
CN103645985A (en) * | 2013-11-28 | 2014-03-19 | 广州视源电子科技股份有限公司 | Source code macro-pairing detection method |
Non-Patent Citations (1)
Title |
---|
REMOTE_ROAME: "在ios iphone编程中使用封装的NSLog来打印调试信息", 《HTTPS://BLOG.CSDN.NET/REMOTE_ROAMER/ARTICLE/DETAILS/7107320》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8645912B2 (en) | System and method for use in replaying software application events | |
US10176079B2 (en) | Identification of elements of currently-executing component script | |
CN106502896B (en) | A kind of generation method and device of function test code | |
CN106649084A (en) | Function call information obtaining method and apparatus, and test device | |
US11455150B2 (en) | Accelerating application modernization | |
TWI566090B (en) | Debugging firmware / software to produce tracking systems and methods, recording media and computer program products | |
US20160162385A1 (en) | Correlation of violating change sets in regression testing of computer software | |
CN103399814B (en) | The method and device of automatic test | |
CN106716398A (en) | Visually differentiating strings for testing | |
CN105630661B (en) | Method and apparatus for the debugging of automated trans system program | |
CN111966580A (en) | Automatic testing method, device, equipment and storage medium based on artificial intelligence | |
CA2811617C (en) | Commit sensitive tests | |
CN107392018A (en) | Application program hulling method and device | |
CN106356053A (en) | Method and device for testing recognition accuracy of voice input method and electronic equipment | |
JP2020102209A (en) | Identification method of defect location on software program | |
CN109241998A (en) | model training method, device, equipment and storage medium | |
CN107832176A (en) | Hard disk pressure automatic test approach and system under a kind of Windows | |
CN104035862A (en) | Method and device for closure testing | |
CN113094252A (en) | Test case generation method and device, computer equipment and storage medium | |
US20140281719A1 (en) | Explaining excluding a test from a test suite | |
CN106776293A (en) | A kind of method and device of program segment detection | |
US10481969B2 (en) | Configurable system wide tests | |
CN110968500A (en) | Test case execution method and device | |
CN105677559B (en) | A kind of detection method and device | |
CN114625663A (en) | Test method, test device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170531 |
|
RJ01 | Rejection of invention patent application after publication |