diff --git a/doc/index.rst b/doc/index.rst index 9b83f6f4edc2e4c5d1e9680623a9053c5741d56b..292107cd457fcdc7141fb982565ac16cfc18d31e 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -29,7 +29,7 @@ Contents: overview setup - lisa_shell + lisa_shell/man/man guides_separator diff --git a/doc/lisa_shell.rst b/doc/lisa_shell.rst deleted file mode 100644 index c5dac3045ae78bfd2e854cb5e4d985f7ef1838cd..0000000000000000000000000000000000000000 --- a/doc/lisa_shell.rst +++ /dev/null @@ -1,20 +0,0 @@ -********** -LISA shell -********** - -.. TODO:: Have the shell manpage here - -Once you have all of the required dependencies installed, you can use the LISA -shell, which provides a convenient set of commands for easy access to many LISA -related functions: - - .. code-block:: sh - - source init_env - -.. note:: - - This is done automatically by vagrant, so you don't have to issue this - command after doing a ``vagrant ssh`` - -.. tip:: Run ``lisa-help`` to see an overview of the provided LISA commands. diff --git a/doc/lisa_shell/man/Makefile b/doc/lisa_shell/man/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..51285967a7d9722c5bdee4f6a81c154a56aa0846 --- /dev/null +++ b/doc/lisa_shell/man/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/lisa_shell/man/conf.py b/doc/lisa_shell/man/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..01b2bca9654f1ccf87e1e665a0ec888c24e4f4b6 --- /dev/null +++ b/doc/lisa_shell/man/conf.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# Base Sphinx configuration for manpages +from lisa.doc.manconf import * + +# -- Project information ----------------------------------------------------- + +project = 'LISA shell' + +# The short X.Y version +version = '' +# The full version, including alpha/beta/rc tags +release = '1.0' + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'lisa', 'LISA shell commands', + [author], 1) +] + diff --git a/doc/lisa_shell/man/man.rst b/doc/lisa_shell/man/man.rst new file mode 100644 index 0000000000000000000000000000000000000000..4a03975a2bb7b34e12034dc6d2a596153ab7336e --- /dev/null +++ b/doc/lisa_shell/man/man.rst @@ -0,0 +1,115 @@ +********** +LISA shell +********** + +DESCRIPTION ++++++++++++ + +Once you have all of the required dependencies installed, you can use the LISA +shell, which provides a convenient set of commands for easy access to many LISA +related functions, scripts and environment variables. + + +ACTIVATION +++++++++++ + +In order to use the shell, source the script: + +.. code-block:: sh + + source init_env + +.. note:: + + This is done automatically by vagrant, so you don't have to issue this + command after doing a ``vagrant ssh`` + +.. tip:: Run ``man lisa`` to see an overview of the provided LISA commands. + + +COMMANDS +++++++++ + +Most LISA Shell commands start with ``lisa-``, thus using shell completion it +is easy to get a list of all the available commands. + +Here is the documentation of the simple ones, more complex scripts have +integrated ``--help`` documentation sections [#]_, or man pages. + +.. [#] ``_ + +Maintenance commands +-------------------- + + +* ``lisa-help`` - Show this help +* ``lisa-install`` - Remove the previous venv and do a fresh ven install +* ``lisa-version`` - Dump info on the LISA in use +* ``lisa-activate-venv`` - Activate the LISA venv, and create it if it does not exist +* ``lisa-deactivate-venv`` - Deactivate the LISA venv, and create it if it does not exist +* ``lisa-update-subtrees`` - Update the subtrees by pulling their latest changes +* ``lisa-log-subtree`` - Git log on the squashed commits of the given + subtree. All other options are passed to `git log`. + + +Notebooks commands +------------------ + +* ``lisa-jupyter`` - Start/Stop the Jupyter Notebook server. + + Usage: ``lisa-jupyter CMD [NETIF [PORT]]`` + + .. list-table:: + :widths: auto + :align: left + + * - `CMD` + - `start` to start the jupyter notebook server, `stop` to stop it + (default: `start`) + * - `NETIF` + - the network interface to start the server on (default: `lo`) + * - `PORT` + - the tcp port for the server (default: 8888) + +Test commands +------------- + +* ``lisa-test`` - Run LISA synthetic tests. + + This is just a wrapper around ``exekall`` that selects all tests modules and + use positional arguments as ``--select`` patterns. The default configuration + file (``$LISA_CONF``) will be used if available. This can be extended with + user-supplied ``--conf``. + + Usage: ``lisa-test TEST_PATTERN ... [EXEKALL_OPTIONS ...]`` + + Example: ``lisa-test 'OneSmallTask*' --list`` + + +* ``lisa-wltest-series`` - See :ref:`wltest main documentation` +* ``exekall`` - See :ref:`exekall main documentation` +* ``bisector`` - See :ref:`bisector main documentation` + +Buildroot commands +------------------ + +* ``lisa-buildroot-create-rootfs``- Create a buildroot based rootfs to be used + as userland for testing +* ``lisa-buildroot-update-kernel-config`` - Update a kernel config to bake a + buildroot initramfs into the kernel. + +ENVIRONMENT VARIABLES ++++++++++++++++++++++ + +The following environment variables are available: + +.. run-command:: + + # Strip-out version-specific info, so we have a more stable output + export LISA_VENV_PATH=".lisa-venv-" + env-list.py --rst --filter-home + +If an environment variable is defined prior to sourcing ``init_env``, it will +keep its value. + + diff --git a/doc/man1/lisa.1 b/doc/man1/lisa.1 new file mode 100644 index 0000000000000000000000000000000000000000..ef6e63957adbb889afc133be030756de5b1573f3 --- /dev/null +++ b/doc/man1/lisa.1 @@ -0,0 +1,258 @@ +.\" Man page generated from reStructuredText. +. +.TH "LISA" "1" "2019" "" "LISA shell" +.SH NAME +lisa \- LISA shell commands +. +.nr rst2man-indent-level 0 +. +.de1 rstReportMargin +\\$1 \\n[an-margin] +level \\n[rst2man-indent-level] +level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] +- +\\n[rst2man-indent0] +\\n[rst2man-indent1] +\\n[rst2man-indent2] +.. +.de1 INDENT +.\" .rstReportMargin pre: +. RS \\$1 +. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] +. nr rst2man-indent-level +1 +.\" .rstReportMargin post: +.. +.de UNINDENT +. RE +.\" indent \\n[an-margin] +.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] +.nr rst2man-indent-level -1 +.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] +.in \\n[rst2man-indent\\n[rst2man-indent-level]]u +.. +.SH DESCRIPTION +.sp +Once you have all of the required dependencies installed, you can use the LISA +shell, which provides a convenient set of commands for easy access to many LISA +related functions, scripts and environment variables. +.SH ACTIVATION +.sp +In order to use the shell, source the script: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +source init_env +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +\fBNOTE:\fP +.INDENT 0.0 +.INDENT 3.5 +This is done automatically by vagrant, so you don\(aqt have to issue this +command after doing a \fBvagrant ssh\fP +.UNINDENT +.UNINDENT +.sp +\fBTIP:\fP +.INDENT 0.0 +.INDENT 3.5 +Run \fBman lisa\fP to see an overview of the provided LISA commands. +.UNINDENT +.UNINDENT +.SH COMMANDS +.sp +Most LISA Shell commands start with \fBlisa\-\fP, thus using shell completion it +is easy to get a list of all the available commands. +.sp +Here is the documentation of the simple ones, more complex scripts have +integrated \fB\-\-help\fP documentation sections [1], or man pages. +.IP [1] 5 +\fI\%https://lisa\-linux\-integrated\-system\-analysis.readthedocs.io/en/master/\fP +.SS Maintenance commands +.INDENT 0.0 +.IP \(bu 2 +\fBlisa\-help\fP \- Show this help +.IP \(bu 2 +\fBlisa\-install\fP \- Remove the previous venv and do a fresh ven install +.IP \(bu 2 +\fBlisa\-version\fP \- Dump info on the LISA in use +.IP \(bu 2 +\fBlisa\-activate\-venv\fP \- Activate the LISA venv, and create it if it does not exist +.IP \(bu 2 +\fBlisa\-deactivate\-venv\fP \- Deactivate the LISA venv, and create it if it does not exist +.IP \(bu 2 +\fBlisa\-update\-subtrees\fP \- Update the subtrees by pulling their latest changes +.IP \(bu 2 +\fBlisa\-log\-subtree\fP \- Git log on the squashed commits of the given +subtree. All other options are passed to \fIgit log\fP\&. +.UNINDENT +.SS Notebooks commands +.INDENT 0.0 +.IP \(bu 2 +\fBlisa\-jupyter\fP \- Start/Stop the Jupyter Notebook server. +.INDENT 2.0 +.INDENT 3.5 +Usage: \fBlisa\-jupyter CMD [NETIF [PORT]]\fP +.TS +center; +|l|l|. +_ +T{ +\fICMD\fP +T} T{ +\fIstart\fP to start the jupyter notebook server, \fIstop\fP to stop it +(default: \fIstart\fP) +T} +_ +T{ +\fINETIF\fP +T} T{ +the network interface to start the server on (default: \fIlo\fP) +T} +_ +T{ +\fIPORT\fP +T} T{ +the tcp port for the server (default: 8888) +T} +_ +.TE +.UNINDENT +.UNINDENT +.UNINDENT +.SS Test commands +.INDENT 0.0 +.IP \(bu 2 +\fBlisa\-test\fP \- Run LISA synthetic tests. +.INDENT 2.0 +.INDENT 3.5 +This is just a wrapper around \fBexekall\fP that selects all tests modules and +use positional arguments as \fB\-\-select\fP patterns. The default configuration +file (\fB$LISA_CONF\fP) will be used if available. This can be extended with +user\-supplied \fB\-\-conf\fP\&. +.sp +Usage: \fBlisa\-test TEST_PATTERN ... [EXEKALL_OPTIONS ...]\fP +.sp +Example: \fBlisa\-test \(aqOneSmallTask*\(aq \-\-list\fP +.UNINDENT +.UNINDENT +.IP \(bu 2 +\fBlisa\-wltest\-series\fP \- See wltest main documentation +.IP \(bu 2 +\fBexekall\fP \- See exekall main documentation +.IP \(bu 2 +\fBbisector\fP \- See bisector main documentation +.UNINDENT +.SS Buildroot commands +.INDENT 0.0 +.IP \(bu 2 +\fBlisa\-buildroot\-create\-rootfs\fP\- Create a buildroot based rootfs to be used +as userland for testing +.IP \(bu 2 +\fBlisa\-buildroot\-update\-kernel\-config\fP \- Update a kernel config to bake a +buildroot initramfs into the kernel. +.UNINDENT +.SH ENVIRONMENT VARIABLES +.sp +The following environment variables are available: +.TS +center; +|l|l|l|. +_ +T{ +EXEKALL_ARTIFACT_ROOT +T} T{ +Default root for exekall\(aqs artifacts +T} T{ +results +T} +_ +T{ +LISA_CONF +T} T{ +Default configuration file for exekall +T} T{ +target_conf.yml +T} +_ +T{ +LISA_DEVMODE +T} T{ +By default use internal libraries +T} T{ +1 +T} +_ +T{ +LISA_HOME +T} T{ +Base directory of LISA environment +T} T{ +\&. +T} +_ +T{ +LISA_HOST_ABI +T} T{ +Add some shell utilities to the PATH, with lower priority than +system\(aqs one in case the user needs a different version of them +T} T{ +x86_64 +T} +_ +T{ +LISA_PRESERVE_SHELL +T} T{ +By default use Lisa\(aqs PS1 and colorscheme for the shell +T} T{ +0 +T} +_ +T{ +LISA_PYTHON +T} T{ +Python binary to use. This allows users to install multiple versions +in parallel, and ease testing +T} T{ +python3 +T} +_ +T{ +LISA_RESULT_ROOT +T} T{ +By default, store the results under that folder +T} T{ +results +T} +_ +T{ +LISA_USE_VENV +T} T{ +1 to make lisa\-install use a venv specified in LISA_VENV_PATH, 0 +otherwise +T} T{ +1 +T} +_ +T{ +LISA_VENV_PATH +T} T{ +Path to venv to be used by lisa\-install +T} T{ +\&.lisa\-venv\- +T} +_ +.TE +.sp +If an environment variable is defined prior to sourcing \fBinit_env\fP, it will +keep its value. +.SH AUTHOR +ARM-Software +.SH COPYRIGHT +2019, ARM-Software +.\" Generated by docutils manpage writer. +. diff --git a/doc/pedantic_build.sh b/doc/pedantic_build.sh index 599ee79d1027ef6d7f8f325ea04d84ac13772e38..258c8b614edf251710b275b5f1c4e16a35fa1687 100755 --- a/doc/pedantic_build.sh +++ b/doc/pedantic_build.sh @@ -64,6 +64,7 @@ echo docs=( "tools/bisector/doc/man/" "tools/exekall/doc/man/" + "doc/lisa_shell/man" ) for doc in "${docs[@]}"; do diff --git a/doc/workflows/wltest.rst b/doc/workflows/wltest.rst index b9081d631b1e9e03938e3411fe97101eacc8528c..41bb853c1fa80fb459bc304a418625cbad74d3ac 100644 --- a/doc/workflows/wltest.rst +++ b/doc/workflows/wltest.rst @@ -1,3 +1,5 @@ +.. _wltest-doc: + ****** Wltest ****** diff --git a/shell/README.txt b/shell/README.txt deleted file mode 100644 index c9863a6e387d8af15e4bd5183cc6d70f75a964c4..0000000000000000000000000000000000000000 --- a/shell/README.txt +++ /dev/null @@ -1,39 +0,0 @@ - -All LISA Shell commands start with "lisa-", thus using shell completion it is -easy to get a list of all the available commands. - -Here is a list of the main ones, with a short description. -For a longer description type "lisa- help" - -.:: Generic commands --------------------- - -lisa-help - Print this help, or command specific helps -lisa-version - Dump info on the LISA in use -lisa-buildroot-create-rootfs - Create a buildroot based rootfs to be used as userland for testing - -.:: Maintenance commands ------------------------- - -lisa-install - Remove the previous venv and do a fresh ven install -lisa-activate-venv - Activate the LISA venv, and create it if it does not exist -lisa-deactivate-venv - Deactivate the LISA venv, and create it if it does not exist -lisa-update-subtrees - Update the subtrees by pulling their latest changes -lisa-log-subtree - Git log on the squashed commits of the give subtree. All other - options are passed to `git log`. - -.:: Notebooks commands ----------------------- - -lisa-jupyter - Start/Stop the Jupyter Notebook server - -.:: Test commands --------------------------------------- - -lisa-test - Run tests and assert behaviours. - This is just a wrapper around exekall that selects all tests - modules and use positional arguments as --select patterns. Also - the default configuration file ($LISA_HOME/target_conf.yml) will - be used if available (but this can be extended with - user-supplied --conf). - diff --git a/shell/lisa_shell b/shell/lisa_shell index ab593bb163f23d5879bd7641e59d25b465dd5f19..bf68e431c100197ef32ecf7552433fdf59bb18f9 100755 --- a/shell/lisa_shell +++ b/shell/lisa_shell @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2015, ARM Limited and contributors. +# Copyright (C) 2019, ARM Limited and contributors. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. @@ -23,26 +23,34 @@ # Set environment variables ################################################################################ -# Python binary to use. This allows users to install multiple versions in -# parallel, and ease testing +export _DOC_LISA_HOME="Base directory of LISA environment" + +export _DOC_LISA_PYTHON="Python binary to use. This allows users to install +multiple versions in parallel, and ease testing" export LISA_PYTHON=${LISA_PYTHON:-python3} -# By default use internal libraries +export _DOC_LISA_DEVMODE="By default use internal libraries" export LISA_DEVMODE=${LISA_DEVMODE:-1} -# By default use Lisa's PS1 and colorscheme for the shell +export _DOC_LISA_PRESERVE_SHELL="By default use Lisa's PS1 and colorscheme for +the shell" export LISA_PRESERVE_SHELL=${LISA_PRESERVE_SHELL:-0} # Setup colors source "$LISA_HOME/shell/lisa_colors" -# Add some shell utilities to the PATH, with lower priority than system's one -# in case the user needs a different version of them +export _DOC_LISA_HOST_ABI="Add some shell utilities to the PATH, with lower +priority than system's one in case the user needs a different version of them" export LISA_HOST_ABI=${LISA_HOST_ABI:-x86_64} export PATH=$PATH:$LISA_HOME/shell/:$LISA_HOME/tools/$LISA_HOST_ABI:$LISA_HOME/tools +export _DOC_LISA_CONF="Default configuration file for exekall" export LISA_CONF=${LISA_CONF:-$LISA_HOME/target_conf.yml} + +export _DOC_LISA_RESULT_ROOT="By default, store the results under that folder" export LISA_RESULT_ROOT=${LISA_RESULT_ROOT:-$LISA_HOME/results} + +export _DOC_EXEKALL_ARTIFACT_ROOT="Default root for exekall's artifacts" export EXEKALL_ARTIFACT_ROOT=${EXEKALL_ARTIFACT_ROOT:-$LISA_RESULT_ROOT} # Add our man pages @@ -71,16 +79,8 @@ function clear { # Generic LISA Shell commands ################################################################################ -# LISA Shell On-Line HELP function lisa-help { - clear - echo -e "$LISASHELL_HELP" - echo " " - echo " .:: LISA Shell - HELP On-Line ::. " - echo " " - echo -ne "$LISASHELL_RESET$LISASHELL_GREEN" - cat "$LISA_HOME/shell/README.txt" - echo -ne "$LISASHELL_DEFAULT" + man lisa } function lisa-version { @@ -105,7 +105,10 @@ EOF # major.minor version number PYTHON_VERSION=$(_lisa-python -c 'import sys; print("{}.{}".format(*sys.version_info))') +export _DOC_LISA_USE_VENV="1 to make lisa-install use a venv specified in +LISA_VENV_PATH, 0 otherwise" export LISA_USE_VENV=${LISA_USE_VENV:-1} +export _DOC_LISA_VENV_PATH="Path to venv to be used by lisa-install" export LISA_VENV_PATH=${LISA_VENV_PATH:-"$LISA_HOME/.lisa-venv-$PYTHON_VERSION"} @@ -262,15 +265,6 @@ function lisa-log-subtree { # LISA Notebooks utility functions ################################################################################ -function _lisa-jupyter-usage { - echo "Usage: lisa-jupyter CMD [NETIF [PORT]]" - echo " CMD - Jupyter Notebooks command (deafult: start)" - echo " start start the jupyter server" - echo " stop stop the jupyter server" - echo " NETIF - the network interface to start the server on (default: lo)" - echo " PORT - the tcp port for the server (default: 8888)" -} - function _lisa-jupyter-start { # Get IP address for the specified interface IPADDR= @@ -371,7 +365,7 @@ function lisa-jupyter { _lisa-jupyter-stop ;; "help"|*) - _lisa-jupyter-usage + echo "see 'man lisa'" ;; esac echo @@ -441,7 +435,7 @@ Welcome to the Linux Integrated System Analysis SHELL! $(lisa-version) -Type "lisa-help" for on-line help on available commands +Type "man lisa" for help on available commands EOF # Setup default SHELL text color @@ -452,6 +446,6 @@ fi # Show relevant env var echo "Environment variables:" -printenv | grep --color=no -E 'LISA|EXEKALL' | sort +env-list.py # vim: set tabstop=4 shiftwidth=4 textwidth=80 expandtab: diff --git a/tools/env-list.py b/tools/env-list.py new file mode 100755 index 0000000000000000000000000000000000000000..2506642015fd8dae800ff271cbff6c86a5f095b8 --- /dev/null +++ b/tools/env-list.py @@ -0,0 +1,99 @@ +#! /usr/bin/env python3 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2019, ARM Limited and contributors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os +import textwrap +import argparse + +VAR_PREFIX = ['LISA', 'BISECTOR', 'EXEKALL'] +TABLE_HEADER = """ +.. list-table:: + :widths: auto + :align: left +""" + +def format_doc(doc, style=None): + if not doc: + return '' + + doc = doc.strip() + doc = textwrap.fill(doc) + + if style == 'rst': + return doc + else: + return "# {}\n".format(doc.replace("\n", "\n# ")) + +def main(): + parser = argparse.ArgumentParser( + description="List LISA environment variable, their value and doc" + ) + parser.add_argument('--rst', + action='store_true', + help='format as reStructuredText' + ) + parser.add_argument('--filter-home', + action='store_true', + help='filter out the value of LISA_HOME from the env var val' + ) + args = parser.parse_args() + + style = 'rst' if args.rst else None + filter_lisa_home = args.filter_home + + env_list = [ + var for var in os.environ.keys() + if any(var.startswith(prefix) for prefix in VAR_PREFIX) + ] + + doc_map = { + var: os.getenv("_DOC_{}".format(var)) + for var in env_list + } + + if style == 'rst': + print(TABLE_HEADER) + + LISA_HOME = os.environ['LISA_HOME'] + for var, doc in sorted(doc_map.items(), key=lambda k_v: k_v[0]): + val = os.getenv(var) + if filter_lisa_home and os.path.isabs(val): + val = os.path.relpath(val, LISA_HOME) + + doc = format_doc(doc, style=style) + + if style == 'rst': + entry = "* - {var}\n - {doc}\n - {val}".format( + var=var, + doc=doc.replace('\n', '\n '), + val=val + ) + entry = textwrap.indent(entry, ' ' * 2) + else: + entry = "{doc}{var}={val}\n".format( + var=var, + doc=doc, + val=val, + ) + + print(entry) + +if __name__ == '__main__': + main() +