mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-27 04:20:38 -09:00
package/octave: new package
GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab. It may also be used as a batch-oriented language. Octave has extensive tools for solving common numerical linear algebra problems, finding the roots of nonlinear equations, integrating ordinary functions, manipulating polynomials, and integrating ordinary differential and differential-algebraic equations. It is easily extensible and customizable via user-defined functions written in Octave's own language, or using dynamically loaded modules written in C++, C, Fortran, or other languages. https://www.octave.org/ Signed-off-by: Julien Olivain <ju.o@free.fr> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
committed by
Arnout Vandecappelle (Essensium/Mind)
parent
adb8399a9e
commit
40ea68b4b2
79
support/testing/tests/package/test_octave.py
Normal file
79
support/testing/tests/package/test_octave.py
Normal file
@@ -0,0 +1,79 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestOctave(infra.basetest.BRTest):
|
||||
# infra.basetest.BASIC_TOOLCHAIN_CONFIG cannot be used as it does
|
||||
# not include gfortran.
|
||||
config = \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.26"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
BR2_TARGET_ROOTFS_CPIO_GZIP=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_PACKAGE_OCTAVE=y
|
||||
"""
|
||||
timeout = 60
|
||||
|
||||
def octave_cmd(self, octave_expr):
|
||||
return "octave --quiet --eval '{}'".format(octave_expr)
|
||||
|
||||
def test_run(self):
|
||||
img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
|
||||
kern = os.path.join(self.builddir, "images", "Image")
|
||||
self.emulator.boot(arch="aarch64",
|
||||
kernel=kern,
|
||||
kernel_cmdline=["console=ttyAMA0"],
|
||||
options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M", "-initrd", img])
|
||||
self.emulator.login()
|
||||
|
||||
# Check Euler identity
|
||||
cmd = self.octave_cmd("assert (exp(i*pi)+1, 0, 1e-10)")
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
# Solve equation system example from Octave homepage
|
||||
octave_expr = "b = [4; 9; 2]; "
|
||||
octave_expr += "A = [ 3 4 5; 1 3 1; 3 5 9 ]; "
|
||||
octave_expr += "x = A \ b; "
|
||||
octave_expr += "assert(x, [-1.5; 4; -1.5], 1e-10)"
|
||||
cmd = self.octave_cmd(octave_expr)
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
# Check octave can fail
|
||||
cmd = self.octave_cmd("assert(false)")
|
||||
_, exit_code = self.emulator.run(cmd)
|
||||
self.assertNotEqual(exit_code, 0)
|
||||
|
||||
# Check string output
|
||||
string = "Hello World"
|
||||
cmd = self.octave_cmd("printf(\"{}\\n\")".format(string))
|
||||
output, exit_code = self.emulator.run(cmd)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertEqual(output, [string])
|
||||
|
||||
# Run some octave self tests
|
||||
octave_modules = [
|
||||
"elfun/atan2d",
|
||||
"elfun/sind",
|
||||
"general/gradient",
|
||||
"general/num2str",
|
||||
"polynomial/poly",
|
||||
"signal/fftconv",
|
||||
"special-matrix/magic",
|
||||
"specfun/isprime",
|
||||
"statistics/corr",
|
||||
"strings/str2num"
|
||||
]
|
||||
|
||||
for mod in octave_modules:
|
||||
cmd = self.octave_cmd('assert(test(\"{}\"),true)'.format(mod))
|
||||
self.assertRunOk(cmd)
|
||||
Reference in New Issue
Block a user