Skip to content

Commit

Permalink
fix(ansible): fixed drivers_test role.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP committed Feb 28, 2024
1 parent ccca551 commit 2be54f4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 80 deletions.
64 changes: 0 additions & 64 deletions ansible-playbooks/build-drivers-test.yml

This file was deleted.

22 changes: 18 additions & 4 deletions ansible-playbooks/drivers-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -26,6 +41,5 @@
path: "./roles/drivers_test/files/"
state: absent
with_items:
- "/tmp/drivers_test"
- "/tmp/scap-open"
- "/tmp/bpf_probe.skel.h"
42 changes: 30 additions & 12 deletions ansible-playbooks/roles/drivers_test/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2be54f4

Please sign in to comment.