diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c index 632ab44737ec..e6233fae245e 100644 --- a/tools/testing/selftests/cachestat/test_cachestat.c +++ b/tools/testing/selftests/cachestat/test_cachestat.c @@ -125,20 +125,27 @@ static int test_cachestat(const char *filename, bool write_random, bool create, long syscall_ret; struct cachestat cs; struct cachestat_range cs_range = { 0, filesize }; - + + ksft_print_msg("Testing cachestat with:\n"); + ksft_print_msg("pages [num_pages]: %d\n", num_pages); + ksft_print_msg("pagesize [PS]: %d\n", PS); + ksft_print_msg("file [filename]: %s\n", filename); + ksft_print_msg("filesize [filesize]: %d\n", filesize); + ksft_print_msg("[write_random]: %d\n", write_random); + + ksft_print_msg("Opening %s\n", filename); int fd = open(filename, open_flags, open_mode); if (fd == -1) { - ksft_print_msg("Unable to create/open file.\n"); + ksft_print_msg("Unable to create/open file: %m\n"); ret = KSFT_FAIL; goto out; - } else { - ksft_print_msg("Create/open %s\n", filename); } + if (write_random) { if (!write_exactly(fd, filesize)) { - ksft_print_msg("Unable to access urandom.\n"); + ksft_print_msg("Unable to access urandom: \n"); ret = KSFT_FAIL; goto out1; } @@ -147,9 +154,10 @@ static int test_cachestat(const char *filename, bool write_random, bool create, syscall_ret = syscall(__NR_cachestat, fd, &cs_range, &cs, 0); ksft_print_msg("Cachestat call returned %ld\n", syscall_ret); + ksft_print_msg("Cachestat range is now: %d + %d\n", cs_range.off, cs_range.len); if (syscall_ret) { - ksft_print_msg("Cachestat returned non-zero.\n"); + ksft_print_msg("Cachestat returned: %m\n"); ret = KSFT_FAIL; goto out1; @@ -157,6 +165,11 @@ static int test_cachestat(const char *filename, bool write_random, bool create, print_cachestat(&cs); if (write_random) { + + ksft_print_msg("nr_cache is now: %d\n", cs.nr_cache); + ksft_print_msg("nr_evicted is now: %d\n", cs.nr_evicted); + ksft_print_msg("num_pages is now: %d\n", num_pages); + if (cs.nr_cache + cs.nr_evicted != num_pages) { ksft_print_msg( "Total number of cached and evicted pages is off.\n");