28
28
#include < lib/support/CHIPMem.h>
29
29
#include < lib/support/CHIPPlatformMemory.h>
30
30
#include < lib/support/UnitTest.h>
31
- #include < lib/support/UnitTestRegistration.h>
32
31
#include < mbedtls/platform.h>
33
32
#include < nl_test_service/nl_test.rpc.pb.h>
34
- #include < nlunit-test.h>
35
33
#include < pigweed/RpcService.h>
36
34
#include < platform/CHIPDeviceLayer.h>
37
35
#include < platform/KeyValueStoreManager.h>
@@ -58,114 +56,12 @@ class NlTest : public pw_rpc::nanopb::NlTest::Service<NlTest>
58
56
public:
59
57
void Run (const pw_protobuf_Empty & request, ServerWriter<chip_rpc_Event> & writer)
60
58
{
61
- stream_writer = &writer;
62
- nlTestSetLogger (&nl_test_logger);
63
-
64
- printf (" --- Running nltest ---" );
65
- int status = RunRegisteredUnitTests ();
66
- printf (" --- Running gtest ---" );
67
- status += chip::test::RunAllTests ();
59
+ printf (" --- Running pw_unit_test ---" );
60
+ int status = chip::test::RunAllTests ();
68
61
printf (" Test status: %d" , status);
69
- stream_writer = nullptr ;
70
- writer.Finish ();
71
- }
72
-
73
- private:
74
- static ServerWriter<chip_rpc_Event> * stream_writer;
75
- nl_test_output_logger_t nl_test_logger = {
76
- chip_nl_test_log_name, chip_nl_test_log_initialize, chip_nl_test_log_terminate, chip_nl_test_log_setup,
77
- chip_nl_test_log_test, chip_nl_test_log_teardown, chip_nl_test_log_statTest, chip_nl_test_log_statAssert,
78
- };
79
-
80
- static void StreamLogEvent (const chip_rpc_Event & event)
81
- {
82
- if (!stream_writer)
83
- {
84
- return ;
85
- }
86
- stream_writer->Write (event);
87
- }
88
-
89
- static void chip_nl_test_log_name (struct _nlTestSuite * inSuite)
90
- {
91
- chip_rpc_Event event = chip_rpc_Event_init_default;
92
- event.which_type = chip_rpc_Event_test_suite_start_tag;
93
- snprintf (event.type .test_suite_start .suite_name , sizeof (event.type .test_suite_start .suite_name ), " %s" , inSuite->name );
94
- StreamLogEvent (event);
95
- }
96
-
97
- static void chip_nl_test_log_initialize (struct _nlTestSuite * inSuite, int inResult, int inWidth)
98
- {
99
- chip_rpc_Event event = chip_rpc_Event_init_default;
100
- event.which_type = chip_rpc_Event_test_case_initialize_tag;
101
- snprintf (event.type .test_case_initialize .suite_name , sizeof (event.type .test_case_initialize .suite_name ), " %s" ,
102
- inSuite->name );
103
- event.type .test_case_initialize .failed = inResult == FAILURE;
104
- StreamLogEvent (event);
105
- }
106
- static void chip_nl_test_log_terminate (struct _nlTestSuite * inSuite, int inResult, int inWidth)
107
- {
108
- chip_rpc_Event event = chip_rpc_Event_init_default;
109
- event.which_type = chip_rpc_Event_test_case_terminate_tag;
110
- snprintf (event.type .test_case_terminate .suite_name , sizeof (event.type .test_case_terminate .suite_name ), " %s" , inSuite->name );
111
- event.type .test_case_terminate .failed = inResult == FAILURE;
112
- StreamLogEvent (event);
113
- }
114
-
115
- static void chip_nl_test_log_setup (struct _nlTestSuite * inSuite, int inResult, int inWidth)
116
- {
117
- chip_rpc_Event event = chip_rpc_Event_init_default;
118
- event.which_type = chip_rpc_Event_test_suite_setup_tag;
119
- snprintf (event.type .test_suite_setup .suite_name , sizeof (event.type .test_suite_setup .suite_name ), " %s" , inSuite->name );
120
- event.type .test_suite_setup .failed = inResult == FAILURE;
121
- StreamLogEvent (event);
122
- }
123
-
124
- static void chip_nl_test_log_teardown (struct _nlTestSuite * inSuite, int inResult, int inWidth)
125
- {
126
- chip_rpc_Event event = chip_rpc_Event_init_default;
127
- event.which_type = chip_rpc_Event_test_suite_teardown_tag;
128
- snprintf (event.type .test_suite_teardown .suite_name , sizeof (event.type .test_suite_teardown .suite_name ), " %s" , inSuite->name );
129
- event.type .test_suite_teardown .failed = inResult == FAILURE;
130
- StreamLogEvent (event);
131
- }
132
-
133
- static void chip_nl_test_log_test (struct _nlTestSuite * inSuite, int inWidth, int inIndex)
134
- {
135
- chip_rpc_Event event = chip_rpc_Event_init_default;
136
- event.which_type = chip_rpc_Event_test_case_run_tag;
137
- snprintf (event.type .test_case_run .suite_name , sizeof (event.type .test_case_run .suite_name ), " %s" , inSuite->name );
138
- snprintf (event.type .test_case_run .test_case_name , sizeof (event.type .test_case_run .test_case_name ), " %s" ,
139
- inSuite->tests [inIndex].name );
140
- event.type .test_case_run .failed = inSuite->flagError ;
141
- StreamLogEvent (event);
142
- }
143
-
144
- static void chip_nl_test_log_statTest (struct _nlTestSuite * inSuite)
145
- {
146
- chip_rpc_Event event = chip_rpc_Event_init_default;
147
- event.which_type = chip_rpc_Event_test_suite_tests_run_summary_tag;
148
- snprintf (event.type .test_suite_tests_run_summary .suite_name , sizeof (event.type .test_suite_tests_run_summary .suite_name ),
149
- " %s" , inSuite->name );
150
- event.type .test_suite_tests_run_summary .total_count = inSuite->runTests ;
151
- event.type .test_suite_tests_run_summary .failed_count = inSuite->failedTests ;
152
- StreamLogEvent (event);
153
- }
154
-
155
- static void chip_nl_test_log_statAssert (struct _nlTestSuite * inSuite)
156
- {
157
- chip_rpc_Event event = chip_rpc_Event_init_default;
158
- event.which_type = chip_rpc_Event_test_suite_asserts_summary_tag;
159
- snprintf (event.type .test_suite_asserts_summary .suite_name , sizeof (event.type .test_suite_asserts_summary .suite_name ), " %s" ,
160
- inSuite->name );
161
- event.type .test_suite_asserts_summary .total_count = inSuite->performedAssertions ;
162
- event.type .test_suite_asserts_summary .failed_count = inSuite->failedAssertions ;
163
- StreamLogEvent (event);
164
62
}
165
63
};
166
64
167
- NlTest::ServerWriter<chip_rpc_Event> * NlTest::stream_writer = 0 ;
168
-
169
65
} // namespace chip::rpc
170
66
171
67
namespace {
0 commit comments