mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
r21222: Merge a couple of pidl fixes:
* Pidl will now warn when trying to use pointers as integers in expressions.
* "subcontext()" is now marked as deprecated. The alternatives,
transmit_as() / represent_as() should be available soon.
* More tests.
* Remove some unused code in smbtorture.
(This used to be commit 37c0da541e
)
This commit is contained in:
parent
2811e18da0
commit
ecf2c1effb
@ -1,8 +1,6 @@
|
||||
- EJS output backend shouldn't use the NDR levels stuff but instead
|
||||
as the "C levels" and NDR levels don't necessarily match.
|
||||
|
||||
- warn about [out] attributes on pointers (midl/samba3 compatibility)
|
||||
|
||||
- true multiple dimension array / strings in arrays support
|
||||
|
||||
- compatibility mode for generating MIDL-readable data:
|
||||
@ -21,3 +19,5 @@
|
||||
- allow data structures outside of interfaces
|
||||
|
||||
- mem_ctx in the interface rather than as struct ndr member.
|
||||
|
||||
- real typelibs
|
||||
|
@ -21,9 +21,7 @@
|
||||
exp: NUM
|
||||
| TEXT { "\"$_[1]\"" }
|
||||
| func
|
||||
| exp '.' VAR { "$_[1].$_[3]" }
|
||||
| VAR { $_[0]->_Lookup($_[1]) }
|
||||
| '*' exp %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" }
|
||||
| var
|
||||
| '~' exp %prec INV { "~$_[2]" }
|
||||
| exp '+' exp { "$_[1] + $_[3]" }
|
||||
| exp '-' exp { "$_[1] - $_[3]" }
|
||||
@ -41,7 +39,6 @@ exp: NUM
|
||||
| exp '||' exp { "$_[1] || $_[3]" }
|
||||
| exp '&&' exp { "$_[1] && $_[3]" }
|
||||
| exp '&' exp { "$_[1] & $_[3]" }
|
||||
| exp '->' VAR { $_[1]."->".$_[3] }
|
||||
| exp '?' exp ':' exp { "$_[1]?$_[3]:$_[5]" }
|
||||
| '~' exp { "~$_[1]" }
|
||||
| '!' exp { "not $_[1]" }
|
||||
@ -52,9 +49,24 @@ exp: NUM
|
||||
| '(' exp ')' { "($_[2])" }
|
||||
;
|
||||
|
||||
possible_pointer:
|
||||
VAR { $_[0]->_Lookup($_[1]) }
|
||||
| '*' possible_pointer %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" }
|
||||
;
|
||||
|
||||
var: possible_pointer { $_[0]->_Use($_[1]) }
|
||||
| var '.' VAR { $_[0]->_Use("$_[1].$_[3]") }
|
||||
| '(' var ')' { "($_[2])" }
|
||||
| var '->' VAR { $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
|
||||
;
|
||||
|
||||
|
||||
func: VAR '(' opt_args ')' { "$_[1]($_[3])" };
|
||||
opt_args: { "" } | args;
|
||||
args: exp | exp ',' args { "$_[1], $_[3]" };
|
||||
exp_or_possible_pointer: exp | possible_pointer;
|
||||
args: exp_or_possible_pointer
|
||||
| exp_or_possible_pointer ',' args { "$_[1], $_[3]" }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
@ -93,6 +105,15 @@ sub _Lexer {
|
||||
}
|
||||
}
|
||||
|
||||
sub _Use($$)
|
||||
{
|
||||
my ($self, $x) = @_;
|
||||
if (defined($self->YYData->{USE})) {
|
||||
return $self->YYData->{USE}->($x);
|
||||
}
|
||||
return $x;
|
||||
}
|
||||
|
||||
sub _Lookup($$)
|
||||
{
|
||||
my ($self, $x) = @_;
|
||||
@ -118,11 +139,12 @@ sub _Error($)
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my($self, $data, $error, $lookup, $deref) = @_;
|
||||
my($self, $data, $error, $lookup, $deref, $use) = @_;
|
||||
$self->YYData->{FULL_INPUT} = $data;
|
||||
$self->YYData->{INPUT} = $data;
|
||||
$self->YYData->{LOOKUP} = $lookup;
|
||||
$self->YYData->{DEREFERENCE} = $deref;
|
||||
$self->YYData->{ERROR} = $error;
|
||||
$self->YYData->{USE} = $use;
|
||||
return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,7 +35,7 @@ use vars qw($VERSION);
|
||||
$VERSION = '0.01';
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
|
||||
@EXPORT_OK = qw(GetElementLevelTable ParseElement);
|
||||
@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement);
|
||||
|
||||
use strict;
|
||||
use Parse::Pidl qw(warning fatal);
|
||||
@ -902,7 +902,6 @@ sub ValidElement($)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (has_property($e, "subcontext") and has_property($e, "represent_as")) {
|
||||
fatal($e, el_name($e) . " : subcontext() and represent_as() can not be used on the same element");
|
||||
}
|
||||
@ -919,6 +918,10 @@ sub ValidElement($)
|
||||
fatal($e, el_name($e) . " : represent_as() and value() can not be used on the same element");
|
||||
}
|
||||
|
||||
if (has_property($e, "subcontext")) {
|
||||
warning($e, "subcontext() is deprecated. Use represent_as() or transmit_as() instead");
|
||||
}
|
||||
|
||||
if (defined (has_property($e, "subcontext_size")) and not defined(has_property($e, "subcontext"))) {
|
||||
fatal($e, el_name($e) . " : subcontext_size() on non-subcontext element");
|
||||
}
|
||||
|
@ -304,6 +304,51 @@ sub ParseArrayPushHeader($$$$$)
|
||||
return $length;
|
||||
}
|
||||
|
||||
sub check_fully_dereferenced($$)
|
||||
{
|
||||
my ($element, $env) = @_;
|
||||
|
||||
return sub ($) {
|
||||
my $origvar = shift;
|
||||
my $check = 0;
|
||||
|
||||
# Figure out the number of pointers in $ptr
|
||||
my $expandedvar = $origvar;
|
||||
$expandedvar =~ s/^(\**)//;
|
||||
my $ptr = $1;
|
||||
|
||||
my $var = undef;
|
||||
foreach (keys %$env) {
|
||||
if ($env->{$_} eq $expandedvar) {
|
||||
$var = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return($origvar) unless (defined($var));
|
||||
my $e;
|
||||
foreach (@{$element->{PARENT}->{ELEMENTS}}) {
|
||||
if ($_->{NAME} eq $var) {
|
||||
$e = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$e or die("Environment doesn't match siblings");
|
||||
|
||||
# See if pointer at pointer level $level
|
||||
# needs to be checked.
|
||||
my $nump = 0;
|
||||
foreach (@{$e->{LEVELS}}) {
|
||||
if ($_->{TYPE} eq "POINTER") {
|
||||
$nump = $_->{POINTER_INDEX}+1;
|
||||
}
|
||||
}
|
||||
warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully derefenced variable") if ($nump > length($ptr));
|
||||
return ($origvar);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_null_pointer($$$$)
|
||||
{
|
||||
my ($element, $env, $print_fn, $return) = @_;
|
||||
@ -373,8 +418,8 @@ sub ParseArrayPullHeader($$$$$)
|
||||
} elsif ($l->{IS_ZERO_TERMINATED}) { # Noheader arrays
|
||||
$length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
|
||||
} else {
|
||||
$length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e,
|
||||
check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"));
|
||||
$length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
|
||||
check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env));
|
||||
}
|
||||
|
||||
if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
|
||||
@ -397,7 +442,7 @@ sub ParseArrayPullHeader($$$$$)
|
||||
if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) {
|
||||
defer "if ($var_name) {";
|
||||
defer_indent;
|
||||
my $size = ParseExprExt($l->{SIZE_IS}, $env, $e, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"));
|
||||
my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env));
|
||||
defer "NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));";
|
||||
defer_deindent;
|
||||
defer "}";
|
||||
@ -406,7 +451,7 @@ sub ParseArrayPullHeader($$$$$)
|
||||
if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
|
||||
defer "if ($var_name) {";
|
||||
defer_indent;
|
||||
my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"));
|
||||
my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env));
|
||||
defer "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));";
|
||||
defer_deindent;
|
||||
defer "}"
|
||||
@ -432,7 +477,7 @@ sub compression_clen($$$)
|
||||
my ($e, $l, $env) = @_;
|
||||
my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION});
|
||||
|
||||
return ParseExpr($clen, $env, $e);
|
||||
return ParseExpr($clen, $env, $e->{ORIGINAL});
|
||||
}
|
||||
|
||||
sub compression_dlen($$$)
|
||||
@ -440,7 +485,7 @@ sub compression_dlen($$$)
|
||||
my ($e,$l,$env) = @_;
|
||||
my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION});
|
||||
|
||||
return ParseExpr($dlen, $env, $e);
|
||||
return ParseExpr($dlen, $env, $e->{ORIGINAL});
|
||||
}
|
||||
|
||||
sub ParseCompressionPushStart($$$$)
|
||||
@ -501,7 +546,7 @@ sub ParseSubcontextPushStart($$$$)
|
||||
{
|
||||
my ($e,$l,$ndr,$env) = @_;
|
||||
my $subndr = "_ndr_$e->{NAME}";
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e);
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
|
||||
|
||||
pidl "{";
|
||||
indent;
|
||||
@ -519,7 +564,7 @@ sub ParseSubcontextPushEnd($$$$)
|
||||
{
|
||||
my ($e,$l,$ndr,$env) = @_;
|
||||
my $subndr = "_ndr_$e->{NAME}";
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e);
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
|
||||
|
||||
if (defined $l->{COMPRESSION}) {
|
||||
ParseCompressionPushEnd($e, $l, $subndr, $env);
|
||||
@ -534,7 +579,7 @@ sub ParseSubcontextPullStart($$$$)
|
||||
{
|
||||
my ($e,$l,$ndr,$env) = @_;
|
||||
my $subndr = "_ndr_$e->{NAME}";
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e);
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
|
||||
|
||||
pidl "{";
|
||||
indent;
|
||||
@ -552,7 +597,7 @@ sub ParseSubcontextPullEnd($$$$)
|
||||
{
|
||||
my ($e,$l,$ndr,$env) = @_;
|
||||
my $subndr = "_ndr_$e->{NAME}";
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e);
|
||||
my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
|
||||
|
||||
if (defined $l->{COMPRESSION}) {
|
||||
ParseCompressionPullEnd($e, $l, $subndr, $env);
|
||||
@ -617,7 +662,7 @@ sub ParseElementPushLevel
|
||||
}
|
||||
} elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and
|
||||
not is_charset_array($e, $l)) {
|
||||
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e);
|
||||
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
|
||||
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
|
||||
|
||||
$var_name = $var_name . "[$counter]";
|
||||
@ -668,7 +713,7 @@ sub ParseElementPush($$$$$$)
|
||||
start_flags($e);
|
||||
|
||||
if (my $value = has_property($e, "value")) {
|
||||
$var_name = ParseExpr($value, $env, $e);
|
||||
$var_name = ParseExpr($value, $env, $e->{ORIGINAL});
|
||||
}
|
||||
|
||||
ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred);
|
||||
@ -719,7 +764,7 @@ sub ParseElementPrint($$$)
|
||||
$var_name = append_prefix($e, $var_name);
|
||||
|
||||
if (my $value = has_property($e, "value")) {
|
||||
$var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e) . ":$var_name";
|
||||
$var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name";
|
||||
}
|
||||
|
||||
foreach my $l (@{$e->{LEVELS}}) {
|
||||
@ -741,8 +786,8 @@ sub ParseElementPrint($$$)
|
||||
if ($l->{IS_ZERO_TERMINATED}) {
|
||||
$length = "ndr_string_length($var_name, sizeof(*$var_name))";
|
||||
} else {
|
||||
$length = ParseExprExt($l->{LENGTH_IS}, $env, $e,
|
||||
check_null_pointer($e, $env, \&pidl, "return;"));
|
||||
$length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL},
|
||||
check_null_pointer($e, $env, \&pidl, "return;"), check_fully_dereferenced($e, $env));
|
||||
}
|
||||
|
||||
if (is_charset_array($e,$l)) {
|
||||
@ -772,8 +817,8 @@ sub ParseElementPrint($$$)
|
||||
}
|
||||
pidl "ndr_print_$l->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name);";
|
||||
} elsif ($l->{TYPE} eq "SWITCH") {
|
||||
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e,
|
||||
check_null_pointer($e, $env, \&pidl, "return;"));
|
||||
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
|
||||
check_null_pointer($e, $env, \&pidl, "return;"), check_fully_dereferenced($e, $env));
|
||||
pidl "ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);";
|
||||
}
|
||||
}
|
||||
@ -803,8 +848,8 @@ sub ParseElementPrint($$$)
|
||||
sub ParseSwitchPull($$$$$$)
|
||||
{
|
||||
my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_;
|
||||
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e,
|
||||
check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"));
|
||||
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
|
||||
check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env));
|
||||
|
||||
$var_name = get_pointer_to($var_name);
|
||||
pidl "NDR_CHECK(ndr_pull_set_switch_value($ndr, $var_name, $switch_var));";
|
||||
@ -815,8 +860,8 @@ sub ParseSwitchPull($$$$$$)
|
||||
sub ParseSwitchPush($$$$$$)
|
||||
{
|
||||
my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_;
|
||||
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e,
|
||||
check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"));
|
||||
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
|
||||
check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env));
|
||||
|
||||
$var_name = get_pointer_to($var_name);
|
||||
pidl "NDR_CHECK(ndr_push_set_switch_value($ndr, $var_name, $switch_var));";
|
||||
@ -1012,7 +1057,7 @@ sub ParseElementPullLevel
|
||||
}
|
||||
} elsif ($l->{TYPE} eq "ARRAY" and
|
||||
not has_fast_array($e,$l) and not is_charset_array($e, $l)) {
|
||||
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e);
|
||||
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
|
||||
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
|
||||
my $array_name = $var_name;
|
||||
|
||||
@ -1181,7 +1226,7 @@ sub ParseStructPush($$)
|
||||
$size = "ndr_string_length(r->$e->{NAME}, sizeof(*r->$e->{NAME}))";
|
||||
}
|
||||
} else {
|
||||
$size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e);
|
||||
$size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
|
||||
}
|
||||
|
||||
pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));";
|
||||
@ -2038,7 +2083,7 @@ sub AllocateArrayLevel($$$$$)
|
||||
{
|
||||
my ($e,$l,$ndr,$env,$size) = @_;
|
||||
|
||||
my $var = ParseExpr($e->{NAME}, $env, $e);
|
||||
my $var = ParseExpr($e->{NAME}, $env, $e->{ORIGINAL});
|
||||
|
||||
my $pl = GetPrevLevel($e, $l);
|
||||
if (defined($pl) and
|
||||
@ -2118,7 +2163,8 @@ sub ParseFunctionPull($)
|
||||
and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED});
|
||||
|
||||
if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") {
|
||||
my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e, check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"));
|
||||
my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"),
|
||||
check_fully_dereferenced($e, $env));
|
||||
|
||||
pidl "NDR_PULL_ALLOC_N(ndr, r->out.$e->{NAME}, $size);";
|
||||
|
||||
|
@ -101,12 +101,12 @@ sub ParseExpr($$$)
|
||||
return($varlist->{$x}) if (defined($varlist->{$x}));
|
||||
return $x;
|
||||
},
|
||||
undef);
|
||||
undef, undef);
|
||||
}
|
||||
|
||||
sub ParseExprExt($$$$)
|
||||
sub ParseExprExt($$$$$)
|
||||
{
|
||||
my($expr, $varlist, $e, $deref) = @_;
|
||||
my($expr, $varlist, $e, $deref, $use) = @_;
|
||||
|
||||
die("Undefined value in ParseExpr") if not defined($expr);
|
||||
|
||||
@ -118,7 +118,7 @@ sub ParseExprExt($$$$)
|
||||
return($varlist->{$x}) if (defined($varlist->{$x}));
|
||||
return $x;
|
||||
},
|
||||
$deref);
|
||||
$deref, $use);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -4,7 +4,7 @@
|
||||
# package to parse IDL files and generate code for
|
||||
# rpc functions in Samba
|
||||
# Copyright tridge@samba.org 2000-2003
|
||||
# Copyright jelmer@samba.org 2005
|
||||
# Copyright jelmer@samba.org 2005-2007
|
||||
# released under the GNU GPL
|
||||
|
||||
=pod
|
||||
@ -319,6 +319,9 @@ Specifies that a size of I<length>
|
||||
bytes should be read, followed by a blob of that size,
|
||||
which will be parsed as NDR.
|
||||
|
||||
subcontext() is deprecated now, and should not be used in new code.
|
||||
Instead, use represent_as() or transmit_as().
|
||||
|
||||
=item flag
|
||||
|
||||
Specify boolean options, mostly used for
|
||||
|
@ -1,220 +0,0 @@
|
||||
some experiments with ref ptrs
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([in] xstruct foo);
|
||||
|
||||
short v = 13;
|
||||
xstruct r;
|
||||
r.x = v;
|
||||
echo_TestRef(r);
|
||||
|
||||
[0D 00]
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short *x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([in] xstruct foo);
|
||||
|
||||
short v = 13;
|
||||
xstruct r;
|
||||
r.x = &v;
|
||||
echo_TestRef(r);
|
||||
|
||||
[PP PP PP PP 0D 00]
|
||||
|
||||
|
||||
xstruct r;
|
||||
r.x = NULL;
|
||||
echo_TestRef(r);
|
||||
|
||||
[00 00 00 00]
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
[ref] short *x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([in] xstruct foo);
|
||||
|
||||
short v = 13;
|
||||
xstruct r;
|
||||
r.x = &v;
|
||||
echo_TestRef(r);
|
||||
|
||||
[XX XX XX XX 0D 00]
|
||||
|
||||
|
||||
xstruct r;
|
||||
r.x = NULL;
|
||||
echo_TestRef(r);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([in] xstruct *foo);
|
||||
|
||||
short v = 13;
|
||||
xstruct r;
|
||||
r.x = v;
|
||||
echo_TestRef(&r);
|
||||
|
||||
[0D 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([in,ref] xstruct *foo);
|
||||
|
||||
short v = 13;
|
||||
xstruct r;
|
||||
r.x = v;
|
||||
echo_TestRef(&r);
|
||||
|
||||
[0D 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([in,unique] xstruct *foo);
|
||||
|
||||
short v = 13;
|
||||
xstruct r;
|
||||
r.x = v;
|
||||
echo_TestRef(&r);
|
||||
|
||||
[PP PP PP PP 0D 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[00 00 00 00]
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
uint16 echo_TestRef([out] xstruct foo);
|
||||
|
||||
[idl compiler error]
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
void echo_TestRef([out] xstruct *foo);
|
||||
|
||||
xstruct r;
|
||||
echo_TestRef(&r);
|
||||
r.x -> 13;
|
||||
|
||||
[0D 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
void echo_TestRef([out,ref] xstruct *foo);
|
||||
|
||||
xstruct r;
|
||||
echo_TestRef(&r);
|
||||
r.x -> 13;
|
||||
|
||||
[0D 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
----------------------------------------------------
|
||||
typedef struct {
|
||||
short x;
|
||||
} xstruct;
|
||||
|
||||
void echo_TestRef([out,unique] xstruct *foo);
|
||||
|
||||
[idl compiler error]
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
void echo_TestRef([in] short **foo);
|
||||
|
||||
short v = 13;
|
||||
short *pv = &v;
|
||||
|
||||
echo_TestRef(&pv);
|
||||
|
||||
[PP PP PP PP 0D 00]
|
||||
|
||||
|
||||
short *pv = NULL;
|
||||
|
||||
echo_TestRef(&pv);
|
||||
|
||||
[00 00 00 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
void echo_TestRef([in,ref] short **foo);
|
||||
|
||||
short v = 13;
|
||||
short *pv = &v;
|
||||
|
||||
echo_TestRef(&pv);
|
||||
|
||||
[PP PP PP PP 0D 00]
|
||||
|
||||
|
||||
short *pv = NULL;
|
||||
|
||||
echo_TestRef(&pv);
|
||||
|
||||
[00 00 00 00]
|
||||
|
||||
|
||||
echo_TestRef(NULL);
|
||||
|
||||
[client runtime error 0x6f4]
|
||||
|
||||
|
28
source4/pidl/tests/ndr_deprecations.pl
Executable file
28
source4/pidl/tests/ndr_deprecations.pl
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/perl
|
||||
# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
|
||||
# Published under the GNU General Public License
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 1;
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin";
|
||||
use Util;
|
||||
use Parse::Pidl::Util qw(MyDumper);
|
||||
use Parse::Pidl::NDR qw(ValidElement);
|
||||
|
||||
# Case 1
|
||||
|
||||
my $e = {
|
||||
'FILE' => 'foo.idl',
|
||||
'NAME' => 'v',
|
||||
'PROPERTIES' => {"subcontext" => 1},
|
||||
'POINTERS' => 0,
|
||||
'TYPE' => 'uint8',
|
||||
'PARENT' => { TYPE => 'STRUCT' },
|
||||
'LINE' => 42 };
|
||||
|
||||
test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n",
|
||||
sub { ValidElement($e); });
|
||||
|
||||
|
36
source4/pidl/tests/ndr_represent.pl
Normal file → Executable file
36
source4/pidl/tests/ndr_represent.pl
Normal file → Executable file
@ -3,7 +3,7 @@
|
||||
# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
|
||||
use strict;
|
||||
|
||||
use Test::More tests => 1 * 8;
|
||||
use Test::More tests => 2 * 8;
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin";
|
||||
use Util qw(test_samba4_ndr);
|
||||
@ -40,3 +40,37 @@ NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
|
||||
}
|
||||
'
|
||||
);
|
||||
|
||||
test_samba4_ndr('transmit_as-simple',
|
||||
'
|
||||
void bla([in,transmit_as(uint32)] uint8 x);
|
||||
',
|
||||
'
|
||||
uint8_t expected[] = { 0x0D };
|
||||
DATA_BLOB in_blob = { expected, 1 };
|
||||
struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL);
|
||||
struct bla r;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
|
||||
return 1;
|
||||
|
||||
if (r.in.x != 13)
|
||||
return 2;
|
||||
',
|
||||
'
|
||||
#include <libcli/util/nterr.h>
|
||||
|
||||
NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
|
||||
{
|
||||
*to = from;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
|
||||
{
|
||||
*to = from;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
'
|
||||
);
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 56;
|
||||
use Test::More tests => 70;
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin";
|
||||
use Util;
|
||||
use Parse::Pidl qw(error);
|
||||
use Parse::Pidl::Util;
|
||||
|
||||
# has_property()
|
||||
@ -89,3 +90,23 @@ is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef));
|
||||
|
||||
test_errors("nofile:0: Parse error in `~' near `~'\n", sub {
|
||||
is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); });
|
||||
|
||||
test_errors("nofile:0: Got pointer, expected integer\n", sub {
|
||||
is(undef, ParseExprExt("foo", {}, {FILE => "nofile", LINE => 0},
|
||||
undef, sub { my $x = shift;
|
||||
error({FILE => "nofile", LINE => 0},
|
||||
"Got pointer, expected integer");
|
||||
return undef; }))});
|
||||
|
||||
is("b.a.a", ParseExpr("b.a.a", {"a" => "b"}, undef));
|
||||
is("((rr_type) == NBT_QTYPE_NETBIOS)", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)", {}, undef));
|
||||
is("talloc_check_name", ParseExpr("talloc_check_name", {}, undef));
|
||||
is("talloc_check_name()", ParseExpr("talloc_check_name()", {}, undef));
|
||||
is("talloc_check_name(ndr)", ParseExpr("talloc_check_name(ndr)", {}, undef));
|
||||
is("talloc_check_name(ndr, 1)", ParseExpr("talloc_check_name(ndr,1)", {}, undef));
|
||||
is("talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("talloc_check_name(ndr,\"struct ndr_push\")", {}, undef));
|
||||
is("((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")", {}, undef));
|
||||
is("(rdata).data.length", ParseExpr("(rdata).data.length", {}, undef));
|
||||
is("((rdata).data.length == 2)", ParseExpr("((rdata).data.length==2)", {}, undef));
|
||||
is("((rdata).data.length == 2)?0:rr_type", ParseExpr("((rdata).data.length==2)?0:rr_type", {}, undef));
|
||||
is("((((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\") && ((rdata).data.length == 2))?0:rr_type)", ParseExpr("((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")&&((rdata).data.length==2))?0:rr_type)", {}, undef));
|
||||
|
@ -583,10 +583,8 @@ int main(int argc,char *argv[])
|
||||
|
||||
if (strcmp(target, "samba3") == 0) {
|
||||
lp_set_cmdline("torture:samba3", "true");
|
||||
lp_set_cmdline("torture:knownfail", "samba3-knownfail");
|
||||
} else if (strcmp(target, "samba4") == 0) {
|
||||
lp_set_cmdline("torture:samba4", "true");
|
||||
lp_set_cmdline("torture:knownfail", "samba4-knownfail");
|
||||
}
|
||||
|
||||
if (max_runtime) {
|
||||
@ -662,8 +660,7 @@ int main(int argc,char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
torture = torture_context_init(talloc_autofree_context(),
|
||||
lp_parm_string(-1, "torture", "knownfail"), ui_ops);
|
||||
torture = torture_context_init(talloc_autofree_context(), ui_ops);
|
||||
|
||||
if (argc_new == 0) {
|
||||
printf("You must specify a test to run, or 'ALL'\n");
|
||||
|
@ -42,7 +42,6 @@ bool torture_register_suite(struct torture_suite *suite)
|
||||
}
|
||||
|
||||
struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
|
||||
const char *known_failures_file,
|
||||
const struct torture_ui_ops *ui_ops)
|
||||
{
|
||||
struct torture_context *torture = talloc_zero(mem_ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user