ANDROID: Incremental fs: Adding perf test

Bug: 156474586
Test: Profile tool runs
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Iff91432f7602fc1e23cf30012c893a99e02c868d
This commit is contained in:
Paul Lawrence
2020-05-06 12:31:31 -07:00
parent f592305c13
commit d093c9e8e2
7 changed files with 772 additions and 36 deletions

View File

@@ -25,6 +25,45 @@
#define __S_IFREG S_IFREG
#endif
unsigned int rnd(unsigned int max, unsigned int *seed)
{
return rand_r(seed) * ((uint64_t)max + 1) / RAND_MAX;
}
int remove_dir(const char *dir)
{
int err = rmdir(dir);
if (err && errno == ENOTEMPTY) {
err = delete_dir_tree(dir);
if (err)
return err;
return 0;
}
if (err && errno != ENOENT)
return -errno;
return 0;
}
int drop_caches(void)
{
int drop_caches =
open("/proc/sys/vm/drop_caches", O_WRONLY | O_CLOEXEC);
int i;
if (drop_caches == -1)
return -errno;
i = write(drop_caches, "3", 1);
close(drop_caches);
if (i != 1)
return -errno;
return 0;
}
int mount_fs(const char *mount_dir, const char *backing_dir,
int read_timeout_ms)
{