Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
318a71fd
Commit
318a71fd
authored
Jan 22, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 23, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
snmpapi: Add tests for SnmpUtilVarBind{, List}{Cpy, Free}. Make them pass.
parent
396f6c05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
+87
-0
main.c
dlls/snmpapi/main.c
+8
-0
util.c
dlls/snmpapi/tests/util.c
+79
-0
No files found.
dlls/snmpapi/main.c
View file @
318a71fd
...
...
@@ -417,6 +417,12 @@ INT WINAPI SnmpUtilVarBindListCpy(SnmpVarBindList *dst, SnmpVarBindList *src)
TRACE
(
"(%p, %p)
\n
"
,
dst
,
src
);
if
(
!
src
)
{
dst
->
list
=
NULL
;
dst
->
len
=
0
;
return
SNMPAPI_NOERROR
;
}
size
=
src
->
len
*
sizeof
(
SnmpVarBind
*
);
if
(
!
(
dst
->
list
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
{
...
...
@@ -456,6 +462,8 @@ void WINAPI SnmpUtilVarBindListFree(SnmpVarBindList *vb)
entry
=
vb
->
list
;
for
(
i
=
0
;
i
<
vb
->
len
;
i
++
)
SnmpUtilVarBindFree
(
entry
++
);
HeapFree
(
GetProcessHeap
(),
0
,
vb
->
list
);
vb
->
list
=
NULL
;
vb
->
len
=
0
;
}
/***********************************************************************
...
...
dlls/snmpapi/tests/util.c
View file @
318a71fd
...
...
@@ -347,6 +347,83 @@ static void test_SnmpUtilOidAppend(void)
"SnmpUtilOidAppend failed
\n
"
);
}
static
void
test_SnmpUtilVarBindCpyFree
(
void
)
{
INT
ret
;
static
UINT
ids
[]
=
{
1
,
3
,
6
,
1
,
4
,
1
,
311
};
static
SnmpVarBind
dst
,
src
=
{
{
7
,
ids
},
{
ASN_INTEGER
,
{
1
}
}
};
ret
=
SnmpUtilVarBindCpy
(
NULL
,
NULL
);
ok
(
!
ret
,
"SnmpUtilVarBindCpy succeeded
\n
"
);
memset
(
&
dst
,
0
,
sizeof
(
SnmpVarBind
));
ret
=
SnmpUtilVarBindCpy
(
&
dst
,
NULL
);
ok
(
ret
,
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
dst
.
name
.
idLength
==
0
,
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
dst
.
name
.
ids
==
NULL
,
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
dst
.
value
.
asnType
==
ASN_NULL
,
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
dst
.
value
.
asnValue
.
number
==
0
,
"SnmpUtilVarBindCpy failed
\n
"
);
ret
=
SnmpUtilVarBindCpy
(
NULL
,
&
src
);
ok
(
!
ret
,
"SnmpUtilVarBindCpy succeeded
\n
"
);
memset
(
&
dst
,
0
,
sizeof
(
SnmpVarBind
));
ret
=
SnmpUtilVarBindCpy
(
&
dst
,
&
src
);
ok
(
ret
,
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
src
.
name
.
idLength
==
dst
.
name
.
idLength
,
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
!
memcmp
(
src
.
name
.
ids
,
dst
.
name
.
ids
,
dst
.
name
.
idLength
*
sizeof
(
UINT
)),
"SnmpUtilVarBindCpy failed
\n
"
);
ok
(
!
memcmp
(
&
src
.
value
,
&
dst
.
value
,
sizeof
(
AsnObjectSyntax
)),
"SnmpUtilVarBindCpy failed
\n
"
);
SnmpUtilVarBindFree
(
NULL
);
SnmpUtilVarBindFree
(
&
dst
);
ok
(
dst
.
name
.
idLength
==
0
,
"SnmpUtilVarBindFree failed
\n
"
);
ok
(
dst
.
name
.
ids
==
NULL
,
"SnmpUtilVarBindFree failed
\n
"
);
ok
(
dst
.
value
.
asnType
==
ASN_NULL
,
"SnmpUtilVarBindFree failed
\n
"
);
ok
(
dst
.
value
.
asnValue
.
number
==
1
,
"SnmpUtilVarBindFree failed
\n
"
);
}
static
void
test_SnmpUtilVarBindListCpyFree
(
void
)
{
INT
ret
;
static
UINT
ids
[]
=
{
1
,
3
,
6
,
1
,
4
,
1
,
311
};
static
SnmpVarBind
src
=
{
{
7
,
ids
},
{
ASN_INTEGER
,
{
1
}
}
};
static
SnmpVarBindList
dst_list
,
src_list
=
{
&
src
,
1
};
if
(
0
)
{
/* these crash on XP */
ret
=
SnmpUtilVarBindListCpy
(
NULL
,
NULL
);
ok
(
!
ret
,
"SnmpUtilVarBindCpy succeeded
\n
"
);
ret
=
SnmpUtilVarBindListCpy
(
NULL
,
&
src_list
);
ok
(
!
ret
,
"SnmpUtilVarBindListCpy succeeded
\n
"
);
}
memset
(
&
dst_list
,
0xff
,
sizeof
(
SnmpVarBindList
));
ret
=
SnmpUtilVarBindListCpy
(
&
dst_list
,
NULL
);
ok
(
ret
,
"SnmpUtilVarBindListCpy failed
\n
"
);
ok
(
dst_list
.
list
==
NULL
,
"SnmpUtilVarBindListCpy failed
\n
"
);
ok
(
dst_list
.
len
==
0
,
"SnmpUtilVarBindListCpy failed
\n
"
);
ret
=
SnmpUtilVarBindListCpy
(
&
dst_list
,
&
src_list
);
ok
(
ret
,
"SnmpUtilVarBindListCpy failed
\n
"
);
ok
(
src_list
.
len
==
dst_list
.
len
,
"SnmpUtilVarBindListCpy failed
\n
"
);
ok
(
src_list
.
list
->
name
.
idLength
==
dst_list
.
list
->
name
.
idLength
,
"SnmpUtilVarBindListCpy failed
\n
"
);
ok
(
!
memcmp
(
src_list
.
list
->
name
.
ids
,
dst_list
.
list
->
name
.
ids
,
dst_list
.
list
->
name
.
idLength
*
sizeof
(
UINT
)),
"SnmpUtilVarBindListCpy failed
\n
"
);
ok
(
!
memcmp
(
&
src_list
.
list
->
value
,
&
dst_list
.
list
->
value
,
sizeof
(
AsnAny
)),
"SnmpUtilVarBindListCpy failed
\n
"
);
if
(
0
)
{
/* crashes on XP */
SnmpUtilVarBindListFree
(
NULL
);
}
SnmpUtilVarBindListFree
(
&
dst_list
);
ok
(
dst_list
.
list
==
NULL
,
"SnmpUtilVarBindListFree failed
\n
"
);
ok
(
dst_list
.
len
==
0
,
"SnmpUtilVarBindListFree failed
\n
"
);
}
START_TEST
(
util
)
{
test_SnmpUtilOidToA
();
...
...
@@ -358,4 +435,6 @@ START_TEST(util)
test_SnmpUtilOidCmp
();
test_SnmpUtilOidNCmp
();
test_SnmpUtilOidAppend
();
test_SnmpUtilVarBindCpyFree
();
test_SnmpUtilVarBindListCpyFree
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment