Commit f095c21d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f50447a9
/*.lock
/*.tmp
/*.tr[0-9]
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""zblk_test_gen.py generates test data for zblk_test.go"""
from ZODB.DB import DB
from ZODB.utils import u64
from wendelin.bigfile.file_zodb import ZBlk0, ZBlk1, ZBigFile
from numpy import arange, uint32
import os, os.path, transaction
blksize = 2*1024*1024 # XXX hardcoded
blksize32 = blksize // 4
def main():
import zodbtools.test.gen_testdata # to make time predictable (XXX)
outfs = "testdata/zblk.fs"
if os.path.exists(outfs):
os.remove(outfs)
db = DB(outfs)
conn = db.open()
root = conn.root()
# 0, 1, 2, ... as u32
data = bytes(arange(0, blksize32, dtype=uint32))
root['zblk0'] = z0 = ZBlk0()
root['zblk1'] = z1 = ZBlk1() # also covers ZData
root['zbigf'] = zf = ZBigFile(blksize)
z0.setblkdata(data)
z1.setblkdata(data)
zf.blktab[0] = z0
zf.blktab[1] = z1
transaction.commit()
with open("ztestdata_zblk_test.go", "w") as f:
def emit(v):
print >>f, v
emit("// Code generated by %s; DO NOT EDIT." % __file__)
emit("package main\n")
emit("const z0_oid = %s" % u64(z0._p_oid))
emit("const z1_oid = %s" % u64(z1._p_oid))
emit("const zf_oid = %s" % u64(zf._p_oid))
conn.close()
db.close()
if __name__ == '__main__':
main()
......@@ -19,4 +19,4 @@
package main
// TODO
//go:generate ./testdata/zblk_test_gen.py
// Code generated by ./testdata/zblk_test_gen.py; DO NOT EDIT.
package main
const z0_oid = 2
const z1_oid = 3
const zf_oid = 1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment