Method, device, electronic device and storage medium for closing background process

By generating and comparing the process files before and after the test, quickly closing the test process is solved, and the cumbersome shutdown process caused by multiple test programs is improved, and testing efficiency and equipment stability are improved.

CN115640123BActive Publication Date: 2025-07-04INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211261049.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-14
Publication Date
2025-07-04
Estimated Expiration
2042-10-14

AI Technical Summary

Technical Problem

In the prior art, the large number of test programs running in the background leads to cumbersome closure processes and reduces testing efficiency.

Method used

By obtaining process information before and after electronic device testing, generating process files, and comparing and closing the test process based on these files, achieving rapid and full closure.

Benefits of technology

It simplifies the shutdown operation of the test process, saves test time, improves test efficiency, and effectively releases equipment performance, improving equipment operation stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115640123B_ABST
    Figure CN115640123B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a method, device, electronic device, and storage medium for closing a background process. The method includes: in response to a test start instruction for the electronic device, obtaining first process information of a first execution process that the electronic device runs before performing a device test, and generating a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information; creating a test process to perform the device test, and then in response to a test end instruction generated after obtaining that the electronic device has completed the device test, obtaining second process information of a second execution process that the electronic device runs when the device test is completed, and generating a second process file for characterizing the process state of the electronic device when the device test is completed according to the second process information; closing the test process involved in the process of the electronic device performing the device test according to the first process file and the second process file, which simplifies the operation of closing the test process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and particularly to a method for closing background processes, a device for closing background processes, an electronic device, and a computer-readable storage medium. Background Art

[0002] In the testing and maintenance work of an electronic device running a system, testers often need to terminate the operation of test programs running in the background during or after a test. When the executed test tasks involve a large number of test scripts or a single test script execution calls many execution programs to complete the test task, the number of test programs to be terminated is large, resulting in a cumbersome termination process for the test programs and reducing the test efficiency. Summary of the Invention

[0003] Embodiments of the present invention provide a method, a device, an electronic device, and a computer-readable storage medium for closing background processes, so as to solve or partially solve the problems in the related art that the closing process is cumbersome due to a large number of test programs when closing test programs running in the background and it is easy to miss some test processes.

[0004] Embodiments of the present invention disclose a method for closing background processes, which is applied to an electronic device running a corresponding Linux system. The method includes:

[0005] In response to a test start instruction for the electronic device, obtaining first process information of a first execution process that the electronic device runs before performing device testing, and generating a first process file for characterizing the process state of the electronic device before performing device testing according to the first process information;

[0006] Creating a test process corresponding to the test start instruction, and executing a test task corresponding to the device testing through the test process;

[0007] In response to obtaining a test end instruction generated after the electronic device completes the device testing, obtaining second process information of a second execution process that the electronic device runs when completing the device testing, and generating a second process file for characterizing the process state of the electronic device when completing the device testing according to the second process information;

[0008] Closing the test processes involved in the process of the electronic device performing the device testing according to the first process file and the second process file.

[0009] Optionally, the first process file includes a first process identifier of the first execution process, the second process file includes a second process identifier of the second execution process, and closing the test processes involved in performing the device test on the electronic device according to the first process file and the second process file includes:

[0010] Comparing the first process identifier with the second process identifier, and closing the test processes involved in performing the device test on the electronic device according to the comparison result.

[0011] Optionally, comparing the first process identifier with the second process identifier includes:

[0012] Comparing the first process identifier in the first process file with the second process identifier in the second process file, and storing the second process identifier that does not exist in the first process file, and / or, the first process identifier in the second process file that does not exist in the second process file, into a preset process closing file.

[0013] Optionally, the process closing file includes a target process identifier corresponding to the process to be closed, and closing the test processes involved in performing the device test on the electronic device according to the comparison result includes:

[0014] Selecting the test process corresponding to the target process identifier from the second execution process, and closing the test process.

[0015] Optionally, in response to a test start instruction for an electronic device, obtaining first process information of a first execution process that the electronic device runs before performing the device test, and generating a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information includes:

[0016] Obtaining a test execution script;

[0017] In response to a test start instruction for the test execution script, executing the test execution script to obtain first process information of a first execution process that the electronic device runs before performing the device test, generating a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information, and saving the first process file to the folder where the test execution script is located.

[0018] Optionally, in response to obtaining the test end instruction generated after the electronic device completes the device test, obtain the second process information of the second execution process that the electronic device runs when completing the device test, and generate a second process file for characterizing the process state of the electronic device when completing the device test, including:

