Test case generation method and device, electronic equipment, storage medium and product

By creating a temporary child process to run candidate interface function test cases in the main process, the process destruction problem caused by interface function call exceptions during the generation of JNI function test cases is solved, and the integrity and optimization of test case generation are achieved.

CN119271538APending Publication Date: 2025-01-07BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310807696.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-03
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

When generating JNI function test cases, an exception occurs during the execution of the interface function call, resulting in the entire test case generation process being destroyed, and the complete dynamic iteration cannot be completed, resulting in the inability to generate better test cases.

Method used

By blocking and creating temporary child processes in the main process, running the candidate interface function test case, and ending the child process based on the running results of the temporary child process, awakening the main process and continuing to execute the main process until the preset algorithm iteration process ends to determine the target interface Function test cases.

Benefits of technology

Ensure the complete execution of the JNI function test case generation process, generate better target test cases, and avoid the destruction of the test case generation process caused by interface function call exceptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271538A_ABST
    Figure CN119271538A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a test case generation method and device, electronic equipment, a storage medium and a product, and the method comprises the steps: in a host process for iteratively generating a target interface function test case through a preset algorithm, when a to-be-operated candidate interface function test case is generated, generating a target interface function test case according to the target interface function test case; blocking the host process and creating a temporary sub-process; running the candidate interface function test case through a temporary sub-process, and ending the temporary sub-process according to a running result of the temporary sub-process; waking up the host process, and continuing to execute the host process according to a return value when the temporary sub-process is ended until the iteration process of the preset algorithm is ended, and determining the test case of the target interface function. According to the technical scheme provided by the embodiment of the invention, the process of generating the JNI function test case can be completely executed, so that a better target test case is generated on the basis of completing execution of a test case generation algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of application development and testing technology, and in particular to a test case generation method, device, electronic device, storage medium and product. Background Art

[0002] In an application that generates unit test cases based on genetic algorithms, the generated test cases are run dynamically. Then, the test cases are updated based on the results of the run and the target test cases are selected to be the best. However, in some cases, the target test case generation process cannot be fully executed, and the best test cases cannot be obtained. Summary of the invention

[0003] The present disclosure provides a test case generation method, device, electronic device, storage medium and product, which can enable the process of generating JNI function test cases to be fully executed, so as to generate a better target test case based on the completion of the execution of the test case generation algorithm.

[0004] In a first aspect, an embodiment of the present disclosure provides a test case generation method, the method comprising:

[0005] In a main process that iteratively generates a target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created;

[0006] Running the candidate interface function test case through the temporary sub-process, and ending the temporary sub-process according to the running result of the temporary sub-process;

[0007] The main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0008] In a second aspect, an embodiment of the present disclosure further provides a test case generating device, the device comprising:

[0009] A subprocess creation module is used to block the main process and create a temporary subprocess whenever a candidate interface function test case to be run is generated in the main process that iteratively generates the target interface function test case through a preset algorithm;

[0010] A subprocess running module, used to run the candidate interface function test case through the temporary subprocess, and end the temporary subprocess according to the running result of the temporary subprocess;

[0011] The main process execution module is used to wake up the main process and continue to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0012] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:

[0013] one or more processors;

[0014] a storage device for storing one or more programs,

[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the test case generation method as described in any one of the embodiments of the present disclosure.

[0016] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute a test case generation method as described in any one of the embodiments of the present disclosure.

[0017] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, including a computer program, which, when executed by a processor, implements a test case generation method as described in any one of the embodiments of the present invention.

[0018] The disclosed embodiment, in the main process that generates the target interface function test case through the preset algorithm iteration, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created; the candidate interface function test case is run through the temporary sub-process, and the temporary sub-process is terminated according to the running result of the temporary sub-process; the main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case. The technical solution of the disclosed embodiment solves the problem that the entire interface function test case generation process will be destroyed if an exception occurs in the interface function call execution process during the process of generating the interface function test case, and the process of generating the JNI function test case can be completely executed to generate a better target test case on the basis of the completion of the execution of the test case generation algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0020] Figure 1 It is a flow chart of a test case generation method provided by an embodiment of the present disclosure;

[0021] Figure 2 It is a flow chart of a test case generation method provided by an embodiment of the present disclosure;

[0022] Figure 3 It is a flow chart of a test case generation method provided by an embodiment of the present disclosure;

[0023] Figure 4 It is a flow chart of a test case generation method provided by an embodiment of the present disclosure;

[0024] Figure 5 It is a structural schematic diagram of a test case generating device provided by an embodiment of the present disclosure;

[0025] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0027] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0028] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0029] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0030] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0031] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0032] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0033] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0034] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0035] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0036] Generally, when testing JNI (Java Native Interface) functions, a crash in a C++ program will cause the entire Java virtual machine test case generation process to be destroyed and the trace information to be lost. Therefore, in a single Java virtual machine process, it is impossible to perform complete dynamic iteration of the test cases of the JNI functions to generate better test cases for testing the JNI functions. The technical solution provided by this embodiment can solve the above technical problems.

[0037] Figure 1A flow chart of a test case generation method provided in an embodiment of the present disclosure is applicable to scenarios in which test cases are automatically generated, such as generating test cases for testing JNI functions. The method can be executed by a test case generation device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC, a server, etc.

[0038] like Figure 1 As shown, the test case generation method includes:

[0039] S110. In a main process that iteratively generates a target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created.

[0040] Among them, the target interface can be a JAVA native interface, the target interface function test case can be a JAVA native interface function test case, and can be a unit test case (Unit Case) used to test a single code component (i.e. a single JAVA native interface function) and ensure that the code works as expected.

[0041] The preset algorithm can be an algorithm for automatically generating test cases, which is a process of searching for a set of test input data that meets a given test standard in a data domain. In order to automatically explore and generate better test cases, the preset algorithm is equivalent to converting test case generation into a path search problem. Correspondingly, the preset algorithm can be a test case generation algorithm based on a genetic algorithm, which realizes multi-generation evolution through algorithm iteration to generate target interface function test cases with better test performance. Among them, the test standard can be based on one or more information of a predetermined test goal, test object, test environment setting, and expected results.

