Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of test macro and method of router, for solving problem of carrying out router test that cannot continue in prior art, that automatically repeat break-make power supply.
For achieving the above object and other relevant objects, the invention provides a kind of test macro of router, comprising: the controlled switch unit be connected with the power supply of router; The control unit be connected with described controlled switch unit, for according to preset rule to the instruction of described controlled switch unit transmit button so that described controlled switch unit carries out make-break operation based on described switch command to the power supply of described router; The test cell be connected with described controlled switch unit, for when the power supply of described router is energized, tests described router.
Preferably, described preset rules comprise following in any one: fixing power on/off periods rules, random power on/off periods rules, in the time zone internal fixtion of setting or the rule in random power on/off cycle.
Preferably, described test cell is used for, when the power supply energising of described router, carrying out the test relevant to power down to described router.
Preferably, the described test relevant to power down comprises following at least one: configuration loss, mirror image damage.
Preferably, described controlled switch unit comprises: relay.
Based on above-mentioned purpose, the present invention also provides a kind of method of testing of router, comprise: according to the rule preset to the controlled switch unit transmit button instruction be connected with router, so that described controlled switch unit carries out make-break operation based on described switch command to the power supply of described router; When the power supply energising of described router, described router is tested.
Preferably, described preset rules comprise following in any one: fixing power on/off periods rules, random power on/off periods rules, in the time zone internal fixtion of setting or the rule in random power on/off cycle.
Preferably, during the described energising of the power supply at described router, the mode that described router is tested is comprised: when the power supply energising of described router, the test relevant to power down is carried out to described router.
Preferably, the described test relevant to power down comprises following at least one: configuration loss, mirror image damage.
As mentioned above, the test macro of router of the present invention and method, there is following beneficial effect: by arranging controlled switch unit at the power end of router and setup control is regular, described test macro can without the need to testing of manually participating in automatically, achieve unattended operation, automatic adjustment power-on time, improves the operational efficiency of test macro; In addition, described test macro can be tested according to various control law, effectively ensures during unattended operation, test comprehensive.
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this specification can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this specification also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.It should be noted that, when not conflicting, the feature in following examples and embodiment can combine mutually.
It should be noted that, the diagram provided in following examples only illustrates basic conception of the present invention in a schematic way, then only the assembly relevant with the present invention is shown in graphic but not component count, shape and size when implementing according to reality is drawn, it is actual when implementing, and the kenel of each assembly, quantity and ratio can be a kind of change arbitrarily, and its assembly layout kenel also may be more complicated.
Refer to Fig. 1, the invention provides a kind of test macro of router.Described test macro 1 comprises: controlled switch unit 11, control unit 12 and test cell 13.
Described controlled switch unit 11 is connected with the power supply of router two to be tested.
Particularly, between described controlled switch unit 11 power interface that can be connected to described router two and electric power system.Such as, described controlled switch is connected between the supply socket of described router two and a wiring board.Described wiring board is connected with civil power.At this, described controlled switch unit 11 comprises: relay and the peripheral circuit for voltage stabilizing.
Described control unit 12 is connected with described controlled switch unit 11, for according to preset rule to the instruction of described controlled switch unit 11 transmit button so that described controlled switch unit 11 carries out make-break operation based on described switch command to the power supply of described router two.
Particularly, technical staff arranges the rule for controlling described controlled switch unit 11 break-make power supply to described control unit 12 in advance by interface or by external equipment in advance, then described control unit 12 based on set rule to the instruction of described controlled switch unit 11 transmit button.Then described controlled switch unit 11 carries out power on/off operation based on described switch command to described router two.Wherein, described rule includes but not limited to: fix power on/off periods rules, at random power on/off periods rules, in the time zone internal fixtion set or the rule in random power on/off cycle.
Such as, technical staff is arranged by interface and made described controlled switch unit 11 be energized once every 3 seconds, and the duration of each energising was 30 seconds.Then described control unit 12 is from described rule settings completes, electrical instruction is sent every 3 seconds to described controlled switch unit 11 according to system clock, then described controlled switch unit 11 performs power-on servicing based on described electrical instruction, when 30 second of energising, described control unit 12 sends cut-offing instruction, then described controlled switch unit 11 performs power operation based on described cut-offing instruction.Repetition like this.
And for example, described technical staff is arranged by interface and adopts the instruction of stochastic model transmit button from 6 pm to the next morning 9, then described control unit 12 is in the afternoon in 6 to the next morning time zone of 9, sends electrical instruction or cut-offing instruction at random.So, described test macro 1 can After Hours proceed test employee, effectively to utilize unattended time zone, completes dependence test.
Preferably, in order to prevent each random number produced from repeating, described control unit 12 adopts different seeds to produce random number.Such as, described control unit 12 produces different seed by performing srand ((int) time (NULL)) statement.
Then, described test cell 13 is connected with described controlled switch unit 11, for when the power supply of described router two is energized, tests described router two.
Particularly, described test cell 13 is by monitoring the power on/off situation of described controlled switch unit 11 or identifying power on/off situation by receiving described switch command, when determining the power supply energising of described router two, according to the testing process preset, described router two is tested.Wherein, described test can be electric test, conventionally test, high/low temperature test etc.
Preferably, the opening and closing for described controlled switch unit 11 is frequent, and described test cell 13, for when the power supply of described router two is energized, carries out the test relevant to power down to described router two.Wherein, the described test relevant to power down includes but not limited to following at least one: configuration loss, mirror image damage.
According to Fig. 1, the course of work of described test macro 1 is exemplified below:
Technical staff by interface input in the afternoon 6 adopt fixing power on/off periods rules to the next morning 9, and setting made described controlled switch unit 11 be energized once every 3 seconds, and the duration of each energising was 30 seconds.Then described control unit 12 sends electrical instruction or cut-offing instruction based on above-mentioned rule to described controlled switch unit 11, described controlled switch unit 11 makes described router two power on/off based on electrical instruction or cut-offing instruction, meanwhile, the test cell 13 be connected with described controlled switch unit 11 sends ping when it is energized to described router two and sets IP instruction, to test the preservation situation of the configuration of described router two.
Refer to Fig. 2, the invention provides a kind of method of testing of router.Described method of testing performs primarily of test macro.Wherein, described test macro comprises: controlled switch unit, control unit and test cell.Described method of testing comprises step S1 and S2.
Described controlled switch unit is connected with the power supply of router to be tested.
Particularly, between the described controlled switch unit power interface that can be connected to described router and electric power system.Such as, described controlled switch is connected between the supply socket of described router and a wiring board.Described wiring board is connected with civil power.At this, described controlled switch unit comprises: relay and the peripheral circuit for voltage stabilizing.
In step sl, described control unit according to preset rule to the instruction of described controlled switch unit transmit button so that described controlled switch unit carries out make-break operation based on described switch command to the power supply of described router.
Particularly, technical staff arranges the rule for controlling described controlled switch unit break-make power supply to described control unit in advance by interface or by external equipment in advance, then described control unit based on set rule to the instruction of described controlled switch unit transmit button.Then described controlled switch unit carries out power on/off operation based on described switch command to described router.Wherein, described rule includes but not limited to: fix power on/off periods rules, at random power on/off periods rules, in the time zone internal fixtion set or the rule in random power on/off cycle.
Such as, technical staff is arranged by interface and made described controlled switch unit be energized once every 3 seconds, and the duration of each energising was 30 seconds.Then described control unit is from described rule settings completes, electrical instruction is sent every 3 seconds to described controlled switch unit according to system clock, then described controlled switch unit performs power-on servicing based on described electrical instruction, when 30 second of energising, described control unit sends cut-offing instruction, then described controlled switch unit performs power operation based on described cut-offing instruction.Repetition like this.
And for example, described technical staff is arranged by interface and adopts the instruction of stochastic model transmit button from 6 pm to the next morning 9, then described control unit is in the afternoon in 6 to the next morning time zone of 9, sends electrical instruction or cut-offing instruction at random.So, described test macro can After Hours proceed test employee, effectively to utilize unattended time zone, completes dependence test.
Preferably, in order to prevent each random number produced from repeating, described control unit adopts different seeds to produce random number.Such as, described control unit produces different seed by performing srand ((int) time (NULL)) statement.
Then, in step s 2, described test cell, when the power supply energising of described router, is tested described router.
Particularly, described test cell is by monitoring the power on/off situation of described controlled switch unit or identifying power on/off situation by receiving described switch command, when determining the power supply energising of described router, according to the testing process preset, described router is tested.Wherein, described test can be electric test, conventionally test, high/low temperature test etc.
Preferably, the opening and closing for described controlled switch unit is frequent, and described test cell is used for, when the power supply energising of described router, carrying out the test relevant to power down to described router.Wherein, the described test relevant to power down includes but not limited to following at least one: configuration loss, mirror image damage.
According to Fig. 2, the course of work of described test macro is exemplified below:
Technical staff by interface input in the afternoon 6 adopt fixing power on/off periods rules to the next morning 9, and setting made described controlled switch unit be energized once every 3 seconds, and the duration of each energising was 30 seconds.Then described control unit sends electrical instruction or cut-offing instruction based on above-mentioned rule to described controlled switch unit, described controlled switch unit makes described router power on/off based on electrical instruction or cut-offing instruction, meanwhile, the test cell be connected with described controlled switch unit sends ping when it is energized to described router and sets IP instruction, to test the preservation situation of the configuration of described router.
In sum, the test macro of router of the present invention and method, by arranging controlled switch unit at the power end of router and setup control is regular, described test macro can without the need to testing of manually participating in automatically, achieve unattended operation, automatic adjustment power-on time, improves the operational efficiency of test macro; In addition, described test macro can be tested according to various control law, effectively ensures during unattended operation, test comprehensive.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.