test_ethtool.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import os
  2. import infra.basetest
  3. class TestEthtool(infra.basetest.BRTest):
  4. # This ethtool test uses an emulated Intel e1000e adapted (which
  5. # is well supported by Qemu, the Kernel and ethtool). We are not
  6. # using the usual virtio_net because it's not supporting some
  7. # ethtool features like adapter testing. For that reason, we need
  8. # to compile a Kernel.
  9. kernel_fragment = \
  10. infra.filepath("tests/package/test_ethtool/linux-e1000e.fragment")
  11. config = \
  12. f"""
  13. BR2_aarch64=y
  14. BR2_TOOLCHAIN_EXTERNAL=y
  15. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  16. BR2_LINUX_KERNEL=y
  17. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  18. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.27"
  19. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  20. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  21. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kernel_fragment}"
  22. BR2_PACKAGE_ETHTOOL=y
  23. BR2_TARGET_ROOTFS_EXT2=y
  24. BR2_TARGET_ROOTFS_EXT2_4=y
  25. # BR2_TARGET_ROOTFS_TAR is not set
  26. """
  27. def test_run(self):
  28. drive = os.path.join(self.builddir, "images", "rootfs.ext4")
  29. kern = os.path.join(self.builddir, "images", "Image")
  30. self.emulator.boot(arch="aarch64",
  31. kernel=kern,
  32. kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
  33. options=["-M", "virt",
  34. "-cpu", "cortex-a57",
  35. "-m", "256M",
  36. "-netdev", "user,id=test_net",
  37. "-net", "nic,model=e1000e,netdev=test_net",
  38. "-drive", f"file={drive},if=virtio,format=raw"])
  39. self.emulator.login()
  40. # We check the program can run.
  41. self.assertRunOk("ethtool --version")
  42. # We check a simple query runs correctly.
  43. self.assertRunOk("ethtool eth0")
  44. # We query the driver name and check it's the expected e1000e.
  45. out, ret = self.emulator.run("ethtool -i eth0")
  46. self.assertEqual(ret, 0)
  47. self.assertEqual(out[0], "driver: e1000e")
  48. # We request an adapter online self test.
  49. self.assertRunOk("ethtool -t eth0 online", timeout=30)
  50. # We query offload parameters and check TSO are enabled (this
  51. # is the driver default).
  52. out, ret = self.emulator.run("ethtool -k eth0")
  53. self.assertEqual(ret, 0)
  54. self.assertIn("tcp-segmentation-offload: on", out)
  55. # We request to disable TSO.
  56. self.assertRunOk("ethtool -K eth0 tcp-segmentation-offload off")
  57. # We check again. TSO should now be disabled.
  58. out, ret = self.emulator.run("ethtool -k eth0")
  59. self.assertEqual(ret, 0)
  60. self.assertIn("tcp-segmentation-offload: off", out)