Method of testing expansion card, electronic device, and testing system
View Patent ↗A method of testing an expansion card includes configuring a configuration file according to contents of instructions of a controller, which may be received by the expansion card, and contents of expected data corresponding to the instructions. Testing instructions are generated based on the configuration file. The testing instructions are sent to the expansion card. Returned data returned from a firmware of the expansion card by responding the testing instructions. Whether an electronic device communicates with the expansion card successfully is determined based on the returned data. An electronic device and a testing system are also provided.
1 . A method of testing an expansion card, applied in an electronic device; the electronic device comprises a storage medium and a processor; the storage medium stores computer programs; and the processor executes the computer programs to implement following processes:
acquiring contents of instructions of a controller corresponding to the expansion card;
acquiring contents of expected data corresponding to the contents of the instructions in response to the expansion card receiving the contents of instructions;
configuring at least one configuration file based on the contents of instructions and the contents of expected data; wherein the controller is a baseboard management controller;
generating testing instructions based on the at least one configuration file;
sending the testing instructions to the expansion card;
receiving returned data from firmware of the expansion card, which is generated while executing the testing instructions;
determining whether the electronic device communicates with the expansion card successfully based on the returned data;
parsing the returned data based on receiving parameters of the at least one configuration file; and
generating a log file based on the parsed returned data in response to the returned data been parsed successfully;
wherein determining whether the electronic device communicates with the expansion card successfully based on the returned data comprises:
reading contents of a state flag in the log file, wherein
in a case that the contents of the state flag indicate that the electronic device communicates with the expansion card successfully, determining the electronic device is communicating with the expansion card; and
in case that the contents of the state flag indicate that the electronic device fails to communicate with the expansion card, triggering an abnormal warning.
2 . The method of claim 1 , wherein generating the testing instructions based on the at least one configuration file comprises:
reading sending parameters in the at least one configuration file; and
filling the sending parameters in a specified format and generating the testing instructions.
3 . The method of claim 1 , after parsing the returned data based on the receiving parameters of the at least one configuration file, the method further comprising:
in a case that the returned data is parsed unsuccessfully, triggering the abnormal warning.
4 . The method of claim 1 , after generating the testing instructions based on the at least one configuration file, the method further comprising:
determining whether a number of the testing instructions is larger than or equal to a specified number, wherein
in a case that the number of the testing instructions is less than the specified number, sending the testing instructions to the expansion card; and
in a case that the number of the testing instructions is larger than or equal to the specified number, stopping testing.
5 . The method of claim 1 , before configuring the at least one configuration file based on the contents of the instructions, and contents of expected data, the method further comprising:
obtaining a device address of the expansion card and a channel address;
wherein the contents of the instructions is acquired based on the device address of the expansion card and the channel address.
6 . The method of claim 1 , wherein a transmission manner of the testing instructions from the electronic device to the expansion card and the returned data from the expansion card to the electronic device comprises an out-of-band manner, or an in-band manner.
7 . The method of claim 1 , wherein the acquired number of the testing instructions is related to the number of at least one configuration file, each testing instruction is generated based on one configuration file.
8 . An electronic device comprises:
a processor, configured to execute computer programs;
a non-transitory computer readable storage medium, configured to store the computer programs; the computer programs are executed by the processor to implement following instructions:
acquiring contents of instructions of a controller corresponding to an expansion card;
acquiring contents of expected data corresponding to the contents of the instructions in response to the expansion card receiving the contents of instructions;
configuring at least one configuration file based on the contents of instructions of a controller and contents of expected data; wherein the controller is a baseboard management controller;
generating testing instructions based on the at least one configuration file;
sending the testing instructions to the expansion card;
receiving returned data from firmware of the expansion card, which is generated while executing the testing instructions; and
determining whether the electronic device communicates with the expansion card successfully based on the returned data;
parsing the returned data based on receiving parameters of the at least one configuration file; and
generating a log file based on the parsed returned data in response to the returned data been parsed successfully;
reading contents of a state flag in the log file; wherein
in a case that the contents of the state flag indicate the electronic device communicates with the expansion card successfully, determining the electronic device communicates with the expansion card successfully; and
in a case that the contents of the state flag indicate the electronic device fails to communicate with the expansion card, triggering an abnormal warning.
9 . The electronic device of claim 8 , wherein the processor further:
reading sending parameters in the at least one configuration file; and
filling the sending parameters in a specified format and generating the testing instructions.
10 . The electronic device of claim 8 , wherein the processor further:
in a case that the returned data is parsed unsuccessfully, triggering the abnormal warning.
11 . The electronic device of claim 8 , wherein the processor further:
determining whether a number of the testing instructions is larger than or equal to a specified number, wherein
in a case that the number of the testing instructions is less than the specified number, sending the testing instructions to the expansion card; and
in a case that the number of the testing instructions is larger than or equal to the specified number, stopping testing.
12 . The electronic device of claim 8 , wherein the processor further:
obtaining a device address of the expansion card and a channel address;
wherein the contents of the instructions is acquired based on the device address of the expansion card and the channel address.
13 . A testing system comprises an electronic device and an expansion card; wherein the electronic device is configured to:
acquire contents of instructions of a controller corresponding to the expansion card;
acquire contents of expected data corresponding to the contents of the instructions in response to the expansion card receiving the contents of instructions;
configure at least one configuration file based on the contents of instructions of a controller, and contents of expected data; wherein the controller is a baseboard management controller;
generate testing instructions based on the at least one configuration file;
send the testing instructions to the expansion card;
receive returned data from firmware of the expansion card, which is generated while executing the testing instructions; and
determines whether the electronic device communicates with the expansion card successfully based on the returned data;
wherein the electronic device is also configured to parse the returned data based on receiving parameters of the at least one configuration file, and generate a log file based on the parsed returned data when the returned data is parsed successfully; the electronic device is also configured to read contents of a state flag in the at least one configuration file; in a case that the contents of the state flag indicate that the electronic device communicates with the expansion card successfully, the electronic device communicates with the expansion card successfully; in case that the contents of the state flag indicate that the electronic device fails to communicate with the expansion card, an abnormal warning is generated.
14 . The testing system of claim 13 , wherein the electronic device is also configured to read sending parameters in the at least one configuration file, and fill the sending parameters in a specified format and generating the testing instructions.
15 . The testing system of claim 13 , wherein in a case that the returned data is parsed unsuccessfully, the abnormal warning is triggered.
16 . The testing system of claim 13 , wherein the electronic device is also configured to determine whether a number of the testing instructions is larger than or equal to a specified number; in a case that the number of the testing instructions is less than the specified number, the testing instructions are sent to the expansion card; in a case that the number of the testing instructions is larger than or equal to the specified number, stopping testing.
17 . The testing system of claim 13 , wherein the electronic device is also configured to obtain a device address of the expansion card and a channel address; wherein the contents of the instructions is acquired based on the device address of the expansion card and the channel address.