| 30 | namespace { |
| 31 | |
| 32 | TEST(CAPI_EXPERIMENTAL, GetServerDefTest) { |
| 33 | const string expected_text_proto(R"(cluster { |
| 34 | job { |
| 35 | name: "worker" |
| 36 | tasks { |
| 37 | key: 0 |
| 38 | value: "tpuserver:0" |
| 39 | } |
| 40 | tasks { |
| 41 | key: 1 |
| 42 | value: "localhost:1" |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | job_name: "worker" |
| 47 | task_index: 1 |
| 48 | protocol: "grpc" |
| 49 | )"); |
| 50 | |
| 51 | TF_Status* status = TF_NewStatus(); |
| 52 | TF_Buffer* result = TFE_GetServerDef(expected_text_proto.c_str(), status); |
| 53 | EXPECT_EQ(TF_GetCode(status), TF_OK); |
| 54 | |
| 55 | ServerDef actual; |
| 56 | ASSERT_TRUE(actual.ParseFromArray(result->data, result->length)); |
| 57 | string actual_text_proto; |
| 58 | tensorflow::protobuf::TextFormat::PrintToString(actual, &actual_text_proto); |
| 59 | EXPECT_EQ(expected_text_proto, actual_text_proto); |
| 60 | |
| 61 | const string malformed_text_proto(R"(cluster { |
| 62 | job { |
| 63 | name: "worker")"); |
| 64 | TF_Buffer* null_result = |
| 65 | TFE_GetServerDef(malformed_text_proto.c_str(), status); |
| 66 | EXPECT_NE(TF_GetCode(status), TF_OK); |
| 67 | EXPECT_TRUE(absl::StrContains(TF_Message(status), |
| 68 | "Invalid text proto for ServerDef")); |
| 69 | EXPECT_EQ(null_result, nullptr); |
| 70 | |
| 71 | // Cleanup |
| 72 | TF_DeleteBuffer(result); |
| 73 | TF_DeleteStatus(status); |
| 74 | } |
| 75 | |
| 76 | TEST(CAPI_EXPERIMENTAL, IsStateful) { |
| 77 | std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)> status( |
nothing calls this directly
no test coverage detected