[0042] Since the test object of the JAVA native interface function test case is the JAVA native interface function (JNI function), and the JNI function is a local function defined in the native layer, it can enable the Java code running inside the Java virtual machine to interact with applications and libraries written in other programming languages ​​(such as C, C++ and assembly language). However, during the test case generation process, when performing JNI function testing, if the called other programming language program conflicts or crashes, the test case generation process running in the JAVA virtual machine will also crash and lose the tracking information, that is, a single JAVA virtual machine cannot routinely perform a complete algorithm iteration process.

[0043] Therefore, in this embodiment, in order to enable the preset algorithm iteration process of generating the target JAVA native interface function test case to complete the operation, a branch thread is set. That is, the preset algorithm iteration process of generating the target JAVA native interface function test case is used as the main process, and a sub-thread is set as the branch thread for the execution process of each generated test case, and then the further execution of the main thread is determined according to the operation result of the sub-thread.

[0044] Specifically, whenever a candidate JAVA local interface function test case to be run is generated, the main process is blocked and a temporary child process is created. Normally, when a candidate JAVA local interface function test case is generated, the case is executed by a unique main thread to track and record information such as the execution path of the test case. Before execution, the main thread is not sure whether it can be executed smoothly or whether a crash will occur. Then, in this embodiment, the main process will be blocked, and the candidate JAVA local interface function test case will not be run for the time being without knowing the running result. Accordingly, a temporary child process will be created to execute the candidate JAVA local interface function test case.

[0045] Among them, you can use commands such as wait or waitpid to block the main process.

[0046] In an optional implementation, the fork() function can be used to create a temporary child process. The child process created by fork() can have a complete copy of the data area and stack area, especially after the child process crashes, it will not affect the main process. It should be noted that the trace information of the child process execution method cannot be directly synchronized to the main process, and serialization is required for inter-process communication.

[0047] S120: Run the candidate interface function test case through the temporary sub-process, and terminate the temporary sub-process according to the running result of the temporary sub-process.

[0048] The temporary subprocess can be understood as a test process of the main process, which determines whether the candidate interface function test case can be successfully executed or whether a crash will occur for the main process, that is, the candidate interface function test case is run through the temporary subprocess. The candidate interface function test case can be the candidate JAVA local interface function test case obtained in the above steps.

[0049] Furthermore, the running results of the temporary subprocess can be divided into two types, including successfully running the corresponding candidate JAVA local interface function test case, and failing to successfully run the corresponding candidate JAVA local interface function test case. Different running results have different running return values, which can identify different running results. For example, after normal execution, the temporary subprocess is terminated by the exit function exit (EXITSUCCESS), and in the case of execution timeout, the temporary subprocess is terminated by the timeout exit function exit (TIMEOUT). When a crash occurs during the execution process, the execution crash returns "CRASH" to terminate the temporary subprocess.

[0050] S130, waking up the main process, and continuing to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0051] After the temporary subprocess ends, the main process will be awakened to continue the execution of the main process. The return value at the end of the temporary subprocess reflects the execution result of the temporary subprocess. When the return value indicates that the candidate JAVA local interface function test case runs successfully, the candidate JAVA local interface function test case runs in the main process; when the return value indicates that the candidate JAVA local interface function test case does not run successfully, the running status corresponding to the return value is returned in the main process.

[0052] That is, when it is determined that the candidate JAVA local interface function test case can run normally, the main process will run the candidate JAVA local interface function test case according to the conventional algorithm iteration process, and collect the test performance of the candidate JAVA local interface function test case; when it is determined that the candidate JAVA local interface function test case cannot run normally, the running process of the candidate JAVA local interface function test case is skipped, and the running process of the test case generation algorithm is continued to ensure that the main process will not be interrupted until the preset algorithm iteration process is completed to determine the target JAVA local interface function test case, that is, to determine the target interface function test case.

[0053] The technical solution of the disclosed embodiment is as follows: in the main process that generates the target interface function test case through the preset algorithm iteration, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created; the candidate interface function test case is run through the temporary sub-process, and the temporary sub-process is terminated according to the running result of the temporary sub-process; the main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case. The technical solution of the disclosed embodiment solves the problem that the entire interface function test case generation process will be destroyed if an exception occurs in the interface function call execution process during the process of generating the interface function test case, and the process of generating the JNI function test case can be completely executed to generate a better target test case on the basis of the completion of the execution of the test case generation algorithm.

[0054] Figure 2 A flow chart of another test case generation method provided by an embodiment of the present disclosure further explains the situation where a temporary sub-thread fails to run smoothly in the process of implementing the test case generation method flow based on the above embodiment. The method can be executed by a test case generation device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.

[0055] like Figure 2 As shown, the test case generation method includes:

[0056] S210. In a main process that iteratively generates a target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created.

[0057] S220. Run the candidate interface function test case through the temporary subprocess and synchronously start a timing thread.

[0058] Among them, the role of the temporary subprocess is to test whether the candidate interface function test cases of the main process can run smoothly. Since the main process is blocked and waits for the running results of the temporary subprocess, this forms a multi-process serial iteration scenario. In order to ensure the execution efficiency of the main process and enable the temporary subprocess to be closed normally, a more stringent timeout process is added to each temporary subprocess in this embodiment.

[0059] Specifically, in this embodiment, when running the candidate interface function test case, a timing thread will be synchronously run to record the running time of the temporary sub-thread to determine whether the running timeout occurs. The timing sub-thread can be a sub-thread in the C++ layer.

[0060] S230: When the running time of the timing thread exceeds a first preset timeout running time, determine that the temporary sub-process has timed out and terminate the temporary sub-process.

[0061] Using a timing subthread to time the operation of a temporary subthread can ensure that the temporary subprocess is closed normally. Once the running time reaches and exceeds the first preset timeout running time, the temporary subprocess will be terminated. Since the timing subthread is a subthread of the C++ layer, it is necessary to call the exit function encapsulated in C++ to terminate the temporary subprocess. Among them, the first preset timeout running time can be determined according to the tolerance of the main process to the running time of the subprocess, and a time value that can make the running efficiency of the main process relatively high is set.

