--- /dev/null
+#!/usr/bin/env python3
+
+""" Test test_helpers.DiscFillChecker by actually writing lots of data to disc
+
+Indulge in the luxury of assuming we have python3 here ;-)
+
+.. codeauthor:: Christian Herdtweck, christian.herdtweck@intra2net.com
+"""
+
+from sys import stderr, argv as cmd_line_args
+from tempfile import NamedTemporaryFile
+from time import monotonic
+from os import fstatvfs
+
+from test_helpers import disc_fill_checked
+
+def main(test_dir):
+ """ Main function, called when running file as script """
+
+ with disc_fill_checked():
+ fill_disc(test_dir)
+
+
+def fill_disc(test_dir):
+ """ write data to file in given directory """
+
+ source = '/dev/random'
+ chunk_size = 1024
+ temp_file_prefix = 'pyi2n_disc_fill_test_'
+ print_interval = 1
+
+ with open(source, 'rb') as read_handle:
+ with NamedTemporaryFile(dir=test_dir, prefix=temp_file_prefix) \
+ as write_handle:
+ os_handle = write_handle.fileno()
+ print('copying data from {0} to {1}...'.format(source,
+ write_handle.name))
+ print_fs_stats(os_handle)
+ last_print = monotonic()
+ while True:
+ write_handle.write(read_handle.read(chunk_size))
+ if monotonic() - last_print > print_interval:
+ print_fs_stats(os_handle)
+ last_print = monotonic()
+
+
+def print_fs_stats(os_handle):
+ print(fstatvfs(os_handle))
+
+
+if __name__ == '__main__':
+ if len(cmd_line_args) != 2:
+ print('Need to known which dir I am allowed to abuse', file=stderr)
+ exit(1)
+ main(cmd_line_args[1])