@@ -2507,3 +2507,176 @@ mod get_log_page {
25072507 } ) ;
25082508 }
25092509}
2510+
2511+ mod namespace_management {
2512+ use mctp:: MsgIC ;
2513+
2514+ use crate :: {
2515+ RESP_INVALID_COMMAND_SIZE ,
2516+ common:: { DeviceType , ExpectedRespChannel , new_device, setup} ,
2517+ } ;
2518+
2519+ #[ test]
2520+ fn create_short ( ) {
2521+ setup ( ) ;
2522+
2523+ let ( mut mep, mut subsys) = new_device ( DeviceType :: P1p1tC1aN0a0a ) ;
2524+
2525+ #[ rustfmt:: skip]
2526+ const REQ : [ u8 ; 71 ] = [
2527+ 0x10 , 0x00 , 0x00 ,
2528+ 0x0d , 0x00 , 0x00 , 0x00 ,
2529+
2530+ // SQE DWORD 1
2531+ 0x00 , 0x00 , 0x00 , 0x00 ,
2532+ 0x00 , 0x00 , 0x00 , 0x00 ,
2533+ 0x00 , 0x00 , 0x00 , 0x00 ,
2534+ 0x00 , 0x00 , 0x00 , 0x00 ,
2535+ 0x00 , 0x00 , 0x00 , 0x00 ,
2536+
2537+ // DOFST
2538+ 0x00 , 0x00 , 0x00 , 0x00 ,
2539+ 0x00 , 0x10 , 0x00 , 0x00 ,
2540+
2541+ // Reserved
2542+ 0x00 , 0x00 , 0x00 , 0x00 ,
2543+ 0x00 , 0x00 , 0x00 , 0x00 ,
2544+
2545+ // SQE DWORD 10
2546+ 0x00 , 0x00 , 0x00 , 0x00 ,
2547+ 0x00 , 0x00 , 0x00 , 0x00 ,
2548+ 0x00 , 0x00 , 0x00 , 0x00 ,
2549+ 0x00 , 0x00 , 0x00 , 0x00 ,
2550+ 0x00 , 0x00 , 0x00 , 0x00 ,
2551+ 0x00 , 0x00 , 0x00 , 0x00 ,
2552+
2553+ // Missing request data
2554+
2555+ // MIC
2556+ 0x17 , 0xc6 , 0x4c , 0x65
2557+ ] ;
2558+
2559+ let resp = ExpectedRespChannel :: new ( & RESP_INVALID_COMMAND_SIZE ) ;
2560+ smol:: block_on ( async {
2561+ mep. handle_async ( & mut subsys, & REQ , MsgIC ( true ) , resp, async |_| Ok ( ( ) ) )
2562+ . await
2563+ } ) ;
2564+ }
2565+
2566+ #[ test]
2567+ fn create_long ( ) {
2568+ setup ( ) ;
2569+
2570+ let ( mut mep, mut subsys) = new_device ( DeviceType :: P1p1tC1aN0a0a ) ;
2571+
2572+ #[ rustfmt:: skip]
2573+ const REQ_DATA : [ u8 ; 67 ] = [
2574+ 0x10 , 0x00 , 0x00 ,
2575+ 0x0d , 0x00 , 0x00 , 0x00 ,
2576+
2577+ // SQE DWORD 1
2578+ 0x00 , 0x00 , 0x00 , 0x00 ,
2579+ 0x00 , 0x00 , 0x00 , 0x00 ,
2580+ 0x00 , 0x00 , 0x00 , 0x00 ,
2581+ 0x00 , 0x00 , 0x00 , 0x00 ,
2582+ 0x00 , 0x00 , 0x00 , 0x00 ,
2583+
2584+ // DOFST
2585+ 0x00 , 0x00 , 0x00 , 0x00 ,
2586+ 0x00 , 0x10 , 0x00 , 0x00 ,
2587+
2588+ // Reserved
2589+ 0x00 , 0x00 , 0x00 , 0x00 ,
2590+ 0x00 , 0x00 , 0x00 , 0x00 ,
2591+
2592+ // SQE DWORD 10
2593+ 0x00 , 0x00 , 0x00 , 0x00 ,
2594+ 0x00 , 0x00 , 0x00 , 0x00 ,
2595+ 0x00 , 0x00 , 0x00 , 0x00 ,
2596+ 0x00 , 0x00 , 0x00 , 0x00 ,
2597+ 0x00 , 0x00 , 0x00 , 0x00 ,
2598+ 0x00 , 0x00 , 0x00 , 0x00 ,
2599+ ] ;
2600+
2601+ const REQ_MIC : [ u8 ; 4 ] = [ 0x5d , 0x13 , 0x77 , 0x61 ] ;
2602+
2603+ let mut req = [ 0u8 ; { 71 + 4096 + 1 } ] ;
2604+ let len = req. len ( ) ;
2605+ req[ ..REQ_DATA . len ( ) ] . copy_from_slice ( & REQ_DATA ) ;
2606+ req[ { len - REQ_MIC . len ( ) } ..] . copy_from_slice ( & REQ_MIC ) ;
2607+
2608+ let resp = ExpectedRespChannel :: new ( & RESP_INVALID_COMMAND_SIZE ) ;
2609+ smol:: block_on ( async {
2610+ mep. handle_async ( & mut subsys, & req, MsgIC ( true ) , resp, async |_| Ok ( ( ) ) )
2611+ . await
2612+ } ) ;
2613+ }
2614+
2615+ #[ test]
2616+ fn create ( ) {
2617+ setup ( ) ;
2618+
2619+ let ( mut mep, mut subsys) = new_device ( DeviceType :: P1p1tC1aN0a0a ) ;
2620+
2621+ #[ rustfmt:: skip]
2622+ const REQ_DATA : [ u8 ; 83 ] = [
2623+ 0x10 , 0x00 , 0x00 ,
2624+ 0x0d , 0x00 , 0x00 , 0x00 ,
2625+
2626+ // SQE DWORD 1
2627+ 0x00 , 0x00 , 0x00 , 0x00 ,
2628+ 0x00 , 0x00 , 0x00 , 0x00 ,
2629+ 0x00 , 0x00 , 0x00 , 0x00 ,
2630+ 0x00 , 0x00 , 0x00 , 0x00 ,
2631+ 0x00 , 0x00 , 0x00 , 0x00 ,
2632+
2633+ // DOFST
2634+ 0x00 , 0x00 , 0x00 , 0x00 ,
2635+ 0x00 , 0x10 , 0x00 , 0x00 ,
2636+
2637+ // Reserved
2638+ 0x00 , 0x00 , 0x00 , 0x00 ,
2639+ 0x00 , 0x00 , 0x00 , 0x00 ,
2640+
2641+ // SQE DWORD 10
2642+ 0x00 , 0x00 , 0x00 , 0x00 ,
2643+ 0x00 , 0x00 , 0x00 , 0x00 ,
2644+ 0x00 , 0x00 , 0x00 , 0x00 ,
2645+ 0x00 , 0x00 , 0x00 , 0x00 ,
2646+ 0x00 , 0x00 , 0x00 , 0x00 ,
2647+ 0x00 , 0x00 , 0x00 , 0x00 ,
2648+
2649+ // Request Data
2650+ // NSZE
2651+ 0x00 , 0x10 , 0x00 , 0x00 ,
2652+ 0x00 , 0x00 , 0x00 , 0x00 ,
2653+
2654+ // NCAP
2655+ 0x00 , 0x10 , 0x00 , 0x00 ,
2656+ 0x00 , 0x00 , 0x00 , 0x00 ,
2657+ ] ;
2658+
2659+ const REQ_MIC : [ u8 ; 4 ] = [ 0xd1 , 0xf0 , 0x5b , 0xd1 ] ;
2660+
2661+ let mut req = [ 0u8 ; { 71 + 4096 } ] ;
2662+ let len = req. len ( ) ;
2663+ req[ ..REQ_DATA . len ( ) ] . copy_from_slice ( & REQ_DATA ) ;
2664+ req[ { len - REQ_MIC . len ( ) } ..] . copy_from_slice ( & REQ_MIC ) ;
2665+
2666+ #[ rustfmt:: skip]
2667+ const RESP : [ u8 ; 23 ] = [
2668+ 0x90 , 0x00 , 0x00 ,
2669+ 0x00 , 0x00 , 0x00 , 0x00 ,
2670+ 0x01 , 0x00 , 0x00 , 0x00 ,
2671+ 0x00 , 0x00 , 0x00 , 0x00 ,
2672+ 0x00 , 0x00 , 0x01 , 0x00 ,
2673+ 0x00 , 0x01 , 0xd3 , 0xaa
2674+ ] ;
2675+
2676+ let resp = ExpectedRespChannel :: new ( & RESP ) ;
2677+ smol:: block_on ( async {
2678+ mep. handle_async ( & mut subsys, & req, MsgIC ( true ) , resp, async |_| Ok ( ( ) ) )
2679+ . await
2680+ } ) ;
2681+ }
2682+ }
0 commit comments