From 5cb453d3518ae2b7692a617c4889c00a6594c540 Mon Sep 17 00:00:00 2001 From: Tamas K Lengyel Date: Mon, 30 Sep 2024 19:46:35 -0400 Subject: [PATCH] Add check tests to meson test (#1810) * Add check tests to meson * Add libusermode tests to meson * Fix whitespace * Stop CI testing on Ubuntu focal * Enable deb-src on noble * Check isn't used in container builds * Need meson 1.1.0 for objects * Don't install check executables * libaio1t64 Xen deb dependency * Xen conflicts with 17/18 * Specify ubuntu-24.04 instead of ubuntu-latest * Use venv for python3 * Add setuptools to install.sh through pip --- .github/workflows/ci.yml | 36 +++++++++++------- .github/workflows/container-compile.yml | 4 +- .github/workflows/deb.yml | 4 +- meson.build | 4 ++ package/depends.sh | 9 +++-- package/mkdeb | 4 +- scripts/install.sh | 2 +- src/libusermode/meson.build | 24 ++++++++++++ src/plugins/meson.build | 50 +++++++++++++++++++++++++ 9 files changed, 114 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68f84874c..f936400e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: strategy: matrix: os: - - 'ubuntu-20.04' - - 'ubuntu-latest' + - 'ubuntu-22.04' + - 'ubuntu-24.04' steps: - uses: actions/checkout@v4 - name: Install dependencies @@ -101,8 +101,8 @@ jobs: strategy: matrix: os: - - 'ubuntu-20.04' - - 'ubuntu-latest' + - 'ubuntu-22.04' + - 'ubuntu-24.04' flags: - '' - '-Dbuildtype=debug -Db_lto=false' @@ -117,8 +117,14 @@ jobs: sudo apt-get update -q sudo apt-get install -y \ clang llvm lld build-essential flex bison \ - libjson-c-dev liblzo2-dev libglib2.0-dev meson ninja-build check - sudo pip3 install ctypesgen ipython + libjson-c-dev liblzo2-dev libglib2.0-dev meson ninja-build check \ + python3-ipython + + - name: Setup python venv for REPL + run: | + python3 -m venv venv + source venv/bin/activate + pip3 install ctypesgen - name: Cache Xen debball uses: actions/cache@v4 @@ -145,9 +151,14 @@ jobs: - name: Compile ${{ matrix.flags }} run: | + source venv/bin/activate meson setup build --native-file llvm.ini ${{ matrix.flags }} ninja -C build + - name: Run check ${{ matrix.flags }} + run: | + meson test -C build + tarbuild: name: Build using autoconf tarball runs-on: ${{ matrix.os }} @@ -157,8 +168,8 @@ jobs: fail-fast: false matrix: os: - - 'ubuntu-20.04' - - 'ubuntu-latest' + - 'ubuntu-22.04' + - 'ubuntu-24.04' steps: - name: Checkout repository @@ -170,7 +181,6 @@ jobs: sudo apt-get install -y \ clang autoconf-archive automake check \ libjson-c-dev liblzo2-dev libglib2.0-dev - sudo pip3 install ctypesgen ipython - name: Cache Xen debball uses: actions/cache@v4 @@ -225,8 +235,8 @@ jobs: fail-fast: false matrix: os: - - 'ubuntu-20.04' - - 'ubuntu-latest' + - 'ubuntu-22.04' + - 'ubuntu-24.04' steps: - name: Checkout repository @@ -291,7 +301,7 @@ jobs: sudo apt-get update -q sudo apt-get install -y \ clang clang-tools-15 llvm lld \ - libjson-c-dev meson ninja-build check + libjson-c-dev meson ninja-build - name: Cache Xen debball uses: actions/cache@v4 @@ -337,7 +347,7 @@ jobs: sudo apt-get update -q sudo apt-get install -y \ clang clang-tools clang-tidy llvm lld \ - libjson-c-dev meson ninja-build check + libjson-c-dev meson ninja-build - name: Cache Xen debball uses: actions/cache@v4 diff --git a/.github/workflows/container-compile.yml b/.github/workflows/container-compile.yml index 78d9a2b16..e06104b7d 100644 --- a/.github/workflows/container-compile.yml +++ b/.github/workflows/container-compile.yml @@ -14,8 +14,8 @@ jobs: container: - 'debian:bullseye-slim' - 'debian:bookworm-slim' - - 'ubuntu:focal' - 'ubuntu:jammy' + - 'ubuntu:noble' - 'ubuntu:rolling' runs-on: ubuntu-latest @@ -31,7 +31,7 @@ jobs: apt-get install -y \ autoconf-archive flex bison libjson-c-dev build-essential \ git libtool autotools-dev libglib2.0-dev libyajl-dev liblzo2-dev \ - clang llvm lld meson ninja-build check + clang llvm lld meson ninja-build apt-get clean - name: Configure safe dirs diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml index 6f65e88bd..babbcbc93 100644 --- a/.github/workflows/deb.yml +++ b/.github/workflows/deb.yml @@ -18,8 +18,8 @@ jobs: container: - "debian:bullseye" - "debian:bookworm" - - "ubuntu:focal" - "ubuntu:jammy" + - "ubuntu:noble" steps: - uses: actions/checkout@v4 with: @@ -102,8 +102,8 @@ jobs: container: - "debian:bullseye" - "debian:bookworm" - - "ubuntu:focal" - "ubuntu:jammy" + - "ubuntu:noble" container: image: ${{ matrix.container}} steps: diff --git a/meson.build b/meson.build index 6014d9560..4c50fd1ac 100644 --- a/meson.build +++ b/meson.build @@ -28,6 +28,10 @@ libvmi = dependency('libvmi') jsonc = dependency('json-c') deps = [glib, libvmi, jsonc] +# Find optional dependencies +check = dependency('check', required : false) + +# Set version string version = meson.project_version() if not get_option('release') version += '-' + run_command('git', 'describe', '--always', check: true).stdout().strip() diff --git a/package/depends.sh b/package/depends.sh index 8d62ed7d2..00c129a3b 100644 --- a/package/depends.sh +++ b/package/depends.sh @@ -11,12 +11,15 @@ DISTRIBUTION=$(lsb_release -cs) if [ "$SYSTEM" = "Debian" ] then echo "deb-src http://deb.debian.org/debian ${DISTRIBUTION} main" >> /etc/apt/sources.list - apt-get update else - sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list - apt-get update + if [ "$DISTRIBUTION" = "noble" ]; then + sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources + else + sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list + fi fi +apt-get update apt-get --quiet --yes install build-essential git wget curl cmake flex bison \ libjson-c-dev autoconf-archive clang python3-dev libsystemd-dev nasm bc \ libx11-dev ninja-build python3-pip meson llvm lld zlib1g-dev diff --git a/package/mkdeb b/package/mkdeb index 434671b34..370f673cb 100644 --- a/package/mkdeb +++ b/package/mkdeb @@ -46,8 +46,8 @@ Source: xen-hypervisor Version: $xenversion Architecture: $arch Maintainer: Tamas K Lengyel -Depends: libpixman-1-0, libpng16-16, libnettle6 | libnettle7 | libnettle8, libgnutls30, libfdt1, libyajl2, libaio1, libncurses6, libc6, libtinfo6, libgnutls28-dev, systemd, lvm2 -Conflicts: xen-hypervisor-4.6-amd64, xen-hypervisor-4.7-amd64, xen-hypervisor-4.8-amd64, xen-hypervisor-4.9-amd64, xen-hypervisor-4.10-amd64, xen-hypervisor-4.11-amd64, xen-hypervisor-4.12-amd64, xen-hypervisor-4.13-amd64, xen-hypervisor-4.14-amd64, xen-hypervisor-4.15-amd64, xen-hypervisor-4.16-amd64 +Depends: libpixman-1-0, libpng16-16, libnettle6 | libnettle7 | libnettle8, libgnutls30, libfdt1, libyajl2, libaio1 | libaio1t64, libncurses6, libc6, libtinfo6, libgnutls28-dev, systemd, lvm2 +Conflicts: xen-hypervisor-4.6-amd64, xen-hypervisor-4.7-amd64, xen-hypervisor-4.8-amd64, xen-hypervisor-4.9-amd64, xen-hypervisor-4.10-amd64, xen-hypervisor-4.11-amd64, xen-hypervisor-4.12-amd64, xen-hypervisor-4.13-amd64, xen-hypervisor-4.14-amd64, xen-hypervisor-4.15-amd64, xen-hypervisor-4.16-amd64, xen-hypervisor-4.17-amd64, xen-hypervisor-4.18-amd64 Section: admin Priority: optional Installed-Size: $(du -ks deb | cut -f1) diff --git a/scripts/install.sh b/scripts/install.sh index 2220862e6..8038adaec 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -125,7 +125,7 @@ apt-get --quiet --yes install python3-pip python3-venv python3 -m venv /opt/volatility3 source /opt/volatility3/bin/activate -pip3 install wheel construct pefile +pip3 install wheel construct pefile setuptools cd /opt/volatility3 python3 setup.py build python3 -m pip install . diff --git a/src/libusermode/meson.build b/src/libusermode/meson.build index 94039dddd..f312a1b8d 100644 --- a/src/libusermode/meson.build +++ b/src/libusermode/meson.build @@ -14,3 +14,27 @@ libusermode = static_library('usermode', include_directories : libusermode_h, link_with : libdrakvuf ) + +if check.found() + userhook_check = executable('userhook_check', + sources : 'check.cpp', + include_directories : libusermode_h, + dependencies : [deps, check], + link_with : [libdrakvuf, libusermode], + install : false + ) + test('userhook_check', userhook_check) + + if meson.version().version_compare('>=1.1.0') + utils_o = libusermode.extract_objects('printers/utils.cpp') + utils_dep = declare_dependency(objects: utils_o) + libusermode_printers_check = executable('libusermode_printers_check', + sources : 'printers/check.cpp', + include_directories : libusermode_h, + dependencies : [deps, utils_dep, check], + link_with : libdrakvuf, + install : false + ) + test('libusermode_printers_check', libusermode_printers_check) + endif +endif diff --git a/src/plugins/meson.build b/src/plugins/meson.build index dcb4b5139..45abe88eb 100644 --- a/src/plugins/meson.build +++ b/src/plugins/meson.build @@ -14,6 +14,17 @@ if get_option('plugin-syscalls') plugin_sources += 'syscalls/linux.cpp' config_h.set('ENABLE_PLUGIN_SYSCALLS', 1) + + if check.found() + syscalls_check = executable('syscalls_check', + sources : 'syscalls/check.cpp', + include_directories : incdir, + dependencies : [deps, check], + link_with : libdrakvuf, + install : false + ) + test('syscalls_check', syscalls_check) + endif endif if get_option('plugin-poolmon') @@ -361,3 +372,42 @@ drakvuf_plugins = static_library('drakvuf_plugins', link_with : [libdrakvuf, libhook, libusermode], link_args : hardened_link_args ) + +if check.found() + output_format_check = executable('output_format_check', + sources : 'output_format/check.cpp', + include_directories : incdir, + dependencies : [deps, check], + link_with : libdrakvuf, + install : false + ) + test('output_format_check', output_format_check) + + if meson.version().version_compare('>=1.1.0') + plugin_utils_o = drakvuf_plugins.extract_objects('plugin_utils.cpp') + plugin_utils_dep = declare_dependency(objects: plugin_utils_o) + plugin_utils_check = executable('plugin_utils_check', + sources : 'plugin_utils_check.cpp', + include_directories : incdir, + dependencies : [deps, plugin_utils_dep, check], + link_with : libdrakvuf, + install : false + ) + test('plugin_utils_check', plugin_utils_check) + + if get_option('plugin-procmon') + linux_utils_o = drakvuf_plugins.extract_objects('procmon/linux_utils.cpp') + winnt_o = drakvuf_plugins.extract_objects('procmon/winnt.cpp') + procmon_deps = declare_dependency(objects: [linux_utils_o, winnt_o]) + + procmon_check = executable('procmon_check', + sources : 'procmon/check.cpp', + include_directories : incdir, + dependencies : [deps, procmon_deps, check], + link_with : libdrakvuf, + install : false + ) + test('procmon_check', procmon_check) + endif + endif +endif