Summary of the invention
The present invention proposes a kind of computer system and method for carrying out hardware unit test based on virtual machine, its computer system can utilize virtual machine to test hardware or the firmware of real hardware device, if produce abnormal situation when the hardware of real hardware device or the test of firmware driver, only can have influence on the running of the client operating system of virtual machine, that can not cause the host side operating system of computer system works as machine or collapse, can guarantee security during hardware or the firmware driver of computer system test real hardware device.
The present invention proposes a kind of computer system and method for carrying out hardware unit test based on virtual machine, its computer system utilizes the operating function of a virtual hardware device emulation surrounding hardware device, then, the surrounding hardware device of an outside need not be connected, can develop for the firmware driver of surrounding hardware device, to promote the convenience of firmware Driver Development and ageing.
For reaching above-mentioned purpose, the invention provides a kind of computer system of carrying out hardware unit test based on virtual machine, comprising: a virtual machine, comprise: a client operating system, comprise: a client driver, be configured in client operating system, in order to send a series of test instruction; And a virtual machine management program, comprise an expansion test module; And a real hardware device, lead directly to unit through a hardware and connect expansion test module, wherein client driver sequentially transmits test instruction to real hardware device via expansion test module, and real hardware device process test instruction is to produce at least one response message and to transmit response message to client driver via expansion test module.
In one embodiment of the invention, expand test module in test instruction, add the instruction that a false command or does not meet host-host protocol specification.
In one embodiment of the invention, expand test module and set a time delay, expand test module according to time delay to postpone the time that each test instruction is sent to real hardware device.
In one embodiment of the invention, when true hardware unit is via processing test instruction to judge that test instruction includes a false command, and do not meet the instruction of host-host protocol specification or have the situation of instruction propagation delay, the response message being labeled with firmware mistake will be produced.
In one embodiment of the invention, expand test module and copy test instruction to repeat to transmit test instruction to real hardware device.
In one embodiment of the invention, expand test module and add the data that a misdata or does not meet host-host protocol specification in the response message.
In one embodiment of the invention, expand test module and set a time delay, expand test module according to time delay to postpone the time that each response message is sent to client driver.
In one embodiment of the invention, real hardware device is a surrounding hardware device according with PCI, PCI Express, SATA or USB transport protocol specification.
The present invention provides again a kind of computer system of carrying out hardware unit test based on virtual machine, comprise: a virtual machine, comprising: a client operating system, comprising: a client driver, be configured in client operating system, in order to send a series of test instruction; And a virtual machine management program, comprise an expansion test module and a virtual hardware device, wherein client driver sequentially transmits test instruction to virtual hardware device via expansion test module, and virtual hardware device process test instruction is to produce at least one response message and to transmit response message to client driver via expansion test module.
In one embodiment of the invention, virtual hardware device is emulated into by virtual machine management program the device that accords with PCI, PCI Express, SATA or USB transport protocol specification.
The present invention provides again a kind of computer system of carrying out hardware unit test based on virtual machine, comprise: a virtual machine, comprising: a client operating system, comprising: a client driver, be configured in client operating system, in order to send a series of test instruction; And a virtual machine management program, comprise an expansion test module and a virtual hardware device, wherein client driver sequentially transmits test instruction to expanding test module, if expand test module can process test instruction, expands test module and directly produces at least one response message; Otherwise, expands test module and transmit test instruction to virtual hardware device, produce response message by virtual hardware device process test instruction, and response message is sent to client driver via expansion test module.
The present invention provides again a kind of method of carrying out hardware unit test based on virtual machine, its method is useful in one and is configured with in the computer system of a virtual machine, virtual machine comprises a client operating system and a virtual machine management program, client operating system is configured with at least one client driver, virtual machine management program comprises an expansion test module, and method step comprises: make client driver send a series of test instruction and transmit test instruction to expanding test module; Order is expanded test module and is transmitted test instruction to real hardware device or a virtual hardware device; Make real hardware device or virtual hardware device process test instruction to produce at least one response message; And make real hardware device or virtual hardware device transmit response message to client driver via expansion test module.
Embodiment
Refer to Fig. 1, the department of computer science carrying out hardware unit test for the present invention is based on virtual machine unifies the structural representation of embodiment.As shown in Figure 1, the present embodiment computer system 100 comprises a virtual machine 12, and it is configured among a host side operating system 11.Virtual machine 12 comprises a virtual machine management program (Hyper-visor) 13 and a client operating system 15.Virtual machine management program 13 comprises an expansion test module 131, and client operating system 15 is configured with a client driver 151.
In the present embodiment, the expansion test module 131 of virtual machine 12 can connect the real hardware device 20 of an outside via straight-through (hardware pass-through) unit 130 of a hardware.It is one can construction communication is connected between virtual machine 12 with real hardware device 20 software interface that this hardware leads directly to unit 130.In the present invention, real hardware device 20 also can be the surrounding hardware device that accords with PCI, PCI Express, SATA, USB or other interface transmission protocols specifications.
When computer system 100 is for testing for real hardware device 20, client driver 151 sends a series of test instruction 1510, and test instruction 1510 is sent to real hardware device 20 via expansion test module 131.Real hardware device 20 processes test instruction 1510 to produce at least one response message 2000, and transmits response message 2000 to client driver 151 via expansion test module 131.Afterwards, client driver 151 detects response message 2000 and whether can order about real hardware device 20 normal operation to learn.
In further embodiment of this invention, expanding test module 131 can the test instruction 1510 that sends of replication client driver 151, and repeat to transmit test instruction 1510 to real hardware device 20, make these test instructions 1510 of real hardware device 20 re-treatment, verify the fiduciary level of real hardware device 20.
Separately, in further embodiment of this invention, computer system 100 can perform the testing process of debug for real hardware device 20.Add an extra instruction 1511 among the test instruction 1510 that expansion test module 131 can send at client driver 151, this extra instruction 1511 can be the instruction that a false command or does not meet host-host protocol specification; Or, expand test module 131 and set a time delay, expand test module 131 according to time delay to postpone the time that each test instruction 1510 is sent to real hardware device 20.If when real hardware device 20 receives test instruction 1510, correctly can judge that this test instruction 1510 includes false command, do not meet the instruction of host-host protocol specification or has the situation of instruction propagation delay, generation one is labeled with the response message 2000 of firmware mistake, and transmits via expansion test module 131 response message 2000 to the client driver 151 that this is labeled with firmware mistake.Via this response message 2000 being labeled with firmware mistake of detection, client driver 151 can learn that real hardware device 20 can perform correct process for the test instruction 1510 of mistake.Otherwise, if when real hardware device 20 receives test instruction 1510, cannot judge that this test instruction 1510 includes false command, do not meet the instruction of host-host protocol specification or has the situation of instruction propagation delay, still produce a regular response message 2000 with normal procedure, and transmit this regular response message 2000 to client driver 151 via expansion test module 131.Via this regular response message 2000 of detection, client driver 151 can learn that real hardware device 20 cannot perform correct process for the test instruction 1510 of mistake, can revise to make the developer of real hardware device 20 for the hardware of real hardware device 20.
Certainly, in further embodiment of this invention, computer system 100 also can perform the testing process of debug for client driver 151.The response message 2000 that expansion test module 131 can transmit at real hardware device 20 adds an extra information 2001, and this extra information 2001 can be the data that a misdata or does not meet host-host protocol specification; Or, expand test module 131 and set a time delay, expand test module 131 according to time delay to postpone the time that each response message 2000 is sent to client driver 151.If when client driver 151 receives response message 2000, correctly can judge that this response message 2000 includes fault data, do not meet the data of host-host protocol specification or has the situation of message propagation delay, can confirm that the firmware design of client driver 151 is normally errorless.Otherwise, if when client driver 151 receives response message 2000, cannot judge that this response message 2000 includes misdata, do not meet the data of host-host protocol specification or has the situation of message propagation delay, the firmware for client driver 151 is carried out debug by the developer of client driver 151.
At this, computer system 100 of the present invention utilizes virtual machine 12 to test real hardware device 20.If produce abnormal situation when the hardware of real hardware device 20 or firmware driver (such as: client driver 151) test, only can have influence on the running of the client operating system 15 of virtual machine 12, can not cause the host side operating system 11 of computer system 100 when machine or collapse, security when computer system 100 tests hardware or the firmware driver of real hardware device 20 can be guaranteed.In addition, restart can recover normal running as long as be subject to the abnormal and virtual machine 12 that is impact of real hardware device 20 or client driver 151.
Referring to Fig. 2, carrying out the structural representation of the another embodiment of computer system of hardware unit test for the present invention is based on virtual machine.As shown in Figure 2, the virtual machine management program 13 of the virtual machine 12 of the present embodiment computer system 101 will include a virtual hardware device 133.The virtual unit that virtual hardware device 133 is formed for a virtual machine management program 13 simulating realistic hardware unit 20, it accords with the specification of PCI, PCIExpress, SATA or USB transport protocol.Moreover client operating system 15 can manipulate including one the client driver 153 that virtual hardware device 133 operates.
When whether computer system 101 can manipulate virtual hardware device 133 normal operation for test client driver 153, require that client driver 153 sends a series of test instruction 1530, test instruction 1530 is sent to virtual hardware device 133 via expansion test module 131.Virtual hardware device 133 processes test instruction 1530 to produce at least one response message 1330, and transmits response message 1330 to client driver 153 via expansion test module 131.Afterwards, via detection response message 1330, client driver 153 can verify whether the design of its firmware is correct.
Further, computer system 101 can perform the testing process of debug for client driver 153.The response message 1330 that expansion test module 131 can transmit in virtual hardware device 133 adds an extra information 1331, and this extra information 1331 can be the data that a misdata or does not meet host-host protocol specification; Or, expand test module 131 and set a time delay, according to time delay to postpone the time that each response message 1330 is sent to client driver 153.Afterwards, if when client driver 153 receives response message 1330, correctly can judge that this response message 1330 includes fault data, do not meet the data of host-host protocol specification or has the situation of message propagation delay, can confirm that the firmware design of client driver 153 is normally errorless.Otherwise, if when client driver 151 receives response message 1330, cannot judge that response message 1330 includes misdata, do not meet the data of host-host protocol specification or has the situation of message propagation delay, then, the firmware for client driver 153 is carried out debug by the developer of client driver 153.
So, in the present embodiment computer system 101, virtual hardware device 133 is utilized to emulate the operating function of surrounding hardware device (the real hardware device 20 as Fig. 1), then, the surrounding hardware device of an outside need not be connected, can develop for the firmware driver of surrounding hardware device (such as: client driver 153), to promote the convenience of firmware Driver Development and ageing.
Moreover in one embodiment of the invention, the combination that the operating function of surrounding hardware device also can be expanded test module 131 and virtual hardware device 133 emulated.In other words, expand the operating function that test module 131 has the part of surrounding hardware device, and virtual hardware device 133 has remaining operating function of surrounding hardware device.So, when expansion test module 131 is when receiving the test instruction 1530 that client driver 153 sends, if expand test module 131 can process test instruction 1530, direct generation response message 1330 customer in response end driver 153, otherwise, if expand test module 131 cannot process test instruction 1530, test instruction 1530 to virtual hardware device 133 will be transmitted, produce response message 1330 by virtual hardware device 133.
Refer to Fig. 3, carry out the method flow diagram of an embodiment of the hardware testing of hardware unit for the present invention is based on virtual machine, and consult in Fig. 1 simultaneously.When computer system 100 is for testing for the hardware of real hardware device 20, first, perform step S301, client driver 151 sends a series of test instruction 1510, and transmits test instruction 1510 to expansion test module 131.
Then, step S303, expands test module 131 and test instruction 1510 is sent to real hardware device 20.Step S305, real hardware device 20 is after receiving test instruction 1510, and process test instruction 1510 to produce at least one response message 2000, and transmits response message 2000 to expansion test module 131.Afterwards, step S307, expand test module 131 transmit response message 2000 to client driver 151, client driver 151 via detection response message 2000 with learn whether can order about real hardware device 20 normal operation and firmware design whether correct.
In further embodiment of this invention, before execution step S303, still perform a step S302, expansion test module 131 adds a false command or and does not meet the instruction of host-host protocol specification in test instruction 1510, or expansion test module 131 postpones the time that each test instruction 1510 is sent to real hardware device 20.Then, step S305, real hardware device 20, after receiving this test instruction 1510 including false command, do not meet the instruction of host-host protocol specification or have an instruction propagation delay, processes this test instruction 1510, and transmits response message 2000 to expansion test module 131.Afterwards, step S307, expand test module 131 and transmit response message 2000 to client driver 151, then, client driver 151 is via detecting response message 1330 to learn whether real hardware device 20 can perform correct process for the test instruction 1510 of mistake.If via detection response message 2000, client driver 151 learns that real hardware device 20 cannot perform correct process for the test instruction 1510 of mistake, the hardware for real hardware device 20 is revised by the developer of real hardware device 20.
Refer to Fig. 4, carry out the method flow diagram of the another embodiment of the firmware test of hardware unit for the present invention is based on virtual machine, and consult in Fig. 1 simultaneously.When computer system 100 is for testing for the firmware of real hardware device 20, as above-mentioned steps S301 and S303, client driver 151 sends a series of test instruction 1510, and transmits test instruction 1510 to real hardware device 20 via expansion test module 131.Step S305, real hardware device 20 is after receiving test instruction 1510, and process test instruction 1510 to produce at least one response message 2000, and transmits response message 2000 to expansion test module 131.
Then, perform step S306, expansion test module 131 can add a fault data or and not meet the data of host-host protocol specification to response message 2000; Or expand test module 131 and postpone the time that each response message 2000 is sent to client driver 151.Afterwards, step S307, if when client driver 151 receives response message 2000, correctly can judge that this response message 2000 includes fault data, do not meet the data of host-host protocol specification or has the situation of message propagation delay, can confirm that the firmware design of client driver 151 is normally errorless.Otherwise, if when client driver 151 receives response message 2000, cannot judge that this response message 2000 includes misdata, do not meet the data of host-host protocol specification or has the situation of message propagation delay, the firmware for client driver 151 is carried out debug by the developer of client driver 151.
Refer to Fig. 5, carry out the method flow diagram of the another embodiment of hardware unit test for the present invention is based on virtual machine, and consult in Fig. 2 simultaneously.When computer system 100 is for testing for virtual hardware device 133, first, perform step S331, client driver 153 sends a series of test instruction 1530, and transmits test instruction 1530 to expansion test module 131.
Then, step S333, expands test module 131 and test instruction 1530 is sent to virtual hardware device 133.Step S335, virtual hardware device 133 is after receiving test instruction 1530, and process test instruction 1530 to produce at least one response message 1330, and transmits response message 1330 to expansion test module 131.Afterwards, step S337, expand test module 131 transmit response message 1330 to client driver 153, client driver 153 via detection response message 1330 with learn whether can order about virtual hardware device 133 normal operation and firmware design whether correct.
Moreover, before execution step S333, still perform step S332, judge whether expand test module 131 can directly process test instruction 1530.If expand test module 131 can directly process test instruction 1530, then, continue and perform step S3321, expand test module 131 and will produce response message 1330, otherwise, if expand test module 131 cannot process test instruction 1530, then, continue and perform step S333 and S335, expand test module 131 and test instruction 1530 is sent to virtual hardware device 133, produce response message 1330 by virtual hardware device 133.
In further embodiment of this invention, before execution step S337, still perform step S336, expansion test module 131 can add a fault data or and not meet the data of host-host protocol specification to response message 1330; Or expand test module 131 and postpone the time that each response message 1330 is sent to client driver 153.Afterwards, step S337, if when client driver 153 receives response message 1330 from expansion test module 131, correctly can judge that this response message 1330 includes fault data, do not meet the data of host-host protocol specification or has the situation of message propagation delay, can confirm that the firmware design of client driver 153 is normally errorless.Otherwise, if when client driver 153 receives response message 2000, cannot judge that this response message 1330 includes misdata, do not meet the data of host-host protocol specification or has the situation of message propagation delay, the firmware for client driver 153 is carried out debug by the developer of client driver 153.
As described above, be only a preferred embodiment of the present invention, not be used for limiting scope of the invention process, namely all equalizations of doing according to shape, structure, feature and the spirit described in the present patent application the scope of the claims change and modify, and all should be included in claim of the present invention.