Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ name: build
on: [push, pull_request]

jobs:
python-tests:
name: "Python Tests"

runs-on: ubuntu-20.04

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: pre-commit checks - setup cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- run: make -j $(nproc)

- name: pre-commit checks - run checks
uses: pre-commit/action@v3.0.0

# Python2 pytest/pylint CI:
- run: sudo apt-get update && sudo apt-get install -y python2
- run: curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 -
- run: pip2 install pytest pylint==1.9.4
- run: python2 -m pytest -v -rA
- run: python2 -m pylint xtf-runner build/*.py tests/python/*.py

build:

strategy:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:

jobs:
analyse:
# https://github.com/orgs/community/discussions/26409 (private secrets):
# Run this job if the feature branch is in the main repo (not in a fork):
if: github.event.pull_request.head.repo.full_name == github.repository

strategy:
matrix:
Expand Down
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
#

fail_fast: false
default_stages: [commit, push]
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
# https://pre-commit.com/hooks.html
hooks:
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace

- repo: local
hooks:
- id: pytest
name: run python3 unit tests for xtf-runner
entry: env PYTHONDEVMODE=yes python3 -m pytest -v -rA
pass_filenames: false
language: python
types: [python]
additional_dependencies: [pytest]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy

- repo: https://github.com/pylint-dev/pylint
rev: v3.0.3
hooks:
- id: pylint
args: [--jobs=2]
files: '(^xtf-runner|\.py)$'
log_file: ".git/pre-commit-pylint.log"
additional_dependencies: [pytest]

- repo: local
hooks:
- id: git-diff # For reference: https://github.com/pre-commit/pre-commit/issues/1712
name: Show not staged changes (fixups may make them too)
entry: git diff --exit-code
language: system
pass_filenames: false
always_run: true
40 changes: 37 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension-pkg-whitelist=
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time. See also the "--disable" option for examples.
#enable=
enable=spelling

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
Expand All @@ -48,7 +48,24 @@ extension-pkg-whitelist=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=bad-whitespace, bad-continuation, global-statement, star-args
disable=bad-whitespace, bad-continuation, global-statement, star-args,
# Allow older pylint-1.9.x for Python2 to tolerate newer pylint options:
bad-option-value,
unrecognized-inline-option,
# Not real problems, returns on the same indentation level can be easier:
consider-using-with,
no-else-raise,
no-else-return,
multiple-imports,
len-as-condition,
# For Python3-only projects:
consider-using-f-string,
deprecated-module,
unrecognized-option,
unspecified-encoding,
use-implicit-booleaness-not-len,
useless-object-inheritance,
useless-option-value,


[REPORTS]
Expand Down Expand Up @@ -103,6 +120,23 @@ ignore-docstrings=yes
ignore-imports=no


[SPELLING]

# Spelling dictionary name. Available dictionaries: en (aspell), en_AU
# (aspell), en_CA (aspell), en_GB (aspell), en_US (aspell).
# To support spelling checks for older python2 pylint versions,
# `sudo apt-get install -y libenchant-2-2` would be needed,
# so we enable it for newer Python3 pylint in .pre-commit-config.yaml:
#spelling-dict=en_US

# A path to a file that contains the private dictionary; one word per line.
spelling-private-dict-file=.pylintrc.project-dict.txt

# Tells whether to store unknown words to the private dictionary (see the
# --spelling-private-dict-file option) instead of raising a message.
spelling-store-unknown-words=y


[TYPECHECK]

# Tells whether missing members accessed in mixin class should be ignored. A
Expand Down Expand Up @@ -337,4 +371,4 @@ max-public-methods=20

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
50 changes: 50 additions & 0 deletions .pylintrc.project-dict.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
arg
basestring
CFG
config
conftest
CWD
dev
dir
dirs
entrypoint
env
ENVS
epilog
hvm
init
invlpg
iopl
json
logfile
logline
logpath
mkcfg
nonexisting
Normalise
O_CREAT
O_RDONLY
os
pre
pseduo
pv
py
pylintrc
pyright
pytest
reportMissingImports
reportUndefinedVariable
src
stdout
subproc
substitue
sys
toolstack
unimported
unioned
Unrecognised
VM
xenconsole
xenconsoled
xl
xtf
1 change: 0 additions & 1 deletion arch/x86/include/arch/msr-index.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@
* indent-tabs-mode: nil
* End:
*/

