test_syslog_ng.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import infra.basetest
  3. class TestSyslogNg(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_LINUX_KERNEL=y
  7. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  8. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.16"
  9. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  10. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux.config"
  11. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"
  12. BR2_LINUX_KERNEL_DTS_SUPPORT=y
  13. BR2_LINUX_KERNEL_INTREE_DTS_NAME="versatile-pb"
  14. BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
  15. BR2_PACKAGE_SYSLOG_NG=y
  16. BR2_TARGET_ROOTFS_CPIO=y
  17. # BR2_TARGET_ROOTFS_TAR is not set
  18. """.format(infra.filepath("conf/syslog-ng-kernel-fragment.config"))
  19. def test_run(self):
  20. kernel = os.path.join(self.builddir, "images", "zImage")
  21. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  22. dtb = os.path.join(self.builddir, "images", "versatile-pb.dtb")
  23. options = ["-M", "versatilepb",
  24. "-dtb", dtb,
  25. "-initrd", cpio_file,
  26. "-device", "virtio-rng-pci"]
  27. self.emulator.boot(arch="armv5", kernel=kernel, options=options)
  28. self.emulator.login()
  29. cmd = "grep syslog-ng /var/log/messages | grep starting"
  30. _, exit_code = self.emulator.run(cmd)
  31. self.assertEqual(exit_code, 0)
  32. cmd = "logger my-message;"
  33. cmd += "sleep 1;"
  34. cmd += "grep my-message /var/log/messages"
  35. _, exit_code = self.emulator.run(cmd)
  36. self.assertEqual(exit_code, 0)
  37. cmd = "syslog-ng-ctl reload;"
  38. cmd += "sleep 1;"
  39. cmd += "grep syslog-ng /var/log/messages | grep -i warning"
  40. _, exit_code = self.emulator.run(cmd)
  41. self.assertEqual(exit_code, 1)