[0062] S240: When an exception occurs during the running of the temporary sub-process, the temporary sub-process is terminated and the candidate interface function test case is marked as abnormal.

[0063] If an exception occurs during the operation of the temporary subprocess, such as a crash, the temporary subprocess will be terminated and the crash will be executed to return CRASH.

[0064] In addition, when a temporary child process crash occurs, it indicates that the candidate interface function test case cannot be used for JNI function testing, and it is marked as an exception to facilitate subsequent acquisition and analysis of exception information.

[0065] It should be noted here that there is no clear execution order between S230 and S240. The two are different situations for ending temporary sub-processes. Once one of the situations occurs, it will enter S250. With the end of the temporary sub-process and the awakening of the main process, the other situation will not occur. That is, if the candidate interface function test case fails to run smoothly, the temporary sub-process will be ended by S230 or S240.

[0066] S250, waking up the main process, and continuing to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0067] When the candidate interface function test case fails to run smoothly, the return value of the temporary subprocess can be used to determine whether it is due to a timeout or a crash. The main process can then skip running the candidate interface function test case that fails to run smoothly, further advancing the preset algorithm iteration process of the main process.

[0068] The technical solution of the disclosed embodiment is as follows: in the main process that generates the target interface function test case through the preset algorithm iteration, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary subprocess is created; the candidate interface function test case is run through the temporary subprocess, and a timing thread is started synchronously, when the running time of the timing thread exceeds the first preset timeout running time, the temporary subprocess is determined to be running timeout and the temporary subprocess is terminated, or when an exception occurs in the temporary subprocess during the running process, the temporary subprocess is terminated and the candidate interface function test case is marked as abnormal; then, the main process is awakened, and the main process is continued to be executed according to the return value at the end of the temporary subprocess until the process of the preset algorithm iteration is terminated to determine the target interface function test case. The technical solution of the disclosed embodiment solves the problem that the entire interface function test case generation process will be destroyed if an exception occurs in the interface function call execution process during the process of generating the interface function test case, and the execution process of the candidate interface function test case can be tested in advance for the main process to see whether it is smooth before advancing the operation of the main process, so that the process of generating the JNI function test case can be fully executed, so as to generate a better target test case on the basis of the completion of the execution of the test case generation algorithm.

[0069] Figure 3 A flow chart of another test case generation method provided by an embodiment of the present disclosure further describes the process of collecting the operation logs of abnormally running candidate test cases based on the above embodiment. The method can be executed by a test case generation device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.

[0070] like Figure 3 As shown, the test case generation method includes:

[0071] S310. In the main process that iteratively generates the target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created.

[0072] S320: Run the candidate interface function test case through the temporary sub-process, terminate the temporary sub-process when an exception occurs during the running of the temporary sub-process, and mark the candidate interface function test case as abnormal.

[0073] Among them, the occurrence of an exception in the temporary subprocess during operation can be understood as the candidate interface function test case failing to run smoothly, which may be that the temporary subprocess has timed out or crashed. Accordingly, when marking the candidate interface function test case for exceptions, the timeout mark and the crash mark can be marked separately, or the same exception mark (such as error) can be uniformly marked.

[0074] S330, waking up the main process, and continuing to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0075] S340, acquiring each abnormal candidate interface function test case with abnormal marking information, and creating a case running sub-thread for each abnormal candidate interface function test case.

[0076] Usually, after determining the target interface function test case, the target interface function test case is directly converted into a JAVA document for storage. In this embodiment, the abnormal situation of the abnormal candidate interface function test case is also analyzed, in order to subsequently optimize the algorithm for automatically generating test cases, such as adjusting the search strategy in the preset algorithm search process.

[0077] To analyze the abnormal candidate interface function test case, it is necessary to obtain the abnormal execution log information of the corresponding abnormal candidate interface function test case. However, when running each abnormal candidate interface function test case through a temporary child process, the first preset timeout running time is usually set to a short time. When an abnormality occurs in the temporary child process, it is also difficult to obtain complete stack information; and the thread identifier of each log file is the identifier of the parent process, and it is impossible to match a certain abnormal candidate interface function test case with its specific running stack information. Therefore, a case running subthread will be created for each abnormal candidate interface function test case, and each abnormal candidate interface function test case will be run once to obtain the corresponding abnormal log information.

[0078] S350: Run each of the use case running sub-threads respectively, and obtain the running log of each of the use case running sub-threads during the running process.

[0079] In particular, the second preset timeout running length of the case running subthread of each abnormal candidate interface function test case is greater than the first preset timeout running length of the temporary subprocess that first runs each candidate interface function test case. Thus, there is enough time to collect the abnormal running logs of each abnormal candidate interface function test case. In an optional implementation, the first preset timeout running length can be set to any duration value between 300ms-1s, and the second preset timeout running length can be set to a duration value of 1s or more.

[0080] Moreover, in order to correspond each abnormal candidate interface function test case to its specific running stack information, when running each of the test case running sub-threads respectively, the thread ID of each of the test case running sub-threads can be set in the corresponding running log file name when each of the test case running sub-threads is started. Specifically, the thread ID setting can be done by adding a thread ID setting function in the JAVA virtual machine, calling the thread ID setting function when each of the test case running sub-threads is started, and writing the thread ID of each of the test case running sub-threads into the corresponding running log file name.

[0081] Furthermore, after the use case running sub-threads are finished running, the target stack information of each of the use case running sub-threads during the running process can be obtained, and the target stack information can be written into the running log file of the corresponding thread identifier. Among them, the target stack information can be all the stack information in the running stack of each use case running sub-thread, or it can be the key information selected from all the stack information, such as clearing all the memory status information of the virtual machine to ensure that the core stack information is completely recorded, and it can also reduce the redundant information that is invalid for abnormal state analysis.

[0082] After obtaining the running log of each test case running sub-thread, it can be used to analyze and optimize the test case generation algorithm.