2 changes: 1 addition & 1 deletion build/mkcfg.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys, os

# Usage: mkcfg.py $OUT $DEFAULT-CFG $EXTRA-CFG $VARY-CFG
_, out, defcfg, vcpus, extracfg, varycfg = sys.argv
_, out, defcfg, vcpus, extracfg, varycfg = sys.argv # pylint: disable=unbalanced-tuple-unpacking

# Evaluate environment and name from $OUT
_, env, name = out.split('.')[0].split('-', 2)
Expand Down
35 changes: 34 additions & 1 deletion build/mkinfo.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
mkcfg.py - Generate a configuration JSON file based on provided parameters.

Usage:
python mkcfg.py $OUT $NAME $CATEGORY $ENVS $VARIATIONS

Arguments:

$OUT: Path to the output file where the generated JSON configuration
will be saved.
$NAME: Name to be assigned in the configuration.
$CATEGORY: Category designation in the configuration.
$ENVS: Optional space-separated list of environments (can be empty).
$VARIATIONS: Optional space-separated list of variations (can be empty).

Description:

This script generates a JSON configuration file using provided parameters
and saves it to the specified output file. The generated JSON structure
includes fields for 'name', 'category', 'environments', and 'variations'.
The 'environments' and 'variations' fields can be populated with
space-separated lists if corresponding arguments ($ENVS and $VARIATIONS)
are provided.

Example:

python mkcfg.py config.json ExampleConfig Utilities prod dev test

This example will create a configuration file named 'config.json' with
'name' as 'ExampleConfig',
'category' as 'Utilities', and
'environments' as ['prod', 'dev', 'test'].
"""

import sys, json

# Usage: mkcfg.py $OUT $NAME $CATEGORY $ENVS $VARIATIONS
_, out, name, cat, envs, variations = sys.argv
_, out, name, cat, envs, variations = sys.argv # pylint: disable=unbalanced-tuple-unpacking

template = {
"name": name,
Expand Down
2 changes: 1 addition & 1 deletion docs/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Environment | Guest | Width | Paging

Requirements:
- GNU Make >= 3.81
- Python 2.6 or later
- Python 2.7 or later

For x86:
- GNU compatible 32 and 64-bit toolchain, capable of `-std=gnu99`, `-m64`,
Expand Down
Empty file modified include/xen/sysctl.h
100755 → 100644
Empty file.
62 changes: 62 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[project]
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
name = "xtf"
description = "Xen Test Framework"
requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
license = {file = "COPYING"}
keywords = ["xen", "xen-project"]
authors = [
{name = "Andrew Cooper"},
{name = "Bernhard Kaindl"},
{name = "Jan Beulich"},
{name = "Michal Orzel"},
{name = "Haozhong Zhang"},
{name = "Roger Pau Monne"},
{name = "Wei Liuq"},
]
maintainers = [
{name = "Andrew Cooper"},
]
readme = "README"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: System :: Virtualization",
]

[tool.black]
line-length = 80

[tool.isort]
profile = "black"

[tool.mypy]
files = ["xtf-runner", "build/*.py", "tests/python/test_*.py"]
pretty = true
error_summary = true
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
disallow_any_unimported = true
disallow_any_explicit = false
disallow_any_generics = true
disallow_subclassing_any = true
show_error_context = true
show_error_codes = true
strict_equality = true
# Enables checking the contents of not yet typed functions:
check_untyped_defs = true

[[tool.mypy.overrides]]
module = ["xtf-runner"]
disable_error_code = ["name-defined", "method-assign"]
Loading