[0019] In response to obtaining the test end instruction generated after the electronic device completes the device test, execute the test execution script to obtain the second process information of the second execution process that the electronic device runs when completing the device test, generate a second process file for characterizing the process state of the electronic device when completing the device test according to the second process information, and save the second process file to the folder where the test execution script belongs.

[0020] Optionally, closing the test process involved in the device test execution of the electronic device according to the first process file and the second process file includes:

[0021] If it is detected that there are at least two process files in the folder where the test execution script belongs, close the test process involved in the device test execution of the electronic device according to the first process file and the second process file.

[0022] An embodiment of the present invention also discloses a device for closing background processes, which is applied to an electronic device, and the electronic device runs a corresponding Linux system. The device includes:

[0023] A first file generation module, configured to, in response to a test start instruction for an electronic device, obtain the first process information of the first execution process that the electronic device runs before executing the device test, and generate a first process file for characterizing the process state of the electronic device before executing the device test according to the first process information;

[0024] A test task execution module, configured to create a test process corresponding to the test start instruction, and execute a test task corresponding to the device test through the test process;

[0025] A second file generation module, configured to, in response to obtaining the test end instruction generated after the electronic device completes the device test, obtain the second process information of the second execution process that the electronic device runs when completing the device test, and generate a second process file for characterizing the process state of the electronic device when completing the device test according to the second process information;

[0026] A process closing module, configured to close the test processes involved in the device test process of the electronic device according to the first process file and the second process file.

[0027] Optionally, the first process file includes a first process identifier of the first execution process, the second process file includes a second process identifier of the second execution process, and the process closing module is specifically configured to:

[0028] Compare the first process identifier with the second process identifier, and close the test processes involved in the device test process of the electronic device according to the comparison result.

[0029] Optionally, the process closing module is specifically configured to:

[0030] Compare the first process identifier in the first process file with the second process identifier in the second process file, and store the second process identifier that does not exist in the first process file, and / or, the first process identifier in the second process file that does not exist in the second process file into a preset process closing file.

[0031] Optionally, the process closing file includes a target process identifier corresponding to the process to be closed, and the process closing module is specifically configured to:

[0032] Select the test process corresponding to the target process identifier from the second execution process, and close the test process.

[0033] Optionally, the first file generation module is specifically configured to:

[0034] Obtain a test execution script;

[0035] In response to a test start instruction for the test execution script, execute the test execution script to obtain first process information of a first execution process that the electronic device runs before performing the device test, generate a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information, and save the first process file to the folder where the test execution script is located.

[0036] Optionally, the second file generation module is specifically configured to:

[0037] In response to obtaining a test end instruction generated after the electronic device completes the device test, execute the test execution script to obtain second process information of a second execution process that the electronic device runs when completing the device test, generate a second process file for characterizing the process state of the electronic device when completing the device test according to the second process information, and save the second process file to the folder where the test execution script is located.

[0038] Optionally, the process closing module is specifically configured to:

[0039] If it is detected that there are at least two process files in the folder where the test execution script is located, close the test processes involved in the device test of the electronic device according to the first process file and the second process file.

[0040] An embodiment of the present invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0041] The memory is used to store a computer program;

[0042] When the processor is used to execute the program stored on the memory, it implements the method described in the embodiment of the present invention.

[0043] An embodiment of the present invention also discloses a computer-readable storage medium, on which instructions are stored. When executed by one or more processors, the instructions cause the processors to execute the method described in the embodiment of the present invention.

[0044] The embodiments of the present invention have the following advantages:

[0045] In an embodiment of the present invention, during the process of testing an electronic device, in response to a test start instruction for the electronic device, the first process information of the first execution process running before the electronic device executes the device test can be obtained, and a first process file for characterizing the process state of the electronic device before executing the device test can be generated according to the first process information. At the same time, a test process corresponding to the test start instruction can be created, and a test task corresponding to the device test can be executed through the test process. Then, after the electronic device test is completed, in response to obtaining a test end instruction generated after the electronic device completes the device test, the second process information of the second execution process running when the electronic device completes the device test can be obtained, and a second process file for characterizing the process state of the electronic device when completing the device test can be generated according to the second process information. Then, the test process involved in the process of the electronic device executing the device test can be closed according to the first process file and the second process file. Thus, during the process of testing the electronic device, by obtaining the execution process on the electronic device once before the test and then obtaining the execution process of the electronic device again after the test is completed, and then closing the test process involved in the test process based on the obtained process information, the rapid closing of the test process is realized, the operation of closing the test process in the test is simplified, the test time is saved, and the test efficiency is improved. At the same time, the full-scale closing of the test process can be realized based on the comparison of the process information during the closing process, which can effectively release the device performance and improve the device operation stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 is a flowchart of the steps of a method for closing a background process provided in an embodiment of the present invention;

