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>
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp
index 275a5da..74d3675 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 @@
 
   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);
+    }
   }
 }