r6873: fixed exec bit
[samba.git] / source / build / pidl / tests / ndr_string.pl
1 #!/usr/bin/perl
2 # String tests for pidl
3 # (C) 2005 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU General Public License
5 use strict;
6
7 use FindBin qw($RealBin);
8 use lib "$RealBin/..";
9 use test;
10
11 my %settings = Test::GetSettings(@ARGV);
12
13 $settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
14 $settings{'IncludeFiles'} = ['ndr_test.h'];
15 $settings{'ExtraFiles'} = ['ndr_test.c'];
16
17 Test::test_idl("string-pull-empty", \%settings,
18 ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
19 '
20         uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
21         DATA_BLOB b = { data, 4 };
22         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
23         struct TestString r;
24         r.in.data = NULL;
25
26         if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) 
27                 return 1;
28         
29         if (r.in.data == NULL)
30                 return 2;
31
32         if (r.in.data[0] != 0)
33                 return 3;
34 ');
35
36 Test::test_idl("string-ascii-pull", \%settings,
37 '
38         [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);
39 ',
40 '
41         uint8_t data[] = { 0x03, 0x00, 0x00, 0x00, 
42                                            \'f\', \'o\', \'o\', 0 };
43         DATA_BLOB b = { data, 8 };
44         struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
45         struct TestString r;
46         r.in.data = NULL;
47
48         if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) 
49                 return 1;
50         
51         if (r.in.data == NULL)
52                 return 2;
53
54         if (strncmp(r.in.data, "foo", 3) != 0)
55                 return 3;
56
57         if (r.in.data[4] != 0)
58                 return 4;
59 ');