[0047] Figure 2 is a schematic diagram of the process of closing a process provided in an embodiment of the present invention;

[0048] Figure 3 is a block diagram of a structure of a device for closing a background process provided in an embodiment of the present invention;

[0049] Figure 4 is a block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0050] In order to make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0051] As an example, the electronic device can be a server, and a corresponding Linux system can run on the server. During the testing and maintenance work under the server Linux system, testers often need to terminate the running of background test programs during or after the test. When the executed test tasks involve a large number of test scripts or a single test script execution calls many execution programs to complete the test tasks, the number of test programs to be terminated is large, resulting in a cumbersome termination process of the test programs and reducing the test efficiency.

[0052] In this regard, one of the core inventive points of the present invention is that during the process of testing an electronic device, in response to a test start instruction for the electronic device, the first process information of the first execution process running before the electronic device executes the device test can be obtained, and a first process file for characterizing the process state of the electronic device before executing the device test can be generated according to the first process information. At the same time, a test process corresponding to the test start instruction can be created, and the test task corresponding to the device test can be executed through the test process. Then, after the electronic device test is completed, in response to obtaining a test end instruction generated after the electronic device completes the device test, the second process information of the second execution process running when the electronic device completes the device test can be obtained, and a second process file for characterizing the process state of the electronic device when completing the device test can be generated according to the second process information. Then, the test processes involved in the process of the electronic device executing the device test can be closed according to the first process file and the second process file. Thus, during the process of testing the electronic device, by obtaining the execution process on the electronic device once before the test and then obtaining the execution process of the electronic device again after the test is completed, and then closing the test processes involved in the test process based on the obtained process information, the rapid closing of the test processes is realized, the operation of closing the test processes in the test is simplified, the test time is saved and the test efficiency is improved. At the same time, the full-scale closing of the test processes can be realized based on the comparison of the process information during the closing process, which can effectively release the device performance and improve the device operation stability.

[0053] Specifically, referring to Figure 1 , a step flowchart of a method for closing a background process provided in an embodiment of the present invention is shown, which may specifically include the following steps:

[0054] Step 101, in response to a test start instruction for the electronic device, obtain the first process information of the first execution process running before the electronic device executes the device test, and generate a first process file for characterizing the process state of the electronic device before executing the device test according to the first process information;

[0055] Optionally, for an electronic device, which can be a server, and a corresponding operating system, such as the Linux system, can run on the server. During the process of testing relevant content (such as hardware performance) of the server under the Linux system, it is often necessary to execute corresponding test tasks through corresponding execution processes. After the test is completed, the processes involved in the test process need to be closed to release the running performance of the server. It should be noted that in the embodiments of the present invention, the server is taken as an example for illustrative purposes. It can be understood that the electronic device can also be other devices, and the present invention does not limit this.

[0056] In the embodiments of the present invention, the electronic device can respond to a test start instruction for the electronic device, obtain first process information of a first execution process that the electronic device runs before performing a device test, and generate a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information. It should be noted that for the execution process, it can include a conventional process involved in the process of the electronic device running an application program and a test process involved in the process of performing a performance test on the electronic device. The process that needs to be closed in the embodiments of the present invention can be the test process involved in the performance test process.

[0057] Among them, the test start instruction can be an instruction for starting a performance test on the electronic device and obtaining the process information involved in the execution process currently running on the electronic device before performing the performance test task; for the process information, it can be the process identifier (such as the process number, etc.) corresponding to the execution process run by the electronic device. Then, the electronic device can generate a corresponding first process file based on the obtained process identifier corresponding to the execution process for characterizing the process state of the electronic device before performing the device test. For example, before the electronic device performs the device test, the execution processes it runs include Process ①, Process ②, Process ③, Process ④, and Process ⑤. Then, by obtaining the process numbers corresponding to each execution process, a corresponding process file can be generated, as shown in Table 1 below:

[0058] Execution process Process identifier Process ① A Process ② B Process ③ C Process ④ D Process ⑤ E

[0059] Table 1