[0083] The technical solution of the embodiment of the present disclosure is that in the main process that generates the target interface function test case through the preset algorithm iteration, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary subprocess is created; the candidate interface function test case is run through the temporary subprocess, and the temporary subprocess is terminated according to the running result of the temporary subprocess; the main process is awakened, and the main process is continued to be executed according to the return value at the end of the temporary subprocess, until the process of the preset algorithm iteration is terminated to determine the target interface function test case, and after the main process is terminated, each abnormal candidate interface function test case with abnormal marking information is obtained, and a case running subthread is created for each abnormal candidate interface function test case, and each case running subthread is run respectively, and the running log of each case running subthread during the running process is obtained for the analysis and research of the test case generation algorithm. The technical solution of the embodiment of the present disclosure solves the problem that the entire interface function test case generation process will be destroyed if an exception occurs in the interface function call execution process during the test case generation process of the interface function, and the process of generating the JNI function test case can be completely executed to generate a better target test case on the basis of the completion of the execution of the test case generation algorithm. It is also possible to further fully collect the running logs of each abnormal candidate interface function test case.

[0084] Figure 4 A flow chart of another test case generation method provided by an embodiment of the present disclosure further describes the process of pre-configuring the algorithm operating environment for generating test cases based on the above embodiment, especially when the test case generation algorithm is running in a Linux system environment. The method can be executed by a test case generation device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC terminal or a server, etc.

[0085] Since JNI functions are local functions defined in the native layer, the execution of JNI functions can enable the JAVA code running inside the JAVA virtual machine to interact with applications and libraries written in other programming languages ​​(such as C, C++ and assembly language), such as calling the basic dynamic library (Android lib, such as C library) in Android. Among them, the C library in Android is named Bionic C. When building Android, you need to build the Bionic C library first, and then build Android based on Bionic C.

[0086] The test case automatic generation process is mostly run in the cloud based on the Linux system for cloud computing. Among them, Linux usually uses the GNU tool chain, and the C library of Linux is Glib C and some basic libraries based on Glib C. However, Bionic C is not completely compatible with Glib C. Calling the basic dynamic library of Android in the Linux system cannot be successfully loaded and run, and the closed-source Android Bionic C library provided by some manufacturers cannot be directly used through JNI. Moreover, it is impossible to run the dynamic library of the ARM instruction set on the Linux desktop (x86 instruction set) system.

[0087] Then, it is necessary to configure the basic dynamic library of Android of the corresponding architecture in Linux, and perform compatibility processing on the dynamic libraries of two different architectures, so that the automatic generation process of JNI function test cases can be implemented and run in an environment based on the Linux system.

[0088] like Figure 4 As shown, the test case generation method includes:

[0089] S4010. Obtain the basic dynamic library and tool chain in the Android system resource data package.

[0090] In the Linux system, you must first set up the Android system resource data in order to configure the system environment later.

[0091] The Android system resource data package may be an Android image resource package (Android Image), and all basic runtime dynamic libraries and tool chains (Linker) may be obtained from the Android Image by decompressing the Android Image.

[0092] The tool chain includes a compiler, an assembler, a linker, and various functional programs in matching libraries (such as the C library).

[0093] S4020. Compile the basic dynamic library based on the tool chain, and store the compiled basic dynamic library in a preset system file in the root directory of the Linux system environment.

[0094] Specifically, the basic dynamic library can be compiled by the compiler in the tool chain, and then the compiled basic dynamic library file plus the library can be linked by the linker to make the compiled basic dynamic library file an executable file, which can be stored in the preset system file in the root directory of the Linux system environment. Among them, the preset system file storage path in the root directory is the preset dynamic library dependency path, and the preset Android dynamic library loader used later also specifies the same path in the corresponding hook function.

[0095] In addition, in an optional implementation, the compiled basic dynamic library can also be stored in a preset system file in the root directory of the Linux system environment through Linux Docker in the Mac system.

[0096] After the above two steps, the basic dynamic library resources of Android are prepared and the preparation of the Linux system environment is completed.

[0097] S4030. Under the preset dynamic library loading environment variable configuration, compile a preset Android dynamic library loader based on a header file with the same version as the Android system resource data packet, and use the compiled preset Android dynamic library loader as the loader of the compiled basic dynamic library.

[0098] The preset dynamic library loading environment variable includes the loading path of the compiled basic dynamic library to be loaded, and also includes the path of the So library of the preset Android dynamic library loader.

[0099] It should be noted that due to the incompatibility between Bionic C and Glib C and the differences in tool chains, the dynamic libraries compiled on Android cannot be used directly in a standard Linux environment. When you need to use Android's dynamic libraries in a standard Linux environment, you need to choose a loader that can solve the compatibility issues between different C libraries, such as Libhybris.

[0100] Libhybris can link the Android library's method references to Bionic C to Glib C, so that the libraries compiled with Bionic (mainly closed-source HAL libraries under Android) can be run on systems based on the GNU C library. The basic working principle of Libhybris is to encapsulate the interfaces of all Android basic dynamic libraries, and use a Linker-like mechanism inside Libhybris to dynamically load the Android basic dynamic libraries and redirect the corresponding interfaces.

[0101] After compiling the preset Android dynamic library loader based on the header file (Header) with the same version as the Android system resource data package, the preparation of the loader is completed.

[0102] S4040. During the process of loading the target basic dynamic library, when the target basic dynamic library fails to be opened, determining that the target basic dynamic library is the compiled basic dynamic library.

[0103] When the Linux system is running, some function instructions (such as the library loading instruction loadlibrary) will be used to load the basic dynamic library. After the system environment is prepared in the above steps, the basic dynamic libraries that can be loaded currently include the basic dynamic libraries of the Linux system and the basic dynamic libraries of the Android system.

[0104] According to the conventional basic dynamic library loading process, the basic dynamic library of the Linux system is opened directly through the dynamic library opening function of the C++ layer, and the content in the library is loaded into the target memory. However, in the present embodiment, there are two basic dynamic libraries of the system, and different dynamic libraries need to be loaded by different loaders. The basic dynamic library of the Linux system can be loaded based on the loader of the Linux system itself, while the Android system dynamic library needs to select a loader that can solve the compatibility problem of different C libraries.

