ANDROID: selftests: incfs: skip large_file_test test is not enough free space
Make the large_file_test check if there is at least 3GB of free disk space and skip the test if there is not. This is to make the tests pass on a VM with limited disk size, now all functional tests are passing. TAP version 13 1..26 ok 1 basic_file_ops_test ok 2 cant_touch_index_test ok 3 dynamic_files_and_data_test ok 4 concurrent_reads_and_writes_test ok 5 attribute_test ok 6 work_after_remount_test ok 7 child_procs_waiting_for_data_test ok 8 multiple_providers_test ok 9 hash_tree_test ok 10 read_log_test ok 11 get_blocks_test ok 12 get_hash_blocks_test ok 13 large_file_test ok 14 mapped_file_test ok 15 compatibility_test ok 16 data_block_count_test ok 17 hash_block_count_test ok 18 per_uid_read_timeouts_test ok 19 inotify_test ok 20 verity_test ok 21 enable_verity_test ok 22 mmap_test ok 23 truncate_test ok 24 stat_test ok 25 sysfs_test Error mounting fs.: File exists Error mounting fs.: File exists ok 26 sysfs_rename_test Bug: 211066171 Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org> Change-Id: I2260e2b314429251070d0163c70173f237f86476
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
#define FS_IOC_GETFLAGS _IOR('f', 1, long)
|
#define FS_IOC_GETFLAGS _IOR('f', 1, long)
|
||||||
#define FS_VERITY_FL 0x00100000 /* Verity protected inode */
|
#define FS_VERITY_FL 0x00100000 /* Verity protected inode */
|
||||||
|
|
||||||
|
#define TEST_SKIP 2
|
||||||
#define TEST_FAILURE 1
|
#define TEST_FAILURE 1
|
||||||
#define TEST_SUCCESS 0
|
#define TEST_SUCCESS 0
|
||||||
|
|
||||||
@@ -2793,14 +2795,16 @@ failure:
|
|||||||
return TEST_FAILURE;
|
return TEST_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define THREE_GB (3LL * 1024 * 1024 * 1024)
|
||||||
|
#define FOUR_GB (4LL * 1024 * 1024 * 1024) /* Have 1GB of margin */
|
||||||
static int large_file_test(const char *mount_dir)
|
static int large_file_test(const char *mount_dir)
|
||||||
{
|
{
|
||||||
char *backing_dir;
|
char *backing_dir;
|
||||||
int cmd_fd = -1;
|
int cmd_fd = -1;
|
||||||
int i;
|
int i;
|
||||||
int result = TEST_FAILURE;
|
int result = TEST_FAILURE, ret;
|
||||||
uint8_t data[INCFS_DATA_FILE_BLOCK_SIZE] = {};
|
uint8_t data[INCFS_DATA_FILE_BLOCK_SIZE] = {};
|
||||||
int block_count = 3LL * 1024 * 1024 * 1024 / INCFS_DATA_FILE_BLOCK_SIZE;
|
int block_count = THREE_GB / INCFS_DATA_FILE_BLOCK_SIZE;
|
||||||
struct incfs_fill_block *block_buf =
|
struct incfs_fill_block *block_buf =
|
||||||
calloc(block_count, sizeof(struct incfs_fill_block));
|
calloc(block_count, sizeof(struct incfs_fill_block));
|
||||||
struct incfs_fill_blocks fill_blocks = {
|
struct incfs_fill_blocks fill_blocks = {
|
||||||
@@ -2809,6 +2813,22 @@ static int large_file_test(const char *mount_dir)
|
|||||||
};
|
};
|
||||||
incfs_uuid_t id;
|
incfs_uuid_t id;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
struct statvfs svfs;
|
||||||
|
unsigned long long free_disksz;
|
||||||
|
|
||||||
|
ret = statvfs(mount_dir, &svfs);
|
||||||
|
if (ret) {
|
||||||
|
ksft_print_msg("Can't get disk size. Skipping %s...\n", __func__);
|
||||||
|
return TEST_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
free_disksz = (unsigned long long)svfs.f_bavail * svfs.f_bsize;
|
||||||
|
|
||||||
|
if (FOUR_GB > free_disksz) {
|
||||||
|
ksft_print_msg("Not enough free disk space (%lldMB). Skipping %s...\n",
|
||||||
|
free_disksz >> 20, __func__);
|
||||||
|
return TEST_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
backing_dir = create_backing_dir(mount_dir);
|
backing_dir = create_backing_dir(mount_dir);
|
||||||
if (!backing_dir)
|
if (!backing_dir)
|
||||||
@@ -2849,6 +2869,7 @@ static int large_file_test(const char *mount_dir)
|
|||||||
failure:
|
failure:
|
||||||
close(fd);
|
close(fd);
|
||||||
close(cmd_fd);
|
close(cmd_fd);
|
||||||
|
unlink("very_large_file");
|
||||||
umount(mount_dir);
|
umount(mount_dir);
|
||||||
free(backing_dir);
|
free(backing_dir);
|
||||||
return result;
|
return result;
|
||||||
@@ -4665,9 +4686,15 @@ struct test_case {
|
|||||||
|
|
||||||
void run_one_test(const char *mount_dir, struct test_case *test_case)
|
void run_one_test(const char *mount_dir, struct test_case *test_case)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
ksft_print_msg("Running %s\n", test_case->name);
|
ksft_print_msg("Running %s\n", test_case->name);
|
||||||
if (test_case->pfunc(mount_dir) == TEST_SUCCESS)
|
ret = test_case->pfunc(mount_dir);
|
||||||
|
|
||||||
|
if (ret == TEST_SUCCESS)
|
||||||
ksft_test_result_pass("%s\n", test_case->name);
|
ksft_test_result_pass("%s\n", test_case->name);
|
||||||
|
else if (ret == TEST_SKIP)
|
||||||
|
ksft_test_result_skip("%s\n", test_case->name);
|
||||||
else
|
else
|
||||||
ksft_test_result_fail("%s\n", test_case->name);
|
ksft_test_result_fail("%s\n", test_case->name);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user