[0060] In an alternative embodiment, a tester can write a test execution script for automatically closing processes using the Shell language and run the test execution script on a Linux system. During the testing of the electronic device, the test execution script can be obtained, and then in response to a test start instruction for the test execution script, the test execution script can be executed to obtain the first process information of the first execution process that the electronic device runs before performing the device test. Based on the first process information, a first process file for characterizing the process state of the electronic device before performing the device test can be generated, and the first process file can be saved to the folder where the test execution script is located. Thus, the test execution script can be used to obtain the process information before testing the electronic device, generate the corresponding process file, and then store the process file in the folder where the test execution script is stored, establishing a mapping relationship between the test execution script and the process file, which is convenient for closing the test processes involved in the subsequent testing process.

[0061] Step 102: Create a test process corresponding to the test start instruction, and execute a test task corresponding to the device test through the test process;

[0062] In a specific implementation, different test tasks can correspond to different test processes. Then the electronic device can parse the test start instruction to obtain the corresponding test task and at least one process identifier corresponding to the test task, and then create a corresponding test process based on the process identifier, and then execute the corresponding test task according to the created test process, such as performing performance testing, stability testing, stress testing, etc. on the hard disk of the electronic device. The present invention does not limit this.

[0063] Step 103: In response to obtaining a test end instruction generated after the electronic device completes the device test, obtain the second process information of the second execution process that the electronic device runs when it completes the device test, and generate a second process file for characterizing the process state of the electronic device when it completes the device test according to the second process information;

[0064] When starting the performance test of an electronic device, based on the test task, the electronic device can create a corresponding test process and execute the corresponding performance test content based on the test process. After the test task is completed, the electronic device can respond to the test end instruction generated after the electronic device completes the device test, obtain the second process information of the second execution process running when the electronic device completes the device test, and generate a second process file for characterizing the process state of the electronic device when the device test is completed according to the second process information. Among them, the test end instruction can be an instruction automatically generated by the electronic device by detecting the task state of the test task and detecting that the test task is completed, or an instruction manually input by the tester after the test task is completed. The present invention does not limit this.

[0065] In a specific implementation, after the test of the electronic device is completed, the electronic device can respond to the test end instruction generated after the electronic device completes the device test, execute a test execution script to obtain the second process information of the second execution process running when the electronic device completes the device test, generate a second process file for characterizing the process state of the electronic device when the device test is completed according to the second process information, and save the second process file to the folder where the test execution script belongs. For example, after the electronic device completes the test task, the running execution processes include process ①, process ②, process ③, process ④, process ⑤, process ⑥, process ⑦, and process ⑧, etc. Then, the corresponding process files can be generated by obtaining the process numbers corresponding to each execution process, as shown in Table 2 below:

[0066] Execution process Process identifier Process ① A Process ③ C Process ④ D Process ⑤ E Process ⑥ F Process ⑦ G Process ⑧ H

[0067] Table 2

[0068] Step 104, close the test processes involved in the device test process of the electronic device according to the first process file and the second process file.

[0069] For a first process file that characterizes the process state of an electronic device before performing a device test, and a second process file that characterizes the process state of the electronic device when the device test is completed, the electronic device can close the test processes involved in the device test execution of the electronic device according to the first process file and the second process file. Thus, during the process of testing the electronic device, by obtaining the execution processes on the electronic device once before the test and then obtaining the execution processes on the electronic device again after the test is completed, and then closing the test processes involved in the test process based on the obtained process information, the rapid closing of the test processes is achieved, the operation of closing the test processes during the test is simplified, the test time is saved, and the test efficiency is improved. At the same time, the full-scale closing of the test processes can be realized based on the comparison of the process information during the closing process, which can effectively release the device performance and improve the device operation stability.

[0070] In a specific implementation, the first process file includes the first process identifier of the first execution process, and the second process file includes the second process identifier of the second execution process. Then, after the electronic device completes the test task, it can compare the first process identifier with the second process identifier and close the test processes involved in the device test execution of the electronic device according to the comparison result. Specifically, the first process identifier in the first process file can be compared with the second process identifier in the second process file, and the second process identifier that does not exist in the first process file, and / or, the first process identifier in the second process file that does not exist in the second process file can be stored in a preset process closing file. Among them, if the process closing file includes the target process identifier corresponding to the process to be closed, the test process corresponding to the target process identifier can be selected from the second execution process and the test process can be closed.

