| 130 | }; |
| 131 | |
| 132 | TEST_F(ResourceOpKernelTest, PrivateResource) { |
| 133 | // Empty shared_name means private resource. |
| 134 | const int code = -100; |
| 135 | auto op = CreateOp(code, ""); |
| 136 | ASSERT_TRUE(op != nullptr); |
| 137 | TF_EXPECT_OK(RunOpKernel(op.get())); |
| 138 | |
| 139 | // Default non-shared name provided from ContainerInfo. |
| 140 | const string key = "_0_" + op->name(); |
| 141 | |
| 142 | StubResource* resource; |
| 143 | TF_ASSERT_OK( |
| 144 | mgr_.Lookup<StubResource>(mgr_.default_container(), key, &resource)); |
| 145 | EXPECT_EQ(op->resource(), resource); // Check resource identity. |
| 146 | EXPECT_EQ(code, resource->code); // Check resource stored information. |
| 147 | resource->Unref(); |
| 148 | |
| 149 | // Destroy the op kernel. Expect the resource to be released. |
| 150 | op = nullptr; |
| 151 | Status s = |
| 152 | mgr_.Lookup<StubResource>(mgr_.default_container(), key, &resource); |
| 153 | |
| 154 | EXPECT_FALSE(s.ok()); |
| 155 | } |
| 156 | |
| 157 | TEST_F(ResourceOpKernelTest, SharedResource) { |
| 158 | const string shared_name = "shared_stub"; |