From 64af2467ca096d1894842cf8b191a9eaaab59394 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Tue, 20 Feb 2024 09:39:20 +0100 Subject: [PATCH 1/3] new(playbooks): added a `drivers_test` playbook. Signed-off-by: Federico Di Pierro --- ansible-playbooks/build-drivers-test.yml | 64 ++++++ ansible-playbooks/build-scap-open.yml | 61 ++++++ ansible-playbooks/build-skeleton.yml | 39 ++++ ansible-playbooks/drivers-test.yml | 31 +++ .../roles/drivers_test/tasks/main.yml | 199 ++++++++++++++++++ .../roles/drivers_test/vars/main.yml | 6 + ansible-playbooks/scap-open.yml | 101 +-------- 7 files changed, 404 insertions(+), 97 deletions(-) create mode 100644 ansible-playbooks/build-drivers-test.yml create mode 100644 ansible-playbooks/build-scap-open.yml create mode 100644 ansible-playbooks/build-skeleton.yml create mode 100644 ansible-playbooks/drivers-test.yml create mode 100644 ansible-playbooks/roles/drivers_test/tasks/main.yml create mode 100644 ansible-playbooks/roles/drivers_test/vars/main.yml diff --git a/ansible-playbooks/build-drivers-test.yml b/ansible-playbooks/build-drivers-test.yml new file mode 100644 index 0000000..e826fa2 --- /dev/null +++ b/ansible-playbooks/build-drivers-test.yml @@ -0,0 +1,64 @@ +# Playbook used to build and distribute drivers_test to all vms. + +- name: Build drivers_test on designated builder + hosts: "centos-builder" + remote_user: "{{ user }}" + gather_facts: false + tasks: + - name: Copy bpf skeleton to centos builder + ansible.builtin.copy: + src: "/tmp/bpf_probe.skel.h" + dest: "/tmp" + mode: '0755' + + - name: Create cmake output dir + ansible.builtin.file: + path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + state: directory + mode: "0755" + register: cmake_result + + - name: Prepare cmake for repository + ansible.builtin.shell: + cmd: | + source /opt/rh/devtoolset-9/enable && + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_LIBSCAP_MODERN_BPF=ON \ + -DMODERN_BPF_SKEL_DIR=/tmp \ + -DBUILD_DRIVER=Off \ + -DBUILD_BPF=Off \ + -DBUILD_LIBSCAP_GVISOR=OFF \ + -DENABLE_DRIVERS_TESTS=On \ + -DCREATE_TEST_TARGETS=On \ + -DENABLE_IA32_TESTS=Off \ + -DSCAP_FILES_SUITE_ENABLE=Off \ + .. + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + changed_when: false + register: cmake_result + + - name: Build drivers_test with modern probe + ansible.builtin.shell: + cmd: source /opt/rh/devtoolset-9/enable && make drivers_test -j {{ cpus }} + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + changed_when: false + register: cmake_result + + - name: Fetch the drivers_test binary + ansible.builtin.fetch: + src: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build/test/drivers/drivers_test" + dest: "/tmp/" + flat: true + +- name: Play that distributes drivers_test binary to VMs + hosts: "machines" + remote_user: "{{ user }}" + gather_facts: false + tasks: + - name: Copy drivers_test binary to all VMs + ansible.builtin.copy: + src: "/tmp/drivers_test" + dest: "/tmp" + mode: '0755' + become: false diff --git a/ansible-playbooks/build-scap-open.yml b/ansible-playbooks/build-scap-open.yml new file mode 100644 index 0000000..82c3faf --- /dev/null +++ b/ansible-playbooks/build-scap-open.yml @@ -0,0 +1,61 @@ +# Playbook used to build and distribute scap-open to all vms. + +- name: Build scap-open on designated builder + hosts: "centos-builder" + remote_user: "{{ user }}" + gather_facts: false + tasks: + - name: Copy bpf skeleton to centos builder + ansible.builtin.copy: + src: "/tmp/bpf_probe.skel.h" + dest: "/tmp" + mode: '0755' + + - name: Create cmake output dir + ansible.builtin.file: + path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + state: directory + mode: "0755" + register: cmake_result + + - name: Prepare cmake for repository + ansible.builtin.shell: + cmd: | + source /opt/rh/devtoolset-9/enable && + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_LIBSCAP_MODERN_BPF=ON \ + -DMODERN_BPF_SKEL_DIR=/tmp \ + -DBUILD_DRIVER=Off \ + -DBUILD_BPF=Off \ + -DBUILD_LIBSCAP_GVISOR=OFF \ + -DCREATE_TEST_TARGETS=Off \ + .. + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + changed_when: false + register: cmake_result + + - name: Build scap-open with modern probe + ansible.builtin.shell: + cmd: source /opt/rh/devtoolset-9/enable && make scap-open -j {{ cpus }} + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + changed_when: false + register: cmake_result + + - name: Fetch the scap-open binary + ansible.builtin.fetch: + src: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build/libscap/examples/01-open/scap-open" + dest: "/tmp/" + flat: true + +- name: Play that distributes scap-open binary to VMs + hosts: "machines" + remote_user: "{{ user }}" + gather_facts: false + tasks: + - name: Copy scap-open binary to all VMs + ansible.builtin.copy: + src: "/tmp/scap-open" + dest: "/tmp" + mode: '0755' + become: false diff --git a/ansible-playbooks/build-skeleton.yml b/ansible-playbooks/build-skeleton.yml new file mode 100644 index 0000000..8bcbc96 --- /dev/null +++ b/ansible-playbooks/build-skeleton.yml @@ -0,0 +1,39 @@ +# Playbook used to build modern bpf skeleton. + +- name: Build bpf skeleton on designated builder VM + hosts: "fedora-builder" + remote_user: "{{ user }}" + gather_facts: false + tasks: + - name: Create cmake output dir + ansible.builtin.file: + path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build" + state: directory + mode: "0755" + register: cmake_result + + - name: Prepare cmake for repository + ansible.builtin.command: + cmd: > + cmake + -DUSE_BUNDLED_DEPS=ON + -DBUILD_LIBSCAP_MODERN_BPF=ON + -DBUILD_LIBSCAP_GVISOR=OFF + -DCREATE_TEST_TARGETS=OFF + .. + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build" + changed_when: false + register: cmake_result + + - name: Build skeleton + ansible.builtin.command: + cmd: make ProbeSkeleton -j {{ cpus }} + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build" + changed_when: false + register: cmake_result + + - name: Fetch the skeleton file + ansible.builtin.fetch: + src: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build/skel_dir/bpf_probe.skel.h" + dest: /tmp/ + flat: true diff --git a/ansible-playbooks/drivers-test.yml b/ansible-playbooks/drivers-test.yml new file mode 100644 index 0000000..864f135 --- /dev/null +++ b/ansible-playbooks/drivers-test.yml @@ -0,0 +1,31 @@ +# Playbook used to run drivers_test role. +# Check the role for more information + +- name: Include build-skeleton playbook + import_playbook: build-skeleton.yml +- name: Include build-scap-open playbook + import_playbook: build-scap-open.yml +- name: Include build-drivers-test playbook + import_playbook: build-drivers-test.yml + +- name: Play that runs probes tests using drivers_test binary + hosts: "machines" + gather_facts: true + remote_user: "{{ user }}" + become: true + serial: 30 + roles: + - drivers_test + +- name: Remove artifacts from localhost + hosts: localhost + gather_facts: false + tasks: + - name: Remove artifacs + ansible.builtin.file: + path: "./roles/drivers_test/files/" + state: absent + with_items: + - "/tmp/drivers_test" + - "/tmp/scap-open" + - "/tmp/bpf_probe.skel.h" diff --git a/ansible-playbooks/roles/drivers_test/tasks/main.yml b/ansible-playbooks/roles/drivers_test/tasks/main.yml new file mode 100644 index 0000000..54ba0a9 --- /dev/null +++ b/ansible-playbooks/roles/drivers_test/tasks/main.yml @@ -0,0 +1,199 @@ +--- +# tasks file for drivers_test +- name: Setting output directory for results + ansible.builtin.set_fact: + output_dest_dir: "{{ output_dir }}/drivers-test-test/{{ inventory_hostname }}" + +- name: Create output directory on localhost + become: false + delegate_to: localhost + block: + - name: Create output directory if it does not exist ({{ output_dir }}) + ansible.builtin.file: + path: "{{ output_dest_dir }}" + state: directory + mode: '0755' + +- name: Check Modern Bpf Support + block: + - name: Check modern-bpf support + ansible.builtin.command: + cmd: /tmp/scap-open --num_events 0 --modern_bpf + register: result + changed_when: false + rescue: + - name: Disable Modern Bpf support + ansible.builtin.set_fact: + modern_bpf_supported: false + when: result.rc == 95 + +- name: Check Old Bpf Support + block: + - name: Enable old Bpf support + ansible.builtin.set_fact: + bpf_supported: true + when: ansible_kernel is version(bpf_minimum_kver[ansible_architecture],'>=') + +- name: Prepare the build directory + block: + - name: Create cmake output dir + ansible.builtin.file: + path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + state: directory + mode: "0766" + register: cmake_result + + - name: Prepare cmake for repository + ansible.builtin.command: + cmd: > + cmake + -DUSE_BUNDLED_DEPS=ON + -DBUILD_LIBSCAP_MODERN_BPF=OFF + -DBUILD_LIBSCAP_GVISOR=OFF + -DBUILD_BPF={{ bpf_supported }} + -DCREATE_TEST_TARGETS=OFF + .. + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + changed_when: false + register: cmake_result + rescue: + - name: Print error message to stdout --- build directory + ansible.builtin.debug: + var: cmake_result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ cmake_result | to_nice_json }}" + dest: "{{ output_dest_dir }}/cmake-configure.json" + mode: '0755' + delegate_to: localhost + become: false + +- name: Build and load the kernel module + block: + - name: Unload the kernel module + ansible.builtin.command: + cmd: rmmod driver/scap.ko + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + failed_when: false + changed_when: false + + - name: Build kmod + ansible.builtin.command: + cmd: make driver -j {{ cpus }} + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: km_result + changed_when: false + + - name: Load the kernel module + ansible.builtin.command: + cmd: insmod driver/scap.ko + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: km_result + changed_when: false + rescue: + - name: Print error message to stdout --- kernel module + ansible.builtin.debug: + var: km_result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ km_result | to_nice_json }}" + dest: "{{ output_dest_dir }}/kmod_build.json" + mode: '0755' + delegate_to: localhost + become: false + +- name: drivers_test + kernel module + block: + - name: Run drivers_test with kernel module + ansible.builtin.command: + cmd: /tmp/drivers_test -k + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: result + changed_when: false + + - name: Unload the kernel module + ansible.builtin.command: + cmd: rmmod driver/scap.ko + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: result + changed_when: false + rescue: + - name: Print error message to stdout -- drivers_test + kernel module + ansible.builtin.debug: + var: result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ result | to_nice_json }}" + dest: "{{ output_dest_dir }}/kmod_drivers_test.json" + mode: '0755' + delegate_to: localhost + become: false + +- name: Build bpf probe + block: + - name: Build bpf probe + ansible.builtin.command: + cmd: make bpf -j {{ cpus }} + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: bpf_probe_result + when: bpf_supported + changed_when: false + rescue: + - name: Print error message to stdout --- build bpf probe + ansible.builtin.debug: + var: bpf_probe_result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ bpf_probe_result | to_nice_json }}" + dest: "{{ output_dest_dir }}/bpf-probe_build.json" + mode: '0755' + delegate_to: localhost + become: false + +- name: drivers_test + bpf probe + block: + - name: Run drivers_test with bpf probe + ansible.builtin.command: + cmd: /tmp/drivers_test -b driver/bpf/probe.o + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: result + when: bpf_supported + changed_when: false + rescue: + - name: Print error message to stdout --- drivers_test + bpf probe + ansible.builtin.debug: + var: result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ result | to_nice_json }}" + dest: "{{ output_dest_dir }}/bpf-probe_drivers_test.json" + mode: '0755' + delegate_to: localhost + become: false + +- name: drivers_test + modern probe + block: + - name: Run drivers_test with modern-probe + ansible.builtin.command: + cmd: /tmp/drivers_test -m + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: result + when: modern_bpf_supported + changed_when: false + rescue: + - name: Print error message to stdout --- drivers_test + modern probe + ansible.builtin.debug: + var: result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ result | to_nice_json }}" + dest: "{{ output_dest_dir }}/modern-bpf_drivers_test.json" + mode: '0755' + delegate_to: localhost + become: false diff --git a/ansible-playbooks/roles/drivers_test/vars/main.yml b/ansible-playbooks/roles/drivers_test/vars/main.yml new file mode 100644 index 0000000..c1d3acd --- /dev/null +++ b/ansible-playbooks/roles/drivers_test/vars/main.yml @@ -0,0 +1,6 @@ +--- +modern_bpf_supported: true +bpf_supported: false +bpf_minimum_kver: + aarch64: '4.17' + x86_64: '4.14' diff --git a/ansible-playbooks/scap-open.yml b/ansible-playbooks/scap-open.yml index 5207c8a..386e040 100644 --- a/ansible-playbooks/scap-open.yml +++ b/ansible-playbooks/scap-open.yml @@ -1,103 +1,10 @@ # Playbook used to run scap-open-test role. # Check the role for more information -- name: Build bpf skeleton on designated builder VM - hosts: "fedora-builder" - remote_user: "{{ user }}" - gather_facts: false - tasks: - - name: Create cmake output dir - ansible.builtin.file: - path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build" - state: directory - mode: "0755" - register: cmake_result - - - name: Prepare cmake for repository - ansible.builtin.command: - cmd: > - cmake - -DUSE_BUNDLED_DEPS=ON - -DBUILD_LIBSCAP_MODERN_BPF=ON - -DBUILD_LIBSCAP_GVISOR=OFF - -DCREATE_TEST_TARGETS=OFF - .. - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build" - changed_when: false - register: cmake_result - - - name: Build skeleton - ansible.builtin.command: - cmd: make ProbeSkeleton -j {{ cpus }} - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build" - changed_when: false - register: cmake_result - - - name: Fetch the skeleton file - ansible.builtin.fetch: - src: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/skeleton-build/skel_dir/bpf_probe.skel.h" - dest: /tmp/ - flat: true - -- name: Build scap-open on designated builder - hosts: "centos-builder" - remote_user: "{{ user }}" - gather_facts: false - tasks: - - name: Copy bpf skeleton to centos builder - ansible.builtin.copy: - src: "/tmp/bpf_probe.skel.h" - dest: "/tmp" - mode: '0755' - - - name: Create cmake output dir - ansible.builtin.file: - path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - state: directory - mode: "0755" - register: cmake_result - - - name: Prepare cmake for repository - ansible.builtin.shell: - cmd: | - source /opt/rh/devtoolset-9/enable && - cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_LIBSCAP_MODERN_BPF=ON \ - -DMODERN_BPF_SKEL_DIR=/tmp \ - -DBUILD_DRIVER=Off \ - -DBUILD_BPF=Off \ - -DBUILD_LIBSCAP_GVISOR=OFF \ - -DCREATE_TEST_TARGETS=Off \ - .. - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - changed_when: false - register: cmake_result - - - name: Build scap-open with modern probe - ansible.builtin.shell: - cmd: source /opt/rh/devtoolset-9/enable && make scap-open -j {{ cpus }} - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - changed_when: false - register: cmake_result - - - name: Fetch the scap-open binary - ansible.builtin.fetch: - src: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build/libscap/examples/01-open/scap-open" - dest: "/tmp/" - flat: true - -- name: Play that distributes scap-open binary to VMs - hosts: "machines" - remote_user: "{{ user }}" - gather_facts: false - tasks: - - name: Copy scap-open binary to all VMs - ansible.builtin.copy: - src: "/tmp/scap-open" - dest: "/tmp" - mode: '0755' - become: false +- name: Include build-skeleton playbook + import_playbook: build-skeleton.yml +- name: Include build-scap-open playbook + import_playbook: build-scap-open.yml - name: Play that runs probes tests using scap-open binary hosts: "machines" From ccca551e36738e457ea39dd9aa5870b9e08767bc Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Tue, 20 Feb 2024 09:40:59 +0100 Subject: [PATCH 2/3] chore(action): allow users to select a test to be run between drivers_test and scap-open. Signed-off-by: Federico Di Pierro --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 470a248..e11a7aa 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: description: 'Whether to generate matrixes as matrix_$architecture artifact' required: false default: 'false' + testexe: + description: 'Test executable to be run. One of scap-open or drivers-test' + required: false + default: 'scap-open' outputs: ansible_output: @@ -59,7 +63,7 @@ runs: working-directory: ${{ github.action_path }}/ansible-playbooks shell: bash run: | - ansible-playbook scap-open.yml --extra-vars "@vars.yml" || : + ansible-playbook ${{ inputs.testexe }}.yml --extra-vars "@vars.yml" || : - name: Tar output files shell: bash From 2be54f4c04a8d15149c6c8d9d73e0b572b1082bd Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Fri, 23 Feb 2024 09:24:27 +0100 Subject: [PATCH 3/3] fix(ansible): fixed drivers_test role. Signed-off-by: Federico Di Pierro --- ansible-playbooks/build-drivers-test.yml | 64 ------------------- ansible-playbooks/drivers-test.yml | 22 +++++-- .../roles/drivers_test/tasks/main.yml | 42 ++++++++---- 3 files changed, 48 insertions(+), 80 deletions(-) delete mode 100644 ansible-playbooks/build-drivers-test.yml diff --git a/ansible-playbooks/build-drivers-test.yml b/ansible-playbooks/build-drivers-test.yml deleted file mode 100644 index e826fa2..0000000 --- a/ansible-playbooks/build-drivers-test.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Playbook used to build and distribute drivers_test to all vms. - -- name: Build drivers_test on designated builder - hosts: "centos-builder" - remote_user: "{{ user }}" - gather_facts: false - tasks: - - name: Copy bpf skeleton to centos builder - ansible.builtin.copy: - src: "/tmp/bpf_probe.skel.h" - dest: "/tmp" - mode: '0755' - - - name: Create cmake output dir - ansible.builtin.file: - path: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - state: directory - mode: "0755" - register: cmake_result - - - name: Prepare cmake for repository - ansible.builtin.shell: - cmd: | - source /opt/rh/devtoolset-9/enable && - cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_LIBSCAP_MODERN_BPF=ON \ - -DMODERN_BPF_SKEL_DIR=/tmp \ - -DBUILD_DRIVER=Off \ - -DBUILD_BPF=Off \ - -DBUILD_LIBSCAP_GVISOR=OFF \ - -DENABLE_DRIVERS_TESTS=On \ - -DCREATE_TEST_TARGETS=On \ - -DENABLE_IA32_TESTS=Off \ - -DSCAP_FILES_SUITE_ENABLE=Off \ - .. - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - changed_when: false - register: cmake_result - - - name: Build drivers_test with modern probe - ansible.builtin.shell: - cmd: source /opt/rh/devtoolset-9/enable && make drivers_test -j {{ cpus }} - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - changed_when: false - register: cmake_result - - - name: Fetch the drivers_test binary - ansible.builtin.fetch: - src: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build/test/drivers/drivers_test" - dest: "/tmp/" - flat: true - -- name: Play that distributes drivers_test binary to VMs - hosts: "machines" - remote_user: "{{ user }}" - gather_facts: false - tasks: - - name: Copy drivers_test binary to all VMs - ansible.builtin.copy: - src: "/tmp/drivers_test" - dest: "/tmp" - mode: '0755' - become: false diff --git a/ansible-playbooks/drivers-test.yml b/ansible-playbooks/drivers-test.yml index 864f135..e8dd641 100644 --- a/ansible-playbooks/drivers-test.yml +++ b/ansible-playbooks/drivers-test.yml @@ -5,10 +5,25 @@ import_playbook: build-skeleton.yml - name: Include build-scap-open playbook import_playbook: build-scap-open.yml -- name: Include build-drivers-test playbook - import_playbook: build-drivers-test.yml -- name: Play that runs probes tests using drivers_test binary +# We need this since every VM is going to build its own drivers_test binary, +# because drivers_test is very tied to the kernel we are running on +# and must be built on each VM. +# To eventually (where supported) build drivers_test with modern_bpf support enabled, +# we need to pass the modern probe skeleton to each VM. +- name: Play that distributes modern bpf skeleton to VMs + hosts: "machines" + remote_user: "{{ user }}" + gather_facts: false + tasks: + - name: Copy bpf_probe.skel.h to all VMs + ansible.builtin.copy: + src: "/tmp/bpf_probe.skel.h" + dest: "/tmp" + mode: '0755' + become: false + +- name: Play that builds and runs drivers tests using drivers_test binary hosts: "machines" gather_facts: true remote_user: "{{ user }}" @@ -26,6 +41,5 @@ path: "./roles/drivers_test/files/" state: absent with_items: - - "/tmp/drivers_test" - "/tmp/scap-open" - "/tmp/bpf_probe.skel.h" diff --git a/ansible-playbooks/roles/drivers_test/tasks/main.yml b/ansible-playbooks/roles/drivers_test/tasks/main.yml index 54ba0a9..183a8c3 100644 --- a/ansible-playbooks/roles/drivers_test/tasks/main.yml +++ b/ansible-playbooks/roles/drivers_test/tasks/main.yml @@ -48,10 +48,14 @@ cmd: > cmake -DUSE_BUNDLED_DEPS=ON - -DBUILD_LIBSCAP_MODERN_BPF=OFF + -DBUILD_LIBSCAP_MODERN_BPF={{ modern_bpf_supported }} + -DMODERN_BPF_SKEL_DIR=/tmp -DBUILD_LIBSCAP_GVISOR=OFF -DBUILD_BPF={{ bpf_supported }} - -DCREATE_TEST_TARGETS=OFF + -DENABLE_DRIVERS_TESTS=On + -DCREATE_TEST_TARGETS=On + -DENABLE_IA32_TESTS=Off + -DSCAP_FILES_SUITE_ENABLE=Off .. chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" changed_when: false @@ -69,6 +73,27 @@ delegate_to: localhost become: false +- name: Build drivers_test binary + block: + - name: Build drivers_test + ansible.builtin.command: + cmd: make drivers_test -j {{ cpus }} + chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" + register: dt_result + changed_when: false + rescue: + - name: Print error message to stdout --- drivers_test + ansible.builtin.debug: + var: dt_result + always: + - name: Dump error message to file + ansible.builtin.copy: + content: "{{ dt_result | to_nice_json }}" + dest: "{{ output_dest_dir }}/drivers_test_build.json" + mode: '0755' + delegate_to: localhost + become: false + - name: Build and load the kernel module block: - name: Unload the kernel module @@ -108,14 +133,7 @@ block: - name: Run drivers_test with kernel module ansible.builtin.command: - cmd: /tmp/drivers_test -k - chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" - register: result - changed_when: false - - - name: Unload the kernel module - ansible.builtin.command: - cmd: rmmod driver/scap.ko + cmd: ./test/drivers/drivers_test -k chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" register: result changed_when: false @@ -158,7 +176,7 @@ block: - name: Run drivers_test with bpf probe ansible.builtin.command: - cmd: /tmp/drivers_test -b driver/bpf/probe.o + cmd: ./test/drivers/drivers_test -b driver/bpf/probe.o chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" register: result when: bpf_supported @@ -180,7 +198,7 @@ block: - name: Run drivers_test with modern-probe ansible.builtin.command: - cmd: /tmp/drivers_test -m + cmd: ./test/drivers/drivers_test -m chdir: "{{ remote_repos_folder }}/repos/{{ repos['libs'].name }}/build" register: result when: modern_bpf_supported