[0071] For example, as shown in Table 1 and Table 2 above, the process identifiers included in the first process file and the second process file can be compared to obtain process identifiers such as B, F, G, and H. Then, these process identifiers can be used as the target process identifiers of the processes to be closed. Among them, process ② corresponding to process identifier B has already been closed. Then, based on process identifiers F, G, and H, the test processes corresponding to process identifiers F, G, and H can be screened out from the execution processes currently running on the electronic device, including process ⑥, process ⑦, and process ⑧. Then, process ⑥, process ⑦, and process ⑧ are closed. Thus, during the process of testing the electronic device, by obtaining the execution processes on the electronic device once before the test and then obtaining the execution processes on the electronic device again after the test is completed, and then closing the test processes involved in the test process based on the obtained process information, the rapid closing of the test processes is achieved, the operation of closing the test processes in the test is simplified, the test time is saved, and the test efficiency is improved. At the same time, the full-scale closing of the test processes can be realized based on the comparison of the process information during the closing process, which can effectively release the device performance and improve the device operation stability.

[0072] In addition, before executing the closing of the test process, the electronic device can first detect the process file. If it is detected that there are at least two process files in the folder where the test execution script is located, the test processes involved in the device test process of the electronic device are closed according to the first process file and the second process file.

[0073] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It can be understood that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention. The present invention does not limit this.

[0074] In an embodiment of the present invention, during the process of testing an electronic device, in response to a test start instruction for the electronic device, the first process information of the first execution process that the electronic device runs before performing the device test can be obtained, and a first process file for characterizing the process state of the electronic device before performing the device test can be generated according to the first process information. At the same time, a test process corresponding to the test start instruction can be created, and a test task corresponding to the device test can be executed through the test process. Then, after the electronic device test ends, in response to obtaining a test end instruction generated after the electronic device completes the device test, the second process information of the second execution process that the electronic device runs when it completes the device test can be obtained, and a second process file for characterizing the process state of the electronic device when it completes the device test can be generated according to the second process information. Then, the test process involved in the process of performing the device test on the electronic device can be closed according to the first process file and the second process file. Thus, during the process of testing the electronic device, by obtaining the execution process on the electronic device once before the test and then obtaining the execution process of the electronic device again after the test is completed, and then closing the test process involved in the test process based on the obtained process information, the rapid closing of the test process is realized, the operation of closing the test process in the test is simplified, the test time is saved, and the test efficiency is improved. At the same time, the full-scale closing of the test process can be realized based on the comparison of the process information during the closing process, which can effectively release the device performance and improve the device operation stability.

[0075] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, an exemplary illustration is provided below through an example:

[0076] The tester can write an automatic process closing tool using the shell language for use in the Linux system. First, initially collect all the process information running before the test, filter out the irrelevant information in the process information, extract the process numbers to generate a document, and save it as pid1.log; then, after the test ends, collect all the process information again, filter the process information captured this time again, extract the process numbers to generate a document, and save it as pid2.log; compare the generated pid1.log and pid2.log files, and then save the different parts of the content after the comparison to the differ.log file; finally, execute the kill operation one by one on the process numbers saved in the differ.log, that is, complete the process killing operation; back up the pid*.log documents in the current file to a newly created old folder (if any, there is no need to create a new one), and clear the pid*.log documents for future use. Thus, the automated closing of the execution test program runs to completion. Specifically, referring to Figure 2 , which shows the schematic flow diagram of process closing provided in the embodiment of the present invention, including:

[0077] 1. Before test execution, execute this script first. It can automatically obtain the process IDs of all running programs on the server before the test and save all the process IDs as pid1.log in the folder where the script is located.

[0078] The relevant command for this step in the script: ps - ef | awk '{print $2}' >> pid*.log; where $2 is the serial number of the column where the process ID is located in the process information obtained by the command in ps - ef.

[0079] 2. After the script finishes the first step, it will check the documents pid*.log (for example, pid1.log for the first time and pid2.log for the second time) in the file to determine if there are two (for example, pid1.log and pid2.log). If there are not two, it will end; if there are two, it will execute the remaining steps of the script.

[0080] The relevant command for this step in the script: ls - l | grep 'pid*' | wc - l; This command can check the number of generated pid.log files for subsequent comparison and judgment.

[0081] 3. After the test task is completed, execute this script again. It can automatically obtain the process IDs of all running programs on the server before the test and save all the process IDs as pid2.log in the folder where the script is located. (The command in step 2 has been described)

[0082] 4. After the script finishes the previous step, it will check the pid*.log document in the file to determine if there are two (for example, pid1.log and pid2.log). If there are not two, it will end; if there are two, it will execute the remaining steps of the script. (The command in step 3 has been described)

