CN115426300A - Method for automatically testing NP chip API (application program interface) based on data packet - Google Patents

Method for automatically testing NP chip API (application program interface) based on data packet Download PDF

Info

Publication number
CN115426300A
CN115426300A CN202210975602.3A CN202210975602A CN115426300A CN 115426300 A CN115426300 A CN 115426300A CN 202210975602 A CN202210975602 A CN 202210975602A CN 115426300 A CN115426300 A CN 115426300A
Authority
CN
China
Prior art keywords
test
api
chip
message
testing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210975602.3A
Other languages
Chinese (zh)
Other versions
CN115426300B (en
Inventor
余立江
廖鹏举
顾蔚文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Beizhong Network Core Technology Co ltd
Original Assignee
Chengdu Beizhong Network Core Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Beizhong Network Core Technology Co ltd filed Critical Chengdu Beizhong Network Core Technology Co ltd
Priority to CN202210975602.3A priority Critical patent/CN115426300B/en
Publication of CN115426300A publication Critical patent/CN115426300A/en
Application granted granted Critical
Publication of CN115426300B publication Critical patent/CN115426300B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Maintenance And Management Of Digital Transmission (AREA)

Abstract

The invention relates to a method for automatically testing an API (application program interface) of an NP (network processor) chip based on a data packet, belonging to the field of computer networks. The test PC is responsible for assembling test messages and sending the test messages to a platform network card of an NP platform through the network card, the NP platform comprises an NP chip and the platform network card, the NP chip triggers an automatic test flow after receiving the test messages through the platform network card and assembles test response messages containing test results and sends the test response messages back to the test PC, and the test PC automatically analyzes the message contents and judges the test results. The invention not only designs the test message format of the API interface of the NP chip, but also compiles an automatic test framework, a microcode and a test case, the test environment is easy to transplant and copy, and the test can be synchronously carried out in a plurality of environments. After the method is adopted, the verification efficiency of the testing personnel on the NP chip API interface is greatly improved, and all API interface coverage verification can be automatically realized in the regression stage.

Description

Method for automatically testing NP chip API (application program interface) based on data packet
Technical Field
The invention belongs to the field of computer networks, and particularly relates to a method for automatically testing an API (application program interface) of an NP (network processor) chip based on a data packet.
Background
Network processor chips (hereinafter NP chips) are a more specialized and efficient processing solution for network data traffic today. In order to make it easier and more efficient for users to use various functions provided by the NP chip, powerful API support is usually provided in the NP chip. Generally, the testing of the API is performed more in the verification stage, and the functional correctness testing is performed through logic simulation, but the method has obvious limitations. Another way to test is by writing microcode programs to call the API interface to see if the API inputs and outputs conform to the desired design. However, test schemes that use microcode programs to validate APIs have many limitations. Firstly, microcode belongs to a lower-level programming language, learning and compiling efficiency is low, and a lot of time is wasted on coding when testing is carried out by using the microcode; secondly, the capacity of a microcode program which can be written in the NP processor is limited, the function of one-time performance verification is extremely limited, and the efficiency bottleneck is caused by repeatedly importing the microcode program; finally, the scheme cannot realize automatic testing, or the difficulty of realizing the automatic testing is higher.
Disclosure of Invention
Technical problem to be solved
The technical problem to be solved by the invention is how to provide a method for automatically testing an NP chip API (application program interface) based on a data packet, so as to solve the problems that the test scheme for verifying the API by using a microcode program has many limitations, so that the automatic test cannot be realized, or the difficulty for realizing the automatic test is higher.
(II) technical scheme
In order to solve the technical problem, the invention provides a method for automatically testing an API (application program interface) of an NP (network processor) chip based on a data packet, which comprises the following steps:
firstly, designing a test message format, wherein the message is designed based on an Ethernet header, belongs to a two-layer communication protocol, and adopts an Ethernet protocol 0x4500 as an identification protocol number;
secondly, compiling an automatic test framework; the frame is operated on a test PC, firstly, a test case file is read, the test case describes the value of each field of a test message to be sent and the value of each field of an expected return test message of the test, each field value of the test message to be sent is extracted to form a test message, and the test message is sent to an NP chip; the NP chip carries out a series of processing on the test message and returns a test response message, the test framework carries out analysis processing on the result of the test response message and judges whether the test passes or not, thereby completing a test; then repeating the process, continuously reading the use cases, assembling and sending the test messages, analyzing the test response messages, collecting the test results and generating test reports;
thirdly, writing microcode; the microcode is a code stored and operated in the NP chip and is used for disassembling the test message sent to the NP chip and sending the effective load part to an API processing module of the NP chip; then after the API processing module returns the result, the result is packaged into the test response message again, and the test response message is sent out;
fourthly, compiling a test case file; after the frame and the microcode work are completed, a test case is designed, and the file content of the test case comprises the following steps: the method comprises the following steps of testing a serial number, a test case name, an API (application program interface) name, sending parameter values of each field of a test message, returning parameter values of each field of a test response message and remark information;
and step five, executing the test: firstly, preparing an NP chip to be tested, and filling written micro-codes; secondly, preparing a test PC, installing an automatic test framework, and importing a test case file; finally, the two are linked together using a network cable, and verification of the NP chip is started.
Furthermore, the test PC is responsible for assembling the test message, and sends the message to a platform network card of an NP platform through the network card, the NP platform comprises an NP chip and the platform network card, the NP chip triggers an automatic test flow after receiving the test message through the platform network card, and assembles a test response message containing a test result and sends the test response message back to the test PC, and the test PC automatically analyzes the message content and judges the test result.
Furthermore, in the first step, each word of the test packet is 32bt, all the words 0-2 and the high-order 16 bt of the word3 belong to the ethernet part; the lower 16bi t of word3 and all of words 4-11 belong to the test control field part; all parts of word12 to the end belong to a specific test content part.
Further, in the first step, the fields of the test packet include: the microcode test processing system comprises an opcode, a miss _ case, a code, a subcode, an extcode, tags, data _ len, dst _ value, API _ ack _ dataLen, API _ Header, API _ data and Padding, wherein the opcode is used for identifying a test request or a test response, and the miss _ case is used for identifying whether a microcode test processing branch is hit; the code, subcode and extcode are used for identifying each processing branch path in the microcode test; the tags are used for identifying id serial numbers of the test messages; data _ len is used for identifying the total length of API _ ack _ dataLen, API _ Header, API _ data and Padding; dst _ value is used for identifying a final test result; the API _ ack _ dataLen is used for setting the API return data length; the API _ dataLen is used for setting the data length of the API to be sent; API _ Header is the API Command part; API _ data is an API data part; padding is a packet Padding part.
Further, in the second step, the test framework is implemented based on the python program.
Furthermore, in the second step, after the test framework is written, the test framework needs to be designed additionally unless the new API interface is greatly different from the previous interface usage mode.
Further, in the third step, different API processing flows are judged and processed through code, subcode and extcode branch paths.
Furthermore, in the third step, after the microcode is written and solidified, a branch path needs to be additionally designed for a new processing flow unless the use mode of the new API interface is greatly different from that of the previous interface.
Further, in the fourth step, the test case file uses an excel format.
Further, in the fourth step, the parameter values of each field of the test message are sent and the parameter values of each field of the test response message are returned, wherein the values to be set for each field when the message is assembled are recorded in detail.
(III) advantageous effects
The invention provides a method for automatically testing an API (application program interface) of an NP (network processor) chip based on a data packet, which not only designs a test message format of the API of the NP chip, but also compiles an automatic test framework, a microcode and a test case, so that a test environment is easy to transplant and copy and can be synchronously carried out in a plurality of environments. After the method is adopted, the verification efficiency of the testing personnel on the NP chip API interface is greatly improved, and all API interface coverage verification can be automatically realized in the regression stage. The method has more efficient and accurate test guarantee for the NP chip research and development process.
Drawings
FIG. 1 is a general flow chart of the present invention;
FIG. 2 is a topology diagram of the present invention;
FIG. 3 is a flow chart of an execution phase of the present invention;
FIG. 4 is a diagram of a test message format according to the present invention.
Detailed Description
In order to make the objects, contents and advantages of the present invention clearer, the following detailed description of the embodiments of the present invention will be made in conjunction with the accompanying drawings and examples.
The invention aims to provide a method for testing and verifying an API (application program interface) of an NP (Internet protocol) chip more efficiently. Firstly, more energy of a tester can be used for designing a test scheme and a test case, rather than more time spent on compiling a test program; secondly, the efficiency of API verification is improved, and various input and output of one API interface can be verified more quickly; finally, the scheme is realized based on an automatic mode, and the regression efficiency can be greatly improved.
Fig. 1 is a general flow chart of the present invention. The core principle of the method is that the method is driven by using a data packet mode, so that a large amount of work content is expanded around the aspects of generation, processing and verification of data messages.
Fig. 2 is a topology diagram of the present invention. The test PC is responsible for assembling test messages and sending the test messages to a platform network card of an NP platform through the network card, the NP platform comprises an NP chip and the platform network card, the NP chip triggers an automatic test flow after receiving the test messages through the platform network card and assembles test response messages containing test results and sends the test response messages back to the test PC, and the test PC automatically analyzes the message contents and judges the test results.
The following is a description of each step of the overall flow:
firstly, designing a test message format. As shown in fig. 4, the message is based on the ethernet header design and belongs to a two-layer communication protocol. Ethernet protocol 0x4500 is used as the identification protocol number.
Wherein each word is 32bit, all of word0-2 and the high-order 16bit of word3 belong to the Ethernet part; the low-order 16bit of word3 and all words 4-11 belong to a test control field part; all parts of word12 to the end belong to a specific test content part. The meaning of each field is as follows:
Figure BDA0003798364440000041
the message design not only can be suitable for API interface test, but also has expansibility, not only can be suitable for microcode instruction test of an NP chip, but also can be suitable for service function test of the NP chip, and compatibility can be realized only by modifying the content of a test content part.
And secondly, compiling an automatic test framework. The framework is realized based on a python program, is operated on a test PC in a topological graph, and mainly realizes the realization of the flow in the execution stage of the test flow. As shown in fig. 3, firstly, a python program reads a test case file, the test case mainly describes values of fields of a test message to be sent and fields of an expected return test message of the test, and the python program extracts field values of the test message to be sent to form a test message and sends the test message to an NP chip; the NP chip carries out a series of processing on the test message and returns a test response message, and the test framework carries out analysis processing on the result of the test response message and judges whether the test passes or not, thereby completing a test. And repeating the process, continuously reading the use cases, assembling and sending the test messages, analyzing the test response messages, collecting the test results and generating the test reports. After the test framework is written, the test framework does not need to be modified again. Unless new API interfaces are present that differ significantly from the previous interface usage patterns, additional test frameworks need not be designed.
Third, microcode is written. The microcode is a code stored and run in the NP chip, and the main purpose of writing the microcode in the step is to disassemble the test message sent to the NP chip and send the payload part of the test message to the API processing module of the NP chip. And then after the API processing module returns the result, packaging the result into a test response message again, and sending out the test response message. Since the types of APIs are many, different API processing flows are designed, and determination processing is performed by a branch path such as code, subcode, extcode, or the like. After the microcode is written and solidified, the microcode does not need to be modified again. The new processing flow is not needed to be carried out by designing a branch path unless the new API interface is greatly different from the use mode of the previous interface.
Fourthly, compiling a test case file. After the framework and microcode work is completed, the long-term work content is mainly in the design aspect of the test case. The test case file uses an excel format, and the content mainly comprises the following components: test number, test case name, API interface name, parameter values of each field of the test message, remark information and the like. Wherein, the values of each field required to be set when the message in fig. 4 is assembled are recorded in detail in each field parameter value of the sending test message and each field parameter value of the returning test response message.
And fifthly, executing the test. Firstly, preparing tested NP chip equipment, and filling a written microcode test program; secondly, preparing a test PC, installing an automatic test framework program, and importing a test case file; finally, the two are linked together using a network cable. The verification of the NP chip program can begin. The environment is easy to migrate and replicate, and can be synchronized across multiple environments.
The invention not only designs the test message format of the API interface of the NP chip, but also compiles an automatic test framework, a microcode and a test case, the test environment is easy to transplant and copy, and the test can be synchronously carried out in a plurality of environments. After the method is adopted, the verification efficiency of the testing personnel on the NP chip API interface is greatly improved, and all API interface coverage verification can be automatically realized in the regression stage. The method has more efficient and accurate test guarantee for the NP chip research and development process.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, it is possible to make various improvements and modifications without departing from the technical principle of the present invention, and those improvements and modifications should be considered as the protection scope of the present invention.

Claims (10)

1. A method for automatically testing an API (application program interface) of an NP (network processor) chip based on a data packet is characterized by comprising the following steps:
firstly, designing a test message format, wherein the message is designed based on an Ethernet header, belongs to a two-layer communication protocol, and adopts an Ethernet protocol 0x4500 as an identification protocol number;
secondly, compiling an automatic test framework; the frame is operated on a test PC, firstly, a test case file is read, the test case describes the value of each field of a test message to be sent of the test and the value of each field of an expected return test message, each field value of the test message to be sent is extracted to form a test message, and the test message is sent to an NP chip; the NP chip returns a test response message after a series of processing on the test message, and the test framework analyzes and processes the result of the test response message and judges whether the test passes or not so as to finish a test; then repeating the process, continuously reading the cases, assembling and sending the test messages, analyzing the test response messages, collecting the test results and generating test reports;
thirdly, writing microcode; the microcode is a code stored and operated in the NP chip and is used for disassembling the test message sent to the NP chip and sending the effective load part to an API processing module of the NP chip; then after the API processing module returns the result, the result is packaged into the test response message again, and the test response message is sent out;
fourthly, compiling a test case file; after the frame and the microcode work are completed, a test case is designed, and the file content of the test case comprises the following steps: the method comprises the following steps of testing a serial number, a test case name, an API (application program interface) name, sending parameter values of each field of a test message, returning parameter values of each field of a test response message and remark information;
and step five, executing the test: firstly, preparing an NP chip to be tested, and filling a written microcode; secondly, preparing a test PC, installing an automatic test framework, and importing a test case file; finally, the two are linked together using a network cable, and verification of the NP chip is started.
2. The method according to claim 1, wherein the testing PC is responsible for assembling the test message and sending the test message to the platform network card of the NP platform via the network card, the NP platform comprises the NP chip and the platform network card, the NP chip triggers the automatic testing process after receiving the test message via the platform network card and assembles the test response message containing the test result and sends the test response message back to the testing PC, and the testing PC automatically analyzes the message content to determine the test result.
3. The method for automatically testing the API of the NP chip based on the data packet according to claim 1 or 2, wherein in the first step, each word of the test message is 32bi t, all of word0-2 and the high-order 16bit of word3 belong to the Ethernet part; all of the lower 16bi t of word3 and words 4-11 belong to a test control field part; all parts of word12 to the end belong to a specific test content part.
4. The method for automatically testing the API interface of the NP chip based on the data packet as set forth in claim 3, wherein in the first step, the fields of the test packet include: the microcode testing method comprises the following steps of (1) encoding, miss _ case, code, subcode, extcode, tags, data _ len, dst _ value, API _ ack _ dataLen, API _ Header, API _ data and Padding, wherein the opcode is used for identifying a testing request or a testing response, and the miss _ case is used for identifying whether a microcode testing processing branch is hit; the code, the subcode and the extcode are used for identifying each processing branch path in the microcode test; the tags are used for identifying id serial numbers of the test messages; data _ len is used to identify the total length of API _ ack _ dataLen, API _ Header, API _ data, and Padding; dst _ value is used for identifying a final test result; the API _ ack _ dataLen is used for setting the API return data length; the API _ dataLen is used for setting the data length of the API to be transmitted; API _ Header is the API Command part; API _ data is an API data part; padding is a packet Padding part.
5. The method for automatically testing the API of the NP-chip based on the data packet according to claim 4, wherein in the second step, the test framework is implemented based on python program.
6. The method for automatically testing the API of the NP-chip based on the data packet according to claim 4, wherein in the second step, after the test framework is written, the test framework is not designed unless the new API is different from the previous API in the using mode.
7. The method for automatically testing the API of the NP chip based on the data packet according to claim 4, wherein in the third step, different API processing flows are processed by the branch path judgment of code, subcode and extcode.
8. The method of claim 7, wherein in the third step, after the microcode is written and solidified, a branch path is not designed to be used for a new process unless the new API interface is different from the previous API interface.
9. The method for automatically testing an API interface of an NP chip based on a data packet as set forth in claim 4, wherein in the fourth step, the test case file uses an excel format.
10. The method for automatically testing the API interface of the NP chip based on the data packet as recited in claim 9, wherein in the fourth step, the parameter values of each field of the test packet and the parameter values of each field of the test response packet are sent, and the values to be set for each field when the packet is assembled are recorded in detail.
CN202210975602.3A 2022-08-15 2022-08-15 Method for automatically testing API (application program interface) of NP (network Programming) chip based on data packet Active CN115426300B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210975602.3A CN115426300B (en) 2022-08-15 2022-08-15 Method for automatically testing API (application program interface) of NP (network Programming) chip based on data packet

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210975602.3A CN115426300B (en) 2022-08-15 2022-08-15 Method for automatically testing API (application program interface) of NP (network Programming) chip based on data packet

Publications (2)

Publication Number Publication Date
CN115426300A true CN115426300A (en) 2022-12-02
CN115426300B CN115426300B (en) 2023-12-01

Family

ID=84199128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210975602.3A Active CN115426300B (en) 2022-08-15 2022-08-15 Method for automatically testing API (application program interface) of NP (network Programming) chip based on data packet

Country Status (1)

Country Link
CN (1) CN115426300B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1394010A (en) * 2001-06-21 2003-01-29 华为技术有限公司 Microcode test method and device for network processor
US6721276B1 (en) * 2000-06-29 2004-04-13 Cisco Technology, Inc. Automated microcode test packet generation engine
US9021440B1 (en) * 2014-08-11 2015-04-28 Pmc-Sierra Us, Inc. System and method for automated test script generation
US9419884B1 (en) * 2012-12-28 2016-08-16 Emc Corporation Intelligent automated testing method for restful web services
CN107678942A (en) * 2017-08-30 2018-02-09 苏州朗动网络科技有限公司 A kind of API automated testing methods
CN108073519A (en) * 2018-01-31 2018-05-25 百度在线网络技术(北京)有限公司 Method for generating test case and device
CN109189684A (en) * 2018-08-28 2019-01-11 四川长虹电器股份有限公司 Automatic interface testing method based on Python
CN109697160A (en) * 2017-10-23 2019-04-30 中国舰船研究设计中心 A kind of Ethernet interface software automated testing system and method
US10678679B1 (en) * 2018-02-21 2020-06-09 Amdocs Development Limited System, method, and computer program for automated application programming interface (API) regression testing
CN112241373A (en) * 2020-10-30 2021-01-19 久瓴(江苏)数字智能科技有限公司 Automatic test method, test device, processor and test system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6721276B1 (en) * 2000-06-29 2004-04-13 Cisco Technology, Inc. Automated microcode test packet generation engine
CN1394010A (en) * 2001-06-21 2003-01-29 华为技术有限公司 Microcode test method and device for network processor
US9419884B1 (en) * 2012-12-28 2016-08-16 Emc Corporation Intelligent automated testing method for restful web services
US9021440B1 (en) * 2014-08-11 2015-04-28 Pmc-Sierra Us, Inc. System and method for automated test script generation
CN107678942A (en) * 2017-08-30 2018-02-09 苏州朗动网络科技有限公司 A kind of API automated testing methods
CN109697160A (en) * 2017-10-23 2019-04-30 中国舰船研究设计中心 A kind of Ethernet interface software automated testing system and method
CN108073519A (en) * 2018-01-31 2018-05-25 百度在线网络技术(北京)有限公司 Method for generating test case and device
US10678679B1 (en) * 2018-02-21 2020-06-09 Amdocs Development Limited System, method, and computer program for automated application programming interface (API) regression testing
CN109189684A (en) * 2018-08-28 2019-01-11 四川长虹电器股份有限公司 Automatic interface testing method based on Python
CN112241373A (en) * 2020-10-30 2021-01-19 久瓴(江苏)数字智能科技有限公司 Automatic test method, test device, processor and test system

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
SE-HUN JANG: "API Automation Test with API Relation Diagram", 2006 INTERNATIONAL CONFERENCE ON HYBRID INFORMATION TECHNOLOGY *
古锐;肖璞;: "基于Appium的Android应用自动化测试框架的研究", 现代计算机(专业版), no. 29 *
易利娜: "基于Lua脚本语言的嵌入式API级自动测试框架的设计与实现", 中国优秀硕士学位论文全文数据库-信息科技辑 *
杨欣;朱志东;高远;: "《基于Robot Framework的自动化接口测试框架的设计与实现》", 《电子质量》, no. 10 *

Also Published As

Publication number Publication date
CN115426300B (en) 2023-12-01

Similar Documents

Publication Publication Date Title
CN109189684B (en) Python-based automatic interface testing method
CN103178996B (en) Distributed packet-switching chip model verification system and method
CN100511149C (en) Logic emulation testing system and method
CN104268079A (en) POS (Point Of Sale) application program testing method and system
CN111367818A (en) System component testing method and device based on dynamic data return
CN102480467A (en) SOC (System on a Chip) software and hardware collaborative simulation verification method based on network communication protocol
CN111399828A (en) Model-driven logic device modeling method and terminal
JP2000232516A (en) Method for generating validity check rule, generating module, control module and storage means
CN114757135B (en) Programmable logic device verification method and system based on demand drive verification
CN113050929A (en) Intelligent contract development, operation and maintenance integrated platform based on HyperLegger Fabric
CN106339249B (en) Dynamic configuration programmed method
CN107122307B (en) Internet of things execution system
CN108833005B (en) Optical network communication equipment and automatic test kit and method for networking service thereof
CN112583663B (en) Automatic network performance testing method based on domestic operating system
Pang et al. Automatic model generation of IEC 61499 function block using net condition/event systems
CN101158919A (en) Unit test method driven by data
CN115426300A (en) Method for automatically testing NP chip API (application program interface) based on data packet
CN111142861B (en) Method and device for integrating structured comprehensive control system
Simonsen et al. Generating protocol software from cpn models annotated with pragmatics
CN111506305A (en) Tool kit generation method and device, computer equipment and readable storage medium
Sirjani et al. A front-end tool for automated abstraction and modular verification of actor-based models
CN106354966B (en) The method of the conversion of chip id E project file and rapid configuration artificial debugging environment
CN115833964A (en) Performance test method and performance test system of dual-mode communication module
CN104579837A (en) Method and system for performing conformance testing on OpenFlow protocols
CN114115832A (en) Internet of things embedded equipment and cloud platform communication protocol implementation method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant