Skip to content
Closed
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
12 changes: 10 additions & 2 deletions .github/workflows/latest-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ jobs:
cargo update --verbose

- name: Build with feature combinations
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ matrix.runner_os != 'ubuntu-22.04' || endsWith(matrix.target, '-musl') }}
run: >-
cargo hack --each-feature
build --locked

- name: Run tests (bins/lib/tests/examples) with feature combinations
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# Disable tests for musl libc target(s) due to build failure for unknown reasons.
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ !endsWith(matrix.target, '-musl') }}
if: ${{ matrix.runner_os != 'ubuntu-22.04' && !endsWith(matrix.target, '-musl') }}
run: >-
cargo hack --each-feature
test --locked
Expand All @@ -120,15 +124,19 @@ jobs:
# certain features only for some doctests, so we run them without
# `cargo-hack`.
- name: Run doctests with all features enabled
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# Disable tests for musl libc target(s) due to build failure for unknown reasons.
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ !endsWith(matrix.target, '-musl') }}
if: ${{ matrix.runner_os != 'ubuntu-22.04' && !endsWith(matrix.target, '-musl') }}
run: >-
cargo test
--locked --all-features
--doc

- name: Build package with all features enabled
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ matrix.runner_os != 'ubuntu-22.04' || endsWith(matrix.target, '-musl') }}
# We allow dirty state here because it is only expected after update.
run: >-
cargo package
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ jobs:
shared-key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.target }}-${{ matrix.runner_os }}

- name: Build with feature combinations
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ matrix.runner_os != 'ubuntu-22.04' || endsWith(matrix.target, '-musl') }}
run: >-
cargo hack --each-feature
build --locked

- name: Run tests (bins/lib/tests/examples) with feature combinations
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# Disable tests for musl libc target(s) due to build failure for unknown reasons.
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ !endsWith(matrix.target, '-musl') }}
if: ${{ matrix.runner_os != 'ubuntu-22.04' && !endsWith(matrix.target, '-musl') }}
run: >-
cargo hack --each-feature
test --locked
Expand All @@ -136,15 +140,19 @@ jobs:
# certain features only for some doctests, so we run them without
# `cargo-hack`.
- name: Run doctests with all features enabled
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# Disable tests for musl libc target(s) due to build failure for unknown reasons.
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ !endsWith(matrix.target, '-musl') }}
if: ${{ matrix.runner_os != 'ubuntu-22.04' && !endsWith(matrix.target, '-musl') }}
run: >-
cargo test
--locked --all-features
--doc

