Method and system for testing router
Technical Field
The present invention relates to the field of router technologies, and in particular, to a method and a system for testing a router.
Background
As routers become more popular, the functions of the routers become more powerful and more intelligent. At present, a router not only has routing and internet access functions of a traditional router, but also has more intelligent service functions, such as offline downloading, data sharing and the like. These functions are usually realized by external USB storage devices on the router, so that the general intelligent router has the external USB storage function.
The router development stage and the commissioning stage both test the functions of the router, some of the test problems occur in each starting process, and some of the probabilistic problems occur only by restarting the router for many times. For such a probabilistic problem, the router needs to be repeatedly restarted to reproduce the problem and analyze the problem.
Since many routers that are not rigorously tested may experience various unpredictable problems after reboot, it is necessary to rigorously test the routers to solve these problems.
The existing problem of testing the repeatability is often completed by matching a computer with a relay, the computer is connected with a router through a serial port and a network cable, the computer controls the router to be started through the relay and issues certain commands to test the router through the serial port, a test log is stored at a computer end through the serial port, and then data is processed at the computer end.
The patent with publication number CN104901848A discloses an automatic testing system and method for the startup and shutdown of a router, which includes setting a lower power-on time limit, an upper power-on time limit, cycle times, waiting time and interval time; after the router is controlled to be powered on circularly and repeatedly, the router is controlled to be powered on and lasts for a certain time; detecting whether a gateway of a router is smoothly connected; if not, judging that the test fails, if so, setting the power-on time as the sum of the current power-on time and the interval time when the current power-on time is less than the upper limit of the power-on time, and repeating the test step; and when the current power-on time is larger than the upper limit of the power-on time, judging that the test is successful. The system tested by the method has a complex structure and higher requirements for testers. Further, the problems of the present invention cannot be solved.
Generally, in the prior art, a method for testing a router is complex, a large number of test devices are involved, requirements for test personnel are high, and implementation is easily limited by test conditions.
Disclosure of Invention
The method is mainly used for testing the problems possibly generated in the process of restarting the router for multiple times. In view of the above-mentioned deficiencies of the prior art, a method and system for testing a router are provided.
The method for testing the router comprises the following steps:
s11, after the router is started, detecting whether the operation of the router has a problem or not;
s12, when detecting that the operation of the router has problems, storing the information containing the problems to a test U disk, and ending the test;
s13, when detecting that there is no problem in the operation of the router, detecting whether there is control information for restarting the router in the test U disk;
s14, when control information of restarting the router exists in the test U disk, judging whether the restarting frequency of the router exceeds the preset frequency;
s15, when the number of times of restarting the router does not exceed the preset number of times, restarting the router and returning to the step S11.
Further, before detecting whether the control information for restarting the router exists in the test U disk, the method further includes:
detecting whether a test script for testing the function of the router exists in the U disk;
if yes, executing the test script to test whether the function of the router runs normally;
and when the function of the router is abnormal, storing the information containing the abnormality to the test U disk, and terminating the test.
Further, the executing the test script to test whether the function of the router is operating normally includes:
and executing the test script to test whether the wireless connection function of the router operates normally.
Further, after determining whether the number of times of restarting the router exceeds a preset number of times, the method further includes:
and when the restarting times of the router exceed the preset times, terminating the test.
Further, after executing the test script to test whether the function of the router is operating normally, the method further includes:
and after the test script is executed, storing a test result to the test U disk.
In another aspect, the system for testing a router includes:
the system comprises a problem detection module, a problem detection module and a problem detection module, wherein the problem detection module is used for detecting whether the operation of the router has a problem or not after the router is started;
the first information storage module is used for storing information containing problems to a test U disk and ending the test when the router is detected to have problems in operation;
the control information detection module is used for detecting whether control information for restarting the router exists in the test U disk or not when the router is detected to run without problems;
the judging module is used for judging whether the restarting frequency of the router exceeds the preset frequency or not when the control information of the restarting router exists in the test U disk;
and the router restarting module is used for restarting the router and executing the problem detection module when the restarting times of the router do not exceed the preset times.
Further, the system for testing a router further includes:
the test script detection module is used for detecting whether a test script for testing the router function exists in the U disk;
the function testing module is used for executing the testing script when the testing script exists in the U disk so as to test whether the function of the router runs normally or not;
and the second information storage module is used for storing the information containing the abnormity to the test U disk and terminating the test when the function of the router is abnormal in operation.
Further, the functional test module comprises:
and the function test submodule is used for executing the test script so as to test whether the wireless connection function of the router runs normally.
Further, the system for testing a router further includes:
and the test termination module is used for terminating the test when the restart times of the router exceed the preset times.
Further, the system for testing a router further includes:
and the test result storage module is used for storing the test result to the test USB flash disk after the test script is executed.
The invention provides a method for testing a router through a USB flash disk, and the test system has a simple structure and is easy to implement.
In addition, the method of the invention can conveniently test a large number of routers and can realize batch test.
Drawings
Fig. 1 is a flowchart of a method for testing a router according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for testing a router according to a second embodiment of the present invention;
fig. 3 is a block diagram of a system for testing a router according to a third embodiment of the present invention.
Detailed Description
The following are specific embodiments of the present invention and are further described with reference to the drawings, but the present invention is not limited to these embodiments.
It should also be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention.
The system comprises a router to be tested and a USB flash disk to be tested, wherein the test system is positioned in the router, and the USB flash disk to be tested is used for storing test scripts and control information. And the router reads data from the test U disk to test the router.
The router to be tested is provided with a USB interface, and can read data in the USB flash disk through the USB interface.
Example one
The present embodiment provides a method for testing a router, a flowchart of which is shown in fig. 1, and the following is detailed with reference to the accompanying drawings:
step S101, after the router is started, whether the operation of the router has a problem is detected.
It should be noted that the router may have unpredictable problems after startup.
Further, the problems include software problems and hardware problems. The problem may cause the function of the router to be not realized or the router to be not operated normally.
And step S102', when the router is detected to have a problem in operation, storing the information containing the problem to a test U disk, and ending the test.
And when detecting that the router has a problem in operation, storing the information containing the problem to a test U disk, and ending the test.
The information should include as much information about the problem as possible so that the tester can learn more about the problem.
Step S102, when it is detected that no problem exists in the operation of the router, whether control information for restarting the router exists in the test U disk is detected.
The control information of the router to be tested is stored in the test U disk, and the router can read the control information in the test U disk and execute related operation according to the control information.
And when no problem in the operation of the router is detected, detecting whether control information for restarting the router is stored in the U disk.
Step S103, when control information for restarting the router exists in the test U disk, whether the restarting frequency of the router exceeds a preset frequency is judged.
Generally, in order to detect a problem occurring during a plurality of reboots of a router, the router needs to be rebooted a plurality of times to record whether the router under test has a problem.
Further, an upper limit of the number of restarts is set. And when the restarting times of the router reach the preset times, stopping testing.
The preset times can be stored in the test U disk, and the router under test can read the preset times of restart from the test U disk; e.g., 50, 100, etc
Furthermore, due to many unforeseen problems at ordinary times, it may occur after a number of restarts of the router. The present invention can be used to find such problems.
And step S104, when the times of restarting the router do not exceed the preset times, restarting the router, and returning to the step S101.
And when the restarting times of the router do not exceed the preset times, restarting the router, and returning to the step S101.
Through repeated reboots, to test for problems with the router.
The invention finds the problem by the repeated restart of the USB flash disk test router; the test structure is simple and easy to implement.
It should be understood that the steps described above are not in the exact order of execution and that all changes that can be envisioned and do not affect the implementation of the functions are intended to be within the scope of the invention.
Example two
The present embodiment provides a method for testing a router, a flowchart of which is shown in fig. 2, and the following is detailed with reference to the accompanying drawings:
step S201, after the router is started, detecting whether the operation of the router has a problem.
Step S202', when detecting that the operation of the router has a problem, storing the information containing the problem to a test U disk, and ending the test.
Step S202, detecting whether a test script for testing the router function exists in the U disk.
And when detecting that no problem exists in the operation of the router, detecting whether a test script for testing the function of the router exists in the test U disk.
Further, the test script may be used to test the functionality of the router.
Further, the functions include a wireless connection function. In addition, when the router is an intelligent router, the test script can be used for testing more functional modules; such as offline download, data sharing functions.
Step S203, when the test script exists in the U disk, executing the test script to test whether the function of the router runs normally.
The executing the test script comprises:
and reading the test script from the test U disk.
And executing the test script to test whether the function of the router runs normally.
The test script is used for testing the corresponding router function. After the router is restarted every time, the function of the router is tested to judge whether the function of the router operates normally.
Further, the test script is executed to test whether the wireless connection function of the router operates normally.
Further, after the test script is executed, a test result is saved to the test U disk.
And after each restart, storing a test result obtained by executing the test script to the USB flash disk. So that the tester can obtain the test result from the USB flash disk.
After the router is restarted each time, the router is tested to obtain a corresponding test result, so that whether each functional module is abnormal after the router is restarted each time is analyzed.
Step S204', when the function operation of the router is abnormal, the information containing the abnormality is stored to the test U disk, and the test is terminated.
And when the function of the router is abnormal, storing the information corresponding to the abnormality to the U disk, and terminating the test.
The tester can analyze the anomalies by the information containing the anomalies to obtain valuable analysis results.
Step S204, when detecting that no problem exists in the operation of the router, detecting whether control information for restarting the router exists in the test U disk;
step S205, when control information for restarting the router exists in the test U disk, judging whether the restarting frequency of the router exceeds a preset frequency;
step S206, when the number of times of restarting the router does not exceed the preset number of times, restarting the router, and returning to step S201.
Further, after determining whether the number of times of restarting the router exceeds a preset number of times, the method further includes:
and when the restarting times of the router exceed the preset times, terminating the test.
It should be understood that the steps described above are not in the exact order of execution and that all changes that can be envisioned and do not affect the implementation of the functions are intended to be within the scope of the invention.
EXAMPLE III
The present embodiment provides a system for testing a router, a block diagram of which is shown in fig. 3, and the following details are provided in conjunction with the accompanying drawings:
the system for testing the router comprises:
the problem detection module 310 is configured to detect whether a problem exists in operation of a router after the router is started;
a first information storage module 350, configured to, when it is detected that there is a problem in operation of the router, store information including the problem to a test usb disk, and end the test;
a control information detection module 320, configured to detect whether there is control information for restarting the router in the test U disk when it is detected that there is no problem with operation of the router;
a judging module 330, configured to, when there is control information for restarting a router in the test usb disk, judge whether a number of times that the router is restarted exceeds a preset number of times;
the router restarting module 340 is configured to restart the router and execute the problem detecting module when the number of times of restarting the router does not exceed a preset number of times.
Further, the system for testing a router further includes:
the test script detection module is used for detecting whether a test script for testing the router function exists in the U disk;
the function testing module is used for executing the testing script when the testing script exists in the U disk so as to test whether the function of the router runs normally or not;
and the second information storage module is used for storing the information containing the abnormity to the test U disk and terminating the test when the function of the router is abnormal in operation.
Further, the functional test module comprises:
and the function test submodule is used for executing the test script so as to test whether the wireless connection function of the router runs normally.
Further, the system for testing a router further includes:
and the test termination module is used for terminating the test when the restart times of the router exceed the preset times.
Further, the system for testing a router further includes:
and the test result storage module is used for storing the test result to the test USB flash disk after the test script is executed.
Since the system for testing a router provided in this embodiment is applied to the methods provided in the first and second embodiments, the relevant contents have been already detailed in the embodiments of the methods, and are not repeated here, refer to the foregoing embodiments of the methods.
In the embodiments provided in this application, it should be understood that the methods and systems described are illustrative and that variations may be made in the actual implementation by adaptation.
In addition, specific names of the functional units or modules are only used for distinguishing one functional unit from another, and are not used for the protection scope of the present invention.
The specific embodiments described herein are merely illustrative of the spirit of the invention. Various modifications or additions may be made to the described embodiments or alternatives may be employed by those skilled in the art without departing from the spirit or ambit of the invention as defined in the appended claims.