diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2021-09-15 18:55:59 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2021-09-15 18:55:59 +0100 |
commit | 57b6f58c1d0df757c9311496c32d502925056894 (patch) | |
tree | ed3efc670580fda321854d892382347f93c7c212 /scripts/simplebench/table_templater.py | |
parent | 7b7ab2d6c99987e46aa53478798a05fcaf02226e (diff) | |
parent | 1899bf47375ad40555dcdff12ba49b4b8b82df38 (diff) | |
download | qemu-57b6f58c1d0df757c9311496c32d502925056894.zip qemu-57b6f58c1d0df757c9311496c32d502925056894.tar.gz qemu-57b6f58c1d0df757c9311496c32d502925056894.tar.bz2 |
Merge remote-tracking branch 'remotes/hreitz/tags/pull-block-2021-09-15' into staging
Block patches:
- Block-status cache for data regions
- qcow2 optimization (when using subclusters)
- iotests delinting, and let 297 (lint checker) cover named iotests
- qcow2 check improvements
- Added -F (target backing file format) option to qemu-img convert
- Mirror job fix
- Fix for when a migration is initiated while a backup job runs
- Fix for uncached qemu-img convert to a volume with 4k sectors (for an
unaligned image)
- Minor gluster driver fix
# gpg: Signature made Wed 15 Sep 2021 18:39:11 BST
# gpg: using RSA key CB62D7A0EE3829E45F004D34A1FA40D098019CDF
# gpg: issuer "hreitz@redhat.com"
# gpg: Good signature from "Hanna Reitz <hreitz@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: CB62 D7A0 EE38 29E4 5F00 4D34 A1FA 40D0 9801 9CDF
* remotes/hreitz/tags/pull-block-2021-09-15: (32 commits)
qemu-img: Add -F shorthand to convert
qcow2-refcount: check_refblocks(): add separate message for reserved
qcow2-refcount: check_refcounts_l1(): check reserved bits
qcow2-refcount: improve style of check_refcounts_l1()
qcow2-refcount: check_refcounts_l2(): check reserved bits
qcow2-refcount: check_refcounts_l2(): check l2_bitmap
qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap
qcow2-refcount: introduce fix_l2_entry_by_zero()
qcow2: introduce qcow2_parse_compressed_l2_entry() helper
qcow2: compressed read: simplify cluster descriptor passing
qcow2-refcount: improve style of check_refcounts_l2()
qemu-img: Allow target be aligned to sector size
qcow2: handle_dependencies(): relax conflict detection
qcow2: refactor handle_dependencies() loop body
simplebench: add img_bench_templater.py
block: bdrv_inactivate_recurse(): check for permissions and fix crash
tests: add migrate-during-backup
block/mirror: fix NULL pointer dereference in mirror_wait_on_conflicts()
iotests/297: Cover tests/
mirror-top-perms: Fix AbnormalShutdown path
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/simplebench/table_templater.py')
-rw-r--r-- | scripts/simplebench/table_templater.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/simplebench/table_templater.py b/scripts/simplebench/table_templater.py new file mode 100644 index 0000000..950f3b3 --- /dev/null +++ b/scripts/simplebench/table_templater.py @@ -0,0 +1,62 @@ +# Parser for test templates +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import itertools +from lark import Lark + +grammar = """ +start: ( text | column_switch | row_switch )+ + +column_switch: "{" text ["|" text]+ "}" +row_switch: "[" text ["|" text]+ "]" +text: /[^|{}\[\]]+/ +""" + +parser = Lark(grammar) + +class Templater: + def __init__(self, template): + self.tree = parser.parse(template) + + c_switches = [] + r_switches = [] + for x in self.tree.children: + if x.data == 'column_switch': + c_switches.append([el.children[0].value for el in x.children]) + elif x.data == 'row_switch': + r_switches.append([el.children[0].value for el in x.children]) + + self.columns = list(itertools.product(*c_switches)) + self.rows = list(itertools.product(*r_switches)) + + def gen(self, column, row): + i = 0 + j = 0 + result = [] + + for x in self.tree.children: + if x.data == 'text': + result.append(x.children[0].value) + elif x.data == 'column_switch': + result.append(column[i]) + i += 1 + elif x.data == 'row_switch': + result.append(row[j]) + j += 1 + + return ''.join(result) |