MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/framework/resource_mgr_test.cc:90–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90TEST(ResourceMgrTest, Basic) {
91 ResourceMgr rm;
92 TF_CHECK_OK(rm.Create("foo", "bar", new Resource("cat")));
93 TF_CHECK_OK(rm.Create("foo", "baz", new Resource("dog")));
94 TF_CHECK_OK(rm.Create("foo", "bar", new Other("tiger")));
95
96 // Expected to fail.
97 HasError(rm.Create("foo", "bar", new Resource("kitty")),
98 "Already exists: Resource foo/bar");
99
100 // Expected to be found.
101 EXPECT_EQ("R/cat", Find<Resource>(rm, "foo", "bar"));
102 EXPECT_EQ("R/dog", Find<Resource>(rm, "foo", "baz"));
103 EXPECT_EQ("O/tiger", Find<Other>(rm, "foo", "bar"));
104
105 // Expected to be not found.
106 HasError(FindErr<Resource>(rm, "bar", "foo"), "Not found: Container bar");
107 HasError(FindErr<Resource>(rm, "foo", "xxx"), "Not found: Resource foo/xxx");
108 HasError(FindErr<Other>(rm, "foo", "baz"), "Not found: Resource foo/baz");
109
110 // Delete foo/bar/Resource.
111 TF_CHECK_OK(rm.Delete<Resource>("foo", "bar"));
112 HasError(FindErr<Resource>(rm, "foo", "bar"), "Not found: Resource foo/bar");
113
114 TF_CHECK_OK(rm.Create("foo", "bar", new Resource("kitty")));
115 EXPECT_EQ("R/kitty", Find<Resource>(rm, "foo", "bar"));
116
117 // Drop the whole container foo.
118 TF_CHECK_OK(rm.Cleanup("foo"));
119 HasError(FindErr<Resource>(rm, "foo", "bar"), "Not found: Container foo");
120
121 // Dropping it a second time is OK.
122 TF_CHECK_OK(rm.Cleanup("foo"));
123 HasError(FindErr<Resource>(rm, "foo", "bar"), "Not found: Container foo");
124
125 // Dropping a non-existent container is also ok.
126 TF_CHECK_OK(rm.Cleanup("bar"));
127}
128
129TEST(ResourceMgrTest, CreateOrLookup) {
130 ResourceMgr rm;

Callers

nothing calls this directly

Calls 14

DefaultFunction · 0.85
WrongPolicyFunction · 0.85
CreateResourceFunction · 0.85
LookupResourceFunction · 0.85
HasErrorFunction · 0.70
PolicyFunction · 0.70
DeleteResourceFunction · 0.70
CreateMethod · 0.45
CleanupMethod · 0.45
ScheduleMethod · 0.45
SleepForMicrosecondsMethod · 0.45
UnrefMethod · 0.45

Tested by

no test coverage detected