[0105] In the process of loading the target basic dynamic library, when the target basic dynamic library is not opened successfully, it is determined that the target basic dynamic library is the compiled basic dynamic library, that is, the basic dynamic library of the Android system.

[0106] S4050, calling the basic dynamic library opening function in the compiled preset Android dynamic library loader to open the compiled basic dynamic library, and recording the corresponding basic dynamic library pointer.

[0107] For the basic dynamic library of the Android system, it must be loaded into the target cache space through the preset Android dynamic library loader.

[0108] Specifically, you can first call the basic dynamic library opening function in the preset Android dynamic library loader to open the compiled basic dynamic library.

[0109] The basic dynamic library pointer is the address information for finding the basic dynamic library, which can be used in subsequent basic dynamic library loading and / or calling processes.

[0110] S4060. Load entry pointers of all JAVA native interface functions in the compiled basic dynamic library according to the basic dynamic library pointer.

[0111] After determining the basic dynamic library pointer, the entry pointers of all JAVA native interface functions will be further loaded to determine the entry position of each JNI function.

[0112] S4070. Load the basic dynamic library into the target storage space based on each of the entry pointers.

[0113] Each functional function in the basic dynamic library can be loaded into the target storage space based on each entry pointer.

[0114] After the above steps, the operating environment for running the JNI test case generation algorithm in Linux can be set up. It can be understood that the above Android system basic dynamic library loading process is based on the optimized business logic of JDK, and the Android basic dynamic library is loaded based on Libhybris. In the subsequent system application process, users do not need to modify the business code too much, which is very user-friendly.

[0115] S4080. In the main process that iteratively generates the target JAVA native interface function test case through a preset algorithm, whenever a candidate JAVA native interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created.

[0116] Based on the above system environment, you can run the preset algorithm iteration to generate test cases for the JNI function.

[0117] S4090. Run the candidate JAVA native interface function test case through the temporary subprocess, and when any JAVA native interface function call request is obtained, extract the target entry pointer of any JAVA native interface function.

[0118] When running the candidate JAVA local interface function test case, the corresponding JNI function will be executed and the function in the basic dynamic library will be called. The target entry pointer of the JAVA local interface function is the search address of the JNI function.

[0119] S4100. When it is determined that the target entry pointer is a pointer to a function loaded based on the compiled preset Android dynamic library loader, any JAVA native interface function is called based on the function calling method in the compiled preset Android dynamic library loader to perform an operation test of any JAVA native interface function.

[0120] In this embodiment, since the operating system includes two basic dynamic libraries of different instruction set architecture systems and different basic dynamic library loaders are different, it is necessary to further determine whether the target function to be called is a function in the basic dynamic library of the Android system. The function corresponding to the pointer of the function loaded by the compiled preset Android dynamic library loader is the function in the basic dynamic library of the Android system.

[0121] If so, then any JAVA native interface function is called based on the function calling method in the compiled preset Android dynamic library loader to perform a running test of any JAVA native interface function, so as to determine the function of any JAVA native interface function.

[0122] S4110. End the temporary sub-process according to the running result of the temporary sub-process.

[0123] S4120, waking up the main process, and continuing to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target JAVA native interface function test case.

[0124] The technical solution of the disclosed embodiment starts with Linux system environment preparation to save the basic dynamic library resources of the Android system in a specified path, then prepares a preset Android dynamic library loader, and then loads the compiled Android dynamic library into the system memory and uses it through the preset Android dynamic library loader; then in the main process that generates the target JAVA native interface function test case through the preset algorithm iteration, each time a candidate JAVA native interface function test case to be run is generated, the main process is blocked and a temporary child process is created; the candidate JAVA native interface function test case is run through the temporary child process, and when the JNI function is called during the test case running process, the basic dynamic library resources under the corresponding Android system are loaded through the preset Android dynamic library loader, and then the temporary child process can be terminated according to the running result of the temporary child process; the main process is awakened, and the main process is continued to be executed according to the return value when the temporary child process ends, until the process of the preset algorithm iteration ends to determine the target JAVA native interface function test case. The technical solution of the disclosed embodiments solves the problem that the dynamic library compiled by Bionic cannot be loaded on the Linux system using the GNU tool chain, thereby failing to run the working thread for generating JNI function test cases, and the problem that an exception occurs in the interface function call execution process during the process of generating interface function test cases, which will destroy the entire interface function test case generation process. The technical solution can enable the process of generating JNI function test cases to be fully executed, so as to generate a better target test case based on the completion of the execution of the test case generation algorithm, and realize a multi-process JNI testing solution for running Android dynamic libraries on the Linux JVM based on Libhybris.

[0125] Figure 5 A test case generation device is provided in an embodiment of the present disclosure. The device is suitable for scenarios in which test cases are automatically generated, especially for generating test cases for testing JNI functions. The test case generation device can be implemented in the form of software and / or hardware and can be configured on an electronic device, which can be a mobile terminal, a PC, a server, etc.

[0126] like Figure 5 As shown, the test case generating device includes: a sub-process creating module 510, a sub-process running module 520 and a main process executing module 530.

[0127] Among them, the sub-process creation module 510 is used to block the main process and create a temporary sub-process whenever a candidate interface function test case to be run is generated in the main process that generates the target interface function test case through the preset algorithm iteration; the sub-process running module 520 is used to run the candidate interface function test case through the temporary sub-process and end the temporary sub-process according to the running result of the temporary sub-process; the main process execution module 530 is used to wake up the main process and continue to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0128] The technical solution of the disclosed embodiment is as follows: in the main process that generates the target interface function test case through the preset algorithm iteration, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created; the candidate interface function test case is run through the temporary sub-process, and the temporary sub-process is terminated according to the running result of the temporary sub-process; the main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case. The technical solution of the disclosed embodiment solves the problem that the entire interface function test case generation process will be destroyed if an exception occurs in the interface function call execution process during the process of generating the interface function test case, and the process of generating the JNI function test case can be completely executed to generate a better target test case on the basis of the completion of the execution of the test case generation algorithm.

[0129] In an optional implementation, the sub-process running module 520 may be specifically used for:

