test_fluidsynth.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import os
  2. import infra.basetest
  3. class TestFluidsynth(infra.basetest.BRTest):
  4. # infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it is
  5. # armv5 and based on qemu versatilepb which is limited to 256MB of
  6. # RAM. The test needs 1GB of RAM (larger initrd and soundfont is
  7. # loaded in memory).
  8. config = \
  9. """
  10. BR2_aarch64=y
  11. BR2_TOOLCHAIN_EXTERNAL=y
  12. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  13. BR2_LINUX_KERNEL=y
  14. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  15. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.86"
  16. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  17. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  18. BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
  19. BR2_PACKAGE_AUBIO=y
  20. BR2_PACKAGE_FLUIDSYNTH=y
  21. BR2_PACKAGE_FLUIDSYNTH_LIBSNDFILE=y
  22. BR2_PACKAGE_FLUID_SOUNDFONT=y
  23. BR2_PACKAGE_PYTHON3=y
  24. BR2_PACKAGE_PYTHON_MIDIUTIL=y
  25. BR2_ROOTFS_OVERLAY="{}"
  26. BR2_TARGET_ROOTFS_CPIO=y
  27. # BR2_TARGET_ROOTFS_TAR is not set
  28. """.format(
  29. # overlay to add helper test scripts
  30. infra.filepath("tests/package/test_fluidsynth/rootfs-overlay"))
  31. def test_run(self):
  32. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  33. kern = os.path.join(self.builddir, "images", "Image")
  34. self.emulator.boot(arch="aarch64",
  35. kernel=kern,
  36. kernel_cmdline=["console=ttyAMA0"],
  37. options=["-M", "virt", "-cpu", "cortex-a57", "-m", "1G", "-initrd", img])
  38. self.emulator.login()
  39. # Test the binary executes
  40. self.assertRunOk("fluidsynth --version")
  41. # Create a simple MIDI file programmatically
  42. self.assertRunOk("/root/gen_midi_file.py /tmp/output.mid")
  43. # Convert the MIDI file to a WAV file
  44. cmd = "fluidsynth"
  45. cmd += " -F /tmp/output.wav"
  46. cmd += " /usr/share/soundfonts/FluidR3_GM.sf2"
  47. cmd += " /tmp/output.mid"
  48. self.assertRunOk(cmd)
  49. # Extract notes in the WAV file with Aubio
  50. self.assertRunOk("aubionotes /tmp/output.wav > /tmp/notes.txt")
  51. # Check the extracted notes are the expected ones
  52. self.assertRunOk("/root/check_notes.py < /tmp/notes.txt")