Skip to content

Commit

Permalink
ci: fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Aug 10, 2024
1 parent 2457c59 commit 2651f05
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 334 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-aot-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build and test AOT cli

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
Expand Down
51 changes: 23 additions & 28 deletions .github/workflows/test-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,40 @@ name: Build and Test VM

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
branches: [ main ]

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
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/setup-python@v4
if: startsWith(matrix.container,'ubuntu')

- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: build
run: make build-vm
- name: run tests x86

- name: Install LLVM 15
run: |
sudo apt update
sudo apt install llvm-15-dev -y
- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug

- name: Build Project
run: cmake --build build --target all -j

- name: Run Testsuite x86
shell: bash
run: |
python3.8 -m venv vm/test
source vm/test/bin/activate
pip install -r vm/test/requirements.txt
# make build # or build-arm32 build-arm64
make -C vm test-vm -j
make -C vm test-vm -j
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,25 @@ name: Run unit tests of llvm-jit

on:
push:
branches: "master"
branches: "main"
pull_request:
branches: "master"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
branches: "main"
jobs:
build:
strategy:
matrix:
container:
- ubuntu-2204
- fedora-39
runs-on: ubuntu-22.04
container:
image: "manjusakalza/bpftime-base-image:${{matrix.container}}"
options: --privileged
steps:
- 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
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A faster and better multi-arch JIT/AOT compiler based on LLVM.

This is part of the bpftime project, and can be used as a standalone library or compiler.
This is part of the [bpftime](https://github.com/eunomia-bpf/bpftime) project, and can be used as a standalone library or compiler.

## build

Expand All @@ -12,12 +12,38 @@ cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target all -j
```

## run
## Use llvmbpf as a library

```sh
build/vm-llvm-example
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);
}
```
## Use llvmbpf as a AOT compiler
## Test with bpf-conformance
- Follow the `build` section to build `llvm-jit`
Expand Down
182 changes: 0 additions & 182 deletions example/Makefile

This file was deleted.

Loading

0 comments on commit 2651f05

Please sign in to comment.