forked from eclipse-iceoryx/iceoryx2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse-iceoryx#210] Move tests to integrationtests
- Loading branch information
1 parent
3b978e5
commit 0b33959
Showing
8 changed files
with
300 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#![allow(dead_code)] | ||
|
||
use iceoryx2::prelude::*; | ||
use iceoryx2_bb_testing::assert_that; | ||
use iceoryx2_ffi::*; | ||
|
||
pub(crate) trait ServiceTypeMapping { | ||
fn service_type() -> iox2_service_type_e; | ||
} | ||
|
||
impl ServiceTypeMapping for iceoryx2::service::zero_copy::Service { | ||
fn service_type() -> iox2_service_type_e { | ||
iox2_service_type_e::IPC | ||
} | ||
} | ||
|
||
impl ServiceTypeMapping for iceoryx2::service::process_local::Service { | ||
fn service_type() -> iox2_service_type_e { | ||
iox2_service_type_e::LOCAL | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
pub(crate) fn create_node<S: Service + ServiceTypeMapping>(node_name: &str) -> iox2_node_h { | ||
unsafe { | ||
let node_builder_handle = iox2_node_builder_new(std::ptr::null_mut()); | ||
|
||
let mut node_name_handle = std::ptr::null_mut(); | ||
let ret_val = iox2_node_name_new( | ||
std::ptr::null_mut(), | ||
node_name.as_ptr() as *const _, | ||
node_name.len() as _, | ||
&mut node_name_handle, | ||
); | ||
assert_that!(ret_val, eq(IOX2_OK)); | ||
iox2_node_builder_set_name( | ||
iox2_cast_node_builder_ref_h(node_builder_handle), | ||
node_name_handle, | ||
); | ||
|
||
let mut node_handle: iox2_node_h = std::ptr::null_mut(); | ||
let ret_val = iox2_node_builder_create( | ||
node_builder_handle, | ||
std::ptr::null_mut(), | ||
S::service_type(), | ||
&mut node_handle as *mut iox2_node_h, | ||
); | ||
|
||
assert_that!(ret_val, eq(IOX2_OK)); | ||
|
||
node_handle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
mod common; | ||
|
||
#[generic_tests::define] | ||
mod node_builder { | ||
|
||
use crate::common::*; | ||
use iceoryx2::prelude::*; | ||
use iceoryx2_bb_testing::assert_that; | ||
use iceoryx2_ffi::*; | ||
|
||
#[test] | ||
fn basic_node_builder_api_test<S: Service + ServiceTypeMapping>() { | ||
unsafe { | ||
let node_builder_handle = iox2_node_builder_new(std::ptr::null_mut()); | ||
let mut node_handle: iox2_node_h = std::ptr::null_mut(); | ||
let ret_val = iox2_node_builder_create( | ||
node_builder_handle, | ||
std::ptr::null_mut(), | ||
S::service_type(), | ||
&mut node_handle as *mut iox2_node_h, | ||
); | ||
|
||
assert_that!(ret_val, eq(IOX2_OK)); | ||
assert_that!(node_handle, ne(std::ptr::null_mut())); | ||
|
||
iox2_node_drop(node_handle); | ||
} | ||
} | ||
|
||
#[instantiate_tests(<iceoryx2::service::zero_copy::Service>)] | ||
mod ipc {} | ||
|
||
#[instantiate_tests(<iceoryx2::service::process_local::Service>)] | ||
mod local {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
use iceoryx2::prelude::*; | ||
use iceoryx2_bb_testing::assert_that; | ||
use iceoryx2_ffi::*; | ||
|
||
use core::{slice, str}; | ||
|
||
#[test] | ||
fn basic_node_name_test() -> Result<(), Box<dyn std::error::Error>> { | ||
unsafe { | ||
let expected_node_name = NodeName::new("hypnotaod")?; | ||
|
||
let mut node_name_handle: iox2_node_name_h = std::ptr::null_mut(); | ||
let ret_val = iox2_node_name_new( | ||
std::ptr::null_mut(), | ||
expected_node_name.as_str().as_ptr() as *const _, | ||
expected_node_name.len() as _, | ||
&mut node_name_handle, | ||
); | ||
assert_that!(ret_val, eq(IOX2_OK)); | ||
|
||
let mut node_name_len = 0; | ||
let node_name_c_str = iox2_node_name_as_c_str( | ||
iox2_cast_node_name_ptr(node_name_handle), | ||
&mut node_name_len, | ||
); | ||
|
||
let slice = slice::from_raw_parts(node_name_c_str as *const _, node_name_len as _); | ||
let node_name = str::from_utf8(slice)?; | ||
|
||
assert_that!(node_name, eq(expected_node_name.as_str())); | ||
|
||
iox2_node_name_drop(node_name_handle); | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.