-
Notifications
You must be signed in to change notification settings - Fork 9
(8) feat(dpdk): test EAL harness (with_eal macro + const fn) #1572
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
450efc7
refactor(dpdk/acl): make compute_min_input_size a const fn
daniel-noland 660ddfd
feat(dpdk): test_support::start_eal + #[with_eal] attribute macro
daniel-noland 4a2de58
feat(fixed-size): FixedSize trait crate + net wire newtype impls
daniel-noland 62f7bd4
feat(lookup): Lookup<K,A> + Projection<T> trait crate
daniel-noland bad9f97
feat(match-action): MatchKey trait + #[derive(MatchKey)] proc-macro
daniel-noland 3741795
feat(match-action): bolero FieldHit / FieldMiss generators
daniel-noland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,15 @@ | ||
| [package] | ||
| name = "dataplane-dpdk-test-macros" | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| publish.workspace = true | ||
| version.workspace = true | ||
|
|
||
| [lib] | ||
| proc-macro = true | ||
|
|
||
| [dependencies] | ||
| proc-macro-crate = { workspace = true, default-features = true } | ||
| proc-macro2 = { workspace = true, default-features = true } | ||
| quote = { workspace = true, default-features = true } | ||
| syn = { workspace = true, default-features = true, features = ["full"] } |
This file contains hidden or 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,39 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright Open Network Fabric Authors | ||
|
|
||
| use proc_macro::TokenStream; | ||
| use proc_macro_crate::{FoundCrate, crate_name}; | ||
| use proc_macro2::{Span, TokenStream as TokenStream2}; | ||
| use quote::quote; | ||
| use syn::{Ident, ItemFn, parse_macro_input, parse_quote}; | ||
| fn dpdk_crate_path() -> TokenStream2 { | ||
| match crate_name("dataplane-dpdk") { | ||
| Ok(FoundCrate::Itself) => quote! { crate }, | ||
| Ok(FoundCrate::Name(name)) => { | ||
| let ident = Ident::new(&name, Span::call_site()); | ||
| quote! { ::#ident } | ||
| } | ||
| Err(_) => { | ||
| let ident = Ident::new("dataplane_dpdk", Span::call_site()); | ||
| quote! { ::#ident } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[proc_macro_attribute] | ||
| pub fn with_eal(args: TokenStream, input: TokenStream) -> TokenStream { | ||
| if !args.is_empty() { | ||
| let err: TokenStream2 = | ||
| syn::Error::new(Span::call_site(), "#[with_eal] takes no arguments").to_compile_error(); | ||
| return err.into(); | ||
| } | ||
|
|
||
| let mut input_fn = parse_macro_input!(input as ItemFn); | ||
| let dpdk = dpdk_crate_path(); | ||
| let init_stmt: syn::Stmt = parse_quote! { | ||
| let _eal = #dpdk::test_support::start_eal(); | ||
| }; | ||
| input_fn.block.stmts.insert(0, init_stmt); | ||
|
|
||
| quote! { #input_fn }.into() | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.