aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Hausner <hausner@google.com>2017-06-02 10:09:19 -0700
committerNick Desaulniers <ndesaulniers@google.com>2017-06-02 14:25:06 -0700
commit47a52109a4a4ba212eaaa001db769f03ccd235ee (patch)
tree2b272c9e86709a8cf3e494a171c48e1938a7bbec
parent8d88abc6c6eefbb6314803544f3f0b465a5d4cfa (diff)
downloadandroid_bionic-47a52109a4a4ba212eaaa001db769f03ccd235ee.tar.gz
android_bionic-47a52109a4a4ba212eaaa001db769f03ccd235ee.tar.bz2
android_bionic-47a52109a4a4ba212eaaa001db769f03ccd235ee.zip
bionic: tests: only test falloc_punch on ext4
Test fcntl#falloc_punch is wrong. It checks that fallocate() with mode FALLOC_FL_PUNCH_HOLE fails on ext4 file system on older kernels. The test fails to ensure that the file it creates is indeed on an ext4 partition. On an Angelfish device for example, the file is created on an f2fs partition, which supports FALLOC_FL_PUNCH_HOLE, and thus the test fails (wrongly). Change-Id: I23c1ba4d0fcee81551531779e93ac3d5e19ba1d7 Fixes: 62220977 Test: run bionic-unit-tests as per bionic/README.md###Device tests Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
-rw-r--r--tests/fcntl_test.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp
index 275a5dac7..74d367564 100644
--- a/tests/fcntl_test.cpp
+++ b/tests/fcntl_test.cpp
@@ -20,12 +20,14 @@
#include <fcntl.h>
#include <string.h>
#include <sys/utsname.h>
+#include <sys/vfs.h>
#include "TemporaryFile.h"
// Glibc v2.19 doesn't include these in fcntl.h so host builds will fail without.
#if !defined(FALLOC_FL_PUNCH_HOLE) || !defined(FALLOC_FL_KEEP_SIZE)
#include <linux/falloc.h>
+#include <linux/magic.h>
#endif
TEST(fcntl, fcntl_smoke) {
@@ -287,7 +289,11 @@ TEST(fcntl, falloc_punch) {
if (major < 4 || (major == 4 && minor < 1)) {
TemporaryFile tf;
- ASSERT_EQ(-1, fallocate(tf.fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1));
- ASSERT_EQ(errno, EOPNOTSUPP);
+ struct statfs sfs;
+ ASSERT_EQ(0, fstatfs(tf.fd, &sfs));
+ if (sfs.f_type == EXT4_SUPER_MAGIC) {
+ ASSERT_EQ(-1, fallocate(tf.fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1));
+ ASSERT_EQ(errno, EOPNOTSUPP);
+ }
}
}