Skip to content

Commit

Permalink
doc: fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Littlefisher619 committed Oct 20, 2023
1 parent 3148578 commit 4aa91c1
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Build and public docker image
on:
push:
branches: "master"
pull_request:
# Why wildcard? Because we want to see test results when examing prs from non-master branches..
branches: "master"

jobs:
build-and-push-image:
Expand Down Expand Up @@ -38,7 +41,7 @@ jobs:
# Note: tags has to be all lower-case
tags: |
ghcr.io/${{ github.repository_owner }}/bpftime:latest
push: true
push: github.repository_owner == 'eunomia-bpf'

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
2 changes: 1 addition & 1 deletion .github/workflows/test-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
- name: Build the target
run: |
CC=gcc-12 CXX=g++-12 make build-unit-test
- name: Run the test
- name: Run the unit test
run: |
make unit-test
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ubuntu:23.04
WORKDIR /bpftime
RUN apt-get update && apt install -y --no-install-recommends \
RUN apt-get update && apt-get install -y --no-install-recommends \
libelf1 libelf-dev zlib1g-dev make cmake git libboost1.74-all-dev \
binutils-dev libyaml-cpp-dev gcc g++ ca-certificates clang llvm
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
binutils-dev libyaml-cpp-dev gcc g++ ca-certificates clang llvm cargo
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
COPY . .
RUN git submodule update --init --recursive
ENV CXX=g++
Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ help:

build-unit-test:
cmake -Bbuild -DBPFTIME_ENABLE_UNIT_TESTING=1 -DCMAKE_BUILD_TYPE:STRING=Debug
cmake --build build --config Debug -j --target bpftime_runtime_tests
cmake --build build --config Debug --target bpftime_runtime_tests

unit-test:
./build/runtime/unit-test/bpftime_runtime_tests
test: ## test the package
make -C third_party/libbpf/src
make -C runtime/test/bpf
cp -r runtime/test/bpf/* build/runtime/test/
cd build/runtime && ctest -VV

build: ## build the package
cmake -Bbuild -DBPFTIME_ENABLE_UNIT_TESTING=1
cmake -Bbuild
cmake --build build --config Debug
cd tools/cli-rs && cargo build

Expand Down
2 changes: 1 addition & 1 deletion documents/build-and-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ make build-llvm # build the vm with llvm jit
Run the test suite for runtime to validate the implementation:

```bash
make test
make unit-test
```
17 changes: 10 additions & 7 deletions runtime/bpftime-daemon/handle_bpf_event.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "handle_bpf_event.hpp"
#include <bpf/libbpf.h>
#include <bpf/bpf.h>
#include <cstdio>
#include <errno.h>
#include <sys/time.h>
#include <time.h>
#include <linux/perf_event.h>
#include "handle_bpf_event.hpp"
#include "bpf-mocker-event.h"

using namespace bpftime;

Expand Down Expand Up @@ -132,12 +135,6 @@ static const char *bpf_prog_type_strings[] = {
"BPF_PROG_TYPE_SYSCALL",
};

bpf_event_handler::bpf_event_handler(struct env config) : config(config)
{
perf_type_id_strings[determine_uprobe_perf_type()] = "PERF_TYPE_UPROBE";
perf_type_id_strings[determine_kprobe_perf_type()] = "PERF_TYPE_KPROBE";
}

int bpf_event_handler::handle_bpf_event(const struct event *e)
{
struct tm *tm;
Expand Down Expand Up @@ -237,3 +234,9 @@ int bpf_event_handler::handle_event(const struct event *e)
}
return 0;
}

bpf_event_handler::bpf_event_handler(struct env config) : config(config)
{
perf_type_id_strings[determine_uprobe_perf_type()] = "PERF_TYPE_UPROBE";
perf_type_id_strings[determine_kprobe_perf_type()] = "PERF_TYPE_KPROBE";
}
1 change: 0 additions & 1 deletion runtime/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ add_test(NAME bpftime_runtime_tests COMMAND bpftime_runtime_tests)
# These are necessary ebpf program required by the test
set(used_ebpf_programs
uprobe

# replace # Not used now
filter)

Expand Down
4 changes: 2 additions & 2 deletions runtime/unit-test/assets/uprobe.bpf.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define BPF_NO_GLOBAL_DATA
#include "vmlinux.h"
#include "bpf/bpf_tracing.h"
#include "bpf/bpf_helpers.h"
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_helpers.h>

SEC("uprobe")
int BPF_UPROBE(my_function_uprobe, int parm1, char* str, char c) {
Expand Down

0 comments on commit 4aa91c1

Please sign in to comment.