am ceb6832c: am 7d604133: am e3cc1555: Merge "Fix some test assumptions that are wrong for __LP64__."

* commit 'ceb6832ca071002e040fab5c1aa0718e030dc3b4':
  Fix some test assumptions that are wrong for __LP64__.
This commit is contained in:
Elliott Hughes 2013-10-18 13:39:48 -07:00 committed by Android Git Automerger
commit ae2639c857
3 changed files with 30 additions and 7 deletions

View File

@ -19,13 +19,14 @@
class TemporaryFile { class TemporaryFile {
public: public:
TemporaryFile() { TemporaryFile() {
#if __BIONIC__ // Since we might be running on the host or the target, and if we're
const char* tmp_dir = "/data/local/tmp"; // running on the host we might be running under bionic or glibc,
#else // let's just try both possible temporary directories and take the
const char* tmp_dir = "/tmp"; // first one that works.
#endif init("/data/local/tmp");
snprintf(filename, sizeof(filename), "%s/TemporaryFile-XXXXXX", tmp_dir); if (fd == -1) {
fd = mkstemp(filename); init("/tmp");
}
} }
~TemporaryFile() { ~TemporaryFile() {
@ -35,4 +36,10 @@ class TemporaryFile {
int fd; int fd;
char filename[1024]; char filename[1024];
private:
void init(const char* tmp_dir) {
snprintf(filename, sizeof(filename), "%s/TemporaryFile-XXXXXX", tmp_dir);
fd = mkstemp(filename);
}
}; };

View File

@ -121,13 +121,21 @@ TEST(libc_logging, d_INT_MIN) {
TEST(libc_logging, ld_LONG_MAX) { TEST(libc_logging, ld_LONG_MAX) {
char buf[BUFSIZ]; char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX); __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
#if __LP64__
EXPECT_STREQ("9223372036854775807", buf);
#else
EXPECT_STREQ("2147483647", buf); EXPECT_STREQ("2147483647", buf);
#endif
} }
TEST(libc_logging, ld_LONG_MIN) { TEST(libc_logging, ld_LONG_MIN) {
char buf[BUFSIZ]; char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN); __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
#if __LP64__
EXPECT_STREQ("-9223372036854775808", buf);
#else
EXPECT_STREQ("-2147483648", buf); EXPECT_STREQ("-2147483648", buf);
#endif
} }
TEST(libc_logging, lld_LLONG_MAX) { TEST(libc_logging, lld_LLONG_MAX) {

View File

@ -300,13 +300,21 @@ TEST(stdio, snprintf_d_INT_MIN) {
TEST(stdio, snprintf_ld_LONG_MAX) { TEST(stdio, snprintf_ld_LONG_MAX) {
char buf[BUFSIZ]; char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%ld", LONG_MAX); snprintf(buf, sizeof(buf), "%ld", LONG_MAX);
#if __LP64__
EXPECT_STREQ("9223372036854775807", buf);
#else
EXPECT_STREQ("2147483647", buf); EXPECT_STREQ("2147483647", buf);
#endif
} }
TEST(stdio, snprintf_ld_LONG_MIN) { TEST(stdio, snprintf_ld_LONG_MIN) {
char buf[BUFSIZ]; char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%ld", LONG_MIN); snprintf(buf, sizeof(buf), "%ld", LONG_MIN);
#if __LP64__
EXPECT_STREQ("-9223372036854775808", buf);
#else
EXPECT_STREQ("-2147483648", buf); EXPECT_STREQ("-2147483648", buf);
#endif
} }
TEST(stdio, snprintf_lld_LLONG_MAX) { TEST(stdio, snprintf_lld_LLONG_MAX) {