| 219 | // Graph Constructor. |
| 220 | |
| 221 | static Graph* TransferFile(const std::string& test_type, |
| 222 | const int32 slice_size) { |
| 223 | Graph* g = new Graph(OpRegistry::Global()); |
| 224 | const int64 timeout_ms = 5000; |
| 225 | std::string recv_dir = "/tmp/FileSliceTransferTestRecv"; |
| 226 | std::string filename = "/tmp/FileSliceTransferTestSend/send_" + test_type; |
| 227 | std::string contents = \ |
| 228 | "The quick brown fox jumps over the lazy dog."; // 44 chars. |
| 229 | |
| 230 | // send filename node. |
| 231 | Tensor filename_t(DT_STRING, TensorShape({})); |
| 232 | filename_t.scalar<tstring>().setConstant(filename); |
| 233 | Node* filename_n = test::graph::Constant(g, filename_t); |
| 234 | |
| 235 | // contents node. |
| 236 | Tensor contents_t(DT_STRING, TensorShape({})); |
| 237 | contents_t.scalar<tstring>().setConstant(contents); |
| 238 | Node* contents_n = test::graph::Constant(g, contents_t); |
| 239 | |
| 240 | Node* write_file_n = WriteFile(g, filename_n, contents_n); |
| 241 | Node* send_n = \ |
| 242 | FileSliceSend(g, filename_n, test_type, "/cpu:0", 1, "/cpu:0", slice_size); |
| 243 | g->AddControlEdge(write_file_n, send_n); |
| 244 | |
| 245 | Node* recv_n = FileSliceRecv(g, test_type, "/cpu:0", 1, "/cpu:0", recv_dir, |
| 246 | slice_size, timeout_ms); |
| 247 | Node* read_file_n = ReadFile(g, recv_n); |
| 248 | Node* equal_n = Equal(g, contents_n, read_file_n); |
| 249 | |
| 250 | std::vector<NodeBuilder::NodeOut> data_out; |
| 251 | data_out.emplace_back(contents_n, 0); |
| 252 | data_out.emplace_back(read_file_n, 0); |
| 253 | Assert(g, equal_n, data_out); |
| 254 | |
| 255 | return g; |
| 256 | } |
| 257 | |
| 258 | static Graph* FileSliceSendTransferFileToSliceRecv(const std::string& test_type, |
| 259 | const int32 slice_size) { |
no test coverage detected