cmdline.py

"""
DPDK Test suite.
Test cmdline.
""" import utils from test_case import TestCase class TestCmdline(TestCase): def set_up_all(self):
"""
Run at the start of each test suite. Cmdline Prerequisites:
cmdline build pass
At least one core in DUT
"""
out = self.dut.build_dpdk_apps('examples/cmdline')
'''
rm -rf ./app/test/test_resource_c.res.o
dut.10.240.176.254: rm -rf ./app/test/test_resource_tar.res.o
dut.10.240.176.254: rm -rf ./app/test/test_pci_sysfs.res.o
dut.10.240.176.254: make -j 70 -C examples/cmdline
'''
self.verify('make: Leaving directory' in out, "Compilation failed")
self.verify("Error" not in out, "compilation error 1")
self.verify("No such file" not in out, "compilation error 2") # Run cmdline app
cores = self.dut.get_core_list('1S/1C/1T') #['1']
'''
(Pdb) self.dut.get_core_list('1S/3C/1T')
['1', '2', '3']
(Pdb) self.dut.get_core_list('2S/3C/1T')
['1', '2', '3', '32', '33', '34']
(Pdb) self.dut.get_core_list('1S/5C/1T')
['1', '2', '3', '4', '5']
(Pdb) self.dut.get_core_list('1S/3C/1T')
['1', '2', '3'] '''
coreMask = utils.create_mask(cores)
'''
['1'] -> '0x2' #转换为16进制
['1', '2', '3'] -> '0xe'
['1', '2', '3', '32', '33', '34'] -> '0x70000000e'
'''
self.dut.send_expect("./examples/cmdline/build/app/cmdline -n 1 -c " + coreMask, "> ", 10) def set_up(self):
"""
Run before each test case.
Nothing to do.
"""
pass def test_cmdline_sample_commands(self):
"""
Sample commands test.
""" # add a test object with an IP address associated
out = self.dut.send_expect("add object 192.168.0.1", "example> ")
self.verify("Object object added, ip=192.168.0.1" in out, "add command error") # verify the object existance
out = self.dut.send_expect("add object 192.168.0.1", "example> ")
self.verify("Object object already exist" in out, "double add command error") # show the object result by 'show' command
out = self.dut.send_expect("show object", "example> ")
self.verify("Object object, ip=192.168.0.1" in out, "show command error") # delete the object in cmdline
out = self.dut.send_expect("del object", "example> ")
self.verify("Object object removed, ip=192.168.0.1" in out, "del command error") # double delete the object to verify the correctness
out = self.dut.send_expect("del object", "example> ", 1)
self.verify("Bad arguments" in out, "double del command error") # verify no such object anymore
out = self.dut.send_expect("show object", "example> ", 1)
self.verify("Bad arguments" in out, "final show command error") # verify the help command
out = self.dut.send_expect("help", "example> ", 1) """
Demo example of command line interface in RTE This is a readline-like interface that can be used to
debug your RTE application. It supports some features
of GNU readline like completion, cut/paste, and some
other special bindings. This demo shows how rte_cmdline library can be
extended to handle a list of objects. There are
3 commands:
- add obj_name IP
- del obj_name
- show obj_name
"""
self.verify(" " in out, "help command error") out = self.dut.send_expect("?", "example> ", 1)
"""
show [Mul-choice STRING]: Show/del an object
del [Mul-choice STRING]: Show/del an object
add [Fixed STRING]: Add an object (name, val)
help [Fixed STRING]: show help
"""
self.verify(" " in out, "? command error") def tear_down(self):
"""
Run after each test case.
Nothing to do.
"""
pass def tear_down_all(self):
"""
Run after each test suite.
Stop cmdline app.
"""
self.dut.kill_all()

测试的目的:

