| From 8d2b6305a6d0497bc6d78832be256380b1691694 Mon Sep 17 00:00:00 2001 |
| From: Vincent Fu <vincent.fu@samsung.com> |
| Date: Tue, 30 Aug 2022 09:59:55 -0400 |
| Subject: [PATCH] test: add tests for lfsr and norandommap |
| |
| t0021 checks whether the lfsr random generator actually touches every |
| offset. |
| |
| t0022 checks whether fio touches offsets more than once when |
| norandommap=1. |
| |
| We should have automated tests for basic functionality to detect |
| problems early. |
| |
| Signed-off-by: Vincent Fu <vincent.fu@samsung.com> |
| --- |
| t/jobs/t0021.fio | 15 +++++++++++++ |
| t/jobs/t0022.fio | 13 +++++++++++ |
| t/run-fio-tests.py | 55 +++++++++++++++++++++++++++++++++++++++++++++- |
| 3 files changed, 82 insertions(+), 1 deletion(-) |
| create mode 100644 t/jobs/t0021.fio |
| create mode 100644 t/jobs/t0022.fio |
| |
| diff --git a/t/jobs/t0021.fio b/t/jobs/t0021.fio |
| new file mode 100644 |
| index 00000000..47fbae71 |
| --- /dev/null |
| +++ b/t/jobs/t0021.fio |
| @@ -0,0 +1,15 @@ |
| +# make sure the lfsr random generator actually does touch all the offsets |
| +# |
| +# Expected result: offsets are not accessed sequentially and all offsets are touched |
| +# Buggy result: offsets are accessed sequentially and one or more offsets are missed |
| +# run with --debug=io or logging to see which offsets are read |
| + |
| +[test] |
| +ioengine=null |
| +filesize=1M |
| +rw=randread |
| +write_bw_log=test |
| +per_job_logs=0 |
| +log_offset=1 |
| +norandommap=1 |
| +random_generator=lfsr |
| diff --git a/t/jobs/t0022.fio b/t/jobs/t0022.fio |
| new file mode 100644 |
| index 00000000..2324571e |
| --- /dev/null |
| +++ b/t/jobs/t0022.fio |
| @@ -0,0 +1,13 @@ |
| +# make sure that when we enable norandommap we touch some offsets more than once |
| +# |
| +# Expected result: at least one offset is touched more than once |
| +# Buggy result: each offset is touched only once |
| + |
| +[test] |
| +ioengine=null |
| +filesize=1M |
| +rw=randread |
| +write_bw_log=test |
| +per_job_logs=0 |
| +log_offset=1 |
| +norandommap=1 |
| diff --git a/t/run-fio-tests.py b/t/run-fio-tests.py |
| index 78f43521..47823761 100755 |
| --- a/t/run-fio-tests.py |
| +++ b/t/run-fio-tests.py |
| @@ -576,7 +576,7 @@ class FioJobTest_t0019(FioJobTest): |
| |
| |
| class FioJobTest_t0020(FioJobTest): |
| - """Test consists of fio test job t0020 |
| + """Test consists of fio test jobs t0020 and t0021 |
| Confirm that almost all offsets were touched non-sequentially""" |
| |
| def check_result(self): |
| @@ -614,6 +614,41 @@ class FioJobTest_t0020(FioJobTest): |
| self.failure_reason += " missing offset {0}".format(i*4096) |
| |
| |
| +class FioJobTest_t0022(FioJobTest): |
| + """Test consists of fio test job t0022""" |
| + |
| + def check_result(self): |
| + super(FioJobTest_t0022, self).check_result() |
| + |
| + bw_log_filename = os.path.join(self.test_dir, "test_bw.log") |
| + file_data, success = self.get_file(bw_log_filename) |
| + log_lines = file_data.split('\n') |
| + |
| + filesize = 1024*1024 |
| + bs = 4096 |
| + seq_count = 0 |
| + offsets = set() |
| + |
| + prev = int(log_lines[0].split(',')[4]) |
| + for line in log_lines[1:]: |
| + offsets.add(prev/bs) |
| + if len(line.strip()) == 0: |
| + continue |
| + cur = int(line.split(',')[4]) |
| + if cur - prev == bs: |
| + seq_count += 1 |
| + prev = cur |
| + |
| + # 10 is an arbitrary threshold |
| + if seq_count > 10: |
| + self.passed = False |
| + self.failure_reason = "too many ({0}) consecutive offsets".format(seq_count) |
| + |
| + if len(offsets) == filesize/bs: |
| + self.passed = False |
| + self.failure_reason += " no duplicate offsets found with norandommap=1".format(len(offsets)) |
| + |
| + |
| class FioJobTest_iops_rate(FioJobTest): |
| """Test consists of fio test job t0009 |
| Confirm that job0 iops == 1000 |
| @@ -973,6 +1008,24 @@ TEST_LIST = [ |
| 'pre_success': None, |
| 'requirements': [], |
| }, |
| + { |
| + 'test_id': 21, |
| + 'test_class': FioJobTest_t0020, |
| + 'job': 't0021.fio', |
| + 'success': SUCCESS_DEFAULT, |
| + 'pre_job': None, |
| + 'pre_success': None, |
| + 'requirements': [], |
| + }, |
| + { |
| + 'test_id': 22, |
| + 'test_class': FioJobTest_t0022, |
| + 'job': 't0022.fio', |
| + 'success': SUCCESS_DEFAULT, |
| + 'pre_job': None, |
| + 'pre_success': None, |
| + 'requirements': [], |
| + }, |
| { |
| 'test_id': 1000, |
| 'test_class': FioExeTest, |