[0083] 5. Compare the contents of different process IDs in pid1.log and pid2.log and save the different process IDs as the differ.log document. The relevant command for this step in the script: diff pid1.log pid2.log >> differ.log

[0084] 6. Use the process IDs in the differ.log document as variables and perform the operation of killing processes one by one for each process ID. After all are executed, the test processes are killed.

[0085] The command for this step in the script: Use a loop function to extract the process IDs one by one from the differ.log document, set the variable as $pid, and execute kill - 9 $pid to close all the newly added process IDs during the test.

[0086] 7. Back up the pid*.log files in the current folder to a newly created old folder, and then delete the pid*.log files in the current folder to prepare for the next automated shutdown program test.

[0087] The command for this step of the script: Create the old folder in the current document using "mkdir old", and move the pid*.log files generated after the test ends to the old folder using "mv pid*.log old / " for use in the next script.

[0088] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the described action sequences, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.

[0089] Refer to Figure 3 , which shows a structural block diagram of a background process shutdown device provided in an embodiment of the present invention, applied to an electronic device that runs a corresponding Linux system. Specifically, it may include the following modules:

[0090] The first file generation module 301 is configured to, in response to a test start instruction for the electronic device, obtain first process information of a first execution process that the electronic device runs before performing a device test, and generate a first process file for characterizing the process state of the electronic device before performing the device test based on the first process information;

[0091] The test task execution module 302 is configured to create a test process corresponding to the test start instruction, and execute a test task corresponding to the device test through the test process;

[0092] The second file generation module 303 is configured to, in response to obtaining a test end instruction generated after the electronic device completes the device test, obtain second process information of a second execution process that the electronic device runs when completing the device test, and generate a second process file for characterizing the process state of the electronic device when completing the device test based on the second process information;

[0093] The process shutdown module 304 is configured to shut down the test process involved in the device test execution process of the electronic device based on the first process file and the second process file.

[0094] In an alternative embodiment, the first process file includes a first process identifier of the first execution process, the second process file includes a second process identifier of the second execution process, and the process closing module 304 is specifically configured to:

[0095] Compare the first process identifier with the second process identifier, and close the test processes involved in the device testing of the electronic device according to the comparison result.

[0096] In an alternative embodiment, the process closing module 304 is specifically configured to:

[0097] Compare the first process identifier in the first process file with the second process identifier in the second process file, and store the second process identifier that does not exist in the first process file, and / or, the first process identifier in the second process file that does not exist in the second process file, in a preset process closing file.

[0098] In an alternative embodiment, the process closing file includes a target process identifier corresponding to the process to be closed, and the process closing module 304 is specifically configured to:

[0099] Select the test process corresponding to the target process identifier from the second execution process, and close the test process.

[0100] In an alternative embodiment, the first file generation module 301 is specifically configured to:

[0101] Obtain a test execution script;

[0102] In response to a test start instruction for the test execution script, execute the test execution script to obtain first process information of a first execution process that the electronic device runs before performing device testing, generate a first process file for characterizing the process state of the electronic device before performing device testing according to the first process information, and save the first process file to the folder where the test execution script is located.

[0103] In an alternative embodiment, the second file generation module 303 is specifically configured to:

[0104] In response to obtaining a test end instruction generated after the electronic device completes the device testing, execute the test execution script to obtain second process information of a second execution process that the electronic device runs when the electronic device completes the device testing, generate a second process file for characterizing the process state of the electronic device when the electronic device completes the device testing according to the second process information, and save the second process file to the folder where the test execution script is located.

[0105] In an alternative embodiment, the process closing module 304 is specifically configured to:

[0106] If it is detected that there are at least two process files in the folder to which the test execution script belongs, the test processes involved in performing the device test on the electronic device are closed according to the first process file and the second process file.

[0107] For the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiment.

[0108] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, it implements each process of the method embodiment for closing the background process as described above, and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0109] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements each process of the method embodiment for closing the background process as described above, and can achieve the same technical effect. To avoid repetition, it will not be elaborated here. Among them, the computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.

[0110] Figure 4 A schematic diagram of the hardware structure of an electronic device for implementing each embodiment of the present invention.

