mirror of
https://github.com/espressif/openthread.git
synced 2026-08-31 14:29:54 +00:00
[build] move spinel into src/utils (#4558)
Move spinel from src/ncp into src/utils and remove dependency on OpenThread's core configurations.
This commit is contained in:
@@ -28,19 +28,19 @@
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/instance.hpp"
|
||||
#include "ncp/spinel_encoder.hpp"
|
||||
#include "spinel/spinel_encoder.hpp"
|
||||
|
||||
#include "test_util.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
namespace Spinel {
|
||||
|
||||
enum
|
||||
{
|
||||
kTestBufferSize = 800,
|
||||
};
|
||||
|
||||
otError ReadFrame(NcpFrameBuffer &aNcpBuffer, uint8_t *aFrame, uint16_t &aFrameLen)
|
||||
otError ReadFrame(Spinel::Buffer &aNcpBuffer, uint8_t *aFrame, uint16_t &aFrameLen)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
@@ -53,11 +53,11 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void TestSpinelEncoder(void)
|
||||
void TestEncoder(void)
|
||||
{
|
||||
uint8_t buffer[kTestBufferSize];
|
||||
NcpFrameBuffer ncpBuffer(buffer, kTestBufferSize);
|
||||
SpinelEncoder encoder(ncpBuffer);
|
||||
uint8_t buffer[kTestBufferSize];
|
||||
Spinel::Buffer ncpBuffer(buffer, kTestBufferSize);
|
||||
Spinel::Encoder encoder(ncpBuffer);
|
||||
|
||||
uint8_t frame[kTestBufferSize];
|
||||
uint16_t frameLen;
|
||||
@@ -117,7 +117,7 @@ void TestSpinelEncoder(void)
|
||||
printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
printf("\nTest 1: Encoding of simple types");
|
||||
|
||||
SuccessOrQuit(encoder.BeginFrame(NcpFrameBuffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.BeginFrame(Spinel::Buffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.WriteBool(kBool_1), "WriteBool() failed.");
|
||||
SuccessOrQuit(encoder.WriteBool(kBool_2), "WriteBool() failed.");
|
||||
SuccessOrQuit(encoder.WriteUint8(kUint8), "WriteUint8() failed.");
|
||||
@@ -183,7 +183,7 @@ void TestSpinelEncoder(void)
|
||||
printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
printf("\nTest 2: Test a single simple struct.");
|
||||
|
||||
SuccessOrQuit(encoder.BeginFrame(NcpFrameBuffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.BeginFrame(Spinel::Buffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.WriteUint8(kUint8), "WriteUint8() failed.");
|
||||
SuccessOrQuit(encoder.OpenStruct(), "OpenStruct() failed.");
|
||||
{
|
||||
@@ -230,7 +230,7 @@ void TestSpinelEncoder(void)
|
||||
printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
printf("\nTest 3: Test multiple structs and struct within struct.");
|
||||
|
||||
SuccessOrQuit(encoder.BeginFrame(NcpFrameBuffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.BeginFrame(Spinel::Buffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.OpenStruct(), "OpenStruct() failed.");
|
||||
{
|
||||
SuccessOrQuit(encoder.WriteUint8(kUint8), "WriteUint8() failed.");
|
||||
@@ -279,7 +279,7 @@ void TestSpinelEncoder(void)
|
||||
printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
printf("\nTest 4: Test unclosed struct.");
|
||||
|
||||
SuccessOrQuit(encoder.BeginFrame(NcpFrameBuffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.BeginFrame(Spinel::Buffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.WriteUint8(kUint8), "WriteUint8() failed.");
|
||||
SuccessOrQuit(encoder.OpenStruct(), "OpenStruct() failed.");
|
||||
{
|
||||
@@ -312,7 +312,7 @@ void TestSpinelEncoder(void)
|
||||
printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
printf("\nTest 5: Test saving position and reseting back to a saved position");
|
||||
|
||||
SuccessOrQuit(encoder.BeginFrame(NcpFrameBuffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.BeginFrame(Spinel::Buffer::kPriorityLow), "BeginFrame() failed.");
|
||||
SuccessOrQuit(encoder.WriteUint8(kUint8), "WriteUint8() failed.");
|
||||
SuccessOrQuit(encoder.OpenStruct(), "OpenStruct() failed.");
|
||||
{
|
||||
@@ -357,12 +357,12 @@ void TestSpinelEncoder(void)
|
||||
printf(" -- PASS\n");
|
||||
}
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace Spinel
|
||||
} // namespace ot
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ot::Ncp::TestSpinelEncoder();
|
||||
ot::Spinel::TestEncoder();
|
||||
printf("\nAll tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user