aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-10-18 13:17:18 -0700
committerElliott Hughes <enh@google.com>2013-10-18 13:17:18 -0700
commit925753aa1175ae58b24bbfe2d9e38eb4fe3f579d (patch)
tree135216d664f4023020f12df45768f55dbfa399bf
parente9797ac6756481c0c219eb6b99f9062fd6dfb770 (diff)
downloadandroid_bionic-925753aa1175ae58b24bbfe2d9e38eb4fe3f579d.tar.gz
android_bionic-925753aa1175ae58b24bbfe2d9e38eb4fe3f579d.tar.bz2
android_bionic-925753aa1175ae58b24bbfe2d9e38eb4fe3f579d.zip
Fix some test assumptions that are wrong for __LP64__.
Change-Id: Ic79cd5858ceb611640a76bd03f3da4925d3150d9
-rw-r--r--tests/TemporaryFile.h21
-rw-r--r--tests/libc_logging_test.cpp8
-rw-r--r--tests/stdio_test.cpp8
3 files changed, 30 insertions, 7 deletions
diff --git a/tests/TemporaryFile.h b/tests/TemporaryFile.h
index 878fb13dc..b3f085f30 100644
--- a/tests/TemporaryFile.h
+++ b/tests/TemporaryFile.h
@@ -19,13 +19,14 @@
class TemporaryFile {
public:
TemporaryFile() {
-#if __BIONIC__
- const char* tmp_dir = "/data/local/tmp";
-#else
- const char* tmp_dir = "/tmp";
-#endif
- snprintf(filename, sizeof(filename), "%s/TemporaryFile-XXXXXX", tmp_dir);
- fd = mkstemp(filename);
+ // Since we might be running on the host or the target, and if we're
+ // running on the host we might be running under bionic or glibc,
+ // let's just try both possible temporary directories and take the
+ // first one that works.
+ init("/data/local/tmp");
+ if (fd == -1) {
+ init("/tmp");
+ }
}
~TemporaryFile() {
@@ -35,4 +36,10 @@ class TemporaryFile {
int fd;
char filename[1024];
+
+ private:
+ void init(const char* tmp_dir) {
+ snprintf(filename, sizeof(filename), "%s/TemporaryFile-XXXXXX", tmp_dir);
+ fd = mkstemp(filename);
+ }
};
diff --git a/tests/libc_logging_test.cpp b/tests/libc_logging_test.cpp
index 5b10ce3dd..c44b85b96 100644
--- a/tests/libc_logging_test.cpp
+++ b/tests/libc_logging_test.cpp
@@ -121,13 +121,21 @@ TEST(libc_logging, d_INT_MIN) {
TEST(libc_logging, ld_LONG_MAX) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
+#if __LP64__
+ EXPECT_STREQ("9223372036854775807", buf);
+#else
EXPECT_STREQ("2147483647", buf);
+#endif
}
TEST(libc_logging, ld_LONG_MIN) {
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
+#if __LP64__
+ EXPECT_STREQ("-9223372036854775808", buf);
+#else
EXPECT_STREQ("-2147483648", buf);
+#endif
}
TEST(libc_logging, lld_LLONG_MAX) {
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index e47f967b0..2d9717f5c 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -300,13 +300,21 @@ TEST(stdio, snprintf_d_INT_MIN) {
TEST(stdio, snprintf_ld_LONG_MAX) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%ld", LONG_MAX);
+#if __LP64__
+ EXPECT_STREQ("9223372036854775807", buf);
+#else
EXPECT_STREQ("2147483647", buf);
+#endif
}
TEST(stdio, snprintf_ld_LONG_MIN) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%ld", LONG_MIN);
+#if __LP64__
+ EXPECT_STREQ("-9223372036854775808", buf);
+#else
EXPECT_STREQ("-2147483648", buf);
+#endif
}
TEST(stdio, snprintf_lld_LLONG_MAX) {