Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ARM build, and test it in CI #162

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
language: rust

rust:
- stable
- nightly-2019-10-17

sudo: required

services:
- docker

os:
- linux
- osx
jobs:
include:
- os: linux
arch: amd64
rust: stable
- os: linux
arch: amd64
rust: nightly-2019-10-17
env: RDKAFKA_RUN_TESTS=1
- os: linux
arch: arm64
rust: stable
- os: osx
rust: stable

script:
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == nightly* ]]; then ./test_suite.sh; else cargo build --verbose; fi
- if [[ "$RDKAFKA_RUN_TESTS" ]]; then ./test_suite.sh; else cargo build --verbose; fi

notifications:
webhooks:
Expand Down
4 changes: 2 additions & 2 deletions src/consumer/base_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<C: ConsumerContext> Consumer<C> for BaseConsumer<C> {
}
let ret_code = unsafe { rdsys::rd_kafka_subscribe(self.client.native_ptr(), tpl.ptr()) };
if ret_code.is_error() {
let error = unsafe { cstr_to_owned(rdsys::rd_kafka_err2str(ret_code) as *const i8) };
let error = unsafe { cstr_to_owned(rdsys::rd_kafka_err2str(ret_code)) };
return Err(KafkaError::Subscription(error));
};
Ok(())
Expand All @@ -189,7 +189,7 @@ impl<C: ConsumerContext> Consumer<C> for BaseConsumer<C> {
fn assign(&self, assignment: &TopicPartitionList) -> KafkaResult<()> {
let ret_code = unsafe { rdsys::rd_kafka_assign(self.client.native_ptr(), assignment.ptr()) };
if ret_code.is_error() {
let error = unsafe { cstr_to_owned(rdsys::rd_kafka_err2str(ret_code) as *const i8) };
let error = unsafe { cstr_to_owned(rdsys::rd_kafka_err2str(ret_code)) };
return Err(KafkaError::Subscription(error));
};
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/consumer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait ConsumerContext: ClientContext {
}
RDKafkaRespErr::RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS => Rebalance::Revoke,
_ => {
let error = unsafe { cstr_to_owned(rdsys::rd_kafka_err2str(err) as *const i8) };
let error = unsafe { cstr_to_owned(rdsys::rd_kafka_err2str(err)) };
error!("Error rebalancing: {}", error);
Rebalance::Error(error)
}
Expand Down
6 changes: 3 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ impl<T: Send + Sync> IntoOpaque for Box<T> {

// TODO: check if the implementation returns a copy of the data and update the documentation
/// Converts a byte array representing a C string into a String.
pub unsafe fn bytes_cstr_to_owned(bytes_cstr: &[i8]) -> String {
pub unsafe fn bytes_cstr_to_owned(bytes_cstr: &[c_char]) -> String {
CStr::from_ptr(bytes_cstr.as_ptr() as *const c_char).to_string_lossy().into_owned()
}

/// Converts a C string into a String.
pub unsafe fn cstr_to_owned(cstr: *const i8) -> String {
pub unsafe fn cstr_to_owned(cstr: *const c_char) -> String {
CStr::from_ptr(cstr as *const c_char).to_string_lossy().into_owned()
}

Expand All @@ -122,7 +122,7 @@ impl ErrBuf {
ErrBuf { buf: [0; ErrBuf::MAX_ERR_LEN] }
}

pub fn as_mut_ptr(&mut self) -> *mut i8 {
pub fn as_mut_ptr(&mut self) -> *mut c_char {
self.buf.as_mut_ptr()
}

Expand Down