[0130] When the temporary subprocess starts running, a timing thread is synchronously started;

[0131] When the running time of the timing thread exceeds the first preset timeout running time, it is determined that the temporary sub-process has timed out and the temporary sub-process is terminated.

[0132] In an optional implementation, the sub-process running module 520 may be specifically used for:

[0133] When an exception occurs in the temporary sub-process during operation, the temporary sub-process is terminated and the candidate interface function test case is marked as abnormal.

[0134] In an optional implementation, the main process execution module 530 may be specifically used for:

[0135] When the return value indicates that the candidate interface function test case runs successfully, running the candidate interface function test case in the main process;

[0136] When the return value indicates that the candidate interface function test case has not been successfully executed, the running status corresponding to the return value is returned in the main process.

[0137] In an optional implementation, the test case generation device further includes a test case execution log acquisition module, which is specifically used to:

[0138] Acquire each abnormal candidate interface function test case with abnormal marking information, and create a case running sub-thread for each of the abnormal candidate interface function test cases;

[0139] Run each of the use case running sub-threads respectively, and obtain the running log of each of the use case running sub-threads during the running process;

[0140] Among them, the second preset timeout running time of each use case running sub-thread is greater than the first preset timeout running time.

[0141] In an optional implementation, the test case execution log acquisition module is further used to:

[0142] When each of the use case running sub-threads is started, the thread identifier of each of the use case running sub-threads is set in the corresponding running log file name;

[0143] The target stack information of each of the use case running sub-threads during the running process is obtained, and the target stack information is written into the running log file of the corresponding thread identifier.

[0144] In an optional embodiment, the test case generation device also includes a case generation environment configuration module, which is used to configure a basic dynamic library environment for supporting the operation of the main process before starting the main process when the system environment for running the main process is a Linux system environment.

[0145] In an optional implementation, the use case generation environment configuration module is specifically used to:

[0146] Get the basic dynamic library and tool chain in the Android system resource data package;

[0147] Compiling the basic dynamic library based on the tool chain, and storing the compiled basic dynamic library in a preset system file in the root directory of the Linux system environment;

[0148] Under the preset dynamic library loading environment variable configuration, a preset Android dynamic library loader is compiled based on a header file with the same version as the Android system resource data packet, and the compiled preset Android dynamic library loader is used as the loader of the compiled basic dynamic library.

[0149] In an optional implementation, the use case generation environment configuration module is further used to:

[0150] When the compiled basic dynamic library fails to be opened, calling the basic dynamic library opening function in the compiled preset Android dynamic library loader to open the compiled basic dynamic library, and recording the corresponding basic dynamic library pointer;

[0151] Loading the entry pointers of all interface functions in the compiled basic dynamic library according to the basic dynamic library pointer;

[0152] The basic dynamic library is loaded into the target storage space based on each of the entry pointers.

[0153] In an optional implementation, the test case generation device further includes an interface function calling module, which is used to extract a target entry pointer of any interface function when any interface function calling request is obtained after the compiled basic dynamic library is loaded;

[0154] Determine whether the target entry pointer is a pointer to a function loaded based on the compiled preset Android dynamic library loader. If so, call any of the interface functions based on the function calling method in the compiled preset Android dynamic library loader.

[0155] The test case generation device provided in the embodiments of the present disclosure can execute the test case generation method provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method.

[0156] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.

[0157] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6 , which shows an electronic device (eg, Figure 6The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0158] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An edit / output (I / O) interface 605 is also connected to the bus 604.

[0159] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0160] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0161] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0162] The electronic device provided in the embodiment of the present disclosure and the test case generation method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0163] The embodiment of the present disclosure also provides a computer storage medium on which a computer program is stored. When the program is executed by a processor, the test case generation method provided by the above embodiment is implemented.

[0164] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0165] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0166] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0167] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0168] In a main process that iteratively generates a target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created;

[0169] Running the candidate interface function test case through the temporary sub-process, and ending the temporary sub-process according to the running result of the temporary sub-process;

[0170] The main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0171] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0172] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0173] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".

[0174] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0175] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0176] An embodiment of the present disclosure further provides a computer program product, including a computer program, which, when executed by a processor, implements a test case generating method as provided in any one of the embodiments of the present disclosure.

[0177] In the process of implementation, the computer program product can be written in one or more programming languages ​​or a combination thereof to perform the computer program code for the disclosed operation, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0178] According to one or more embodiments of the present disclosure, [Example 1] provides a test case generation method, the method comprising:

[0179] In a main process that iteratively generates a target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created;

[0180] Running the candidate interface function test case through the temporary sub-process, and ending the temporary sub-process according to the running result of the temporary sub-process;

[0181] The main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0182] According to one or more embodiments of the present disclosure, [Example 2] provides a test case generation method, further comprising:

[0183] In some optional implementations, when the candidate interface function test case is run through the temporary sub-process, the method further includes:

[0184] When the temporary subprocess starts running, a timing thread is synchronously started;

[0185] Correspondingly, terminating the temporary sub-process according to the running result of the temporary sub-process includes:

[0186] When the running time of the timing thread exceeds the first preset timeout running time, it is determined that the temporary sub-process has timed out and the temporary sub-process is terminated.

[0187] According to one or more embodiments of the present disclosure, [Example 3] provides a test case generation method, including:

[0188] In some optional implementations, terminating the temporary sub-process according to the running result of the temporary sub-process further includes:

[0189] When an exception occurs in the temporary sub-process during operation, the temporary sub-process is terminated and the candidate interface function test case is marked as abnormal.

[0190] According to one or more embodiments of the present disclosure, [Example 4] provides a test case generation method, further comprising:

[0191] In some optional implementations, continuing to execute the main process according to the return value when the temporary sub-process ends includes:

[0192] When the return value indicates that the candidate interface function test case runs successfully, running the candidate interface function test case in the main process;

[0193] When the return value indicates that the candidate interface function test case has not been successfully executed, the running status corresponding to the return value is returned in the main process.

[0194] According to one or more embodiments of the present disclosure, [Example 5] provides a test case generation method, further comprising:

