The test environment is primarily defined by the target configuration (see conf below).
One can also pass the test configuration - definining which software setups are needed on the hardware target, and a location for the results of the experiments.
Parameters:
In [1]:
# One initial cell for imports
import json
import time
import os
import logging
In [2]:
from conf import LisaLogging
LisaLogging.setup()
# For debug information use:
# LisaLogging.setup(level=logging.DEBUG)
Target configuration:
platform - the currently supported boards are:
board - the currently supported boards are:
host - target IP or MAC address
device - target Android device ID
port - port for Android connection - default port is 5555
ANDROID_HOME - path to android-sdk-linux
username
password
keyfile - you can either specify a password or a keyfile
rtapp-calib - these values are not supposed to be specified at the first run on a target. After the first run, it's best to fill this array with values reported in the log messges for your specific target, for these not to be obtained again.
tftp - tftp server from where the target gets kernel/dtb images at each boot
modules - devlib modules to be enabled
exclude_modules - devlib modules to be disabled
tools - binary tools (available under ./tools/$ARCH/) to install by default
ping_time - wait time before trying to access the target after reboot
reboot_time - maximum time to wait after rebooting the target
features - list of test environment features to enable
ftrace - ftrace configuration
results_dir - location of results of the experiments
In [3]:
# Setup a target configuration
conf = {
# Platform
"platform" : "linux",
# Board
"board" : "juno",
# Login credentials
"host" : "192.168.0.1",
"username" : "root",
# You can specify either a password or keyfile
"password" : "juno",
# "keyfile" : "/complete/path/of/your/keyfile",
# Tools to deploy
"tools" : [ "rt-app", "taskset" ],
"tftp" : {
"folder" : "/var/lib/tftpboot/",
"kernel" : "Image",
"dtb" : "juno.dtb"
},
#"ping_time" : "15",
#"reboot_time" : "180",
# RTApp calibration values (comment to let LISA do a calibration run)
"rtapp-calib" : {
"0": 358, "1": 138, "2": 138, "3": 357, "4": 359, "5": 355
},
# FTrace configuration
"ftrace" : {
"events" : [
"cpu_idle",
"sched_switch",
],
"buffsize" : 10240,
},
# Where results are collected
"results_dir" : "TestEnvExample",
#"__features__" : "no-kernel no-reboot"
}
In [5]:
from env import TestEnv
# Initialize a test environment using the provided configuration
te = TestEnv(conf)
In [6]:
# The complete configuration of the target we have configured
print json.dumps(te.conf, indent=4)
In [7]:
# Last configured kernel and DTB image
print te.kernel
print te.dtb
In [8]:
# The IP and MAC address of the target
print te.ip
print te.mac
In [9]:
# A full platform descriptor
print json.dumps(te.platform, indent=4)
In [10]:
# This is a pre-created folder to host the tests results generated using this
# test environment. Notice that the suite could add additional information
# in this folder, like for example a copy of the target configuration
# and other target specific collected information.
te.res_dir
Out[10]:
In [11]:
# The working directory on the target
te.workdir
Out[11]:
In [12]:
# The target topology, which can be used to build BART assertions
te.topology
Out[12]:
In [13]:
# Calibrate RT-App (if required) and get the most updated calibration value
te.calibration()
Out[13]:
In [14]:
# Generate a JSON file with the complete platform description
te.platform_dump(dest_dir='/tmp')
Out[14]:
In [15]:
# Force a reboot of the target (and wait specified [s] before reconnect)
# Keep in mind that a reboot can be disabled from __features__ in the target configuration
te.reboot(reboot_time=360, ping_time=15)
In [18]:
# Resolve a MAC address into an IP address
te.resolv_host(host='00:02:F7:00:5A:5B')
Out[18]:
In [16]:
# Copy the specified file into the TFTP server folder defined by configuration
te.tftp_deploy('/etc/group')
A special attribute of TestEnv is target, which represents a devlib instance. Using the target attribute we have access to the full set of devlib provided functionalities. A small set of these are exemplified below. For a more extensive set check the examples/devlib notebooks.
In [16]:
# Run a command on the target
te.target.execute("echo -n 'Hello Test Environment'", as_root=False)
Out[16]:
In [17]:
# Spawn a command in background on the target
te.target.kick_off("sleep 10", as_root=True)
Out[17]:
In [18]:
# Acces to many target specific information
print "ABI : ", te.target.abi
print "big Core Family : ", te.target.big_core
print "LITTLE Core Family : ", te.target.little_core
print "CPU's Clusters IDs : ", te.target.core_clusters
print "CPUs type : ", te.target.core_names
In [19]:
# Access to big.LITTLE specific information
print "big CPUs IDs : ", te.target.bl.bigs
print "LITTLE CPUs IDs : ", te.target.bl.littles
print "big CPUs freqs : {}".format(te.target.bl.get_bigs_frequency())
print "big CPUs governor : {}".format(te.target.bl.get_bigs_governor())
In [20]:
# Reset and sample energy counters
te.emeter.reset()
nrg = te.emeter.sample()
nrg = json.dumps(te.emeter.sample(), indent=4)
print "First read: ", nrg
time.sleep(2)
nrg = te.emeter.sample()
nrg = json.dumps(te.emeter.sample(), indent=4)
print "Second read: ", nrg
In [21]:
# Configure a specific set of events to trace
te.ftrace_conf(
{
"events" : [
"cpu_idle",
"cpu_capacity",
"cpu_frequency",
"sched_switch",
],
"buffsize" : 10240
}
)
In [22]:
# Start/Stop a FTrace session
te.ftrace.start()
te.target.execute("uname -a")
te.ftrace.stop()
In [23]:
# Collect and visualize the trace
trace_file = os.path.join(te.res_dir, 'trace.dat')
te.ftrace.get_trace(trace_file)
# There might be a different display value on your machine
# Check by issuing "echo $DISPLAY" in the LISA VM
output = os.popen("DISPLAY=:10.0 kernelshark {}".format(trace_file))