1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_assert/check.h"
16 #include "pw_log/log.h"
17 #include "pw_rpc_system_server/rpc_server.h"
18 #include "pw_rpc_system_server/socket.h"
19 #include "pw_unit_test/framework.h"
20 #include "pw_unit_test/unit_test_service.h"
21
22 namespace {
23
24 pw::unit_test::UnitTestService unit_test_service;
25
TEST(Passing,Zero)26 TEST(Passing, Zero) {}
27
TEST(Passing,One)28 TEST(Passing, One) { EXPECT_TRUE(true); }
29
TEST(Passing,Two)30 TEST(Passing, Two) {
31 EXPECT_FALSE(0);
32 EXPECT_STREQ("Yes!", "Yes!\0extra stuff!");
33 }
34
TEST(Passing,DISABLED_Disabled)35 TEST(Passing, DISABLED_Disabled) {
36 EXPECT_FALSE(0);
37 EXPECT_STREQ("Yes!", "Yes!\0extra stuff!");
38 }
39
TEST(Failing,Zero)40 TEST(Failing, Zero) { FAIL(); }
41
TEST(Failing,One)42 TEST(Failing, One) { EXPECT_TRUE(false); }
43
TEST(Failing,Two)44 TEST(Failing, Two) {
45 EXPECT_FALSE(1);
46 EXPECT_STREQ("No!", "No?");
47 }
48
TEST(Failing,DISABLED_Disabled)49 TEST(Failing, DISABLED_Disabled) {
50 EXPECT_FALSE(1);
51 EXPECT_STREQ("No!", "No?");
52 }
53
TEST(DISABLED_Disabled,Zero)54 TEST(DISABLED_Disabled, Zero) { FAIL(); }
55
TEST(DISABLED_Disabled,One)56 TEST(DISABLED_Disabled, One) { EXPECT_TRUE(false); }
57
TEST(DISABLED_Disabled,Two)58 TEST(DISABLED_Disabled, Two) {
59 EXPECT_FALSE(1);
60 EXPECT_STREQ("No!", "No?");
61 }
62
TEST(DISABLED_Disabled,DISABLED_Disabled)63 TEST(DISABLED_Disabled, DISABLED_Disabled) {
64 EXPECT_FALSE(1);
65 EXPECT_STREQ("No!", "No?");
66 }
67
68 } // namespace
69
main(int argc,char * argv[])70 int main(int argc, char* argv[]) {
71 if (argc != 2) {
72 PW_LOG_ERROR("Usage: %s PORT", argv[0]);
73 return 1;
74 }
75 pw::rpc::system_server::set_socket_port(std::atoi(argv[1]));
76 pw::rpc::system_server::Init();
77 pw::rpc::system_server::Server().RegisterService(unit_test_service);
78
79 PW_LOG_INFO("Starting pw_rpc server");
80 PW_CHECK_OK(pw::rpc::system_server::Start());
81
82 return 0;
83 }
84