Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce WinPacketClone with unit tests
- Divide win_packet.c into two files - win_packet.c - for NDIS-independent logic - win_packet_raw.c - only NDIS-dependent code - Extend WIN_PACKET interface to allow cloning and establishing parent/child relationships - Implement WinPacketClone unit tests Change-Id: I468772725236a1f7bc69f1a7cddaefe21b486790 Depends-On: I1ff3d749b6d94747c89e9a520e56a59daa4c7b6f Partial-Bug: #1737177
- Loading branch information
1 parent
de1ebe1
commit 0625ce3
Showing
25 changed files
with
345 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* fake_win_packet_raw.c | ||
* | ||
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
#include "fake_win_packet.h" | ||
|
||
#include <assert.h> | ||
#include <stdlib.h> | ||
#include <setjmp.h> | ||
#include <cmocka.h> | ||
|
||
struct _WIN_PACKET { | ||
PWIN_PACKET Parent; | ||
LONG ChildRefCount; | ||
}; | ||
|
||
PWIN_PACKET | ||
Fake_WinPacketAllocate() | ||
{ | ||
PWIN_PACKET packet = test_malloc(sizeof(*packet)); | ||
assert(packet != NULL); | ||
memset(packet, 0, sizeof(*packet)); | ||
return packet; | ||
} | ||
|
||
VOID | ||
Fake_WinPacketFree(PWIN_PACKET Packet) | ||
{ | ||
test_free(Packet); | ||
} | ||
|
||
PWIN_PACKET | ||
WinPacketRawGetParentOf(PWIN_PACKET Packet) | ||
{ | ||
return Packet->Parent; | ||
} | ||
|
||
VOID | ||
WinPacketRawSetParentOf(PWIN_PACKET Packet, PWIN_PACKET Parent) | ||
{ | ||
Packet->Parent = Parent; | ||
} | ||
|
||
LONG | ||
WinPacketRawGetChildCountOf(PWIN_PACKET Packet) | ||
{ | ||
return Packet->ChildRefCount; | ||
} | ||
|
||
VOID | ||
WinPacketRawIncrementChildCountOf(PWIN_PACKET Packet) | ||
{ | ||
Packet->ChildRefCount++; | ||
} | ||
|
||
static PWIN_PACKET | ||
WinPacketRawAllocateClone_Impl(PWIN_PACKET Packet) | ||
{ | ||
return NULL; | ||
} | ||
PWIN_PACKET (*WinPacketRawAllocateClone)(PWIN_PACKET Packet) = WinPacketRawAllocateClone_Impl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* fake_win_packet.h | ||
* | ||
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
#ifndef _FAKE_WIN_PACKET_H_ | ||
#define _FAKE_WIN_PACKET_H_ | ||
|
||
#include "win_packet.h" | ||
|
||
PWIN_PACKET Fake_WinPacketAllocate(); | ||
VOID Fake_WinPacketFree(PWIN_PACKET Packet); | ||
|
||
#endif // _FAKE_WIN_PACKET_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
#ifndef _FAKE_NDIS_H_ | ||
#define _FAKE_NDIS_H_ | ||
|
||
typedef struct _NET_BUFFER_LIST NET_BUFFER_LIST, *PNET_BUFFER_LIST; | ||
|
||
#endif // _FAKE_NDIS_H_ |
Oops, something went wrong.