- name: Build package with all features enabled
# Disable build for GNU targets on Ubuntu 22.04 (unsupported `atomic_uintptr_t`).
# TODO: Try to re-enable this step regardless of the build target in the future.
if: ${{ matrix.runner_os != 'ubuntu-22.04' || endsWith(matrix.target, '-musl') }}
run: >-
cargo package
--locked --all-features
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Breaking: Upgrade to open62541 version
[1.5.0](https://github.com/open62541/open62541/releases/tag/v1.5.0).

## [0.5.1] - 2025-10-21

### Changed
Expand Down
2 changes: 1 addition & 1 deletion open62541
Submodule open62541 updated 652 files
38 changes: 10 additions & 28 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,23 @@ use open62541_sys::{
va_list_,
};

// Check validity of explicitly defined type aliases.
#[test]
fn variadic_arguments() {
// Check if `va_list_` type matches.
fn type_aliases() {
const unsafe extern "C" fn log_c(
_log_context: *mut ffi::c_void,
_level: UA_LogLevel,
_category: UA_LogCategory,
_msg: *const ffi::c_char,
_args: va_list_,
) {
// Nothing here.
}
let _logger = UA_Logger {
log: Some(log_c),
context: ptr::null_mut(),
clear: None,
};
}

#[test]
fn logger_types() {
// Check validity of type aliases for `UA_Logger` callbacks.
const unsafe extern "C" fn log_c(
_log_context: *mut ffi::c_void,
_level: UA_LogLevel,
_category: UA_LogCategory,
_msg: *const ffi::c_char,
_args: va_list_,
) {
const unsafe extern "C" fn clear_c(_logger: *mut UA_Logger) {
// Nothing here.
}
const unsafe extern "C" fn clear_c(_logger: *mut UA_Logger) {}

let log: UA_LoggerLogCallback_ = Some(log_c);
let clear: UA_LoggerClearCallback_ = Some(clear_c);
let _logger = UA_Logger {
Expand All @@ -44,16 +31,11 @@ fn logger_types() {
};
}

// Make sure that our custom exports (prefixed with `RS_`) are available under their expected names,
// i.e. without the `RS_` prefix.
#[test]
fn has_custom_exports() {
// Make sure that our custom exports (prefixed internally with `RS_`) are available under their
// expected names.
//
use open62541_sys::{UA_EMPTY_ARRAY_SENTINEL, vsnprintf_va_copy, vsnprintf_va_end};
fn custom_exports() {
use open62541_sys::UA_EMPTY_ARRAY_SENTINEL;

#[expect(clippy::no_effect_underscore_binding, reason = "check existence")]
let _unused = vsnprintf_va_copy;
#[expect(clippy::no_effect_underscore_binding, reason = "check existence")]
let _unused = vsnprintf_va_end;
let _unused = unsafe { UA_EMPTY_ARRAY_SENTINEL };
}
56 changes: 1 addition & 55 deletions wrapper.c
Original file line number Diff line number Diff line change
@@ -1,61 +1,7 @@
#include "wrapper.h"

// Wrapper for `vsnprintf()` with normalized behavior across different platforms
// such as Microsoft Windows.
//
// Other than the standard `vsnprintf()`, this function does not consume the
// passed `va_list` argument! The caller is responsible for calling
// `vsnprintf_va_end()` on the `va_list` argument eventually.
#if defined(_MSC_VER) && _MSC_VER < 1900
int RS_vsnprintf_va_copy(
char *buffer,
size_t count,
const char *format,
va_list args)
{
// Microsoft does not (always) define a standard-conforming `vsnprintf()`. But
// it does define a variant with slightly different behavior. We normalize the
// differences as best we can.
int result = -1;
if (count)
{
va_list args_copied;
va_copy(args_copied, args);
result = _vsnprintf_s(buffer, count, _TRUNCATE, format, args_copied);
}
if (result < 0)
{
va_list args_copied;
va_copy(args_copied, args);
result = _vscprintf(format, args_copied);
}

return result;
}
#else
int RS_vsnprintf_va_copy(
char *buffer,
size_t count,
const char *format,
va_list args)
{
// Forward to existing standards-compliant function. It may have be defined as
// a macro, so we need a wrapper function for bindgen to pick it up anyway.
va_list args_copied;
va_copy(args_copied, args);
int result = vsnprintf(buffer, count, format, args_copied);

return result;
}
#endif

void RS_vsnprintf_va_end(va_list args)
{
va_end(args);
}

// bindgen does not support non-trivial `#define` used for pointer constant. Use
// statically defined constant as workaround for now.
//
// See https://github.com/rust-lang/rust-bindgen/issues/2426
// See <https://github.com/rust-lang/rust-bindgen/issues/2426>.
const void *const RS_UA_EMPTY_ARRAY_SENTINEL = UA_EMPTY_ARRAY_SENTINEL;
34 changes: 4 additions & 30 deletions wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,16 @@
#include <open62541/server_config_default.h>
#include <open62541/plugin/accesscontrol.h>
#include <open62541/plugin/accesscontrol_default.h>
#include <open62541/plugin/certificategroup.h>
#include <open62541/plugin/certificategroup_default.h>
#include <open62541/plugin/create_certificate.h>
#include <open62541/plugin/log.h>
#include <open62541/plugin/log_stdout.h>
#include <open62541/plugin/pki.h>
#include <open62541/plugin/pki_default.h>
#include <open62541/plugin/securitypolicy.h>

// Include files that are only available (by CMake) with certain flags.
#ifdef UA_ENABLE_ENCRYPTION
#include <open62541/plugin/create_certificate.h>
#include <open62541/plugin/securitypolicy_default.h>
#endif

// Include with binding of `vsnprintf()` and `va_list` functions to simplify
// formatting of log messages.
#include <stdarg.h>
#include <stdio.h>

// bindgen does not support non-trivial `#define` used for pointer constant. Use
// statically defined constant as workaround for now.
//
// See https://github.com/rust-lang/rust-bindgen/issues/2426
// See <https://github.com/rust-lang/rust-bindgen/issues/2426>.
extern const void *const RS_UA_EMPTY_ARRAY_SENTINEL;

// Wrapper for `vsnprintf()` with normalized behavior across different platforms
// such as Microsoft Windows.
//
// Other than the standard `vsnprintf()`, this implementation copies the
// `va_list` argument before passing it along to allow repeated calls. The
// caller is responsible to invoke `vsnprintf_va_end()` on the `va_list`
// argument eventually.
int RS_vsnprintf_va_copy(
char *buffer,
size_t count,
const char *format,
va_list args);

// Wrapper for `va_end()` that is supposed to be used with
// `vsnprintf_va_copy()`.
void RS_vsnprintf_va_end(va_list args);