A cross-platform data visualization method
Patent Information
- Application Number
- CN202011325989.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-23
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2040-11-23
AI Technical Summary
[0004]本发明提供的一种跨平台的数据可视化方法,旨在解决现有技术中统计源代码的覆盖率只能限定平台并覆盖率统计效率不高、效果不佳的问题
[0030] In order to realize the visualization effect of the coverage statistics of the code compiled by Gcc under the Windows platform, this article transforms the info file based on the above steps, and realizes the visualization of the code compiled by Gcc under the Windows platform under the Linux platform.
Smart Images

Figure CN112416773B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a cross-platform data visualization method. Background Art
[0002] Software unit testing is a test work that verifies the correctness of a module, a function or a class of source code by writing test cases. The execution results of unit test cases can effectively check the coverage of source code. The so-called source code coverage refers to the ratio of the tested part of the code to the total amount of code. A coverage of 100% indicates that all tests have been completed. Coders supplement use cases or review and correct code for uncovered code based on the coverage results, which plays an important role in improving code quality.
[0003] Qt is a cross-platform C++ graphical user interface application development framework, QTest is a unit testing framework provided by Qt, Gcov is a code coverage tool that can be used for C / C++ and is a built-in tool of Gcc, and Lcov is an open source Linux platform coverage visualization statistics tool. There is no Windows version. The source code written in Qt under Windows can be quickly counted by the Gcov tool for the coverage of each source code file. However, since Lcov only supports Linux systems, we cannot derive a visual representation of coverage data. Using only Gcov for coverage statistics has the following disadvantages: the coverage data of each file is scattered, and the coverage of the entire code project is not formed, which has poor readability; it is not easy to view the code line execution status of each source code file, including whether the code line is executed and the number of code line executions. Summary of the invention
[0004] The present invention provides a cross-platform data visualization method, which aims to solve the problem in the prior art that source code coverage statistics can only be limited to a platform and coverage statistics are inefficient and ineffective.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] A cross-platform data visualization method of the present invention comprises the following steps:
[0007] Obtaining source data generated under the Windows platform;
[0008] Processing the source data to obtain edited data;
[0009] According to the editing data request test instruction, visual data is obtained.
[0010] The source data generated under the Windows platform is obtained, copied and uploaded to the Linux platform, the source data is processed according to the editing tool under the Linux platform to obtain the edited data, and the test instruction is requested according to the edited data to obtain the visualized data.
[0011] Preferably, the source data includes source code files, gcda files and gcno files.
[0012] Preferably, the processing of the source data to obtain edited data comprises:
[0013] Filtering the windows coverage information of the source data according to the filtering instruction;
[0014] Performing symbol replacement on the source data according to the editing tool;
[0015] The source path of the source data is updated to the local source path to obtain updated edited data.
[0016] Preferably, it also includes determining that the source file is not running under the coverage tool on the Windows platform.
[0017] A cross-platform data visualization device, comprising:
[0018] Acquisition module: used to acquire source data generated under the Windows platform;
[0019] Processing module: used for processing the source data to obtain edited data;
[0020] Request module: used to request test instructions according to the edited data to obtain visual data.
[0021] Preferably, the processing module specifically includes:
[0022] Filtering unit: used for filtering the windows coverage information of the source data according to the filtering instruction;
[0023] A replacement unit: used for performing symbol replacement on the source data according to the editing tool;
[0024] Update unit: used for updating the source path of the source data to the local source path to obtain updated edited data.
[0025] As a preference, it also includes:
[0026] A judgment module is used to determine that the source file is not running under the coverage tool of the Windows platform.
[0027] An electronic device comprises a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a cross-platform data visualization method as described in any one of the above.
[0028] A computer-readable storage medium storing a computer program, wherein the computer program enables a computer to implement a cross-platform data visualization method as described in any one of the above when executed.
[0029] The present invention has the following beneficial effects:
[0030] In order to enable the coverage statistics of the code compiled by Gcc under the Windows platform to achieve visualization effect, this paper transforms the info file based on the above steps and realizes the visualization of the code compiled by Gcc under the Windows platform under the Linux platform. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is a first flow chart of a cross-platform data visualization method implemented in an embodiment of the present invention;
[0032] Figure 2 is a second flow chart of a cross-platform data visualization method implemented in an embodiment of the present invention;
[0033] Figure 3 This is a specific implementation flow chart of a cross-platform data visualization method implemented by an embodiment of the present invention;
[0034] Figure 4 It is a schematic diagram of a cross-platform data visualization device implemented in an embodiment of the present invention;
[0035] Figure 5 It is a schematic diagram of a processing module of a cross-platform data visualization device implemented in an embodiment of the present invention;
[0036] Figure 6 This is a specific implementation flow chart of a cross-platform data visualization device implemented by an embodiment of the present invention;
[0037] Figure 7 It is a schematic diagram of an electronic device implementing a cross-platform data visualization device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0039] Example 1
[0040] like Figure 1 As shown, a cross-platform data visualization method includes the following steps:
[0041] S110, obtaining source data generated under the Windows platform;
[0042] S120, processing the source data to obtain edited data;
[0043] S130, obtaining visual data according to the editing data request test instruction.
[0044] Get the gcov file, source code file, and test project on the Windows platform and upload them to the Linux platform. The lcov tool can be executed on the Linux platform to perform coverage statistics, which makes up for the shortcomings of the gcov tool.
[0045] Example 2
[0046] like Figure 2 As shown, a cross-platform data visualization method includes:
[0047] S210, obtaining source data generated under the Windows platform;
[0048] S220, filtering the windows coverage information of the source data according to the filtering instruction;
[0049] S230, performing symbol replacement on the source data according to an editing tool;
[0050] S240, updating the source path of the source data to a local source path to obtain updated edited data;
[0051] S250, obtaining visual data according to the editing data request test instruction.
[0052] As can be seen from Example 2, the gcov file, source code file, and test project file generated under the windows platform are obtained and uploaded to the linux platform; it is determined whether the Gcc version of the windows platform is consistent with the Gcc version of the linux platform, and if not, a corresponding upgrade or downgrade is performed; under the linux platform, the Lcov tool is used to generate an info file, the info file contains coverage information of all data, and the path referenced by the info file is in the path format of the windows platform; the coverage information in the windows format contained in the info file is filtered according to the Lcov tool; the '\' symbol in the info file is replaced with the ' / ' symbol using the Notepad++ text editing tool; according to the local source code path of the linux platform, the source code path of the info file is corrected to the local source code path; according to the ghtml command, an html report is generated, and the html report identifies the target visualization output file.
[0053] Example 3
[0054] like Figure 3 As shown, a specific implementation may be:
[0055] S310, Windows platform and Linux platform can create source code project and test project, and add compilation parameters to the test project;
[0056] S320, including the source code project into the test project, and recompiling the test project to generate a gcno file, wherein the gcno file contains line number information of the source code of the reconstructed basic block graph and the corresponding blocks;
[0057] S330, running the test project to generate a gcda file, wherein the gcda file includes the number of arc jumps and other summary information, and using the gcov command to generate a gcov file from the gcda file;
[0058] S340, determining whether the gcov file is compiled under the Windows platform, and if so, clicking the gcov file corresponding to the source code file to view the code execution status;
[0059] S350, if not, obtain the gcov file, source code file, and test project file generated on the Windows platform and upload them to the Linux platform, determine whether the Gcc version of the Windows platform is consistent with the Gcc version of the Linux platform, and if not, perform corresponding upgrade or downgrade;
[0060] S360. On the Linux platform, use the Lcov tool to generate an info file, where the info file contains coverage information of all data, and the path referenced by the info file is in the path format of the Windows platform;
[0061] S370, filtering the coverage information in Windows format in the info file according to the Lcov tool; using the Notepad++ text editing tool to replace the '\' symbol in the info file with the ' / ' symbol, and correcting the source code path of the info file to the local source code path according to the local source code path of the Linux platform;
[0062] S380. Generate an html report according to the ghtml command, where the html report identifies the target visualization output file.
[0063] Example 4
[0064] like Figure 4 As shown, a cross-platform data visualization device includes:
[0065] Acquisition module 10: used to acquire source data generated under the Windows platform;
[0066] Processing module 20: used to process the source data to obtain edited data;
[0067] Request module 30: used for requesting a test instruction according to the edited data to obtain visual data.
[0068] An implementation method of the above-mentioned device can be: the acquisition module 10 acquires the source data generated under the Windows platform, the processing module 20 processes the source data according to the editing tool under the Linux platform to obtain editing data, and the request module 30 requests test instructions according to the editing data to obtain visualization data.
[0069] Example 5
[0070] like Figure 5 As shown, a processing module 20 of a cross-platform data visualization device includes:
[0071] Filtering unit 22: used for filtering the windows coverage information of the source data according to the filtering instruction;
[0072] A replacement unit 24: used for performing symbol replacement on the source data according to an editing tool;
[0073] Update unit 26: used for updating the source path of the source data to the local source path to obtain updated edited data.
[0074] An implementation mode of the processing module 20 of the above-mentioned device may be: the filtering unit 22 filters the windows coverage information of the source data according to the filtering instruction, the replacement unit 24 performs symbol replacement on the source data according to the editing tool, and the updating unit 26 updates the source path of the source data to the local source path under the Linux platform to obtain updated editing data.
[0075] Example 6
[0076] like Figure 6 As shown, a specific implementation device may be:
[0077] S610, Windows platform and Linux platform can create source code project and test project, and add compilation parameters to the test project;
[0078] S620, including the source code project into the test project, and recompiling the test project to generate a gcno file, wherein the gcno file contains line number information of the source code of the reconstructed basic block graph and the corresponding blocks;
[0079] S630, running the test project to generate a gcda file, wherein the gcda file includes the number of arc jumps and other summary information, and using the gcov command to generate a gcov file from the gcda file;
[0080] S640, determining whether the gcov file is compiled under the Windows platform, and if so, clicking the gcov file corresponding to the source code file to view the code execution status;
[0081] S650, if not, obtain the gcov file, source code file, and test project file generated on the Windows platform and upload them to the Linux platform, determine whether the Gcc version of the Windows platform is consistent with the Gcc version of the Linux platform, and if not, perform corresponding upgrade or downgrade;
[0082] S660. On the Linux platform, use the Lcov tool to generate an info file, where the info file contains coverage information of all data, and the path referenced by the info file is in the path format of the Windows platform;
[0083] S670, filtering the coverage information in Windows format in the info file according to the Lcov tool; using the Notepad++ text editing tool to replace the '\' symbol in the info file with the ' / ' symbol, and correcting the source code path of the info file to the local source code path according to the local source code path of the Linux platform;
[0084] S680. Generate an html report according to the ghtml command, where the html report identifies the target visualization output file.
[0085] Example 7
[0086] like Figure 7 As shown, an electronic device includes a memory 701 and a processor 702, wherein the memory 701 is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 702 to implement the above-mentioned cross-platform data visualization method.
[0087] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the electronic device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0088] A computer-readable storage medium storing a computer program, wherein the computer program enables a computer to implement a cross-platform data visualization method as described above when executed.
[0089] Exemplarily, the computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 701, and executed by the processor 702 to complete the present invention. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in a computer device.
[0090] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The computer device may include, but is not limited to, a memory 701 and a processor 702. Those skilled in the art will appreciate that this embodiment is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components, or a combination of certain components, or different components. For example, the computer device may also include an input / output device, a network access device, a bus, and the like.
[0091] The processor 702 may be a central processing unit (CPU), or other general-purpose processors 702, digital signal processors 702 (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor 702 may be a microprocessor 702 or the processor 702 may be any conventional processor 702, etc.
[0092] The memory 701 may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. The memory 701 may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the computer device. Further, the memory 701 may also include both an internal storage unit of the computer device and an external storage device. The memory 701 is used to store computer programs and other programs and data required by the computer device. The memory 701 may also be used to temporarily store data that has been output or is to be output.
[0093] The above description is only a specific embodiment of the present invention, but the technical features of the present invention are not limited thereto. Any changes or modifications made by any technician in the field of the present invention are included in the patent scope of the present invention.
Claims
1. A cross-platform data visualization method, characterized in that: The method is to obtain data generated under the Windows platform on the Linux platform and realize data visualization on the Linux platform, including: Obtaining source data generated under the Windows platform; Processing the source data to obtain edited data includes: Filtering the windows coverage information of the source data according to the filtering instruction; Performing symbol replacement on the source data according to the editing tool; Updating the source path of the source data to the local source path to obtain updated edited data; Requesting a test instruction according to the editing data to obtain visual data; That is, obtain the gcov file, source code file, and test project file generated under the windows platform and upload them to the linux platform; determine whether the Gcc version of the windows platform is consistent with the Gcc version of the linux platform, if not, perform corresponding upgrade or downgrade; under the linux platform, use the Lcov tool to generate an info file, the info file contains coverage information of all data, and the path referenced by the info file is in the path format of the windows platform; filter the coverage information in the windows format in the info file according to the Lcov tool; use the Notepad++ text editing tool to replace the '\' symbol in the info file with the ' / ' symbol; according to the local source code path of the linux platform, correct the source code path of the info file to the local source code path; according to the ghtml command, generate an html report, the html report identifies the target visualization output file.
2. A cross-platform data visualization method according to claim 1, characterized in that: The source data includes source code files, gcda files and gcno files.
3. A cross-platform data visualization method according to claim 1, characterized in that: The method also includes determining that the source data is not running on a coverage tool under the Windows platform.
4. A cross-platform data visualization device, characterized in that: include: Acquisition module: used to obtain source data generated under the Windows platform; Processing module: used for processing the source data to obtain edited data; The processing module specifically includes: Filtering unit: used for filtering the windows coverage information of the source data according to the filtering instruction; A replacement unit: used for performing symbol replacement on the source data according to the editing tool; Update unit: used for updating the source path of the source data to the local source path to obtain updated edit data; Request module: used for requesting test instructions according to the edited data to obtain visual data; That is, obtain the gcov file, source code file, and test project file generated under the windows platform and upload them to the linux platform; determine whether the Gcc version of the windows platform is consistent with the Gcc version of the linux platform, if not, perform corresponding upgrade or downgrade; under the linux platform, use the Lcov tool to generate an info file, the info file contains coverage information of all data, and the path referenced by the info file is in the path format of the windows platform; filter the coverage information in the windows format in the info file according to the Lcov tool; use the Notepad++ text editing tool to replace the '\' symbol in the info file with the ' / ' symbol; according to the local source code path of the linux platform, correct the source code path of the info file to the local source code path; according to the ghtml command, generate an html report, the html report identifies the target visualization output file.
5. A cross-platform data visualization device according to claim 4, characterized in that: Also includes: Judgment module: used for judging whether the source data is not compiled under the Windows platform.
6. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a cross-platform data visualization method as described in any one of claims 1 to 3.
7. A computer-readable storage medium storing a computer program, characterized in that: The computer program enables a computer to implement a cross-platform data visualization method according to any one of claims 1 to 3 when executed.
