8
8
9
9
#include < gtest/gtest.h>
10
10
#include < cstdio>
11
- #include < stdio.h >
11
+ #include < memory >
12
12
13
13
#include < executorch/devtools/etdump/data_sinks/buffer_data_sink.h>
14
14
#include < executorch/devtools/etdump/data_sinks/file_data_sink.h>
15
15
#include < executorch/devtools/etdump/etdump_flatcc.h>
16
16
#include < executorch/devtools/etdump/etdump_schema_flatcc_builder.h>
17
17
#include < executorch/devtools/etdump/etdump_schema_flatcc_reader.h>
18
+ #include < executorch/extension/testing_util/temp_file.h>
18
19
#include < executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
19
20
#include < executorch/runtime/core/span.h>
20
21
#include < executorch/runtime/platform/runtime.h>
21
22
#include < executorch/test/utils/DeathTest.h>
22
23
#include < cstdint>
23
24
#include < cstring>
24
- #include < fstream>
25
25
26
26
using ::executorch::aten::ScalarType;
27
27
using ::executorch::aten::Tensor;
28
28
using ::executorch::etdump::ETDumpGen;
29
29
using ::executorch::etdump::ETDumpResult;
30
+ using ::executorch::extension::testing::TempFile;
30
31
using ::executorch::runtime::AllocatorID;
31
32
using ::executorch::runtime::ArrayRef;
32
33
using ::executorch::runtime::BoxedEvalueList;
@@ -50,21 +51,19 @@ class ProfilerETDumpTest : public ::testing::Test {
50
51
buf = (uint8_t *)malloc (buf_size * sizeof (uint8_t ));
51
52
etdump_gen[1 ] = new ETDumpGen (Span<uint8_t >(buf, buf_size));
52
53
53
- std::array<char , L_tmpnam> dummy_name;
54
- dummy_name[L_tmpnam-1 ] = ' \0 ' ;
55
- dump_file_path = std::string (dummy_name.data ()) + " -dump" ;
54
+ temp_file = std::make_unique<TempFile>(std::string ());
55
+ dump_file_path = temp_file->path ();
56
56
}
57
57
58
58
void TearDown () override {
59
59
delete etdump_gen[0 ];
60
60
delete etdump_gen[1 ];
61
61
free (buf);
62
-
63
- std::remove (dump_file_path.c_str ());
64
62
}
65
63
66
64
ETDumpGen* etdump_gen[2 ];
67
65
uint8_t * buf = nullptr ;
66
+ std::unique_ptr<TempFile> temp_file;
68
67
std::string dump_file_path;
69
68
};
70
69
@@ -267,7 +266,7 @@ TEST_F(ProfilerETDumpTest, DebugEventTensorList) {
267
266
}
268
267
// using file data sink to record debug dats
269
268
else {
270
- etdump_gen[i]->set_data_sink (&file_data_sink.get ());
269
+ etdump_gen[i]->set_data_sink (&file_data_sink.get ());
271
270
}
272
271
273
272
etdump_gen[i]->log_evalue (evalue);
@@ -301,7 +300,7 @@ TEST_F(ProfilerETDumpTest, VerifyLogging) {
301
300
}
302
301
// using buffer data sink to record debug data
303
302
else {
304
- etdump_gen[i]->set_data_sink (&file_data_sink.get ());
303
+ etdump_gen[i]->set_data_sink (&file_data_sink.get ());
305
304
}
306
305
307
306
etdump_gen[i]->log_evalue (evalue);
0 commit comments