[0111] The electronic device 400 includes but is not limited to: a radio frequency unit 401, a network module 402, an audio output unit 403, an input unit 404, a sensor 405, a display unit 406, a user input unit 407, an interface unit 408, a memory 409, a processor 410, and a power supply 411, etc. Those skilled in the art can understand that the structure of the electronic device involved in the embodiments of the present invention does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a notebook computer, a handheld computer, a vehicle-mounted terminal, a wearable device, and a pedometer, etc.

[0112] It should be understood that in the embodiments of the present invention, the radio frequency unit 401 can be used for receiving and sending signals during information reception and transmission or call processes. Specifically, after receiving the downlink data from the base station, it is given to the processor 410 for processing; in addition, the uplink data is sent to the base station. Generally, the radio frequency unit 401 includes, but is not limited to, antennas, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, etc. In addition, the radio frequency unit 401 can also communicate with the network and other devices through a wireless communication system.

[0113] The network module 402 provides the user of the electronic device with wireless broadband Internet access, such as helping the user to send and receive emails, browse web pages, and access streaming media, etc.

[0114] The audio output unit 403 can convert the audio data received by the radio frequency unit 401 or the network module 402 or stored in the memory 409 into an audio signal and output it as sound. Moreover, the audio output unit 403 can also provide an audio output related to the specific functions executed by the electronic device 400 (for example, call signal reception sound, message reception sound, etc.). The audio output unit 403 includes a speaker, a buzzer, a receiver, etc.

[0115] The input unit 404 is used for receiving audio or video signals. The input unit 404 can include a graphics processing unit (GPU) 4041 and a microphone 4042. The graphics processing unit 4041 processes the image data of the static pictures or videos obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The processed image frames can be displayed on the display unit 406. The processed image frames can be stored in the memory 409 (or other storage media) or sent via the radio frequency unit 401 or the network module 402. The microphone 4042 can receive sounds and can process such sounds into audio data. The processed audio data can be output in a format that can be sent to the mobile communication base station via the radio frequency unit 401 in the case of a phone call mode.

[0116] The electronic device 400 further includes at least one sensor 405, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor. Among them, the ambient light sensor can adjust the brightness of the display panel 4061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 4061 and / or the backlight when the electronic device 400 is moved to the ear. As a kind of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary, and can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 405 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be elaborated here.

[0117] The display unit 406 is used to display information input by the user or information provided to the user. The display unit 406 may include a display panel 4061, and the display panel 4061 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.

[0118] The user input unit 407 can be used to receive input digital or character information, and generate key signal inputs related to the user settings and function controls of the electronic device. Specifically, the user input unit 407 includes a touch panel 4071 and other input devices 4072. The touch panel 4071, also known as a touch screen, can collect touch operations of the user on or near it (such as operations of the user using a finger, a stylus, or any suitable object or accessory on or near the touch panel 4071). The touch panel 4071 can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user and detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 410, and receives and executes the command sent by the processor 410. In addition, the touch panel 4071 can be implemented in multiple types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 4071, the user input unit 407 may further include other input devices 4072. Specifically, the other input devices 4072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, a joystick, which will not be elaborated here.

[0119] Further, the touch panel 4071 can cover the display panel 4061. After the touch panel 4071 detects a touch operation on or near it, it transmits the information to the processor 410 to determine the type of touch event. Subsequently, the processor 410 provides a corresponding visual output on the display panel 4061 according to the type of touch event. It can be understood that, in one embodiment, the touch panel 4071 and the display panel 4061 are implemented as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 4071 and the display panel 4061 can be integrated to realize the input and output functions of the electronic device, and the specific implementation here is not limited.

[0120] The interface unit 408 is an interface for connecting an external device to the electronic device 400. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headset port, and so on. The interface unit 408 can be used to receive inputs from external devices (such as data information, power, etc.) and transmit the received inputs to one or more components within the electronic device 400 or can be used to transfer data between the electronic device 400 and external devices.

[0121] The memory 409 can be used to store software programs and various data. The memory 409 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, phone book, etc.). In addition, the memory 409 can include a high-speed random access memory and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices.

[0122] The processor 410 is the control center of the electronic device, connecting various parts of the entire electronic device using various interfaces and lines. By running or executing software programs and / or modules stored in the memory 409, and by calling the data stored in the memory 409, it executes various functions of the electronic device and processes data, thereby providing overall monitoring of the electronic device. The processor 410 can include one or more processing units; preferably, the processor 410 can integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 410.

[0123] The electronic device 400 may further include a power source 411 (such as a battery) for powering each component. Preferably, the power source 411 may be logically connected to the processor 410 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system.

[0124] In addition, the electronic device 400 includes some functional modules not shown herein, which will not be elaborated further.

