Test method of operating system and computing equipment
By dividing test scripts into interpreted and compiled language scripts during operating system testing, and independently compiling compiled language scripts before testing, the problem of low testing efficiency in the existing technology is solved and more efficient testing is achieved. Use case execution and flexible testing process.
Patent Information
- Application Number
- CN202410790680.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, automated testing of operating systems is inefficient because compiled language scripts are compiled in interpreted language scripts, resulting in increased test case execution time.
By dividing test scripts into interpreted language scripts and compiled language scripts, and independently compiling compiled language scripts before test execution to generate binary files, the decoupling of compiled language scripts and interpreted language scripts is achieved, reducing testing The execution time of the use case.
It improves the efficiency and flexibility of operating system testing, reduces the execution time of test cases, and improves the efficiency of automated testing.
Smart Images

Figure CN118642959A
Abstract
Description
Technical Field
[0001] The present application relates to the field of software testing technology, and in particular to a testing method and computing device for an operating system. Background Art
[0002] Software automation testing refers to writing test scripts for test cases, or using automated testing tools to simulate user operations to verify the functionality and stability of the software system. Since the languages for writing test scripts include interpreted languages (such as Python and Shell) and compiled languages (such as C and Java), the corresponding scripts are interpreted test scripts and compiled test scripts.
[0003] For automated testing of operating systems, the interpreted language scripts and compiled language scripts corresponding to the test cases have their own corresponding test frameworks. When it is necessary to test interpreted language scripts and compiled language scripts, they are usually tested in the test framework corresponding to the interpreted language script due to research and development cost considerations. In related technologies, the compiled language script is written into the interpreted language script, and the compilation of the compiled language script is completed during the execution of the interpreted language script, which increases the execution time of the test case and reduces the efficiency of automated testing. Summary of the invention
[0004] The embodiments of the present application provide a method and a computing device for testing an operating system, which are used to improve the testing efficiency of the operating system.
[0005] In a first aspect, an embodiment of the present application provides a method for testing an operating system, the method comprising:
[0006] Obtain a test script corresponding to a target test case; the test script includes an interpreted language script and a compiled language script; wherein the target test case is a test case used for operating system testing; determine whether the test script is an interpreted language script or a compiled language script; when the test script is a compiled language script, compile the compiled language script to obtain a binary file; execute the interpreted language script and the binary file to test the operating system.
[0007] It can be seen that in the operating system testing method in the embodiment of the present application, the compilation of the compiled language script and the execution of the interpreted language script are two independent steps, that is, the decoupling between the compilation of the compiled language script and the execution of the interpreted language script is achieved, the execution time of the test case is reduced, and the test efficiency of the test case is improved. On the other hand, due to the decoupling between the compilation of the compiled language script and the execution of the interpreted language script, the flexibility of the operating system testing is improved.
[0008] In a possible implementation, it is determined whether the test script is an interpreted language script or a compiled language script according to keywords of the test script and / or grammatical rules of the test script, or an interpreter of the test script.
[0009] In a possible implementation, the compiled language scripts are recorded in the corresponding preset language partitions according to the language type; and the compiled language scripts of each preset language partition are compiled synchronously. In the embodiment of the present application, by recording the compiled language scripts of different language types in the corresponding language partitions, when the computing device compiles the compiled language scripts, the compiled language scripts of different language partitions can be compiled simultaneously, thereby improving the compilation efficiency of the compiled language scripts.
[0010] In a possible implementation, before compiling the compiled language script to obtain a binary file, the language type of the compiled language script is determined according to an extension of the compiled language script, or keywords of the compiled language script and / or grammatical rules of the compiled language script.
[0011] In a possible implementation, it is determined whether a compiled language script has an extension; if the compiled language script has an extension, the language type of the compiled language script is determined according to the extension; if the compiled language script does not have an extension, the language type of the compiled language script is determined according to keywords of the compiled language script and / or grammatical rules of the compiled language script.
[0012] In a possible implementation, one or more executable files are obtained according to an interpreted language script and / or a binary file; and the executable files are executed to test the operating system.
[0013] In a possible implementation, the language type of the interpreted language script is determined based on the keywords of the interpreted language script and the grammatical rules of the interpreted language script, or the extension of the interpreted language script; and the executable file is executed to test the operating system based on the configuration file of the interpreted language script and the language type of the interpreted language script.
[0014] In a possible implementation, the interpreted language script and / or binary file is packaged to obtain one or more executable files; wherein the packaging method includes full packaging, packaging by script type, packaging by test suite, or packaging by use case list; wherein the full packaging is to package all binary files and interpreted language scripts into one executable file; packaging by script type is to package the interpreted language script into one executable file, and the binary file corresponding to the compiled language script is packaged into one executable file; packaging by test suite is to package the interpreted language script corresponding to each test suite into a corresponding executable file, and the binary file of the compiled language script corresponding to each test suite is packaged into a corresponding executable file; packaging by use case list is to package the interpreted language script and binary file corresponding to the use case in the use case list into an executable file. In the embodiment of the present application, binary files and / or interpreted language scripts are packaged by different packaging methods to improve the flexibility of operating system testing.
[0015] In a possible implementation, the interpreted language script that has been executed and the compiled language script corresponding to the binary file are marked.
[0016] In the second aspect, the embodiment of the present application provides a testing device for an operating system, which includes: an acquisition module, a determination module, a compilation module, and an execution module. The acquisition module is used to acquire the test script corresponding to the target test case; the test script includes an interpreted language script and a compiled language script; wherein the target test case is a test case used for operating system testing; the determination module is used to determine whether the test script is an interpreted language script or a compiled language script; the compilation module is used to compile the compiled language script to obtain a binary file when the test script is a compiled language script; the execution module is used to execute the interpreted language script and the binary file to test the operating system.
[0017] In a third aspect, an embodiment of the present application provides a computing device, comprising a memory and a processor; the memory and the processor are coupled; wherein the memory is used to store programs / instructions; and the processor is used to call the programs / instructions for execution, so that the computing device implements a method for testing an operating system as described in any one of the first aspects.
[0018] In a fourth aspect, an embodiment of the present application further provides a computer program product, which, when running on a computing device, executes the method for testing an operating system as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;
[0021] Figure 2 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0022] Figure 3 A flowchart of a method for testing an operating system provided in an embodiment of the present application;
[0023] Figure 4 A flowchart of another operating system testing method provided in an embodiment of the present application;
[0024] Figure 5 A schematic diagram of recording a compiled language script and an interpreted language script provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram of recording a compiled language script provided in an embodiment of the present application;
[0026] Figure 7 A flowchart of another operating system testing method provided in an embodiment of the present application;
[0027] Figure 8 A schematic diagram of the structure of a testing device for an operating system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] It should be noted that the embodiments described in this application are only part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] The terms "first" and "second" in the specification and claims of this application are used to distinguish different objects rather than to describe a specific order of objects. For example, first data and second data are used to distinguish different data rather than to describe a specific order of data.
[0030] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0031] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
[0032] In order to enable those skilled in the art to better understand and implement the technical solutions provided by the embodiments of the present application, the technical terms involved in the embodiments of the present application are first introduced below.
[0033] A test case (TC) is a part of software automation testing, which describes in detail how to perform a specific test, including preconditions, input data, test steps, expected results, and actual results.
[0034] A test script (TS) is a script program written to automatically execute a series of tasks or tests. The languages for writing test scripts include compiled languages and interpreted languages. Compiled languages include C, C++, Delphi, Pascal, Fortran, and Golang, etc.; interpreted languages include JavaScript, Python, PHP, Ruby, Perl, Shell, VBScript, and MATLAB, etc.
[0035] The system under test (SUT) is the core object of the testing activity. The SUT is the device to which the tested operating system belongs.
[0036] In view of the problem of low test efficiency caused by the long execution time of test cases (the interpreted language script needs to be compiled during the execution of the compiled language script) in the process of performing automated testing on the operating system in the related art, the embodiment of the present application provides a test method and computing device for the operating system. In the embodiment of the present application, the computing device divides the test script corresponding to the test case into an interpreted language script and a compiled language script, and the computing device compiles the compiled language script to obtain the corresponding binary file; then, the computing device executes the interpreted language script and the binary file to complete the test of the operating system. In the embodiment of the present application, the computing device decouples the execution of the interpreted language script and the compilation of the compiled language script during the automated testing process, compiles the compiled language script before the test execution, and then only needs to execute the binary file and the interpreted language script corresponding to the compiled language script during the execution of the test case, thereby reducing the execution time of the test case and improving the efficiency of automated testing.
[0037] To facilitate understanding of the technical solution of the present application, the application scenarios of the embodiments of the present application are introduced below.
[0038] For example, Figure 1 A schematic diagram of an application scenario of an embodiment of the present application is shown in the figure.
[0039] like Figure 1 As shown, after the version of the operating system running in the server 10 is updated, it is necessary to test the function, serviceability, reliability, etc. of the operating system in the server 10. During the test, it can be implemented through the management device or automation platform of the server 10, for example Figure 1 The computing device 20 shown in FIG. The computing device 20 identifies an interpreted language script or a compiled language script, and compiles the compiled language script to obtain a corresponding binary file; then, the computing device 20 executes the interpreted language script and the binary file to test the operating system.
[0040] Exemplarily, the operating system running in the server may be an operating system having a Linux kernel.
[0041] As an example, the test scripts of the test cases used for the operating system test include interpreted language scripts and compiled language scripts. Among them, the interpreted language scripts include Python scripts and Shell scripts, and the compiled language scripts include C scripts and Golang scripts. The computing device 20 compiles the compiled language scripts (C scripts and Golang scripts) to obtain corresponding binary files respectively; the computing device 20 directly executes the Python script, Shell script, C script corresponding binary files and Golang script corresponding binary files. In the embodiment of the present application, the computing device 20 compiles the compiled language scripts (C scripts and Golang scripts) before executing the interpreted language scripts (Python scripts and Shell scripts) and obtains the corresponding binary files, thereby realizing the decoupling between the compilation of the compiled language script and the execution of the interpreted language script. During the execution of the test case, only the Python script, Shell script, C script corresponding binary files and Golang script corresponding binary files need to be executed, thereby reducing the execution time of the test case, thereby improving the efficiency of automated testing.
[0042] It can be understood that the computing device 20 can be a personal computer (PC), a physical server, a cloud server, or a virtual device (such as a virtual machine), etc., but is not limited thereto.
[0043] See also Figure 2 , which is a schematic diagram of the structure of a computing device provided in an embodiment of the present application.
[0044] like Figure 2 As shown, the computing device 200 includes a processor 210, a memory 220 and a communication interface 230; wherein the memory 220 is used to store computer instructions; the processor 210 is used to execute the computer instructions, so that the computing device 200 executes the operating system testing method.
[0045] In some embodiments, the processor 210 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, etc. The general-purpose processor may also be a microprocessor or any conventional processor.
[0046] In some embodiments, the memory 220 may be a volatile memory or a non-volatile memory, such as a register. Specifically, a volatile memory refers to a memory in which the data stored inside will be lost when the power supply is interrupted. Among them, the volatile memory is mainly a random access memory (RAM), including a static random access memory (SRAM) and a dynamic random access memory (DRAM). A non-volatile memory refers to a memory in which the data stored inside will not be lost even if the power supply is interrupted. Common non-volatile memories include read-only memory (ROM), optical disks, magnetic disks, solid-state hard disks, and various memory cards based on flash memory technology.
[0047] In some embodiments, the memory 220 stores executable code, and the processor 210 executes the code to implement a testing method for an operating system.
[0048] The communication interface 230 is used to enable the computing device 200 to communicate with the server, and the computing device 200 obtains the test cases of the operating system of the server through the communication interface 230. The test cases include interpreted language scripts and compiled language scripts.
[0049] The bus can be a Peripheral Component Interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, and a control bus. For ease of understanding, Figure 2 It is represented by only one thick line, but it does not mean that there is only one bus or one type of bus.
[0050] Next, the solution of the present application will be described in conjunction with other embodiments.
[0051] It should be noted that the test method for the operating system involved below can be Figure 2 The computing device shown is executed, and specifically, can be executed by a processor in the computing device.
[0052] See also Figure 3 , which is a flow chart of a method for testing an operating system provided in an embodiment of the application. Figure 3 As shown, the method includes:
[0053] S310: The computing device obtains a test script corresponding to a target test case; the test script includes an interpreted language script and a compiled language script; wherein the target test case is a test case used for operating system testing.
[0054] Before executing a compiled language script, the source code needs to be converted into machine language code by a compiler. Then, when the program is running, the computing device can directly execute these compiled machine language codes without interpreting or converting them again. Therefore, it is suitable for developing system-level applications, games, high-performance computing and other application scenarios that require high execution efficiency and low operating overhead.
[0055] When an interpreted language script is executed, the interpreter reads the source code line by line and executes it immediately, without the need to compile the source code into machine language code in advance. It is suitable for application scenarios such as automated testing, system management, data processing, network programming, and rapid prototyping.
[0056] Exemplarily, the compiled languages described in the embodiments of the present application may include C, C++, Delphi, Pascal, Fortran and Golang, and the test scripts corresponding to the compiled languages are compiled language scripts; the interpreted languages may include JavaScript, Python, PHP, Ruby, Perl, Shell, VBScript and MATLAB, and the scripts corresponding to the interpreted languages are interpreted language scripts.
[0057] S320: The computing device determines whether the test script is an interpreted language script or a compiled language script.
[0058] In a possible implementation, the computing device classifies the test script into an interpreted language script or a compiled language script through an interpreter of the test script, wherein the interpreted language script includes an interpreter, while the compiled language script does not include an interpreter.
[0059] An interpreter is a computer program that can convert readable source code into machine language that a computer can understand and execute the code line by line. Interpreters are usually used to execute code in scripting languages or interpreted languages, such as Python, Shell, and Perl. The computer program corresponding to the interpreter can be stored in the memory of a computing device so that the computing device can call and execute it.
[0060] In a possible implementation, the computing device determines the language type corresponding to the test script, that is, an interpreted language or a compiled language, according to keywords of the test script and / or grammatical rules of the test script.
[0061] For example, the extension of a C script is .c, the extension of a C++ script is .cpp, the extension of a Delphi script is .dpr, the extension of a Pascal script is .pas, the extension of a Fortran is .for, and the extension of a Golang script is .go. Therefore, the computing device can determine the language type used by the script according to the extension of the script.
[0062] It should be noted that the compiled language script itself does not define whether to use an extension name, which mainly depends on the conventions of the developer, tool chain or specific community. Therefore, the language type of some compiled language scripts cannot be determined by the extension name.
[0063] In a possible implementation, for a test script without an extension, the language type corresponding to the test script may be determined according to keywords and grammar rules of the test script.
[0064] For example, the keywords of Delphi scripts are procedure, function, var, if, else, while, for, try, except, class, object, inherit and override, etc. Syntax rules of Delphi scripts: Delphi uses Pascal-style syntax, including semicolon (;) as the end of a statement and using begin...end to define a code block.
[0065] If the keywords and grammatical rules of the test script conform to the keywords and grammatical rules of Delphi respectively, the language type of the test script is determined to be Delphi, and the test script is a compiled language script. This embodiment takes the Delphi script as an example, and the recognition principle for test scripts of other language types is the same as above, which will not be repeated here.
[0066] Since not all test scripts can determine the language type according to their extensions, the embodiment of the present application can determine the language type of the test script in the following manner.
[0067] In a possible implementation, when the test script has an extension, the language type corresponding to the test script is determined directly through the extension; when the test script has no extension, the language type corresponding to the test script can be determined through the test script's keywords and / or grammar rules.
[0068] In addition, in the embodiment of the present application, the language type corresponding to the test script can be directly determined through the keywords and / or grammatical rules of the test script.
[0069] Therefore, in the embodiment of the present application, it is preferred to determine the language type of the test script by means of an extension name, and the use of keywords and grammar rules can be used as a supplementary method to make up for the shortcomings of relying solely on extension names or keywords and grammar rules for separate implementation, which is efficient and reliable.
[0070] S330: When the test script is a compiled language script, the computing device compiles the compiled language script to obtain a binary file.
[0071] Exemplarily, in the embodiment of the present application, compiling a compiled language script can be performed through the following three steps:
[0072] In the first step, the computing device parses the YAML configuration file.
[0073] Since there is no built-in YAML parsing library in the compiled language script, the computing device can parse the YAML configuration file through a third-party library. For example, the computing device uses the libyaml library to parse YAML data.
[0074] Exemplarily, the computing device installs the libyaml library through a package manager or directly compiles from source code; reads the YAML configuration file through the libyaml library; initializes a YAML parser using the yaml_parser_initialize function; and parses the YAML configuration file using the yaml_parser_parse function.
[0075] In the second step, the computing device searches for a corresponding library according to the language type of the compiled language script.
[0076] Exemplarily, if the language type of the compiled language script is C language, the corresponding library may be syck or lyaml.
[0077] In the third step, the computing device writes and compiles the corresponding compiled language script according to the library documentation.
[0078] Exemplarily, when the language type of the compiled language script is C language, the compiled language script is written and compiled through the syck library or the lyaml library to obtain a binary file.
[0079] It should be understood that the binary file can be directly executed by the computing device.
[0080] S340: The computing device executes the interpreted language script and binary file to test the operating system.
[0081] In an embodiment of the present application, the computing device first obtains a test script corresponding to a target test case; the test script includes an interpreted language script and a compiled language script; wherein the target test case is a test case used for operating system testing; secondly, it is determined whether the test script is an interpreted language script or a compiled language script; then, if the test script is a compiled language script, the compiled language script is compiled to obtain a binary file; finally, the interpreted language script and the binary file are executed to test the operating system. In an embodiment of the present application, by identifying a compiled language script and separately compiling the compiled language script, the decoupling between the compilation of the compiled language script and the execution of the interpreted language script is achieved, so that the execution time of the test case is reduced and the testing efficiency of the operating system is improved.
[0082] See also Figure 4 , which is a flowchart of another method for testing an operating system provided in an embodiment of the present application.
[0083] like Figure 4 As shown, the method includes:
[0084] S410: The computing device obtains unmarked test cases and test scripts corresponding to the test cases.
[0085] The test cases described in the embodiment of the present application include executed test cases and unexecuted test cases. The embodiment of the present application distinguishes the executed test cases from the unmarked test cases by marking. Among them, the executed test cases will not be tested again.
[0086] Generally speaking, each test case that has not been executed includes a test script.
[0087] Exemplarily, test cases can be stored in test management tools such as TestRail and Jira, or in version control systems such as the distributed version control system Git, or in comma-separated values (CSV) files, databases, or Excel files. When test cases are stored in test management tools such as TestRail and Jira, the computing device obtains test cases through the application programming interface (API) or export function provided by test management tools such as TestRail and Jira; when stored in a version control system (such as Git), the computing device can use a version control client (such as the Git command line or graphical interface tool) on the computing device to obtain test case files; when test cases are stored in CSV files, databases, or Excel files in the form of data, the computing device obtains test cases through corresponding tools or libraries.
[0088] S420: The computing device determines whether the test script is classified as an interpreted language script or a compiled language script.
[0089] In order to further improve the compilation efficiency of test cases, the embodiment of the present application records the compiled language script and the interpreted language script in the following manner.
[0090] S430: The computing device records the interpreted language script and the compiled language script into corresponding language partitions respectively.
[0091] In a possible implementation, the present application embodiment divides the storage area into a compiled language script storage area and an interpreted language script storage area, wherein the interpreted language script is recorded in the corresponding storage area, and the compiled language script is stored in the corresponding storage area.
[0092] As an example, Figure 5 As shown, the storage area is divided into a first storage area and a second storage area, the first storage area is used to record compiled language scripts, and the second storage area is used to record interpreted language scripts. Compiled language scripts include C scripts and Golang scripts, and interpreted language scripts include Python scripts and Shell scripts. C scripts and Golang scripts are recorded in the first storage area, and Python scripts and Shell scripts are recorded in the second storage area.
[0093] Furthermore, the first region corresponding to the compiled language script is divided into a plurality of language partitions, each of which records a compiled language script of a corresponding language type. The computing device determines the language type of the compiled language script by the extension of the compiled language script, and records the compiled language script of each language type in the corresponding language partition.
[0094] Exemplarily, the language types of the compiled language script include C, C++, Delphi, Pascal, Fortran and Golang, and the language partitions of the compiled language script include a first partition, a second partition, a third partition, a fourth partition, a fifth partition and a sixth partition. Figure 6 shown.
[0095] The extension of a C script is .c, the extension of a C++ script is .cpp, the extension of a Delphi script is .dpr, the extension of a Pascal script is .pas, the extension of a Fortran is .for, and the extension of a Golang script is .go. The computing device records the compiled language script with the extension .c in the first partition, the compiled language script with the extension .cpp in the second partition, the compiled language script with the extension .dpr in the third partition, the compiled language script with the extension .dpr in the fourth partition, the compiled language script with the extension .for in the fifth partition, and the compiled language script with the extension .go in the sixth partition.
[0096] It should be noted that the compiled language script itself does not define whether to use an extension name, which mainly depends on the agreement of the developer, tool chain or specific community. Therefore, for some compiled language scripts, the language type cannot be determined by the extension name. The embodiment of the present application further determines the language type of the compiled language script in the following way.
[0097] In a possible implementation, for a compiled language script type without an extension, its corresponding language type may be determined according to keywords and / or grammar rules of the compiled language script, and the compiled language script of each language type may be recorded in a corresponding language partition.
[0098] For example, the keywords of Delphi scripts include procedure, function, var, if, else, while, for, try, except, class, object, inherit and override, etc. The syntax rules of Delphi scripts, that is, Delphi uses Pascal-style syntax, including semicolon (;) as the end of a statement, using begin...end to define a code block, etc.
[0099] When the keywords and grammar rules of the compiled language script respectively conform to the above-mentioned Delphi keywords and Delphi grammar rules, the language type of the compiled language script is determined to be Delphi, and then the compiled language script is recorded in the corresponding partition. This embodiment takes the Delphi script as an example, and the recognition principle of compiled language scripts of other language types is the same as above, which will not be repeated here.
[0100] It should be understood that in the embodiments of the present application, when the compiled language script has an extension, the corresponding language type is determined directly by the extension; when the compiled language script has no extension, the corresponding language type can be determined by the keywords and / or grammar rules of the compiled language script.
[0101] In addition, the language type of the compiled language script may be directly determined through keywords and / or grammatical rules of the compiled language script, and then the corresponding script may be recorded in the corresponding storage area.
[0102] In the embodiment of the present application, compiled language scripts of different language types are recorded in corresponding partitions, so that when the compiled language scripts are subsequently compiled, the compiled language scripts of different language types can be compiled at the same time, thereby improving the compilation efficiency.
[0103] S440: The computing device compiles the compiled language script to obtain a binary file.
[0104] In one possible implementation, Figure 5 As shown, the compiled language script and the interpreted language script are recorded in the first storage area and the second storage area respectively, and each compiled language script in the first storage area is compiled to obtain a corresponding binary file.
[0105] In the embodiment of the present application, while recording the interpreted language script and the compiled language script, the language types of the compiled language script and the interpreted language script are recorded respectively. When compiling the compiled language script, it is only necessary to compile each compiled language script in the storage area corresponding to the compiled language script, thereby improving the compilation efficiency by reducing the cardinality.
[0106] In order to further improve the compilation efficiency of compiled language scripts, the embodiments of the present application provide the following implementation methods.
[0107] In one possible implementation, Figure 6 As shown, the storage area corresponding to the compiled language script is further divided into multiple partitions according to the language type, and the compiled language script of the corresponding language type is recorded in the corresponding partition. The embodiment of the present application further divides the storage area corresponding to the compiled language script so that the computing device can compile the compiled language scripts in different partitions at the same time, further improving the compilation efficiency of the compiled language script.
[0108] Exemplarily, the language types of compiled language scripts include C, C++, Delphi, Pascal, Fortran and Golang, and the language partitions of compiled language scripts include the first partition, the second partition, the third partition, the fourth partition, the fifth partition and the sixth partition. Among them, the C script is recorded in the first partition, the C++ script is recorded in the second partition, the Delphi is recorded in the third partition, the Pascal is recorded in the fourth partition, the Fortran is recorded in the fifth partition and the Golang is recorded in the sixth partition. The computing device can simultaneously compile the C script of the first partition class, the C++ script in the second partition, the Delphi script in the third partition, the Pascal script in the fourth partition, the Fortran in the fifth partition and the Golang script in the sixth partition, thereby improving the compilation efficiency of the compiled language scripts.
[0109] S450: The computing device obtains an executable file by packaging the binary file and / or the interpreted language script.
[0110] The number and content of the executable files depend on the packaging method. The present application embodiment provides the following four packaging methods:
[0111] (1) Full packaging: All binary files and interpreted language scripts are packaged into one executable file.
[0112] Exemplarily, the interpreted language script may include a Python script and a Shell script, and the binary file may include a binary file corresponding to a C script and a binary file corresponding to a Golang script. The Python script, the Shell script, the binary file corresponding to the C script, and the binary file corresponding to the Golang script are packaged into one executable file.
[0113] The advantage of full packaging is that there is no need to identify the language type of interpreted language scripts and the language type of compiled language scripts, which improves packaging efficiency.
[0114] (2) Packaging by script type: Packing the interpreted language script into an executable file, and packing the binary file corresponding to the compiled language script into an executable file.
[0115] Packaging the binary files corresponding to the interpreted language scripts and compiled language scripts separately is conducive to the subsequent distribution and deployment of the executable files, which can improve the efficiency of automated testing.
[0116] (3) Packaging by test suite: Packaging the interpreted language scripts corresponding to each test suite into one or more executable files, and packaging the binary files of the compiled language scripts corresponding to each test suite into corresponding executable files.
[0117] A test suite, also known as a validation suite, is a collection of multiple test cases. A test suite generally contains detailed descriptions of the test cases and their test purposes, as well as system configuration information for executing the test and pre-test preparation steps. A test suite can organically combine multiple test cases that serve the same test purpose or the same operating environment, so that complex test scenarios can be decomposed into multiple test cases within a single suite and share status between all test cases.
[0118] Exemplarily, the interpreted language script may include JavaScript script, Python script, PHP script, Ruby script, Perl script, Shell script, VBScript script and MATLAB script. Among them, JavaScript script, Python script and PHP script belong to one test suite, and Ruby script, Perl script, Shell script, VBScript script and MATLAB script belong to another test suite. Therefore, JavaScript script, Python script and PHP script can be packaged into one executable file, and Ruby script, Perl script, Shell script, VBScript script and MATLAB script can be packaged into one executable file.
[0119] The method of packaging the test scripts under the same suite and obtaining the executable file allows the executable file to be quickly deployed to the test environment, thereby improving the efficiency of automated testing.
[0120] (4) Package according to the use case list, and package the interpreted language scripts and binary files corresponding to the use cases in the use case list into executable files.
[0121] A test case list is a key document in the software testing process. It lists in detail all the test cases that need to be executed. These test cases are designed to verify whether a specific function or feature of the software system works as expected. Each test case contains the specific information required to perform the test, such as test objectives, prerequisites, test steps, expected results, and actual results.
[0122] Exemplarily, the test cases to be executed in the test case list include test case TC1, test case TC2, ... test case TC n The computing device will test case TC1, test case TC2, and so on. n The corresponding test scripts are packaged into an executable file.
[0123] When the test case corresponding to the obtained test script is not in the use case list, packaging it in the form of the use case list can prevent the test case from participating in the automated testing of the operating system, thereby improving the testing efficiency of the operating system.
[0124] S460: The computing device executes the executable file.
[0125] Due to the different packaging methods in the above steps, executable files can be divided into the following three types: first, the executable file only includes interpreted language scripts; second, the executable file only includes binary files; third, the executable file includes both interpreted language scripts and binary files.
[0126] In a possible implementation, for an executable file that only includes a binary file, the computing device may directly execute the executable file.
[0127] In a possible implementation, for an executable file including an interpreted language script (an executable file including only an interpreted language script, or an executable file including both an interpreted language script and a binary file), the computing device may determine the language type of the interpreted language script according to the grammatical rules of the interpreted language script or the extension of the interpreted language script; then parse the YAML configuration file and extract the YAML data through the function library corresponding to the language type of the interpreted language script; and finally execute the interpreted language script according to the extracted YAML data.
[0128] Exemplarily, the language type of the interpreted language script is Python, and its corresponding function library can be a PyYAML library. The PyYAML library parses the YAML configuration file corresponding to the Python script, extracts the corresponding YAML data, and executes the Python script according to the extracted YAML data.
[0129] S470: Mark the test script that has been executed.
[0130] After the test script corresponding to the executable file is executed, it can be marked so that it can be judged whether the test script has been executed. If it has been executed, the automated test of the operating system is terminated directly and the unmarked test script is retrieved. By marking the executed interpreted language script and the compiled language script corresponding to the binary text, repeated testing of the test script can be avoided.
[0131] In the embodiment of the present application, when the computing device tests the compiled language script and the interpreted language script at the same time, the compilation of the compiled language script is decoupled from the execution of the interpreted language script, which reduces the execution time of the test case and improves the test efficiency of the test case. In addition, in the embodiment of the present application, the compiled language scripts of different language types are stored in the corresponding partitions, so that the computing device can compile the compiled language scripts of different language types at the same time, which improves the compilation efficiency of the compiled language scripts.
[0132] In addition, in order to reduce the test steps of the operating system, the embodiment of the present application provides a test method of the operating system, and its corresponding flowchart is as follows: Figure 7 shown.
[0133] like Figure 7 As shown, the method includes:
[0134] S710: The computing device obtains unmarked test cases and test scripts corresponding to the test cases.
[0135] S720: The computing device determines the language type used by each test script according to the keywords and grammatical rules of the test script, and records the compiled language script into a corresponding partition according to the language type.
[0136] Exemplarily, an embodiment of the present application determines the language type of each test script according to the keywords and grammatical rules of each test script, such as C script, C++ script, Delphi script, Python script and Shell script, and directly compiles the language scripts, such as C script, C++ script and Delphi script, into the corresponding partition.
[0137] S730: The computing device synchronously compiles the compiled language script to obtain a binary file.
[0138] S740: The computing device obtains an executable file by packaging the binary file and the interpreted language script.
[0139] S750: The computing device executes the executable file.
[0140] Compared with the aforementioned embodiment, in this embodiment, the language type of each test script is directly determined through the keywords and grammatical rules of the test script, and the compiled language script of the corresponding language type is stored in the corresponding partition. Only one judgment is required for the language type of the test script, thereby reducing the number of judgments on the language type of the test script (the aforementioned embodiment judges the language type of the test script twice, the first time is to identify the interpreted language script and the compiled language script, and the second time is to identify the language type of the compiled language script), thereby reducing the testing steps of the operating system.
[0141] In addition, the present application also provides an automated testing device, the structural diagram of which is shown in FIG. Figure 8 shown.
[0142] like Figure 8 As shown, the device includes: an acquisition module 801, a determination module 802, a compilation module 803 and an execution module 804.
[0143] The acquisition module 801 is used to acquire the test script corresponding to the target test case; the test script includes an interpreted language script and a compiled language script; wherein the target test case is a test case used for operating system testing;
[0144] A determination module 802 is used to determine whether the test script is an interpreted language script or a compiled language script;
[0145] A compiling module 803, for compiling the compiled language script to obtain a binary file when the test script is a compiled language script;
[0146] The execution module 804 is used to execute the interpreted language script and binary file to test the operating system.
[0147] Optionally, the determination module 802 is specifically configured to determine whether the test script is an interpreted language script or a compiled language script according to keywords of the test script and / or grammatical rules of the test script, or an interpreter of the test script.
[0148] Optionally, the compiled language scripts are recorded in corresponding preset language partitions according to language types; the compiling module 803 is specifically used to synchronously compile the compiled language scripts of each preset language partition.
[0149] Optionally, before compiling the compiled language script to obtain a binary file, the determination module 702 is further configured to determine the language type of the compiled language script according to an extension of the compiled language script, or keywords of the compiled language script and grammatical rules of the compiled language script.
[0150] Optionally, the determination module 802 is specifically used to determine whether the compiled language script has an extension; if the compiled language script has an extension, determine the language type of the compiled language script according to the extension; if the compiled language script does not have an extension, determine the language type of the compiled language script according to keywords of the compiled language script and grammatical rules of the compiled language script.
[0151] Optionally, the execution module 804 is specifically used to obtain one or more executable files according to the interpreted language script and / or binary file; and execute the executable files to test the operating system.
[0152] Optionally, the executable file includes an interpreted language script; the execution module 804 is specifically used to determine the language type of the interpreted language script based on the keywords of the root interpreted language script and the grammatical rules of the interpreted language script, or the extension of the interpreted language script; and executes the executable file to test the operating system according to the configuration file of the interpreted language script and the language type of the interpreted language script.
[0153] Optionally, one or more executable files are obtained according to the interpreted language script and / or binary file, and the acquisition module is also used to package the interpreted language script and / or binary file to obtain one or more executable files; wherein the packaging method includes full packaging, packaging by script type, packaging by test suite or packaging by use case list; wherein, full packaging is to package all binary files and interpreted language scripts into one executable file; packaging by script type is to package the interpreted language script into one executable file, and the binary file corresponding to the compiled language script into one executable file; packaging by test suite is to package the interpreted language script corresponding to each test suite into a corresponding executable file, and the binary file of the compiled language script corresponding to each test suite into a corresponding executable file; packaging by use case list is to package the interpreted language script and binary file corresponding to the use case in the use case list into an executable file.
[0154] Optionally, the device further comprises: a marking module;
[0155] The marking module is specifically used to mark the executed interpreted language scripts and the compiled language scripts corresponding to the binary files.
[0156] In addition, an embodiment of the present application also provides a computer program product, which, when running on a computing device, executes the method for testing the operating system as described in the above embodiments.
[0157] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.
[0158] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0159] The above description is merely an exemplary embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for testing an operating system, characterized in that: The method comprises: Obtain a test script corresponding to a target test case; the test script includes an interpreted language script and a compiled language script; wherein the target test case is a test case used for operating system testing; Determining whether the test script is the interpreted language script or the compiled language script; In the case where the test script is the compiled language script, compile the compiled language script to obtain a binary file; Executing the interpreted language script and the binary file tests the operating system.
2. The method according to claim 1, characterized in that The step of determining whether the test script is the interpreted language script or the compiled language script comprises: According to the keywords of the test script and / or the grammatical rules of the test script, or the interpreter of the test script, it is determined whether the test script is the interpreted language script or the compiled language script.
3. The method according to claim 1 or 2, characterized in that: The compiled language script is recorded in the corresponding preset language partition according to the language type; the compiled language script is compiled to obtain a binary file, including: The compiled language scripts of the preset language partitions are synchronously compiled.
4. The method according to claim 3, characterized in that Before compiling the compiled language script to obtain a binary file, the method further includes: The language type of the compiled language script is determined according to an extension of the compiled language script, or a keyword of the compiled language script and / or a grammatical rule of the compiled language script.
5. The method according to claim 4, characterized in that The determining the language type of the compiled language script according to the extension of the compiled language script, or the keywords of the compiled language script and / or the grammatical rules of the compiled language script includes: Determining whether the compiled language script has an extension; In the case where the compiled language script has an extension, determining the language type of the compiled language script according to the extension; In the case that the compiled language script does not have an extension, the language type of the compiled language script is determined according to keywords of the compiled language script and / or grammatical rules of the compiled language script.
6. The method according to any one of claims 1 to 5, characterized in that: The executing of the interpreted language script and the binary file to test the operating system includes: Obtain one or more executable files according to the interpreted language script and / or the binary file; Executing the executable file tests the operating system.
7. The method according to claim 6, characterized in that The executable file includes the interpreted language script; and executing the executable file to test the operating system includes: Determining the language type of the interpreted language script according to the keywords of the interpreted language script and the grammatical rules of the interpreted language script, or the extension of the interpreted language script; The executable file is executed to test the operating system according to the configuration file of the interpreted language script and the language type of the interpreted language script.
8. The method according to claim 6, characterized in that The step of obtaining one or more executable files according to the interpreted language script and / or the binary file comprises: The interpreted language script and / or the binary file are packaged to obtain the one or more executable files; wherein the packaging method includes full packaging, packaging by script type, packaging by test suite, or packaging by use case list; wherein, The full packaging is to package all binary files and interpreted language scripts into one executable file; The packaging by script type is to package the interpreted language script into an executable file, and to package the binary file corresponding to the compiled language script into an executable file; The packaging by test suite is to package the interpreted language scripts corresponding to each test suite into corresponding executable files, and to package the binary files of the compiled language scripts corresponding to each test suite into corresponding executable files; The packaging according to the use case list is to package the interpreted language scripts and binary files corresponding to the use cases in the use case list into executable files.
9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: The interpreted language script and the compiled language script corresponding to the binary file are marked as executed.
10. A computing device, characterized in that The computing device comprises a memory and a processor; the memory and the processor are coupled; Wherein, the memory is used to store programs / instructions; The processor is used to call the program / instruction to execute, so that the computing device implements the method for testing the operating system as described in any one of claims 1-9.
Citation Information
Patent Citations
SQL test script generation method
CN111694738A
Compiler test method, compiler test device and storage medium
CN116521550A
Script generation method and device, equipment and storage medium
CN117851237A
Common debug scripting framework for driving hybrid applications consisting of compiled languages and interpreted languages
US20180165175A1
Cited By
Method for executing simulation test based on excel table
CN119179649A
A method for performing simulation testing based on Excel tables
CN119179649B