Test Case: cmdline sample commands test
======================================= Add a test object with an IP address associated to it:: example>add object 192.168.0.1
Object object added, ip=192.168.0.1 Verify the object existence:: example>add object 192.168.0.1
Object object already exist Show the object result by ``show`` command:: example>show object
Object object, ip=192.168.0.1 Verify the output matches the configuration. Delete the object in cmdline and show the result again:: example>del object
Object object removed, ip=192.168.0.1 Double delete the object to verify the correctness:: example>del object
Bad arguments Verify no such object exist now.:: example>show object
Bad arguments Verify the hidden command ? and help command:: example>help
Demo example of command line interface in RTE This is a readline-like interface that can be used to
debug your RTE application. It supports some features
of GNU readline like completion, cut/paste, and some
other special bindings. This demo shows how rte_cmdline library can be
extended to handle a list of objects. There are
3 commands:
- add obj_name IP
- del obj_name
- show obj_name example>?
show [Mul-choice STRING]: Show/del an object
del [Mul-choice STRING]: Show/del an object
add [Fixed STRING]: Add an object (name, val)
help [Fixed STRING]: show help cmdline.py
# add a test object with an IP address associated
out = self.dut.send_expect("add object 192.168.0.1", "example> ")
self.verify("Object object added, ip=192.168.0.1" in out, "add command error") # verify the object existance
out = self.dut.send_expect("add object 192.168.0.1", "example> ")
self.verify("Object object already exist" in out, "double add command error") # show the object result by 'show' command
out = self.dut.send_expect("show object", "example> ")
self.verify("Object object, ip=192.168.0.1" in out, "show command error") # delete the object in cmdline
out = self.dut.send_expect("del object", "example> ")
self.verify("Object object removed, ip=192.168.0.1" in out, "del command error") # double delete the object to verify the correctness
out = self.dut.send_expect("del object", "example> ", 1)
self.verify("Bad arguments" in out, "double del command error") # verify no such object anymore
out = self.dut.send_expect("show object", "example> ", 1)
self.verify("Bad arguments" in out, "final show command error") # verify the help command
out = self.dut.send_expect("help", "example> ", 1) """
Demo example of command line interface in RTE This is a readline-like interface that can be used to
debug your RTE application. It supports some features
of GNU readline like completion, cut/paste, and some
other special bindings. This demo shows how rte_cmdline library can be
extended to handle a list of objects. There are
3 commands:
- add obj_name IP
- del obj_name
- show obj_name
"""
self.verify(" " in out, "help command error") out = self.dut.send_expect("help", "example> ", 1)
"""
show [Mul-choice STRING]: Show/del an object
del [Mul-choice STRING]: Show/del an object
add [Fixed STRING]: Add an object (name, val)
help [Fixed STRING]: show help
"""
self.verify(" " in out, "? command error")

dut:执行详细信息

    [root@localhost cmdline]# ./examples/cmdline/build/app/cmdline -n 1 -c 0x2
EAL: PCI device 0000:82:00.0 on NUMA socket 1
EAL: probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:82:00.1 on NUMA socket 1
EAL: probe driver: 8086:10fb net_ixgbe
example> add object 192.168.0.1
Object object added, ip=192.168.0.1
example> add object 192.168.0.1
Object object already exist
example> show object 192.168.0.1
Bad arguments
example> show object
Object object, ip=192.168.0.1
example> del object
Object object removed, ip=192.168.0.1
example> del object
Bad arguments
example> show object
Bad arguments
example> help
Demo example of command line interface in RTE This is a readline-like interface that can be used to
debug your RTE application. It supports some features
of GNU readline like completion, cut/paste, and some
other special bindings. This demo shows how rte_cmdline library can be
extended to handle a list of objects. There are
3 commands:
- add obj_name IP
- del obj_name
- show obj_name example>
show [Mul-choice STRING]: Show/del an object
del [Mul-choice STRING]: Show/del an object
add [Fixed STRING]: Add an object (name, val)
help [Fixed STRING]: show help

最新文章

  1. ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core
  2. mybatis,sql 批量更新
  3. Educational Codeforces Round 3 E. Minimum spanning tree for each edge LCA/(树链剖分+数据结构) + MST
  4. ado.net access oracle dataset via store procedure
  5. HDU 1429 胜利大逃亡(续)(DP + 状态压缩)
  6. WebKit JavaScript Binding添加新DOM对象的三种方式
  7. Java的动态代理机制详解(转)
  8. L轻松学习inux教程5 知识与学习bash
  9. css复习内容
  10. 给定了经纬度的一张my_latlng表,和一个my_grid表,怎么实现my_latlng表回mygrid中的id?
  11. 迁移FRS至DFSR SYSVOL
  12. 第三节 Python基础之数据类型(列表,元组,字典)
  13. Android 简单调用摄像头
  14. plsql中文乱码问题
  15. Paper | 块分割信息 + 压缩视频质量增强
  16. OneAlert 携手 BearyChat(倍洽)快速构建 IT 运维 on-call 机制
  17. google 与服务器搭建
  18. 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"
  19. WinForm读取指定的config文件的内容
  20. Loader Lock引起的一个Bug

热门文章

  1. 关于微信小程序登录授权
  2. Session有什么重大BUG,有什么方法可以解决
  3. SpingCloud微服务架构学习(二)之Actuator监控
  4. JavaScript 中 call,apply 和 bind
  5. C#开发短信的方法和简介(转)
  6. 服务器返回的14种常见HTTP状态码
  7. DIV内数据删除操作
  8. CSS3制作3D旋转视频展示区
  9. 栅格那点儿事(二)---细看Raster属性
  10. Python开发环境Wing IDE如何检查Python集成