options=options)
self.emulator.login()
cmd = "mount | grep '/dev/root on / type f2fs'"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
options=["-drive", "file={},if=pflash".format(img)])
self.emulator.login()
cmd = "mount | grep '/dev/root on / type jffs2'"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
self.emulator.login()
cmd = "mount | grep '/dev/root on / type squashfs'"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
def check_init(self, path):
cmd = "cmp /proc/1/exe {}".format(path)
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
def check_network(self, interface, exitCode=0):
cmd = "ip addr show {} |grep inet".format(interface)
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, exitCode)
+ self.assertRunOk(cmd)
self.assertEqual(exit_code, 0)
self.assertEqual(out[0], "1")
- _, exit_code = self.emulator.run("mount -t proc none /proc")
- self.assertEqual(exit_code, 0)
+ self.assertRunOk("mount -t proc none /proc")
self.check_init("/bin/sh")
self.assertEqual(len(output), 0)
# Test we can reach the DBus daemon
- _, exit_code = self.emulator.run("busctl --no-pager")
- self.assertEqual(exit_code, 0)
+ self.assertRunOk("busctl --no-pager")
# Test we can read at least one line from the journal
output, _ = self.emulator.run("journalctl --no-pager --lines 1 --quiet")
self.emulator.login()
cmd = "atop -V | grep '^Version'"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "atop -a 1 2 | grep '% *atop *$'"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
def test_run(self):
self.login()
cmd = "/root/{}".format(os.path.basename(self.sample_script))
- _, exit_code = self.emulator.run(cmd, timeout=20)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout=20)
class TestPy2BmapTools(TestBmapTools):
def docker_test(self):
# will download container if not available, which may take some time
- _, exit_code = self.emulator.run('docker run --rm -p 8888:8888 busybox:latest /bin/true', 120)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk('docker run --rm -p 8888:8888 busybox:latest /bin/true', 120)
def docker_compose_test(self):
# will download container if not available, which may take some time
"-net", "user"])
self.emulator.login(self.passwd)
cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "sshpass -p {} ssh -y localhost /bin/true".format(self.passwd)
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
def module_test(self, module, script="a=1"):
cmd = "lua -l {} -e '{}'".format(module, script)
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
class TestLua(TestLuaBase):
self.emulator.login()
cmd = "wget localhost:19999 -O - | grep '<title>netdata dashboard</title>'"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
self.emulator.login(self.passwd)
cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "sshpass -p {} ssh -oStrictHostKeyChecking=no localhost /bin/true".format(self.passwd)
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
class TestOpenSshuClibc(TestOpensshBase):
# and prerm scripting provided in the package archive.
cmd = "opkg install example-snmpd-package_1.0_arm.ipk"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "opkg list-installed | grep example-snmpd-package"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
# Check that postinst script ran to start the services
cmd = "ps aux | grep [s]nmpd"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
# If successful, the prerm script ran to stop the service prior to
# the removal of the service scripting and files
cmd = "opkg remove example-snmpd-package"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
# Verify after package removal that the services is not
# running, but let's give it some time to really stop
def module_test(self, module, script="1"):
cmd = "perl -M{} -e '{}'".format(module, script)
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
class TestPerl(TestPerlBase):
def version_test(self, version, timeout=-1):
cmd = self.interpreter + " --version 2>&1 | grep '^{}'".format(version)
- _, exit_code = self.emulator.run(cmd, timeout)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout)
def math_floor_test(self, timeout=-1):
cmd = self.interpreter + " -c 'import math; math.floor(12.3)'"
- _, exit_code = self.emulator.run(cmd, timeout)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout)
def libc_time_test(self, timeout=-1):
cmd = self.interpreter + " -c 'from __future__ import print_function;"
cmd += "import ctypes;"
cmd += "libc = ctypes.cdll.LoadLibrary(\"libc.so.1\");"
cmd += "print(libc.time(None))'"
- _, exit_code = self.emulator.run(cmd, timeout)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout)
def zlib_test(self, timeout=-1):
cmd = self.interpreter + " -c 'import zlib'"
"""Run each script previously added to the image."""
for script in self.sample_scripts:
cmd = self.interpreter + " " + os.path.basename(script)
- _, exit_code = self.emulator.run(cmd, timeout=self.timeout)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout=self.timeout)
def test_run(self):
self.login()
def run_sample_scripts(self):
for script in self.sample_scripts:
cmd = self.interpreter + " -m pytest " + os.path.basename(script)
- _, exit_code = self.emulator.run(cmd, timeout=self.timeout)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout=self.timeout)
def run_sample_scripts(self):
for script in self.sample_scripts:
cmd = self.interpreter + " -m pytest " + os.path.basename(script)
- _, exit_code = self.emulator.run(cmd, timeout=self.timeout)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd, timeout=self.timeout)
options=["-initrd", cpio_file])
self.emulator.login()
- _, exit_code = self.emulator.run("redis-cli SET hello world")
- self.assertEqual(exit_code, 0)
+ self.assertRunOk("redis-cli SET hello world")
output, exit_code = self.emulator.run("redis-cli GET hello")
self.assertEqual(exit_code, 0)
def test_run(self):
self.build_test_prog()
self.login()
- _, exit_code = self.emulator.run(self.crate)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(self.crate)
class TestRust(TestRustBase):
def test_run(self):
self.build_test_prog()
self.login()
- _, exit_code = self.emulator.run(self.crate)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(self.crate)
self.assertEqual(exit_code, 100)
# Set up two service directories with a dependency
- self.emulator.run("mkdir -p source/testsv1")
- self.emulator.run("mkdir -p source/testsv2")
- self.emulator.run("echo oneshot > source/testsv1/type")
- self.emulator.run("echo oneshot > source/testsv2/type")
- self.emulator.run("echo 'echo foo' > source/testsv1/up")
- self.emulator.run("echo 'echo bar' > source/testsv2/up")
- self.emulator.run("echo testsv1 > source/testsv2/dependencies")
- self.emulator.run("chmod +x source/testsv1/up")
- self.emulator.run("chmod +x source/testsv2/up")
+ self.assertRunOk("mkdir -p source/testsv1")
+ self.assertRunOk("mkdir -p source/testsv2")
+ self.assertRunOk("echo oneshot > source/testsv1/type")
+ self.assertRunOk("echo oneshot > source/testsv2/type")
+ self.assertRunOk("echo 'echo foo' > source/testsv1/up")
+ self.assertRunOk("echo 'echo bar' > source/testsv2/up")
+ self.assertRunOk("echo testsv1 > source/testsv2/dependencies")
+ self.assertRunOk("chmod +x source/testsv1/up")
+ self.assertRunOk("chmod +x source/testsv2/up")
# Compile the service database
- _, exit_code = self.emulator.run("s6-rc-compile compiled source")
- self.assertEqual(exit_code, 0)
+ self.assertRunOk("s6-rc-compile compiled source")
# Inspect dependencies
cmd = "s6-rc-db -c compiled -d dependencies testsv1"
# -h set home directory
# -H don't create home directory
# -s set shell
- _, exit_code = self.emulator.run("adduser -D -h /tmp -H -s /bin/sh sudotest")
- self.assertEqual(exit_code, 0)
+ self.assertRunOk("adduser -D -h /tmp -H -s /bin/sh sudotest")
- _, exit_code = self.emulator.run("echo 'sudotest ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers")
- self.assertEqual(exit_code, 0)
+ self.assertRunOk("echo 'sudotest ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers")
output, exit_code = self.emulator.run("su - sudotest -c 'echo hello world'")
self.assertEqual(output, ["hello world"])
self.emulator.login()
cmd = "grep 'syslog-ng starting' /var/log/messages"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "logger my-message && "
cmd += "sleep 1 && "
cmd += "grep my-message /var/log/messages"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "syslog-ng-ctl reload && "
cmd += "sleep 1"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
+
cmd = "grep -i 'syslog-ng.*warning' /var/log/messages"
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 1)
self.emulator.login()
cmd = "tmux -V"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "tmux -C </dev/null"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "tmux split"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "tmux new-window"
- _, exit_code = self.emulator.run(cmd)
- self.assertEqual(exit_code, 0)
+ self.assertRunOk(cmd)
cmd = "tmux list-windows"
output, exit_code = self.emulator.run(cmd)