2006-03-24 04:03:02 +03:00
#!/usr/bin/perl
# NDR represent_as() / transmit_as() tests
# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
use strict ;
2007-02-07 22:03:19 +03:00
use Test::More tests = > 2 * 8 ;
2006-03-24 04:03:02 +03:00
use FindBin qw( $RealBin ) ;
use lib "$RealBin" ;
use Util qw( test_samba4_ndr ) ;
test_samba4_ndr ( 'represent_as-simple' ,
'
2006-03-24 15:40:07 +03:00
void bla ( [ in , represent_as ( uint32 ) ] uint8 x ) ;
2006-03-24 04:03:02 +03:00
' ,
'
uint8_t expected [] = { 0x0D } ;
DATA_BLOB in_blob = { expected , 1 } ;
2007-12-14 02:27:38 +03:00
struct ndr_pull * ndr = ndr_pull_init_blob ( & in_blob , NULL , NULL ) ;
2006-03-24 04:03:02 +03:00
struct bla r ;
2007-11-09 21:23:25 +03:00
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_pull_bla ( ndr , NDR_SCALARS | NDR_BUFFERS , & r ) ) )
2006-03-24 04:03:02 +03:00
return 1 ;
2006-03-24 15:40:07 +03:00
if ( r . in . x != 13 )
2006-03-24 04:03:02 +03:00
return 2 ;
' ,
'
2007-11-09 21:23:25 +03:00
enum ndr_err_code ndr_uint8_to_uint32 ( uint8_t from , uint32_t * to )
2006-03-24 14:42:03 +03:00
{
* to = from ;
2007-11-09 21:23:25 +03:00
return NDR_ERR_SUCCESS ;
2006-03-24 14:42:03 +03:00
}
2007-11-09 21:23:25 +03:00
enum ndr_err_code ndr_uint32_to_uint8 ( uint32_t from , uint8_t * to )
2006-03-24 04:03:02 +03:00
{
* to = from ;
2007-11-09 21:23:25 +03:00
return NDR_ERR_SUCCESS ;
2006-03-24 04:03:02 +03:00
}
'
) ;
2007-02-07 22:03:19 +03:00
test_samba4_ndr ( 'transmit_as-simple' ,
'
void bla ( [ in , transmit_as ( uint32 ) ] uint8 x ) ;
' ,
'
uint8_t expected [] = { 0x0D } ;
DATA_BLOB in_blob = { expected , 1 } ;
2007-12-14 02:27:38 +03:00
struct ndr_pull * ndr = ndr_pull_init_blob ( & in_blob , NULL , NULL ) ;
2007-02-07 22:03:19 +03:00
struct bla r ;
2007-11-09 21:23:25 +03:00
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_pull_bla ( ndr , NDR_SCALARS | NDR_BUFFERS , & r ) ) )
2007-02-07 22:03:19 +03:00
return 1 ;
if ( r . in . x != 13 )
return 2 ;
' ,
'
2007-11-09 21:23:25 +03:00
enum ndr_err_code ndr_uint8_to_uint32 ( uint8_t from , uint32_t * to )
2007-02-07 22:03:19 +03:00
{
* to = from ;
2007-11-09 21:23:25 +03:00
return NDR_ERR_SUCCESS ;
2007-02-07 22:03:19 +03:00
}
2007-11-09 21:23:25 +03:00
enum ndr_err_code ndr_uint32_to_uint8 ( uint32_t from , uint8_t * to )
2007-02-07 22:03:19 +03:00
{
* to = from ;
2007-11-09 21:23:25 +03:00
return NDR_ERR_SUCCESS ;
2007-02-07 22:03:19 +03:00
}
'
) ;