1#!/usr/bin/perl 2# Support for tagged types 3# (C) 2005 Jelmer Vernooij. Published under the GNU GPL 4use strict; 5 6use Test::More tests => 3 * 8; 7use FindBin qw($RealBin); 8use lib "$RealBin"; 9use Util qw(test_samba4_ndr); 10 11test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', 12' 13 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); 14 struct bla r; 15 uint8_t expected[] = { 0x0D }; 16 DATA_BLOB expected_blob = { expected, 1 }; 17 DATA_BLOB result_blob; 18 r.x = 13; 19 20 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) 21 return 1; 22 23 result_blob = ndr_push_blob(ndr); 24 25 if (data_blob_cmp(&result_blob, &expected_blob) != 0) 26 return 2; 27'); 28 29test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; 30 [public] void myfn([in] struct bla r); ', 31' 32 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); 33 struct myfn fn; 34 uint8_t expected[] = { 0x0D }; 35 DATA_BLOB expected_blob = { expected, 1 }; 36 DATA_BLOB result_blob; 37 fn.in.r.x = 13; 38 39 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_myfn(ndr, NDR_IN, &fn))) 40 return 1; 41 42 result_blob = ndr_push_blob(ndr); 43 44 if (data_blob_cmp(&result_blob, &expected_blob) != 0) 45 return 2; 46'); 47 48 49test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; 50 [public] struct myst { struct bla r; }; ', 51' 52 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); 53 struct myst st; 54 uint8_t expected[] = { 0x0D }; 55 DATA_BLOB expected_blob = { expected, 1 }; 56 DATA_BLOB result_blob; 57 st.r.x = 13; 58 59 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_STRUCT_myst(ndr, NDR_IN, &st))) 60 return 1; 61 62 result_blob = ndr_push_blob(ndr); 63 64 if (data_blob_cmp(&result_blob, &expected_blob) != 0) 65 return 2; 66'); 67