[vlc-commits] [Git][videolan/vlc][master] 2 commits: src: gitignore: limit overzealous test_* exclusion
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Jul 14 10:52:02 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
55a465c2 by Alexandre Janniaux at 2024-07-14T10:35:37+00:00
src: gitignore: limit overzealous test_* exclusion
- - - - -
c8ac4ff6 by Alexandre Janniaux at 2024-07-14T10:35:37+00:00
vlcrs-macros: add missing test file
The test_common.rs file was previously matching a .gitignore rule and
thus wasn't commited previously by other commits. The CI is not building
rust so there were no issues raised but the tests are expecting the
file to be present of course.
Missing from commit 15d9c3b7284b0691324618df0c20615a4dd7bcf8.
- - - - -
6 changed files:
- src/.gitignore
- + src/rust/vlcrs-macros/tests/common/mod.rs
- src/rust/vlcrs-macros/tests/module.rs
- src/rust/vlcrs-macros/tests/module_default.rs
- src/rust/vlcrs-macros/tests/module_multiple.rs
- src/rust/vlcrs-macros/tests/module_specific.rs
Changes:
=====================================
src/.gitignore
=====================================
@@ -1,4 +1,6 @@
test_*
+!test_*.*
+test_*.exe
checkheader_*_h.c
fourcc_gen
fourcc_tables.h
=====================================
src/rust/vlcrs-macros/tests/common/mod.rs
=====================================
@@ -0,0 +1,65 @@
+//
+// Copyright (C) 2024 Alexandre Janniaux <ajanni at videolabs.io>
+//
+
+/* This should only be in the tests/ final modules but cargo doesn't
+ * seem to account them correctly otherwise. */
+
+use std::{ffi::{c_char, c_int, c_void}, marker::FnPtr};
+use vlcrs_plugin::{vlc_activate, vlc_deactivate};
+
+pub struct TestContext<Activate, Deactivate=vlc_deactivate> {
+ pub command_cursor: usize,
+ pub commands: Vec<vlcrs_plugin::ModuleProperties>,
+ pub open_cb: Option<Activate>,
+ pub close_cb: Option<Deactivate>,
+}
+
+pub fn load_manifest<Activate, Deactivate>(
+ context: &mut TestContext<Activate, Deactivate>,
+ vlc_entry: extern "C" fn (vlc_set_cb: vlcrs_plugin::sys::vlc_set_cb, opaque: *mut c_void) -> c_int
+)
+ -> i32
+{
+ use vlcrs_plugin::ModuleProperties;
+
+ unsafe extern "C" fn set_cb<T : Sized + FnPtr>(
+ context: *mut c_void,
+ _target: *mut c_void,
+ propid: c_int,
+ mut args: ...) -> c_int
+ {
+ let context : *mut TestContext::<T> = context as *mut _;
+ let opcode = ModuleProperties::try_from(propid);
+ println!("PropId: {:?} ({})", opcode, propid);
+
+ let opcode = opcode.unwrap();
+ assert!((*context).command_cursor < (*context).commands.len());
+
+ assert_eq!((*context).commands[(*context).command_cursor], opcode);
+ (*context).command_cursor += 1;
+
+ if opcode == ModuleProperties::MODULE_CB_OPEN
+ {
+ let _name = args.arg::<*const c_char>();
+ let func = args.arg::<*mut c_void>();
+ assert_ne!(func, std::ptr::null_mut());
+ (*context).open_cb = unsafe {
+ Some(std::mem::transmute_copy(&func))
+ };
+ }
+ else if opcode == ModuleProperties::MODULE_CB_CLOSE
+ {
+ let _name = args.arg::<*const c_char>();
+ let func = args.arg::<*mut c_void>();
+ assert_ne!(func, std::ptr::null_mut());
+ (*context).close_cb = unsafe {
+ Some(std::mem::transmute_copy(&func))
+ };
+ }
+
+ 0
+ }
+
+ vlc_entry(set_cb::<vlc_activate>, context as *mut _ as *mut c_void)
+}
=====================================
src/rust/vlcrs-macros/tests/module.rs
=====================================
@@ -7,8 +7,8 @@
#![feature(extern_types)]
#![feature(fn_ptr_trait)]
-mod test_common;
-use crate::test_common::TestContext;
+mod common;
+use common::TestContext;
use vlcrs_macros::module;
@@ -92,7 +92,7 @@ fn test_module_load_common_activate()
open_cb: None,
close_cb: None,
};
- let ret = test_common::load_manifest(&mut context, vlc_entry);
+ let ret = common::load_manifest(&mut context, vlc_entry);
assert_eq!(ret, 0);
assert_ne!(context.open_cb, None);
assert_ne!(context.close_cb, None);
=====================================
src/rust/vlcrs-macros/tests/module_default.rs
=====================================
@@ -7,7 +7,8 @@
#![feature(extern_types)]
#![feature(fn_ptr_trait)]
-mod test_common;
+mod common;
+use common::TestContext;
use vlcrs_macros::module;
@@ -21,7 +22,6 @@ fn activate_filter(_obj: *mut vlcrs_plugin::vlc_object_t) -> c_int
0
}
-use crate::test_common::TestContext;
//
// Create an implementation loader for the TestFilterCapability
@@ -95,7 +95,7 @@ fn test_module_load_default_deactivate()
open_cb: None,
close_cb: None,
};
- let ret = test_common::load_manifest(&mut context, vlc_entry);
+ let ret = common::load_manifest(&mut context, vlc_entry);
assert_eq!(ret, 0);
assert_ne!(context.open_cb, None);
assert_eq!(context.close_cb, None);
=====================================
src/rust/vlcrs-macros/tests/module_multiple.rs
=====================================
@@ -7,7 +7,8 @@
#![feature(extern_types)]
#![feature(fn_ptr_trait)]
-mod test_common;
+mod common;
+use common::TestContext;
use vlcrs_macros::module;
@@ -31,8 +32,6 @@ fn activate_filter<T: TestFilterCapability>(_obj: *mut vlc_filter_t, valid: &mut
0
}
-use crate::test_common::TestContext;
-
//
// Create an implementation loader for the TestFilterCapability
//
@@ -147,7 +146,7 @@ fn test_module_manifest_multiple_capabilities()
open_cb: None,
close_cb: None,
};
- let ret = test_common::load_manifest(&mut context, vlc_entry);
+ let ret = common::load_manifest(&mut context, vlc_entry);
assert_eq!(ret, 0);
assert_ne!(context.open_cb, None);
=====================================
src/rust/vlcrs-macros/tests/module_specific.rs
=====================================
@@ -7,7 +7,8 @@
#![feature(extern_types)]
#![feature(fn_ptr_trait)]
-mod test_common;
+mod common;
+use common::TestContext;
use vlcrs_macros::module;
@@ -41,8 +42,6 @@ fn deactivate_filter<T: TestFilterCapability>(_obj: *mut vlc_filter_t, valid: &m
0
}
-use crate::test_common::TestContext;
-
//
// Create an implementation loader for the TestFilterCapability
//
@@ -131,7 +130,7 @@ fn test_module_load_specific_open()
open_cb: None,
close_cb: None,
};
- let ret = test_common::load_manifest(&mut context, vlc_entry);
+ let ret = common::load_manifest(&mut context, vlc_entry);
assert_eq!(ret, 0);
assert_ne!(context.open_cb, None);
assert_ne!(context.close_cb, None);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7e8f8fb3f2bf62df29d43a3a0750fd007b974087...c8ac4ff61d5a6f0d881c95427fb916cd77fe9b94
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7e8f8fb3f2bf62df29d43a3a0750fd007b974087...c8ac4ff61d5a6f0d881c95427fb916cd77fe9b94
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list