Add separate test to check if C++ programs work with Rizin (#1743)

This commit is contained in:
Riccardo Schirone 2021-09-24 10:15:59 +02:00 committed by GitHub
parent fa9146c6c8
commit 618ed4e0a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 0 deletions

View file

@ -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
View 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)

View 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)