diff options
author | Andreas Gampe <agampe@google.com> | 2014-05-02 14:25:12 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-05-02 14:25:12 -0700 |
commit | b40c6a768aa8df4774d2a8c3ac7045237cc748cd (patch) | |
tree | cbfd1265e0e1b43345d97727d21d0e7e5a9859d8 /compiler | |
parent | 1dbbbf6090274ebae6809fdb340c166bb34e09c2 (diff) | |
download | android_art-b40c6a768aa8df4774d2a8c3ac7045237cc748cd.tar.gz android_art-b40c6a768aa8df4774d2a8c3ac7045237cc748cd.tar.bz2 android_art-b40c6a768aa8df4774d2a8c3ac7045237cc748cd.zip |
ART: Fix assembler_test to use ScratchFile
This removes a warning about tmpnam usage.
Also add an assertion to ScratchFile about ANDROID_DATA being set,
which it relies on for the temp directory.
Change-Id: I1202f92e48e61492f0ed3ac36ff44fde34dbb0e1
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/utils/assembler_test.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/utils/assembler_test.h b/compiler/utils/assembler_test.h index ce1c4de2fa..1b050cf88d 100644 --- a/compiler/utils/assembler_test.h +++ b/compiler/utils/assembler_test.h @@ -19,7 +19,7 @@ #include "assembler.h" -#include "gtest/gtest.h" +#include "common_runtime_test.h" // For ScratchFile #include <cstdio> #include <cstdlib> @@ -30,6 +30,10 @@ namespace art { +// Use a glocal static variable to keep the same name for all test data. Else we'll just spam the +// temp directory. +static std::string tmpnam_; + template<typename Ass, typename Reg, typename Imm> class AssemblerTest : public testing::Test { public: @@ -203,6 +207,10 @@ class AssemblerTest : public testing::Test { void SetUp() OVERRIDE { assembler_.reset(new Ass()); + // Fake a runtime test for ScratchFile + std::string android_data; + CommonRuntimeTest::SetEnvironmentVariables(android_data); + SetUpHelpers(); } @@ -667,7 +675,8 @@ class AssemblerTest : public testing::Test { // Use a consistent tmpnam, so store it. std::string GetTmpnam() { if (tmpnam_.length() == 0) { - tmpnam_ = std::string(tmpnam(nullptr)); + ScratchFile tmp; + tmpnam_ = tmp.GetFilename() + "asm"; } return tmpnam_; } @@ -677,7 +686,6 @@ class AssemblerTest : public testing::Test { std::string resolved_assembler_cmd_; std::string resolved_objdump_cmd_; std::string resolved_disassemble_cmd_; - std::string tmpnam_; static constexpr size_t OBJDUMP_SECTION_LINE_MIN_TOKENS = 6; }; |