### Install Avocado Plugin Example Source: https://github.com/avocado-framework/avocado/blob/master/examples/plugins/README.rst Installs an Avocado plugin example on a development environment. This command requires navigating to the specific plugin's directory before execution. ```bash cd /\npython setup.py develop --user ``` -------------------------------- ### Install HTML Plugin from Source Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst A specific example of installing an optional plugin, the HTML plugin, from the source tree's 'optional_plugins' directory. ```shell pip install optional_plugins/html --user ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/environment.rst Installs Python packages specifically required for building the project's documentation locally. ```shell pip install -r requirements-doc.txt ``` -------------------------------- ### Install Optional Plugins (Development) Source: https://github.com/avocado-framework/avocado/blob/master/optional_plugins/README.rst Installs optional plugins shipped with Avocado for development environments. This typically involves navigating to the plugin directory and running the setup script. ```shell cd / python setup.py develop --user ``` -------------------------------- ### Install System Dependencies Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/environment.rst Installs essential system packages required for Avocado development using the DNF package manager. ```shell sudo dnf install gcc python-devel enchant ``` -------------------------------- ### Install Avocado in Develop Mode Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/environment.rst Sets up the Avocado project in 'develop' mode, linking the source tree for active development and enabling Setuptools entry points for plugins. ```shell python3 setup.py develop [--user] ``` -------------------------------- ### Install Avocado from Source Code Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Installs Avocado from its git repository. This involves cloning the repository, navigating into the directory, and using pip to install. ```shell $ git clone git://github.com/avocado-framework/avocado.git $ cd avocado $ pip install . --user ``` -------------------------------- ### Avocado Test with Binary Dependency Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/writer/chapters/writing.rst An example Avocado test class (`BinSleep`) that uses `setUp` to find and ensure a binary dependency (`sleep`) is available, installing it if necessary, before running the test. ```python from avocado import Test from avocado.utils.software_manager import distro_packages from avocado.utils import path as utils_path from avocado.utils import process class BinSleep(Test): """ Sleeps using the /bin/sleep binary """ def setUp(self): self.sleep = None try: self.sleep = utils_path.find_command('sleep') except utils_path.CmdNotFoundError: distro_packages.install_distro_packages({'fedora': ['coreutils']}) self.sleep = utils_path.find_command('sleep') def test(self): process.run("%s 1" % self.sleep) ``` -------------------------------- ### All-in-one Execution in Container (Podman) Source: https://github.com/avocado-framework/avocado/blob/master/selftests/deployment/README.rst An example command to run the Avocado deployment playbook within a fresh container using Podman. It sets up necessary dependencies like git and ansible, clones the repository, and executes the playbook via `ansible-pull`. ```bash RUN_BEFORE='dnf install -y git ansible' GIT_URL='git://github.com/avocado-framework/avocado' INVENTORY='selftests/deployment/inventory' PLAYBOOK='selftests/deployment/deployment.yml' podman run --rm -ti fedora:30 /bin/bash -c '${RUN_BEFORE} && ansible-pull \ -v -U ${GIT_URL} -i ${INVENTORY} -c local ${PLAYBOOK}' ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/environment.rst Installs Python development dependencies using make or pip, essential for running tests and contributing to the project. ```shell make requirements-dev ``` ```shell pip install -r requirements-dev.txt ``` -------------------------------- ### Run Avocado Deployment Playbook Source: https://github.com/avocado-framework/avocado/blob/master/selftests/deployment/README.rst Executes the main `deployment.yml` Ansible playbook to test Avocado installation. This command specifies the inventory, connection type, playbook file, and passes an extra variable for the installation method. ```bash ansible-playbook -i inventory -c local deployment.yml -e "method=pip" ``` -------------------------------- ### Install Avocado from Source Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/52_0.rst Installs the Avocado framework from its source code using the provided Makefile. This method requires manual installation of optional plugins. ```bash # Build and install the core framework make install # To install optional plugins, navigate to their directory and install manually: cd optional_plugins/html sudo python setup.py install ``` -------------------------------- ### Install Optional Plugin from Source Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Installs an optional plugin for Avocado from the source tree. Plugins are located in the 'optional_plugins' directory. ```shell pip install optional_plugins/ --user ``` -------------------------------- ### Install Base Packages for Building from Source (Fedora) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Installs essential packages required for building Avocado from source on Fedora-based distributions. This includes Python 3, git, gcc, and pip. ```shell $ sudo dnf install -y python3 git gcc python3-pip ``` -------------------------------- ### Install Read the Docs Theme Source: https://github.com/avocado-framework/avocado/blob/master/docs/README.rst Installs the read the docs theme for Sphinx using pip, to match the online documentation appearance. ```shell $ sudo pip install sphinx_rtd_theme ``` -------------------------------- ### Install Golang Plugin Source: https://github.com/avocado-framework/avocado/blob/master/optional_plugins/golang/README.rst Installs the Golang plugin for the Avocado framework using pip. This enables the framework to discover and execute tests written in Go. ```shell sudo pip install avocado-framework-plugin-golang ``` -------------------------------- ### Install Golang Plugin Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/plugins/optional/golang.rst Installs the Golang plugin for the Avocado framework using pip. This enables the framework to discover and execute tests written in Go. ```shell sudo pip install avocado-framework-plugin-golang ``` -------------------------------- ### Set up Python Virtual Environment for Avocado Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Creates and activates a Python virtual environment for isolated Avocado installation. This ensures dependencies do not conflict with system Python packages. ```shell python3 -m venv /path/to/new/virtual_environment source /path/to/new/virtual_environment/bin/activate pip3 install avocado-framework ``` -------------------------------- ### Install Avocado via PyPI/pip Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/52_0.rst Installs the Avocado framework and its optional plugins from the Python Package Index (PyPI) using pip. This is the recommended method for most users. ```bash pip install avocado-framework* # Or install specific plugins individually: pip install avocado-framework-plugin-name ``` -------------------------------- ### setup.py Script Improvements Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/91_0.rst The 'setup.py' script has undergone significant improvements, including the implementation of a new 'test' command and a 'plugin' command. Additional tests for 'setup.py' have also been integrated into the CI. ```bash python setup.py test python setup.py plugin ``` -------------------------------- ### Register Plugin with Setuptools Entry Points (Python) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/plugins.rst Explains the standard method for making Avocado plugins discoverable by the framework. This is achieved by defining entry points in a `setup.py` file using `setuptools`, specifically under the `avocado.plugins.` namespace, followed by the plugin type (e.g., `avocado.plugins.cli-cmd`). ```Python from setuptools import setup, find_packages setup( name='avocado-hello-plugin', version='0.1.0', packages=find_packages(), entry_points={ 'avocado.plugins.cli-cmd': [ 'hello = hello_plugin:HelloCommand' ] }, # Other metadata like author, description, etc. ) ``` -------------------------------- ### Avocado Cloudinit Module Introduction Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/69_0.rst A new module, `avocado.utils.cloudinit`, has been introduced to aid in tasks related to cloud-init configurations. ```python # Conceptual usage of the new cloudinit module # from avocado.utils import cloudinit # cloudinit.configure_instance(...) ``` -------------------------------- ### Avocado Run Command Examples Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/introduction.rst Demonstrates how to execute tests using the `avocado run` command, including options for ignoring missing test references and observing live job outputs. ```APIDOC Command: avocado run Usage: avocado run [ ...] [--ignore-missing-references] Description: Executes specified test references. If test references cannot be resolved, the job creation fails by default. The `--ignore-missing-references` option allows the job to proceed with resolvable tests. Examples: # Running tests and encountering a missing reference: $ avocado run examples/tests/passtest.py badtest.py No tests found for given test references: badtest.py Try 'avocado -V list badtest.py' for details # Running tests while ignoring missing references: $ avocado run examples/tests/passtest.py badtest.py --ignore-missing-references JOB ID : e6d1f4d21d6a5e2e039f1acd1670a6882144c189 JOB LOG : $HOME/avocado/job-results/job-2021-09-27T16.50-e6d1f4d/job.log (1/1) examples/tests/passtest.py:PassTest.test: STARTED (1/1) examples/tests/passtest.py:PassTest.test: PASS (0.01 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB TIME : 1.49 s # Running multiple tests and observing live output: $ avocado run examples/tests/sleeptest.py examples/tests/failtest.py JOB ID : 2e83086e5d3f82dd68bdc8885e7cce1cebec5f27 JOB LOG : $HOME/avocado/job-results/job-2021-09-27T17.00-2e83086/job.log (1/2) examples/tests/sleeptest.py:SleepTest.test: STARTED (2/2) examples/tests/failtest.py:FailTest.test: STARTED (2/2) examples/tests/failtest.py:FailTest.test: FAIL: This test is supposed to fail (0.02 s) (1/2) examples/tests/sleeptest.py:SleepTest.test: PASS (1.01 s) RESULTS : PASS 1 | ERROR 0 | FAIL 1 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB HTML : $HOME/avocado/job-results/job-2021-09-27T17.00-2e83086/results.html JOB TIME : 2.80 s Output Formats: Avocado provides a live, text-based UI for ongoing test execution and generates an HTML report upon job completion (requires 'html' plugin). ``` -------------------------------- ### Line-by-Line Profiling with line_profiler Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/tips.rst Instructions for installing and using the `line_profiler` package to perform detailed line-by-line performance analysis of Python code. It covers installation via pip and execution using the `kernprof` command. ```bash # Install line_profiler pip install line_profiler # Mark function with @profile (no import needed) # Example: # @profile # def my_slow_function(): # ... # Run profiling kernprof -l -v avocado run ... ``` -------------------------------- ### Avocado Installation Methods (Ansible) Source: https://github.com/avocado-framework/avocado/blob/master/selftests/deployment/README.rst Demonstrates how to specify the installation method for Avocado using the `method` variable passed via the `-e` option to `ansible-playbook`. Supported methods include `pip`, `copr`, and `official`. ```bash # Install via pip (default) ansible-playbook -i inventory -c local deployment.yml -e "method=pip" # Install via Copr repository ansible-playbook -i inventory -c local deployment.yml -e "method=copr" # Install via Official release repository ansible-playbook -i inventory -c local deployment.yml -e "method=official" ``` -------------------------------- ### Avocado Job Setup and Cleanup Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/60_0.rst This snippet details the requirement for using `avocado.core.job.Job.setup` and `avocado.core.job.Job.cleanup` methods, either explicitly or via a context manager. This ensures proper management and cleanup of temporary files associated with jobs. ```python from avocado.core.job import Job # Using Job as a context manager: # with Job() as job: # job.run_test(...) # Explicit setup and cleanup: # job = Job() # job.setup() # try: # job.run_test(...) # finally: # job.cleanup() ``` -------------------------------- ### Manage External Plugins Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/environment.rst Installs external Avocado plugins in develop mode and configures the environment to recognize them by setting the AVOCADO_EXTERNAL_PLUGINS_PATH. ```shell cd $AVOCADO_PROJECTS_DIR git clone $AVOCADO_GIT git clone $AVOCADO_PROJECT2 # Add more projects cd avocado # go into the main Avocado project dir make requirements-plugins export AVOCADO_EXTERNAL_PLUGINS_PATH=$AVOCADO_PROJECTS_DIR make develop-external ``` -------------------------------- ### Configure Git for GPG Signing Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/environment.rst Sets up GPG keys for signing Git commits and pushes, ensuring contribution traceability. Includes generating a key, exporting it, and configuring Git to use the signing key. ```shell gpg --gen-key gpg --send-keys $YOUR_KEY git config --global user.signingkey $YOUR_KEY # To add key to GitHub: # $(gpg -a --export $YOUR_EMAIL) ``` -------------------------------- ### Testing Avocado with Avocado-VT (Ansible) Source: https://github.com/avocado-framework/avocado/blob/master/selftests/deployment/README.rst Shows how to test Avocado along with Avocado-VT by setting the `avocado_vt` variable to `true` via the `-e` option in the Ansible playbook execution. This can be combined with different installation methods. ```bash # Test Avocado + Avocado-VT from PIP ansible-playbook -i inventory -c local deployment.yml -e "method=pip avocado_vt=true" # Test Avocado + Avocado-VT from Copr repository ansible-playbook -i inventory -c local deployment.yml -e "method=copr avocado_vt=true" # Test Avocado + Avocado-VT from Official repository ansible-playbook -i inventory -c local deployment.yml -e "method=official avocado_vt=true" ``` -------------------------------- ### Avocado Test Execution Output Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/plugins.rst Example output from running Avocado tests. It shows job details, individual test status (STARTED, PASS, FAIL), overall results summary, and job timing. This output is crucial for understanding test outcomes. ```bash $ avocado run -- magic:pass magic:fail JOB ID : 86fd45f8c1f2fe766c252eefbcac2704c2106db9 JOB LOG : $HOME/avocado/job-results/job-2021-02-05T12.43-86fd45f/job.log (1/2) magic:pass: STARTED (1/2) magic:pass: PASS (0.00 s) (2/2) magic:fail: STARTED (2/2) magic:fail: FAIL (0.00 s) RESULTS : PASS 1 | ERROR 0 | FAIL 1 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB HTML : $HOME/avocado/job-results/job-2021-02-05T12.43-86fd45f/results.html JOB TIME : 1.83 s ``` -------------------------------- ### Register Python Settings Entry Point Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/plugins.rst Example of registering a custom Python settings class as an entry point in a setup.py file. This allows Avocado to discover and utilize the custom settings configuration. ```python from setuptools import setup ... setup(name="my-plugin", entry_points={ 'avocado.plugins.settings': [ "my-plugin-settings = my_plugin.settings.MyPluginSettings", ], ... } ) ``` -------------------------------- ### Avocado Cloudinit Utilities Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/69_0.rst Provides utilities for creating cloud-init compatible ISO files and managing 'phone home' functionality. Includes a function to wait for the 'phone home' signal. ```APIDOC avocado.utils.cloudinit: Description: Utilities for cloud-init compatible virtual machine configuration. Features: - ISO file creation with configuration. - 'Phone home' address definition and server implementation. - wait_for_phone_home(): Waits for the 'phone home' signal. - Supports root logins and SSH key authentication for instances. ``` -------------------------------- ### Remote Debugging with pydevd and Eclipse Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/tips.rst Guides on setting up remote debugging for Python code using the `pydevd` library, commonly used with IDEs like Eclipse. It details the `pydevd.settrace` function parameters and the necessary steps to start the debug server in Eclipse. ```python import pydevd # Set trace to connect to Eclipse debug server pydevd.settrace(host="$IP_ADDR_OF_ECLIPSE_MACHINE", stdoutToServer=False, stderrToServer=False, port=5678, suspend=True, trace_only_current_thread=False, overwrite_prev_trace=False, patch_multiprocessing=False) # Ensure Eclipse Debug Server is running (Pydev -> Start Debug Server) # Default Eclipse port is 8000, ensure it's accessible. ``` -------------------------------- ### Avocado Cloudinit Module and Phone Home Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/64_0.rst A new module, avocado.utils.cloudinit, has been introduced to facilitate the creation of ISO files for virtual machine cloud-init configurations. It supports defining authentication credentials and a 'phone home' address. A simple server implementation and a utility function, wait_for_phone_home, are provided to monitor this 'phone home' mechanism. ```APIDOC Module: avocado.utils.cloudinit Description: Aids in creating ISO files for cloud-init compatible virtual machine configurations. Features: - Supports defining authentication credentials. - Allows specification of a 'phone home' address. - Includes a simple 'phone home' server implementation. Function: avocado.utils.cloudinit.wait_for_phone_home Description: A utility function to wait for the 'phone home' signal. ``` -------------------------------- ### Install Avocado Framework via Pip (System-wide) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Installs the Avocado framework package from PyPI system-wide. This method requires root privileges and installs the package for all users. ```shell pip3 install avocado-framework ``` -------------------------------- ### Run a Test with Avocado CLI Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/quickstart/index.rst Demonstrates how to use the Avocado command-line interface to execute a test, such as a simple binary like `/bin/true`. It displays the typical output, including job identification, log file location, test execution status, and a summary of results. ```shell $ avocado run /bin/true JOB ID : e0134e010afa18b55d93276ac2a790dc38db7948 JOB LOG : $HOME/avocado/job-results/job-2023-09-06T10.55-e0134e0/job.log (1/1) /bin/true: STARTED (1/1) /bin/true: PASS (0.02 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB HTML : $HOME/avocado/job-results/job-2023-09-06T10.55-e0134e0/results.html JOB TIME : 1.52 s ``` -------------------------------- ### Task State Machine Implementation Example Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/blueprints/BP003.rst This Python script demonstrates a task state machine using asyncio, simulating task progression through various states like 'under triage', 'started', and 'finished'. It includes logic for handling dependencies, environment checks, and status updates. ```python import asyncio import random # Define task states TASK_INITIAL = "INITIAL" TASK_UNDER_TRIAGE = "TASK_UNDER_TRIAGE" TASK_READY = "TASK_READY" TASK_STARTED = "TASK_STARTED" TASK_FINISHED = "TASK_FINISHED" TASK_FAILED = "TASK_FAILED" class Task: def __init__(self, task_id, kind, requirements): self.task_id = task_id self.kind = kind self.requirements = requirements self.state = TASK_INITIAL self.reason = None self.result = None def __str__(self): return f"Task {self.task_id} ({self.state})" class TaskScheduler: def __init__(self, max_concurrent_tasks=2): self.tasks_under_triage = [] self.tasks_ready = [] self.tasks_started = [] self.tasks_finished = [] self.tasks_failed = [] self.max_concurrent_tasks = max_concurrent_tasks self.status_server_running = False async def add_task(self, task): task.state = TASK_UNDER_TRIAGE self.tasks_under_triage.append(task) print(f"Added {task} to triage queue.") async def _check_requirements(self, task): # Simulate checking environment requirements print(f"Checking requirements for {task}...") await asyncio.sleep(0.1) # Simulate missing package if 'gcc' in task.requirements or 'libc-devel' in task.requirements: task.reason = "Missing system packages" return False return True async def triage_task(self, task): print(f"Triaging {task}...") await asyncio.sleep(0.2) # Simulate runner and dependency check runner_exists = True # Assume runner exists for simplicity dependencies_met = True # Assume dependencies met unless specific ones are missing if runner_exists and dependencies_met: task.state = TASK_READY self.tasks_ready.append(task) print(f"{task} is ready.") else: task.state = TASK_FINISHED task.reason = "Triage failed: Runner not found or dependencies unmet" self.tasks_finished.append(task) print(f"{task} failed triage: {task.reason}") async def start_task(self, task): if len(self.tasks_started) < self.max_concurrent_tasks: task.state = TASK_STARTED self.tasks_started.append(task) print(f"Starting {task}.") # Simulate task execution asyncio.create_task(self.simulate_task_execution(task)) else: print(f"Cannot start {task}, max concurrent tasks reached.") async def simulate_task_execution(self, task): await asyncio.sleep(random.uniform(1, 5)) # Simulate random outcome if random.random() > 0.2: # 80% chance of success task.state = TASK_FINISHED task.result = "PASS" print(f"{task} finished successfully.") else: task.state = TASK_FAILED task.reason = "Execution error" task.result = "FAIL" print(f"{task} failed: {task.reason}") self.tasks_started.remove(task) if task.state == TASK_FINISHED: self.tasks_finished.append(task) else: self.tasks_failed.append(task) async def run_iteration(self): print("\n--- Starting Iteration ---") # Start status server if not running and tasks are ready if not self.status_server_running and self.tasks_ready: print("Starting status server...") self.status_server_running = True # In a real scenario, this would start a server # Move tasks from under triage to ready tasks_to_process = list(self.tasks_under_triage) self.tasks_under_triage.clear() for task in tasks_to_process: if await self._check_requirements(task): await self.triage_task(task) else: task.state = TASK_FINISHED task.reason = "Pre-triage check failed" self.tasks_finished.append(task) print(f"{task} failed pre-triage: {task.reason}") # Start ready tasks if capacity allows while self.tasks_started < self.max_concurrent_tasks and self.tasks_ready: task = self.tasks_ready.pop(0) await self.start_task(task) print("--- Iteration Complete ---") print(f"Status: Under Triage: {len(self.tasks_under_triage)}, Ready: {len(self.tasks_ready)}, Started: {len(self.tasks_started)}, Finished: {len(self.tasks_finished)}, Failed: {len(self.tasks_failed)}") async def main(): scheduler = TaskScheduler(max_concurrent_tasks=2) # Create tasks task1 = Task(1, "python-unittest", {"mylib.py"}) task2 = Task(2, "python-unittest", {"mylib.py", "gcc"}) # Task 2 has a missing dependency await scheduler.add_task(task1) await scheduler.add_task(task2) # Simulate multiple iterations for i in range(5): print(f"\n===== Iteration {i+1} =====") await scheduler.run_iteration() # Break if all tasks are finished or failed if not scheduler.tasks_under_triage and not scheduler.tasks_ready and not scheduler.tasks_started: print("\nAll tasks processed.") break await asyncio.sleep(0.5) # Small delay between iterations print("\n--- Final Tally --- ") print(f"Finished Tasks: {len(scheduler.tasks_finished)}") for task in scheduler.tasks_finished: print(f" - {task}: Result='{task.result}', Reason='{task.reason}'") print(f"Failed Tasks: {len(scheduler.tasks_failed)}") for task in scheduler.tasks_failed: print(f" - {task}: Reason='{task.reason}'") if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Avocado Configuration File Structure Example Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/blueprints/BP001.rst Illustrates the expected structure of an Avocado configuration file, showing how settings are organized into sections, including core settings and plugin-specific configurations. ```ini #avocado.conf: [core] foo = bar [core.sysinfo] foo = bar [pluginx] foo = bar ``` -------------------------------- ### Avocado Command-Line Argument Examples Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/blueprints/BP001.rst Provides examples of command-line arguments used with the 'avocado run' command, highlighting different ways to specify boolean flags and their potential inconsistencies. ```bash $ avocado run -d ``` ```bash $ avocado run --sysinfo on ``` -------------------------------- ### Install Avocado on Fedora (Standard) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Installs the Avocado package from the standard Fedora repositories. The version depends on the Fedora release. ```shell $ dnf install python3-avocado ``` -------------------------------- ### Install Avocado Framework Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/40_0.rst Avocado Framework can now be successfully installed on minimal environments like virtualenvs using pip. Previously, installation could fail due to dependencies required at setup.py execution time. These dependencies are now only required after installation. ```bash pip install avocado-framework ``` -------------------------------- ### Install CIT Varianter Plugin Source: https://github.com/avocado-framework/avocado/blob/master/optional_plugins/varianter_cit/README.rst Installs the Avocado CIT Varianter plugin using pip. This command requires sudo privileges for system-wide installation. ```shell sudo pip install avocado-framework-plugin-varianter-cit ``` -------------------------------- ### Avocado Plugin Registration (setup.py) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/plugins.rst Python setup.py script to register the custom 'magic' test type plugins with the Avocado framework. It defines entry points for resolvers and console scripts. ```python from setuptools import setup, find_packages setup( name='avocado-magic-test', version='0.1.0', packages=find_packages(), entry_points={ 'avocado.plugin': [ 'magic = avocado_magic.resolver:MagicResolver', ], 'console_scripts': [ 'avocado-runner-magic = avocado_magic.runner:MagicRunnerApp', ], }, install_requires=[ 'avocado-framework', ], ) ``` -------------------------------- ### Install CIT Varianter Plugin Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/plugins/optional/varianters/cit.rst Installs the Avocado CIT Varianter plugin using pip. This command requires sudo privileges for system-wide installation. ```shell sudo pip install avocado-framework-plugin-varianter-cit ``` -------------------------------- ### Setup.py for Sub-framework Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/writer/chapters/subclassing.rst Configures the setup.py file for a new framework that depends on avocado-framework. It specifies package details, version, author, and dependencies. ```python from setuptools import setup, find_packages setup(name='apricot', description='Apricot - Avocado SubFramework', version=open("VERSION", "r").read().strip(), author='Apricot Developers', author_email='apricot-devel@example.com', packages=['apricot'], include_package_data=True, install_requires=['avocado-framework'] ) ``` -------------------------------- ### Uninstall Avocado Plugin Example Source: https://github.com/avocado-framework/avocado/blob/master/examples/plugins/README.rst Uninstalls an Avocado plugin example from a development environment. This command requires navigating to the specific plugin's directory before execution. ```bash python setup.py develop --uninstall --user ``` -------------------------------- ### Install Sub-framework Locally Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/writer/chapters/subclassing.rst Command to install the custom sub-framework in development mode using setuptools. This makes the framework available for use without a full package installation. ```shell python setup.py develop --user ``` -------------------------------- ### Signing Git Commits Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/contributor/chapters/styleguides.rst Demonstrates how to sign Git commits using the '-S' command-line option to ensure authenticity and compliance with licensing terms. ```shell $ git commit -S $ git merge -S ``` -------------------------------- ### Avocado Command Line Options Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/82_0.rst Demonstrates common command-line options for interacting with the Avocado framework, including selecting test runners and managing jobs. ```bash avocado --test-runner avocado plugins avocado jobs show avocado config reference avocado assets ``` -------------------------------- ### Install Avocado Framework via Pip (User) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Installs the Avocado framework package from PyPI for the current user. This is the simplest method and requires pip and Python 3.8+. ```shell $ pip3 install --user avocado-framework ``` -------------------------------- ### Install Latest Avocado on Fedora (COPR) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Enables the Avocado COPR repository and installs the latest Avocado release on Fedora. This provides newer versions than standard repositories. ```shell $ dnf copr enable @avocado/avocado-latest-release $ dnf install python3-avocado ``` -------------------------------- ### Avocado Utility Build Make Example Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/52_0.rst Illustrates how to use ``avocado.utils.build.run_make`` to execute a make command and retrieve the full result object, including exit status and output. ```python import avocado from avocado.utils.build import run_make class BuildTest(avocado.Test): def test_build_process(self): # Execute a make command and get the full result result = run_make(directory='.', target='clean') self.log.info(f"Make clean exit status: {result.exit_status}") self.log.info(f"Make clean stdout:\n{result.stdout}") self.log.info(f"Make clean stderr:\n{result.stderr}") # Assertions can be made based on the result self.assert_equal(result.exit_status, 0, "Make clean failed") ``` -------------------------------- ### Avocado List Command Example (Multiple Runnables) Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/writer/chapters/recipes.rst Shows how to list multiple runnables defined in a single recipe file using the 'avocado list' command and the 'runnables-recipe' resolver. ```shell avocado list examples/nrunner/recipes/runnables/true_false.json ``` -------------------------------- ### Avocado Test Setup and Cleanup Methods Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/writer/chapters/writing.rst Illustrates the use of 'setUp' and 'tearDown' methods within an Avocado test class to perform actions before and after test execution, ensuring proper resource management. ```Python # Example usage of setUp and tearDown methods # (Actual code snippet not fully provided in source text, but concept explained) # class MyTest(Test): # def setUp(self): # # Initialize variables or perform setup actions # pass # # def test(self): # # Test logic # pass # # def tearDown(self): # # Clean up resources, executed even if setUp fails # pass ``` -------------------------------- ### Install Latest Development RPM Packages from COPR Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/guides/user/chapters/installing.rst Enables the Avocado development COPR repository and installs the latest continuously built packages from the master branch for Enterprise Linux and Fedora. ```shell $ dnf copr enable @avocado/avocado-latest $ dnf install python3-avocado* ``` -------------------------------- ### Avocado Package Installation via Pip Source: https://github.com/avocado-framework/avocado/blob/master/docs/source/releases/lts/69_0.rst Avocado packages are now available in binary 'wheel' format on PyPI. This enables faster, more convenient, and reliable installations using 'pip', as it avoids the need to build source code on the target system. ```bash pip install avocado-framework ``` -------------------------------- ### Install Mail Results Plugin Source: https://github.com/avocado-framework/avocado/blob/master/optional_plugins/mail/README.rst Installs the Mail results plugin for the Avocado testing framework using pip. This command fetches and installs the necessary package from the Python Package Index. ```bash $ pip install avocado-framework-plugin-result-mail ``` -------------------------------- ### Run a Test with Avocado CLI Source: https://github.com/avocado-framework/avocado/blob/master/README.rst Demonstrates how to use the Avocado command-line interface to execute a test, such as a simple binary like `/bin/true`. It displays the typical output, including job identification, log file location, test execution status, and a summary of results. ```shell $ avocado run /bin/true JOB ID : e0134e010afa18b55d93276ac2a790dc38db7948 JOB LOG : $HOME/avocado/job-results/job-2023-09-06T10.55-e0134e0/job.log (1/1) /bin/true: STARTED (1/1) /bin/true: PASS (0.02 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB HTML : $HOME/avocado/job-results/job-2023-09-06T10.55-e0134e0/results.html JOB TIME : 1.52 s ```