[0195] In some optional implementations, the method further includes:

[0196] Acquire each abnormal candidate interface function test case with abnormal marking information, and create a case running sub-thread for each of the abnormal candidate interface function test cases;

[0197] Run each of the use case running sub-threads respectively, and obtain the running log of each of the use case running sub-threads during the running process;

[0198] Among them, the second preset timeout running time of each use case running sub-thread is greater than the first preset timeout running time.

[0199] According to one or more embodiments of the present disclosure, [Example 6] provides a test case generation method, further comprising:

[0200] In some optional implementations, the running of each of the use case running sub-threads respectively and obtaining the running log of each of the use case running sub-threads during the running process include:

[0201] When each of the use case running sub-threads is started, the thread identifier of each of the use case running sub-threads is set in the corresponding running log file name;

[0202] The target stack information of each of the use case running sub-threads during the running process is obtained, and the target stack information is written into the running log file of the corresponding thread identifier.

[0203] According to one or more embodiments of the present disclosure, [Example 7] provides a test case generation method, further comprising:

[0204] In some optional implementations, when the system environment for running the main process is a Linux system environment, the method further includes:

[0205] Before starting the main process, a basic dynamic library environment for supporting the operation of the main process is configured.

[0206] According to one or more embodiments of the present disclosure, [Example 8] provides a test case generation method, further comprising:

[0207] In some optional implementations, the configuration is used to support a basic dynamic library environment for running the main process, including:

[0208] Get the basic dynamic library and tool chain in the Android system resource data package;

[0209] Compiling the basic dynamic library based on the tool chain, and storing the compiled basic dynamic library in a preset system file in the root directory of the Linux system environment;

[0210] Under the preset dynamic library loading environment variable configuration, a preset Android dynamic library loader is compiled based on a header file with the same version as the Android system resource data packet, and the compiled preset Android dynamic library loader is used as the loader of the compiled basic dynamic library.

[0211] According to one or more embodiments of the present disclosure, [Example 9] provides a test case generation method, further comprising:

[0212] In some optional implementations, the process of loading the compiled basic dynamic library based on the compiled preset Android dynamic library loader includes:

[0213] When the compiled basic dynamic library fails to be opened, calling the basic dynamic library opening function in the compiled preset Android dynamic library loader to open the compiled basic dynamic library, and recording the corresponding basic dynamic library pointer;

[0214] Loading the entry pointers of all interface functions in the compiled basic dynamic library according to the basic dynamic library pointer;

[0215] The basic dynamic library is loaded into the target storage space based on each of the entry pointers.

[0216] According to one or more embodiments of the present disclosure, [Example 10] provides a test case generation method, further comprising:

[0217] In some optional implementations, after the compiled basic dynamic library is loaded, the method further includes:

[0218] When any interface function call request is obtained, a target entry pointer of any interface function is extracted;

[0219] Determine whether the target entry pointer is a pointer to a function loaded based on the compiled preset Android dynamic library loader. If so, call any of the interface functions based on the function calling method in the compiled preset Android dynamic library loader.

[0220] According to one or more embodiments of the present disclosure, [Example 11] provides a test case generation device, including:

[0221] A subprocess creation module is used to block the main process and create a temporary subprocess whenever a candidate interface function test case to be run is generated in the main process that iteratively generates the target interface function test case through a preset algorithm;

[0222] A subprocess running module, used to run the candidate interface function test case through the temporary subprocess, and end the temporary subprocess according to the running result of the temporary subprocess;

[0223] The main process execution module is used to wake up the main process and continue to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

[0224] According to one or more embodiments of the present disclosure, [Example 12] provides a test case generation device, further comprising:

[0225] In an optional implementation, the subprocess running module may be specifically used for:

[0226] When the temporary subprocess starts running, a timing thread is synchronously started;

[0227] When the running time of the timing thread exceeds the first preset timeout running time, it is determined that the temporary sub-process has timed out and the temporary sub-process is terminated.

[0228] According to one or more embodiments of the present disclosure, [Example 13] provides a test case generation device, further comprising:

[0229] In an optional implementation, the subprocess running module may be specifically used for:

[0230] When an exception occurs in the temporary sub-process during operation, the temporary sub-process is terminated and the candidate interface function test case is marked as abnormal.

[0231] According to one or more embodiments of the present disclosure, [Example 14] provides a test case generation device, further comprising:

[0232] In an optional implementation, the main process execution module may be specifically used for:

[0233] When the return value indicates that the candidate interface function test case runs successfully, running the candidate interface function test case in the main process;

[0234] When the return value indicates that the candidate interface function test case has not been successfully executed, the running status corresponding to the return value is returned in the main process.

[0235] According to one or more embodiments of the present disclosure, [Example 15] provides a test case generation device, further comprising:

[0236] In an optional implementation, the test case generation device further includes a test case execution log acquisition module, which is specifically used to:

[0237] Acquire each abnormal candidate interface function test case with abnormal marking information, and create a case running sub-thread for each of the abnormal candidate interface function test cases;

[0238] Run each of the use case running sub-threads respectively, and obtain the running log of each of the use case running sub-threads during the running process;

[0239] Among them, the second preset timeout running time of each use case running sub-thread is greater than the first preset timeout running time.

[0240] According to one or more embodiments of the present disclosure, [Example 16] provides a test case generation device, further comprising:

[0241] In an optional implementation, the test case execution log acquisition module is further used to:

[0242] When each of the use case running sub-threads is started, the thread identifier of each of the use case running sub-threads is set in the corresponding running log file name;

[0243] The target stack information of each of the use case running sub-threads during the running process is obtained, and the target stack information is written into the running log file of the corresponding thread identifier.

[0244] According to one or more embodiments of the present disclosure, [Example 17] provides a test case generation device, further comprising:

[0245] In an optional embodiment, the test case generation device also includes a case generation environment configuration module, which is used to configure a basic dynamic library environment for supporting the operation of the main process before starting the main process when the system environment for running the main process is a Linux system environment.

[0246] According to one or more embodiments of the present disclosure, [Example 18] provides a test case generation device, further comprising:

[0247] In an optional implementation, the use case generation environment configuration module is specifically used to:

[0248] Get the basic dynamic library and tool chain in the Android system resource data package;

[0249] Compiling the basic dynamic library based on the tool chain, and storing the compiled basic dynamic library in a preset system file in the root directory of the Linux system environment;

[0250] Under the preset dynamic library loading environment variable configuration, a preset Android dynamic library loader is compiled based on a header file with the same version as the Android system resource data packet, and the compiled preset Android dynamic library loader is used as the loader of the compiled basic dynamic library.

[0251] According to one or more embodiments of the present disclosure, [Example 19] provides a test case generation device, further comprising:

[0252] In an optional implementation, the use case generation environment configuration module is further used to:

[0253] When the compiled basic dynamic library fails to be opened, calling the basic dynamic library opening function in the compiled preset Android dynamic library loader to open the compiled basic dynamic library, and recording the corresponding basic dynamic library pointer;

[0254] Loading the entry pointers of all interface functions in the compiled basic dynamic library according to the basic dynamic library pointer;

[0255] The basic dynamic library is loaded into the target storage space based on each of the entry pointers.

[0256] According to one or more embodiments of the present disclosure, [Example 20] provides a test case generation device, further comprising:

[0257] In an optional implementation, the test case generation device further includes an interface function calling module, which is used to extract a target entry pointer of any interface function when any interface function calling request is obtained after the compiled basic dynamic library is loaded;

[0258] Determine whether the target entry pointer is a pointer to a function loaded based on the compiled preset Android dynamic library loader. If so, call any of the interface functions based on the function calling method in the compiled preset Android dynamic library loader.

[0259] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0260] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0261] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A test case generation method, characterized in that: include: In a main process that iteratively generates a target interface function test case through a preset algorithm, whenever a candidate interface function test case to be run is generated, the main process is blocked and a temporary sub-process is created; Running the candidate interface function test case through the temporary sub-process, and ending the temporary sub-process according to the running result of the temporary sub-process; The main process is awakened, and the main process is continued to be executed according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

2. The method according to claim 1, characterized in that When the candidate interface function test case is run through the temporary subprocess, the method further includes: When the temporary subprocess starts running, a timing thread is synchronously started; Correspondingly, terminating the temporary sub-process according to the running result of the temporary sub-process includes: When the running time of the timing thread exceeds the first preset timeout running time, it is determined that the temporary sub-process has timed out and the temporary sub-process is terminated.

3. The method according to claim 2, characterized in that The step of terminating the temporary sub-process according to the running result of the temporary sub-process further includes: When an exception occurs in the temporary sub-process during operation, the temporary sub-process is terminated and the candidate interface function test case is marked as abnormal.

4. The method according to claim 1, characterized in that: The continuing to execute the main process according to the return value when the temporary sub-process ends includes: When the return value indicates that the candidate interface function test case runs successfully, running the candidate interface function test case in the main process; When the return value indicates that the candidate interface function test case has not been successfully executed, the running status corresponding to the return value is returned in the main process.

5. The method according to claim 3, characterized in that: The method further comprises: Acquire each abnormal candidate interface function test case with abnormal marking information, and create a case running sub-thread for each of the abnormal candidate interface function test cases; Run each of the use case running sub-threads respectively, and obtain the running log of each of the use case running sub-threads during the running process; Among them, the second preset timeout running time of each use case running sub-thread is greater than the first preset timeout running time.

6. The method according to claim 5, characterized in that The running of each of the use case running sub-threads respectively and obtaining the running log of each of the use case running sub-threads during the running process include: When each of the use case running sub-threads is started, the thread identifier of each of the use case running sub-threads is set in the corresponding running log file name; The target stack information of each of the use case running sub-threads during the running process is obtained, and the target stack information is written into the running log file of the corresponding thread identifier.

7. The method according to any one of claims 1 to 6, characterized in that: When the system environment for running the main process is a Linux system environment, the method further includes: Before starting the main process, a basic dynamic library environment for supporting the operation of the main process is configured.

8. The method according to claim 7, characterized in that The configuration is used to support the basic dynamic library environment for the main process to run, including: Get the basic dynamic library and tool chain in the Android system resource data package; Compiling the basic dynamic library based on the tool chain, and storing the compiled basic dynamic library in a preset system file in the root directory of the Linux system environment; Under the preset dynamic library loading environment variable configuration, a preset Android dynamic library loader is compiled based on a header file with the same version as the Android system resource data packet, and the compiled preset Android dynamic library loader is used as the loader of the compiled basic dynamic library.

9. The method according to claim 8, characterized in that The process of loading a compiled base dynamic library based on the compiled preset Android dynamic library loader includes: When the compiled basic dynamic library fails to be opened, calling the basic dynamic library opening function in the compiled preset Android dynamic library loader to open the compiled basic dynamic library, and recording the corresponding basic dynamic library pointer; Loading the entry pointers of all interface functions in the compiled basic dynamic library according to the basic dynamic library pointer; The basic dynamic library is loaded into the target storage space based on each of the entry pointers.

10. The method according to claim 9, characterized in that After the compiled basic dynamic library is loaded, the method further includes: When any interface function call request is obtained, a target entry pointer of any interface function is extracted; Determine whether the target entry pointer is a pointer to a function loaded based on the compiled preset Android dynamic library loader. If so, call any of the interface functions based on the function calling method in the compiled preset Android dynamic library loader.

11. A test case generating device, characterized in that: include: A subprocess creation module is used to block the main process and create a temporary subprocess whenever a candidate interface function test case to be run is generated in the main process that iteratively generates the target interface function test case through a preset algorithm; A subprocess running module, used to run the candidate interface function test case through the temporary subprocess, and end the temporary subprocess according to the running result of the temporary subprocess; The main process execution module is used to wake up the main process and continue to execute the main process according to the return value when the temporary sub-process ends, until the preset algorithm iteration process ends to determine the target interface function test case.

12. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the test case generation method as described in any one of claims 1-10.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the test case generation method as described in any one of claims 1 to 10 is implemented.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the test case generation method according to any one of claims 1 to 10.