[0125] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device including a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including such element.

[0126] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in various embodiments of the present invention.

[0127] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit and scope protected by the claims of the present invention, and all of them belong to the protection scope of the present invention.

[0128] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in connection with the embodiments disclosed in the present invention can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0129] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0130] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings, direct couplings, or communication connections shown or discussed among each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0131] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0132] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.

[0133] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical discs that can store program codes.

[0134] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention and should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A method for closing a background process, characterized in that, Applied to an electronic device that runs a corresponding Linux system, the method includes: In response to a test start instruction for the electronic device, obtain first process information of a first execution process that the electronic device runs before performing a device test, and generate a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information; Create a test process corresponding to the test start instruction, and execute a test task corresponding to the device test through the test process; In response to obtaining a test end instruction generated after the electronic device completes the device test, obtain second process information of a second execution process that the electronic device runs when completing the device test, and generate a second process file for characterizing the process state of the electronic device when completing the device test according to the second process information; Close the test process involved in the process of the electronic device performing the device test according to the first process file and the second process file.

2. The method according to claim 1, characterized in that The first process file includes a first process identifier of the first execution process, and the second process file includes a second process identifier of the second execution process. Closing the test process involved in the process of the electronic device performing the device test according to the first process file and the second process file includes: Compare the first process identifier with the second process identifier, and close the test process involved in the process of the electronic device performing the device test according to the comparison result.

3. The method according to claim 2, wherein The comparing the first process identifier with the second process identifier includes: Compare the first process identifier in the first process file with the second process identifier in the second process file, and store the second process identifier that does not exist in the first process file, and / or, the first process identifier in the second process file that does not exist in the second process file into a preset process closing file.

4. The method according to claim 3, characterized in that, The process closing file includes a target process identifier corresponding to the process to be closed. Closing the test process involved in the process of the electronic device performing the device test according to the comparison result includes: Select the test process corresponding to the target process identifier from the second execution process, and close the test process.

5. The method according to claim 1, wherein The obtaining first process information of a first execution process that the electronic device runs before performing a device test, and generating a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information in response to a test start instruction for the electronic device includes: Obtain a test execution script; In response to a test start instruction for the test execution script, execute the test execution script to obtain first process information of a first execution process that the electronic device runs before performing a device test, and generate a first process file for characterizing the process state of the electronic device before performing the device test according to the first process information, and save the first process file to the folder where the test execution script is located.

6. The method according to claim 5, wherein In response to obtaining a test end instruction generated after the electronic device completes the device test, obtaining second process information of a second execution process that the electronic device runs when completing the device test, and generating a second process file for characterizing the process state of the electronic device when completing the device test, including: In response to obtaining a test end instruction generated after the electronic device completes the device test, execute the test execution script to obtain second process information of a second execution process that the electronic device runs when completing the device test, generate a second process file for characterizing the process state of the electronic device when completing the device test according to the second process information, and save the second process file to the folder where the test execution script is located.

7. The method according to claim 5 or 6, characterized in that, Closing the test processes involved in the device test execution process of the electronic device according to the first process file and the second process file, including: If it is detected that there are at least two process files in the folder where the test execution script is located, close the test processes involved in the device test execution process of the electronic device according to the first process file and the second process file.

8. A device for closing a background process, characterized in that, Applied to an electronic device, the electronic device runs a corresponding Linux system, and the device includes: A first file generation module, configured to, in response to a test start instruction for the electronic device, obtain first process information of a first execution process that the electronic device runs before executing the device test, and generate a first process file for characterizing the process state of the electronic device before executing the device test according to the first process information; A test task execution module, configured to create a test process corresponding to the test start instruction, and execute a test task corresponding to the device test through the test process; A second file generation module, configured to, in response to obtaining a test end instruction generated after the electronic device completes the device test, obtain second process information of a second execution process that the electronic device runs when completing the device test, and generate a second process file for characterizing the process state of the electronic device when completing the device test according to the second process information; A process closing module, configured to close the test processes involved in the device test execution process of the electronic device according to the first process file and the second process file.

9. An electronic device, characterized in that, Including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used for storing a computer program; When the processor executes the program stored on the memory, the method according to any one of claims 1-7 is implemented.

10. A computer-readable storage medium, on which instructions are stored, and when executed by one or more processors, cause the processors to execute the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Application keep-alive capability test method and related device

    CN110688319A

  • Android application stability test method, device and equipment

    CN112100085A