diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index e315f451e1b7738185992eaa2f9e078b58abe733..e1044530ac8fa7f94c00f7685585bcac95e481c2 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -607,6 +607,19 @@ def _extra_files(name, opts, files): def collect_size ( deviation, path ): return collect_generic_stat ( 'size', deviation, lambda way: os.path.getsize(in_testdir(path)) ) +def get_dir_size(path): + total = 0 + with os.scandir(path) as it: + for entry in it: + if entry.is_file(): + total += entry.stat().st_size + elif entry.is_dir(): + total += get_dir_size(entry.path) + return total + +def collect_size_dir ( deviation, path ): + return collect_generic_stat ( 'size', deviation, lambda way: get_dir_size(path) ) + # Read a number from a specific file def stat_from_file ( metric, deviation, path ): def read_file (way): diff --git a/testsuite/tests/perf/size/Makefile b/testsuite/tests/perf/size/Makefile deleted file mode 100644 index df71b12da38391c2d550b820253fb5743339440b..0000000000000000000000000000000000000000 --- a/testsuite/tests/perf/size/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOP=../../.. -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/test.mk - -libdir_size: - du -s `$(TEST_HC) --print-libdir` | cut -f1 > SIZE - diff --git a/testsuite/tests/perf/size/all.T b/testsuite/tests/perf/size/all.T index 034c16a3195425ae291572fa314805b39d8c88c4..969185e438da4a483d65a7011962159fb0719c7e 100644 --- a/testsuite/tests/perf/size/all.T +++ b/testsuite/tests/perf/size/all.T @@ -1,3 +1,3 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, ['']) -test('libdir',[stat_from_file('size', 10, 'SIZE')], makefile_test, ['libdir_size'] ) +test('libdir',[collect_size_dir(10, config.libdir)], static_stats, [] )