Add separate test to check if C++ programs work with Rizin (#1743)
This commit is contained in:
parent
fa9146c6c8
commit
618ed4e0a8
3 changed files with 65 additions and 0 deletions
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
|
|
@ -575,6 +575,32 @@ jobs:
|
|||
name: rizin-android-${{ matrix.name }}
|
||||
path: /tmp/rizin-android-${{ matrix.name }}.tar.gz
|
||||
|
||||
build-cpp:
|
||||
name: Include Rizin headers from C++ program
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.head_ref, 'dist') || contains(github.head_ref, 'cpp') || ((contains(github.ref, 'release-') || github.ref == 'refs/heads/stable') && github.event_name == 'push') || github.event_name == 'schedule'
|
||||
needs: [build-and-test]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get --assume-yes install pax wget unzip python3-wheel python3-setuptools python3-pip
|
||||
- name: Install meson and ninja
|
||||
run: sudo pip3 install meson ninja PyYAML
|
||||
- name: Compile & Install Rizin
|
||||
run: |
|
||||
export PATH=${HOME}/bin:${HOME}/Library/Python/3.8/bin:${HOME}/Library/Python/3.9/bin:${HOME}/.local/bin:${PATH}
|
||||
meson --buildtype release --prefix=/usr build
|
||||
ninja -C build && sudo ninja -C build install
|
||||
- name: Compile C++ test
|
||||
run: |
|
||||
export PATH=${HOME}/bin:${HOME}/Library/Python/3.8/bin:${HOME}/Library/Python/3.9/bin:${HOME}/.local/bin:${PATH}
|
||||
meson --prefix=/usr build-cpp-test ./test/unit/cpp
|
||||
meson compile -C build-cpp-test
|
||||
- name: Run C++ test
|
||||
run: |
|
||||
export PATH=${HOME}/bin:${HOME}/Library/Python/3.8/bin:${HOME}/Library/Python/3.9/bin:${HOME}/.local/bin:${PATH}
|
||||
meson test -C build-cpp-test
|
||||
|
||||
# build-extras:
|
||||
# name: Build rizin extras and rzpipe
|
||||
# if: contains(github.head_ref, 'dist') || contains(github.head_ref, 'extras') || contains(github.ref, 'release-') || github.event_name == 'schedule'
|
||||
|
|
@ -729,6 +755,7 @@ jobs:
|
|||
build-debian,
|
||||
build-static,
|
||||
build-android,
|
||||
build-cpp,
|
||||
test-osx-pkg,
|
||||
test-windows-clang_cl,
|
||||
build-rzpipe
|
||||
|
|
|
|||
11
test/unit/cpp/meson.build
Normal file
11
test/unit/cpp/meson.build
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
project('rizin-cpp-test', 'cpp')
|
||||
|
||||
rizin_libs = dependency('rz_core', required: true)
|
||||
|
||||
exe = executable('test_cpp', 'test_cpp.cpp',
|
||||
dependencies: [rizin_libs],
|
||||
install: false,
|
||||
implicit_include_directories: false,
|
||||
)
|
||||
|
||||
test('cpp', exe)
|
||||
27
test/unit/cpp/test_cpp.cpp
Normal file
27
test/unit/cpp/test_cpp.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// SPDX-FileCopyrightText: 2021 Florian Märkl <info@florianmaerkl.de>
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
#include <rz_core.h>
|
||||
#include <rz_util.h>
|
||||
|
||||
#include "../minunit.h"
|
||||
|
||||
/*
|
||||
* This is mostly just a test for ensuring all headers can be
|
||||
* compiled as C++.
|
||||
*/
|
||||
|
||||
bool test_cpp(void) {
|
||||
RzCore *core = rz_core_new();
|
||||
char *r = rz_core_cmd_str(core, "?e Hello from C++!");
|
||||
mu_assert_streq(r, "Hello from C++!\n", "cmd");
|
||||
rz_core_free(core);
|
||||
mu_end;
|
||||
}
|
||||
|
||||
bool all_tests() {
|
||||
mu_run_test(test_cpp);
|
||||
return tests_passed != tests_run;
|
||||
}
|
||||
|
||||
mu_main(all_tests)
|
||||
Loading…
Reference in a new issue