Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Aug 10, 2024
1 parent 2457c59 commit 0e9e143
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 312 deletions.
28 changes: 6 additions & 22 deletions .github/workflows/test-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,8 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
container:
- ubuntu-2204
- fedora-39
container:
image: "manjusakalza/bpftime-base-image:${{matrix.container}}"
options: --privileged
steps:

- name: cache dependencies
uses: actions/cache@v2
id: cache
with:
path: ${{ github.workspace }}/${{ env.INSTALL_LOCATION }}
key: ${{ runner.os }}-dependencies
- uses: actions/checkout@v2
with:
submodules: 'recursive'
Expand All @@ -35,8 +15,12 @@ jobs:
with:
python-version: '3.8'
- name: build
run: make build-vm
- name: run tests x86
run:
|
sudo apt install llvm-15-dev
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --target all -j
- name: run testsuit x86
shell: bash
run: |
python3.8 -m venv vm/test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Build and install everything
- name: build
run:
|
sudo apt install llvm-15-dev
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1
cmake --build build --target all -j
- name: Run example
run: |
make build-llvm -j
./build/vm-llvm-example
- name: Run tests
run: |
./build/vm/llvm-jit/unit-test/llvm_jit_tests
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ if(${BPFTIME_LLVM_JIT})
add_subdirectory(cli)
else()
if(${BPFTIME_ENABLE_UNIT_TESTING})
message(INFO " Adding Catch2 seperately..")
FetchContent_Declare(
catch
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
Expand Down
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,35 @@ cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target all -j
```

## run
## Use llvmbpf as a compiler

```sh
build/vm-llvm-example


## Use llvmbpf as a library

See [example](example/main.cpp) of how to use the library as a vm:

```cpp
void run_ebpf_prog(const void *code, size_t code_len)
{
uint64_t res = 0;
bpftime_llvm_jit_vm vm;

res = vm.load_code(code, code_len);
if (res) {
return;
}
vm.register_external_function(2, "print", (void *)ffi_print_func);
auto func = vm.compile();
if (!func) {
return;
}
int err = vm.exec(&bpf_mem, sizeof(bpf_mem), res);
if (err != 0) {
return;
}
printf("res = %" PRIu64 "\n", res);
}
```
## Test with bpf-conformance
Expand Down
182 changes: 0 additions & 182 deletions example/Makefile

This file was deleted.

Loading

0 comments on commit 0e9e143

Please sign in to comment.